@azure-tools/typespec-rust 0.12.0 → 0.13.1
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 +13 -14
- package/dist/src/codegen/clients.js.map +1 -1
- package/dist/src/codegen/context.d.ts.map +1 -1
- package/dist/src/codegen/context.js +7 -6
- package/dist/src/codegen/context.js.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.d.ts.map +1 -1
- package/dist/src/codegen/headerTraits.js +31 -18
- package/dist/src/codegen/headerTraits.js.map +1 -1
- package/dist/src/codegen/helpers.d.ts +4 -3
- package/dist/src/codegen/helpers.d.ts.map +1 -1
- package/dist/src/codegen/helpers.js +13 -7
- package/dist/src/codegen/helpers.js.map +1 -1
- package/dist/src/codegen/lib.js +1 -1
- package/dist/src/codegen/lib.js.map +1 -1
- package/dist/src/codegen/models.js +16 -15
- package/dist/src/codegen/models.js.map +1 -1
- package/dist/src/codegen/use.d.ts +4 -11
- package/dist/src/codegen/use.d.ts.map +1 -1
- package/dist/src/codegen/use.js +91 -62
- package/dist/src/codegen/use.js.map +1 -1
- package/dist/src/codemodel/client.d.ts +11 -6
- package/dist/src/codemodel/client.d.ts.map +1 -1
- package/dist/src/codemodel/client.js +5 -4
- package/dist/src/codemodel/client.js.map +1 -1
- package/dist/src/codemodel/types.d.ts +54 -44
- package/dist/src/codemodel/types.d.ts.map +1 -1
- package/dist/src/codemodel/types.js +37 -65
- package/dist/src/codemodel/types.js.map +1 -1
- package/dist/src/emitter.d.ts.map +1 -1
- package/dist/src/emitter.js +2 -1
- package/dist/src/emitter.js.map +1 -1
- package/dist/src/tcgcadapter/adapter.d.ts +16 -0
- package/dist/src/tcgcadapter/adapter.d.ts.map +1 -1
- package/dist/src/tcgcadapter/adapter.js +107 -37
- package/dist/src/tcgcadapter/adapter.js.map +1 -1
- package/package.json +11 -11
|
@@ -12,18 +12,24 @@ export var ModelFlags;
|
|
|
12
12
|
/** model is used as output from a method */
|
|
13
13
|
ModelFlags[ModelFlags["Output"] = 2] = "Output";
|
|
14
14
|
})(ModelFlags || (ModelFlags = {}));
|
|
15
|
-
export class
|
|
16
|
-
constructor(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.
|
|
15
|
+
export class QualifiedType {
|
|
16
|
+
constructor(name, path) {
|
|
17
|
+
if (name.indexOf('::') > 0) {
|
|
18
|
+
throw new Error(`name ${name} must not include any paths`);
|
|
19
|
+
}
|
|
20
|
+
this.name = name;
|
|
21
|
+
this.path = path;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
constructor(name,
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
class External extends QualifiedType {
|
|
25
|
+
constructor(crate, name, path) {
|
|
26
|
+
super(name, path);
|
|
27
|
+
let crateName = this.path;
|
|
28
|
+
const pathSep = crateName.indexOf('::');
|
|
29
|
+
if (pathSep > 0) {
|
|
30
|
+
crateName = crateName.substring(0, pathSep);
|
|
31
|
+
}
|
|
32
|
+
crate.addDependency(new CrateDependency(crateName));
|
|
27
33
|
}
|
|
28
34
|
}
|
|
29
35
|
class StructBase {
|
|
@@ -44,7 +50,7 @@ class StructFieldBase {
|
|
|
44
50
|
}
|
|
45
51
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
46
52
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
47
|
-
export class Arc extends
|
|
53
|
+
export class Arc extends QualifiedType {
|
|
48
54
|
constructor(type) {
|
|
49
55
|
super('Arc', 'std::sync');
|
|
50
56
|
this.kind = 'arc';
|
|
@@ -53,7 +59,7 @@ export class Arc extends StdType {
|
|
|
53
59
|
}
|
|
54
60
|
export class Bytes extends External {
|
|
55
61
|
constructor(crate) {
|
|
56
|
-
super(crate, '
|
|
62
|
+
super(crate, 'Bytes', 'azure_core');
|
|
57
63
|
this.kind = 'bytes';
|
|
58
64
|
}
|
|
59
65
|
}
|
|
@@ -84,17 +90,17 @@ export class EnumValue {
|
|
|
84
90
|
}
|
|
85
91
|
export class Etag extends External {
|
|
86
92
|
constructor(crate) {
|
|
87
|
-
super(crate, '
|
|
93
|
+
super(crate, 'Etag', 'azure_core::http');
|
|
88
94
|
this.kind = 'Etag';
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
export class ExternalType extends External {
|
|
92
|
-
constructor(crate,
|
|
93
|
-
super(crate,
|
|
98
|
+
constructor(crate, name, path) {
|
|
99
|
+
super(crate, name, path);
|
|
94
100
|
this.kind = 'external';
|
|
95
101
|
}
|
|
96
102
|
}
|
|
97
|
-
export class HashMap extends
|
|
103
|
+
export class HashMap extends QualifiedType {
|
|
98
104
|
constructor(type) {
|
|
99
105
|
super('HashMap', 'std::collections');
|
|
100
106
|
this.kind = 'hashmap';
|
|
@@ -110,7 +116,7 @@ export class ImplTrait {
|
|
|
110
116
|
}
|
|
111
117
|
export class JsonValue extends External {
|
|
112
118
|
constructor(crate) {
|
|
113
|
-
super(crate, '
|
|
119
|
+
super(crate, 'Value', 'serde_json');
|
|
114
120
|
this.kind = 'jsonValue';
|
|
115
121
|
}
|
|
116
122
|
}
|
|
@@ -142,12 +148,13 @@ export class Model extends StructBase {
|
|
|
142
148
|
export class ModelField extends StructFieldBase {
|
|
143
149
|
constructor(name, serde, visibility, type) {
|
|
144
150
|
super(name, visibility, type);
|
|
151
|
+
this.kind = 'modelField';
|
|
145
152
|
this.serde = serde;
|
|
146
153
|
}
|
|
147
154
|
}
|
|
148
155
|
export class OffsetDateTime extends External {
|
|
149
156
|
constructor(crate, encoding, utc) {
|
|
150
|
-
super(crate, '
|
|
157
|
+
super(crate, 'OffsetDateTime', 'time');
|
|
151
158
|
this.kind = 'offsetDateTime';
|
|
152
159
|
this.encoding = encoding;
|
|
153
160
|
this.utc = utc;
|
|
@@ -155,69 +162,34 @@ export class OffsetDateTime extends External {
|
|
|
155
162
|
}
|
|
156
163
|
export class Option {
|
|
157
164
|
constructor(type) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
case 'encodedBytes':
|
|
161
|
-
case 'enum':
|
|
162
|
-
case 'enumValue':
|
|
163
|
-
case 'Etag':
|
|
164
|
-
case 'external':
|
|
165
|
-
case 'hashmap':
|
|
166
|
-
case 'model':
|
|
167
|
-
case 'offsetDateTime':
|
|
168
|
-
case 'requestContent':
|
|
169
|
-
case 'scalar':
|
|
170
|
-
case 'struct':
|
|
171
|
-
case 'Url':
|
|
172
|
-
case 'Vec':
|
|
173
|
-
this.kind = 'option';
|
|
174
|
-
this.type = type;
|
|
175
|
-
break;
|
|
176
|
-
default:
|
|
177
|
-
throw new Error(`unsupported Option generic type param kind ${type.kind}`);
|
|
178
|
-
}
|
|
165
|
+
this.kind = 'option';
|
|
166
|
+
this.type = type;
|
|
179
167
|
}
|
|
180
168
|
}
|
|
181
169
|
export class Pager extends External {
|
|
182
|
-
constructor(crate, type
|
|
183
|
-
super(crate, '
|
|
170
|
+
constructor(crate, type) {
|
|
171
|
+
super(crate, 'Pager', 'azure_core::http');
|
|
184
172
|
this.kind = 'pager';
|
|
185
173
|
this.type = type;
|
|
186
|
-
this.format = format;
|
|
187
174
|
}
|
|
188
175
|
}
|
|
189
176
|
export class Payload {
|
|
190
177
|
constructor(type, format) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
case 'enum':
|
|
195
|
-
case 'external':
|
|
196
|
-
case 'hashmap':
|
|
197
|
-
case 'jsonValue':
|
|
198
|
-
case 'model':
|
|
199
|
-
case 'offsetDateTime':
|
|
200
|
-
case 'scalar':
|
|
201
|
-
case 'Vec':
|
|
202
|
-
this.kind = 'payload';
|
|
203
|
-
this.type = type;
|
|
204
|
-
this.format = format;
|
|
205
|
-
break;
|
|
206
|
-
default:
|
|
207
|
-
throw new Error(`unsupported Payload generic type param kind ${type.kind}`);
|
|
208
|
-
}
|
|
178
|
+
this.kind = 'payload';
|
|
179
|
+
this.type = type;
|
|
180
|
+
this.format = format;
|
|
209
181
|
}
|
|
210
182
|
}
|
|
211
183
|
export class RequestContent extends External {
|
|
212
184
|
constructor(crate, content) {
|
|
213
|
-
super(crate, '
|
|
185
|
+
super(crate, 'RequestContent', 'azure_core::http');
|
|
214
186
|
this.kind = 'requestContent';
|
|
215
187
|
this.content = content;
|
|
216
188
|
}
|
|
217
189
|
}
|
|
218
190
|
export class Response extends External {
|
|
219
191
|
constructor(crate, content) {
|
|
220
|
-
super(crate, '
|
|
192
|
+
super(crate, 'Response', 'azure_core::http');
|
|
221
193
|
this.kind = 'response';
|
|
222
194
|
this.content = content;
|
|
223
195
|
}
|
|
@@ -229,7 +201,7 @@ export class ResponseBody {
|
|
|
229
201
|
}
|
|
230
202
|
export class Result extends External {
|
|
231
203
|
constructor(crate, type) {
|
|
232
|
-
super(crate, '
|
|
204
|
+
super(crate, 'Result', 'azure_core');
|
|
233
205
|
this.kind = 'result';
|
|
234
206
|
this.type = type;
|
|
235
207
|
}
|
|
@@ -266,7 +238,7 @@ export class TokenCredential extends External {
|
|
|
266
238
|
if (scopes.length === 0) {
|
|
267
239
|
throw new Error('scopes must contain at least one entry');
|
|
268
240
|
}
|
|
269
|
-
super(crate, '
|
|
241
|
+
super(crate, 'TokenCredential', 'azure_core::credentials');
|
|
270
242
|
this.kind = 'tokenCredential';
|
|
271
243
|
this.scopes = scopes;
|
|
272
244
|
}
|
|
@@ -278,7 +250,7 @@ export class Unit {
|
|
|
278
250
|
}
|
|
279
251
|
export class Url extends External {
|
|
280
252
|
constructor(crate) {
|
|
281
|
-
super(crate, '
|
|
253
|
+
super(crate, 'Url', 'azure_core::http');
|
|
282
254
|
this.kind = 'Url';
|
|
283
255
|
}
|
|
284
256
|
}
|
|
@@ -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,MA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,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/emitter.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAK9C,OAAO,EAAE,WAAW,EAAY,MAAM,oBAAoB,CAAC;AAC3D,OAAO,gCAAgC,CAAC;AAExC;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/emitter.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAK9C,OAAO,EAAE,WAAW,EAAY,MAAM,oBAAoB,CAAC;AAC3D,OAAO,gCAAgC,CAAC;AAExC;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,kBAAkB,CAAC,iBAqErE"}
|
package/dist/src/emitter.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { CodeGenerator } from './codegen/codeGenerator.js';
|
|
6
6
|
import { Adapter } from './tcgcadapter/adapter.js';
|
|
7
7
|
import { execSync } from 'child_process';
|
|
8
|
-
import { existsSync } from 'fs';
|
|
8
|
+
import { existsSync, rmSync } from 'fs';
|
|
9
9
|
import { mkdir, writeFile } from 'fs/promises';
|
|
10
10
|
import * as path from 'path';
|
|
11
11
|
import { NoTarget } from '@typespec/compiler';
|
|
@@ -48,6 +48,7 @@ export async function $onEmit(context) {
|
|
|
48
48
|
await writeFile(libRsPath, codegen.emitLibRs());
|
|
49
49
|
}
|
|
50
50
|
const files = codegen.emitContent();
|
|
51
|
+
rmSync(path.join(context.emitterOutputDir, 'src', 'generated'), { force: true, recursive: true });
|
|
51
52
|
for (const file of files) {
|
|
52
53
|
await writeToGeneratedDir(context.emitterOutputDir, file.name, file.content);
|
|
53
54
|
}
|
package/dist/src/emitter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../src/emitter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../src/emitter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAe,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,gCAAg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ED;;;;;GAKG;AACH,KAAK,UAAU,mBAAmB,CAAC,MAAc,EAAE,QAAgB,EAAE,OAAe;IAClF,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IACrE,MAAM,WAAW,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAClF,MAAM,KAAK,CAAC,WAAW,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;IAC5C,MAAM,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -15,6 +15,7 @@ export declare class Adapter {
|
|
|
15
15
|
private readonly types;
|
|
16
16
|
private readonly clientMethodParams;
|
|
17
17
|
private readonly renamedMethods;
|
|
18
|
+
private readonly fieldsMap;
|
|
18
19
|
private constructor();
|
|
19
20
|
/** performs all the steps to convert tcgc to a crate */
|
|
20
21
|
tcgcToCrate(): rust.Crate;
|
|
@@ -110,6 +111,13 @@ export declare class Adapter {
|
|
|
110
111
|
* @param rustClient the client to which the method belongs
|
|
111
112
|
*/
|
|
112
113
|
private adaptMethod;
|
|
114
|
+
/**
|
|
115
|
+
* creates the pageable strategy based on the method definition
|
|
116
|
+
*
|
|
117
|
+
* @param method the pageable method for which to create a strategy
|
|
118
|
+
* @returns the pageable strategy
|
|
119
|
+
*/
|
|
120
|
+
private adaptPageableMethodStrategy;
|
|
113
121
|
/**
|
|
114
122
|
* converts a tcgc operation parameter into a Rust method parameter
|
|
115
123
|
*
|
|
@@ -117,6 +125,14 @@ export declare class Adapter {
|
|
|
117
125
|
* @returns a Rust method parameter
|
|
118
126
|
*/
|
|
119
127
|
private adaptMethodParameter;
|
|
128
|
+
/**
|
|
129
|
+
* narrows a rust.Type to a rust.WireType.
|
|
130
|
+
* if type isn't a rust.WireType, an error is thrown.
|
|
131
|
+
*
|
|
132
|
+
* @param type the type to narrow
|
|
133
|
+
* @returns the narrowed type
|
|
134
|
+
*/
|
|
135
|
+
private typeToWireType;
|
|
120
136
|
/**
|
|
121
137
|
* converts a tcgc spread parameter into a Rust partial body parameter.
|
|
122
138
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/tcgcadapter/adapter.ts"],"names":[],"mappings":"AAOA,OAAO,EAAyB,WAAW,EAAY,MAAM,oBAAoB,CAAC;AAIlF,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAE9C,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;IAGtC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAyB;IAG/C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAoC;IAGvE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAc;
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/tcgcadapter/adapter.ts"],"names":[],"mappings":"AAOA,OAAO,EAAyB,WAAW,EAAY,MAAM,oBAAoB,CAAC;AAIlF,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAE9C,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,CA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@@ -32,6 +32,7 @@ export class Adapter {
|
|
|
32
32
|
this.types = new Map();
|
|
33
33
|
this.clientMethodParams = new Map();
|
|
34
34
|
this.renamedMethods = new Set();
|
|
35
|
+
this.fieldsMap = new Map();
|
|
35
36
|
this.ctx = ctx;
|
|
36
37
|
let serviceType = 'data-plane';
|
|
37
38
|
if (this.ctx.arm === true) {
|
|
@@ -43,7 +44,8 @@ export class Adapter {
|
|
|
43
44
|
tcgcToCrate() {
|
|
44
45
|
this.adaptTypes();
|
|
45
46
|
this.adaptClients();
|
|
46
|
-
|
|
47
|
+
// marker models don't require serde so exclude them from the check
|
|
48
|
+
if (this.crate.enums.length > 0 || values(this.crate.models).where(e => e.kind === 'model').any()) {
|
|
47
49
|
this.crate.addDependency(new rust.CrateDependency('serde'));
|
|
48
50
|
}
|
|
49
51
|
if (this.crate.clients.length > 0 || this.crate.enums.length > 0 || this.crate.models.length > 0) {
|
|
@@ -220,7 +222,7 @@ export class Adapter {
|
|
|
220
222
|
// the only exception is for HashMap and Vec since an
|
|
221
223
|
// empty collection conveys the same semantics.
|
|
222
224
|
if ((modelVisibility === 'pub' || property.optional) && fieldType.kind !== 'hashmap' && fieldType.kind !== 'Vec') {
|
|
223
|
-
fieldType = new rust.Option(fieldType);
|
|
225
|
+
fieldType = new rust.Option(this.typeToWireType(fieldType));
|
|
224
226
|
}
|
|
225
227
|
const modelField = new rust.ModelField(naming.getEscapedReservedName(snakeCaseName(property.name), 'prop'), property.serializedName, modelVisibility, fieldType);
|
|
226
228
|
modelField.docs = this.adaptDocs(property.summary, property.doc);
|
|
@@ -230,6 +232,10 @@ export class Adapter {
|
|
|
230
232
|
modelField.serde = xmlName;
|
|
231
233
|
}
|
|
232
234
|
modelField.xmlKind = getXMLKind(property.decorators, modelField);
|
|
235
|
+
// it's possible for different models to reference the same property definition
|
|
236
|
+
if (!this.fieldsMap.get(property)) {
|
|
237
|
+
this.fieldsMap.set(property, modelField);
|
|
238
|
+
}
|
|
233
239
|
return modelField;
|
|
234
240
|
}
|
|
235
241
|
/** converts a tcgc type to a Rust type */
|
|
@@ -296,7 +302,7 @@ export class Adapter {
|
|
|
296
302
|
if (vectorType) {
|
|
297
303
|
return vectorType;
|
|
298
304
|
}
|
|
299
|
-
vectorType = new rust.Vector(this.getType(type.valueType));
|
|
305
|
+
vectorType = new rust.Vector(this.typeToWireType(this.getType(type.valueType)));
|
|
300
306
|
this.types.set(keyName, vectorType);
|
|
301
307
|
return vectorType;
|
|
302
308
|
}
|
|
@@ -322,7 +328,7 @@ export class Adapter {
|
|
|
322
328
|
if (hashmapType) {
|
|
323
329
|
return hashmapType;
|
|
324
330
|
}
|
|
325
|
-
hashmapType = new rust.HashMap(this.getType(type.valueType));
|
|
331
|
+
hashmapType = new rust.HashMap(this.typeToWireType(this.getType(type.valueType)));
|
|
326
332
|
this.types.set(keyName, hashmapType);
|
|
327
333
|
return hashmapType;
|
|
328
334
|
}
|
|
@@ -502,16 +508,15 @@ export class Adapter {
|
|
|
502
508
|
const rustClient = new rust.Client(clientName);
|
|
503
509
|
rustClient.docs = this.adaptDocs(client.summary, client.doc);
|
|
504
510
|
rustClient.parent = parent;
|
|
505
|
-
rustClient.fields.push(new rust.StructField('pipeline', 'pubCrate', new rust.ExternalType(this.crate, '
|
|
511
|
+
rustClient.fields.push(new rust.StructField('pipeline', 'pubCrate', new rust.ExternalType(this.crate, 'Pipeline', 'azure_core::http')));
|
|
506
512
|
// anything other than public means non-instantiable client
|
|
507
513
|
if (client.clientInitialization.initializedBy & tcgc.InitializedByFlags.Individually) {
|
|
508
514
|
const clientOptionsStruct = new rust.Struct(`${rustClient.name}Options`, 'pub');
|
|
509
|
-
const clientOptionsField = new rust.StructField('client_options', 'pub', new rust.ExternalType(this.crate, '
|
|
515
|
+
const clientOptionsField = new rust.StructField('client_options', 'pub', new rust.ExternalType(this.crate, 'ClientOptions', 'azure_core::http'));
|
|
510
516
|
clientOptionsField.defaultValue = 'ClientOptions::default()';
|
|
511
517
|
clientOptionsStruct.fields.push(clientOptionsField);
|
|
512
518
|
rustClient.constructable = new rust.ClientConstruction(new rust.ClientOptions(clientOptionsStruct));
|
|
513
|
-
|
|
514
|
-
clientOptionsStruct.docs.summary = `Options used when creating a [\`${rustClient.name}\`](${buildClientDocPath(rustClient)})`;
|
|
519
|
+
clientOptionsStruct.docs.summary = `Options used when creating a [\`${rustClient.name}\`](${rustClient.name})`;
|
|
515
520
|
// NOTE: per tcgc convention, if there is no param of kind credential
|
|
516
521
|
// it means that the client doesn't require any kind of authentication.
|
|
517
522
|
// HOWEVER, if there *is* a credential param, then the client *does not*
|
|
@@ -680,6 +685,17 @@ export class Adapter {
|
|
|
680
685
|
const subClient = this.recursiveAdaptClient(method.response, rustClient);
|
|
681
686
|
this.adaptClientAccessor(client, method, rustClient, subClient);
|
|
682
687
|
}
|
|
688
|
+
else if (method.kind === 'lro' || method.kind === 'lropaging') {
|
|
689
|
+
// skip LROs for now so that codegen is unblocked
|
|
690
|
+
// TODO: https://github.com/Azure/typespec-rust/issues/188
|
|
691
|
+
this.ctx.program.reportDiagnostic({
|
|
692
|
+
code: 'LroNotSupported',
|
|
693
|
+
severity: 'warning',
|
|
694
|
+
message: `skip emitting LRO ${method.name}`,
|
|
695
|
+
target: method.__raw ? method.__raw.node : NoTarget,
|
|
696
|
+
});
|
|
697
|
+
continue;
|
|
698
|
+
}
|
|
683
699
|
else {
|
|
684
700
|
this.adaptMethod(method, rustClient);
|
|
685
701
|
}
|
|
@@ -808,8 +824,8 @@ export class Adapter {
|
|
|
808
824
|
const optionsLifetime = new rust.Lifetime('a');
|
|
809
825
|
const methodOptionsStruct = new rust.Struct(`${rustClient.name}${codegen.pascalCase(srcMethodName)}Options`, 'pub');
|
|
810
826
|
methodOptionsStruct.lifetime = optionsLifetime;
|
|
811
|
-
methodOptionsStruct.docs.summary = `Options to be passed to [\`${rustClient.name}::${methodName}()\`](
|
|
812
|
-
const clientMethodOptions = new rust.ExternalType(this.crate, '
|
|
827
|
+
methodOptionsStruct.docs.summary = `Options to be passed to [\`${rustClient.name}::${methodName}()\`](crate::generated::clients::${rustClient.name}::${methodName}())`;
|
|
828
|
+
const clientMethodOptions = new rust.ExternalType(this.crate, 'ClientMethodOptions', 'azure_core::http');
|
|
813
829
|
clientMethodOptions.lifetime = optionsLifetime;
|
|
814
830
|
const methodOptionsField = new rust.StructField('method_options', 'pub', clientMethodOptions);
|
|
815
831
|
methodOptionsField.docs.summary = 'Allows customization of the method call.';
|
|
@@ -835,18 +851,6 @@ export class Adapter {
|
|
|
835
851
|
break;
|
|
836
852
|
case 'paging':
|
|
837
853
|
rustMethod = new rust.PageableMethod(methodName, rustClient, pub, methodOptions, httpMethod, httpPath);
|
|
838
|
-
if (method.nextLinkOperation) {
|
|
839
|
-
// TODO: https://github.com/Azure/autorest.rust/issues/103
|
|
840
|
-
throw new Error('next page operation NYI');
|
|
841
|
-
}
|
|
842
|
-
else if (method.nextLinkPath) {
|
|
843
|
-
// this is the name of the field in the response type that contains the next link URL
|
|
844
|
-
if (method.nextLinkPath.indexOf('.') > 0) {
|
|
845
|
-
// TODO: https://github.com/Azure/autorest.rust/issues/102
|
|
846
|
-
throw new Error('nested next link path NYI');
|
|
847
|
-
}
|
|
848
|
-
rustMethod.strategy = new rust.PageableStrategyNextLink(naming.getEscapedReservedName(snakeCaseName(method.nextLinkPath), 'prop'));
|
|
849
|
-
}
|
|
850
854
|
break;
|
|
851
855
|
default:
|
|
852
856
|
throw new Error(`method kind ${method.kind} NYI`);
|
|
@@ -900,6 +904,13 @@ export class Adapter {
|
|
|
900
904
|
fieldType = field.type;
|
|
901
905
|
}
|
|
902
906
|
else {
|
|
907
|
+
switch (adaptedParam.type.kind) {
|
|
908
|
+
case 'requestContent':
|
|
909
|
+
case 'struct':
|
|
910
|
+
break;
|
|
911
|
+
default:
|
|
912
|
+
adaptedParam.type = this.typeToWireType(adaptedParam.type);
|
|
913
|
+
}
|
|
903
914
|
fieldType = new rust.Option(adaptedParam.type);
|
|
904
915
|
}
|
|
905
916
|
const optionsField = new rust.StructField(adaptedParam.name, 'pub', fieldType);
|
|
@@ -953,10 +964,10 @@ export class Adapter {
|
|
|
953
964
|
if (header.serializedName !== 'x-ms-meta' && header.serializedName !== 'x-ms-or') {
|
|
954
965
|
throw new Error(`unexpected response header collection ${header.serializedName}`);
|
|
955
966
|
}
|
|
956
|
-
responseHeader = new rust.ResponseHeaderHashMap(header.name, header.serializedName);
|
|
967
|
+
responseHeader = new rust.ResponseHeaderHashMap(snakeCaseName(header.name), header.serializedName);
|
|
957
968
|
}
|
|
958
969
|
else {
|
|
959
|
-
responseHeader = new rust.ResponseHeaderScalar(
|
|
970
|
+
responseHeader = new rust.ResponseHeaderScalar(snakeCaseName(header.name), fixETagName(header.serializedName), this.getType(header.type));
|
|
960
971
|
}
|
|
961
972
|
responseHeader.docs = this.adaptDocs(header.summary, header.doc);
|
|
962
973
|
rustMethod.responseHeaders.push(responseHeader);
|
|
@@ -979,16 +990,16 @@ export class Adapter {
|
|
|
979
990
|
if (!this.crate.models.includes(synthesizedModel)) {
|
|
980
991
|
this.crate.models.push(synthesizedModel);
|
|
981
992
|
}
|
|
982
|
-
returnType = new rust.Pager(this.crate, synthesizedModel, format);
|
|
993
|
+
returnType = new rust.Pager(this.crate, new rust.Payload(synthesizedModel, format));
|
|
983
994
|
}
|
|
984
995
|
else if (method.response.type && !(method.response.type.kind === 'bytes' && method.response.type.encode === 'bytes')) {
|
|
985
|
-
returnType = new rust.Response(this.crate, new rust.Payload(this.getType(method.response.type), getBodyFormat()));
|
|
996
|
+
returnType = new rust.Response(this.crate, new rust.Payload(this.typeToWireType(this.getType(method.response.type)), getBodyFormat()));
|
|
986
997
|
}
|
|
987
998
|
else if (rustMethod.responseHeaders.length > 0) {
|
|
988
999
|
// for methods that don't return a modeled type but return headers,
|
|
989
1000
|
// we need to return a marker type
|
|
990
1001
|
const markerType = new rust.MarkerType(`${rustClient.name}${codegen.pascalCase(method.name)}Result`);
|
|
991
|
-
markerType.docs.summary = `Contains results for [\`${rustClient.name}::${methodName}()\`](
|
|
1002
|
+
markerType.docs.summary = `Contains results for [\`${rustClient.name}::${methodName}()\`](crate::generated::clients::${rustClient.name}::${methodName}())`;
|
|
992
1003
|
returnType = new rust.Response(this.crate, markerType);
|
|
993
1004
|
this.crate.models.push(markerType);
|
|
994
1005
|
}
|
|
@@ -1000,6 +1011,45 @@ export class Adapter {
|
|
|
1000
1011
|
returnType = new rust.Response(this.crate, this.getUnitType());
|
|
1001
1012
|
}
|
|
1002
1013
|
rustMethod.returns = new rust.Result(this.crate, returnType);
|
|
1014
|
+
if (method.kind === 'paging') {
|
|
1015
|
+
// can't do this until the method has been completely adapted
|
|
1016
|
+
rustMethod.strategy = this.adaptPageableMethodStrategy(method);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
/**
|
|
1020
|
+
* creates the pageable strategy based on the method definition
|
|
1021
|
+
*
|
|
1022
|
+
* @param method the pageable method for which to create a strategy
|
|
1023
|
+
* @returns the pageable strategy
|
|
1024
|
+
*/
|
|
1025
|
+
adaptPageableMethodStrategy(method) {
|
|
1026
|
+
if (method.pagingMetadata.nextLinkOperation) {
|
|
1027
|
+
// TODO: https://github.com/Azure/autorest.rust/issues/103
|
|
1028
|
+
throw new Error('next page operation NYI');
|
|
1029
|
+
}
|
|
1030
|
+
else if (method.pagingMetadata.nextLinkSegments) {
|
|
1031
|
+
if (method.pagingMetadata.nextLinkSegments.length > 1) {
|
|
1032
|
+
// TODO: https://github.com/Azure/autorest.rust/issues/102
|
|
1033
|
+
throw new Error('nested next link path NYI');
|
|
1034
|
+
}
|
|
1035
|
+
// this is the field in the response type that contains the next link URL
|
|
1036
|
+
const nextLinkSegment = method.pagingMetadata.nextLinkSegments[0];
|
|
1037
|
+
if (nextLinkSegment.kind !== 'property') {
|
|
1038
|
+
throw new Error(`unexpected kind ${nextLinkSegment.kind} for next link segment in operation ${method.name}`);
|
|
1039
|
+
}
|
|
1040
|
+
const nextLinkField = this.fieldsMap.get(nextLinkSegment);
|
|
1041
|
+
if (!nextLinkField) {
|
|
1042
|
+
// the most likely explanation for this is lack of reference equality
|
|
1043
|
+
throw new Error(`missing next link field name ${nextLinkSegment.name} for operation ${method.name}`);
|
|
1044
|
+
}
|
|
1045
|
+
return new rust.PageableStrategyNextLink(nextLinkField);
|
|
1046
|
+
}
|
|
1047
|
+
else if (method.pagingMetadata.continuationTokenParameterSegments && method.pagingMetadata.continuationTokenResponseSegments) {
|
|
1048
|
+
throw new Error('PageableStrategyContinuationToken NYI');
|
|
1049
|
+
}
|
|
1050
|
+
else {
|
|
1051
|
+
throw new Error(`unhandled paging strategy for operation ${method.name}`);
|
|
1052
|
+
}
|
|
1003
1053
|
}
|
|
1004
1054
|
/**
|
|
1005
1055
|
* converts a tcgc operation parameter into a Rust method parameter
|
|
@@ -1043,7 +1093,7 @@ export class Adapter {
|
|
|
1043
1093
|
requestType = new rust.Bytes(this.crate);
|
|
1044
1094
|
}
|
|
1045
1095
|
else {
|
|
1046
|
-
requestType = new rust.Payload(paramType, this.adaptBodyFormat(param.defaultContentType));
|
|
1096
|
+
requestType = new rust.Payload(this.typeToWireType(paramType), this.adaptBodyFormat(param.defaultContentType));
|
|
1047
1097
|
}
|
|
1048
1098
|
adaptedParam = new rust.BodyParameter(paramName, paramLoc, param.optional, new rust.RequestContent(this.crate, requestType));
|
|
1049
1099
|
break;
|
|
@@ -1109,6 +1159,35 @@ export class Adapter {
|
|
|
1109
1159
|
}
|
|
1110
1160
|
return adaptedParam;
|
|
1111
1161
|
}
|
|
1162
|
+
/**
|
|
1163
|
+
* narrows a rust.Type to a rust.WireType.
|
|
1164
|
+
* if type isn't a rust.WireType, an error is thrown.
|
|
1165
|
+
*
|
|
1166
|
+
* @param type the type to narrow
|
|
1167
|
+
* @returns the narrowed type
|
|
1168
|
+
*/
|
|
1169
|
+
typeToWireType(type) {
|
|
1170
|
+
switch (type.kind) {
|
|
1171
|
+
case 'bytes':
|
|
1172
|
+
case 'encodedBytes':
|
|
1173
|
+
case 'enum':
|
|
1174
|
+
case 'enumValue':
|
|
1175
|
+
case 'Etag':
|
|
1176
|
+
case 'hashmap':
|
|
1177
|
+
case 'jsonValue':
|
|
1178
|
+
case 'literal':
|
|
1179
|
+
case 'model':
|
|
1180
|
+
case 'offsetDateTime':
|
|
1181
|
+
case 'scalar':
|
|
1182
|
+
case 'str':
|
|
1183
|
+
case 'String':
|
|
1184
|
+
case 'Url':
|
|
1185
|
+
case 'Vec':
|
|
1186
|
+
return type;
|
|
1187
|
+
default:
|
|
1188
|
+
throw new Error(`cannot convert ${type.kind} to a wire type`);
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1112
1191
|
/**
|
|
1113
1192
|
* converts a tcgc spread parameter into a Rust partial body parameter.
|
|
1114
1193
|
*
|
|
@@ -1296,13 +1375,4 @@ function getXMLKind(decorators, field) {
|
|
|
1296
1375
|
}
|
|
1297
1376
|
return undefined;
|
|
1298
1377
|
}
|
|
1299
|
-
/**
|
|
1300
|
-
* contructs the fully qualified path to a client to be used in doc comments
|
|
1301
|
-
*
|
|
1302
|
-
* @param client the client to build the path to
|
|
1303
|
-
* @returns the fully qualified client path (e.g. crate::Client, crate::clients::SubClient)
|
|
1304
|
-
*/
|
|
1305
|
-
function buildClientDocPath(client) {
|
|
1306
|
-
return `crate::${client.constructable ? '' : 'clients::'}${client.name}`;
|
|
1307
|
-
}
|
|
1308
1378
|
//# sourceMappingURL=adapter.js.map
|