@azure-tools/typespec-rust 0.36.0 → 0.38.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.d.ts +4 -4
- package/dist/src/codegen/clients.d.ts.map +1 -1
- package/dist/src/codegen/clients.js +208 -88
- package/dist/src/codegen/clients.js.map +1 -1
- package/dist/src/codegen/codeGenerator.d.ts +6 -0
- package/dist/src/codegen/codeGenerator.d.ts.map +1 -1
- package/dist/src/codegen/codeGenerator.js +112 -32
- package/dist/src/codegen/codeGenerator.js.map +1 -1
- package/dist/src/codegen/context.d.ts +10 -0
- package/dist/src/codegen/context.d.ts.map +1 -1
- package/dist/src/codegen/context.js +57 -15
- package/dist/src/codegen/context.js.map +1 -1
- package/dist/src/codegen/docTests.d.ts +1 -2
- package/dist/src/codegen/docTests.d.ts.map +1 -1
- package/dist/src/codegen/docTests.js +13 -3
- package/dist/src/codegen/docTests.js.map +1 -1
- package/dist/src/codegen/enums.d.ts +4 -4
- package/dist/src/codegen/enums.d.ts.map +1 -1
- package/dist/src/codegen/enums.js +21 -21
- package/dist/src/codegen/enums.js.map +1 -1
- package/dist/src/codegen/headerTraits.d.ts +2 -2
- package/dist/src/codegen/headerTraits.d.ts.map +1 -1
- package/dist/src/codegen/headerTraits.js +17 -9
- package/dist/src/codegen/headerTraits.js.map +1 -1
- package/dist/src/codegen/helpers.d.ts +12 -3
- package/dist/src/codegen/helpers.d.ts.map +1 -1
- package/dist/src/codegen/helpers.js +22 -13
- package/dist/src/codegen/helpers.js.map +1 -1
- package/dist/src/codegen/lib.d.ts +3 -1
- package/dist/src/codegen/lib.d.ts.map +1 -1
- package/dist/src/codegen/lib.js +5 -1
- package/dist/src/codegen/lib.js.map +1 -1
- package/dist/src/codegen/mod.d.ts +9 -2
- package/dist/src/codegen/mod.d.ts.map +1 -1
- package/dist/src/codegen/mod.js +25 -9
- package/dist/src/codegen/mod.js.map +1 -1
- package/dist/src/codegen/models.d.ts +4 -4
- package/dist/src/codegen/models.d.ts.map +1 -1
- package/dist/src/codegen/models.js +96 -39
- package/dist/src/codegen/models.js.map +1 -1
- package/dist/src/codegen/unions.d.ts +4 -4
- package/dist/src/codegen/unions.d.ts.map +1 -1
- package/dist/src/codegen/unions.js +81 -62
- package/dist/src/codegen/unions.js.map +1 -1
- package/dist/src/codegen/use.d.ts +4 -2
- package/dist/src/codegen/use.d.ts.map +1 -1
- package/dist/src/codegen/use.js +22 -26
- package/dist/src/codegen/use.js.map +1 -1
- package/dist/src/codemodel/client.d.ts +32 -16
- package/dist/src/codemodel/client.d.ts.map +1 -1
- package/dist/src/codemodel/client.js +11 -7
- package/dist/src/codemodel/client.js.map +1 -1
- package/dist/src/codemodel/crate.d.ts +42 -12
- package/dist/src/codemodel/crate.d.ts.map +1 -1
- package/dist/src/codemodel/crate.js +21 -46
- package/dist/src/codemodel/crate.js.map +1 -1
- package/dist/src/codemodel/types.d.ts +69 -38
- package/dist/src/codemodel/types.d.ts.map +1 -1
- package/dist/src/codemodel/types.js +31 -10
- package/dist/src/codemodel/types.js.map +1 -1
- package/dist/src/emitter.d.ts.map +1 -1
- package/dist/src/emitter.js +40 -12
- package/dist/src/emitter.js.map +1 -1
- package/dist/src/lib.d.ts +2 -0
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +6 -0
- package/dist/src/lib.js.map +1 -1
- package/dist/src/tcgcadapter/adapter.d.ts +76 -13
- package/dist/src/tcgcadapter/adapter.d.ts.map +1 -1
- package/dist/src/tcgcadapter/adapter.js +777 -190
- package/dist/src/tcgcadapter/adapter.js.map +1 -1
- package/dist/src/utils/utils.d.ts +23 -4
- package/dist/src/utils/utils.d.ts.map +1 -1
- package/dist/src/utils/utils.js +54 -23
- package/dist/src/utils/utils.js.map +1 -1
- package/package.json +17 -17
|
@@ -7,67 +7,93 @@ import * as helpers from './helpers.js';
|
|
|
7
7
|
import * as utils from '../utils/utils.js';
|
|
8
8
|
/**
|
|
9
9
|
* returns the union enum types, or undefined if the
|
|
10
|
-
*
|
|
10
|
+
* module contains no union types.
|
|
11
11
|
*
|
|
12
|
-
* @param
|
|
13
|
-
* @param context the context for the provided
|
|
12
|
+
* @param module the module for which to emit unions
|
|
13
|
+
* @param context the context for the provided module
|
|
14
14
|
* @returns the union content or undefined
|
|
15
15
|
*/
|
|
16
|
-
export function emitUnions(
|
|
16
|
+
export function emitUnions(module, context) {
|
|
17
17
|
var _a, _b;
|
|
18
|
-
if (
|
|
18
|
+
if (module.unions.length === 0) {
|
|
19
19
|
return {};
|
|
20
20
|
}
|
|
21
|
-
const use = new Use('modelsOther');
|
|
21
|
+
const use = new Use(module, 'modelsOther');
|
|
22
22
|
const indent = new helpers.indentation();
|
|
23
23
|
const visTracker = new helpers.VisibilityTracker();
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// Collect all union entries (discriminated and untagged) so they can be sorted.
|
|
25
|
+
const entries = [];
|
|
26
|
+
for (const rustUnion of module.unions) {
|
|
26
27
|
visTracker.update(rustUnion.visibility);
|
|
28
|
+
let body = '';
|
|
27
29
|
const docs = helpers.formatDocComment(rustUnion.docs, true);
|
|
28
30
|
if (docs.length > 0) {
|
|
29
31
|
body += `${indent.get()}#[doc = r#"${docs.substring(0, docs.length - 1)}"#]\n`;
|
|
30
32
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
if (rustUnion.kind === 'discriminatedUnion') {
|
|
34
|
+
const extensiblePolymorphicDU = ((_a = rustUnion.unionKind) === null || _a === void 0 ? void 0 : _a.kind) === 'discriminatedUnionBase' ? rustUnion.unionKind : undefined;
|
|
35
|
+
if (!extensiblePolymorphicDU) {
|
|
36
|
+
// extensible polymorphic unions define Serialize
|
|
37
|
+
use.add('serde', 'Serialize');
|
|
38
|
+
}
|
|
39
|
+
use.add('serde', 'Deserialize');
|
|
40
|
+
use.add('azure_core::fmt', 'SafeDebug');
|
|
41
|
+
body += `#[derive(Clone, Deserialize, ${!extensiblePolymorphicDU ? 'Serialize, ' : ''}SafeDebug)]\n`;
|
|
42
|
+
const content = ((_b = rustUnion.unionKind) === null || _b === void 0 ? void 0 : _b.kind) === 'discriminatedUnionEnvelope' ? `content = "${rustUnion.unionKind.envelopeName}"` : '';
|
|
43
|
+
body += `#[serde(${[content, `tag = "${rustUnion.discriminant}"`].filter(x => x !== '').join(', ')})]\n`;
|
|
44
|
+
body += `${helpers.emitVisibility(rustUnion.visibility)}enum ${rustUnion.name} {\n`;
|
|
45
|
+
for (const member of rustUnion.members) {
|
|
46
|
+
// Use isn't granular enough to realize we're in unions.rs
|
|
47
|
+
// so skip adding when the member is also a DU
|
|
48
|
+
if (member.type.kind !== 'discriminatedUnion') {
|
|
49
|
+
use.addForType(member.type);
|
|
50
|
+
}
|
|
51
|
+
const docs = helpers.formatDocComment(member.docs, true);
|
|
52
|
+
if (docs.length > 0) {
|
|
53
|
+
body += `${indent.get()}#[doc = r#"${docs.substring(0, docs.length - 1)}"#]\n`;
|
|
54
|
+
}
|
|
55
|
+
if (member.discriminantValue !== member.type.name) {
|
|
56
|
+
body += `#[serde(rename = "${member.discriminantValue}")]\n`;
|
|
57
|
+
}
|
|
58
|
+
body += `${indent.get()}${member.type.name}(${helpers.getTypeDeclaration(member.type)})`;
|
|
59
|
+
body += ',\n\n';
|
|
47
60
|
}
|
|
48
|
-
if (
|
|
49
|
-
body +=
|
|
61
|
+
if (extensiblePolymorphicDU) {
|
|
62
|
+
body += `${indent.get()}#[serde(untagged)]\n`;
|
|
63
|
+
body += `${indent.get()}${getPolymorphicUnknownVariant(indent, use, extensiblePolymorphicDU, rustUnion.discriminant, false)},\n`;
|
|
50
64
|
}
|
|
51
|
-
body += `${indent.get()}${member.type.name}(${helpers.getTypeDeclaration(member.type)})`;
|
|
52
|
-
body += ',\n\n';
|
|
53
65
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
66
|
+
else {
|
|
67
|
+
use.add('serde', 'Deserialize', 'Serialize');
|
|
68
|
+
use.add('azure_core::fmt', 'SafeDebug');
|
|
69
|
+
body += `#[derive(Clone, Deserialize, SafeDebug, Serialize)]\n`;
|
|
70
|
+
body += `#[serde(untagged)]\n`;
|
|
71
|
+
body += `${helpers.emitVisibility(rustUnion.visibility)}enum ${rustUnion.name} {\n`;
|
|
72
|
+
for (const variant of rustUnion.variants) {
|
|
73
|
+
use.addForType(variant.type);
|
|
74
|
+
const docs = helpers.formatDocComment(variant.docs, true);
|
|
75
|
+
if (docs.length > 0) {
|
|
76
|
+
body += `${indent.get()}#[doc = r#"${docs.substring(0, docs.length - 1)}"#]\n`;
|
|
77
|
+
}
|
|
78
|
+
body += `${indent.get()}${variant.name}(${helpers.getTypeDeclaration(variant.type)}),\n`;
|
|
79
|
+
}
|
|
57
80
|
}
|
|
58
|
-
body += '}\n\n';
|
|
81
|
+
body += '}\n\n';
|
|
82
|
+
entries.push({ name: rustUnion.name, body: body });
|
|
59
83
|
}
|
|
84
|
+
// Sort all entries alphabetically by name.
|
|
85
|
+
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
60
86
|
let content = helpers.contentPreamble();
|
|
61
87
|
content += use.text();
|
|
62
|
-
content += body;
|
|
88
|
+
content += entries.map(e => e.body).join('');
|
|
63
89
|
return {
|
|
64
90
|
definitions: {
|
|
65
91
|
name: 'unions',
|
|
66
92
|
content: content,
|
|
67
93
|
visibility: visTracker.get(),
|
|
68
94
|
},
|
|
69
|
-
impls: emitUnionImpls(
|
|
70
|
-
serde: emitUnionSerde(
|
|
95
|
+
impls: emitUnionImpls(module, context),
|
|
96
|
+
serde: emitUnionSerde(module),
|
|
71
97
|
};
|
|
72
98
|
}
|
|
73
99
|
/**
|
|
@@ -96,12 +122,14 @@ function getPolymorphicUnknownVariant(indent, use, baseType, discriminant, abbre
|
|
|
96
122
|
if (!abbreviated) {
|
|
97
123
|
unknownDef += helpers.formatDocComment(field.docs, false, undefined, indent);
|
|
98
124
|
}
|
|
99
|
-
use.addForType(field.type);
|
|
100
125
|
if (abbreviated) {
|
|
101
126
|
unknownDef += `${field.name}, `;
|
|
102
127
|
}
|
|
103
128
|
else {
|
|
104
|
-
|
|
129
|
+
use.addForType(field.type);
|
|
130
|
+
// the base internal type declares its fields with refs and a lifetime.
|
|
131
|
+
// we need to omit those for the inline anonymous unknown kind definition.
|
|
132
|
+
unknownDef += `${indent.get()}${field.name}: ${helpers.getTypeDeclaration(field.type, 'omit')},\n\n`;
|
|
105
133
|
}
|
|
106
134
|
}
|
|
107
135
|
unknownDef += `${abbreviated ? '' : indent.pop().get()}}`;
|
|
@@ -111,14 +139,16 @@ function getPolymorphicUnknownVariant(indent, use, baseType, discriminant, abbre
|
|
|
111
139
|
* returns any trait impls for union types.
|
|
112
140
|
* if no helpers are required, undefined is returned.
|
|
113
141
|
*
|
|
114
|
-
* @param
|
|
115
|
-
* @param context the context for the provided
|
|
142
|
+
* @param module the module for which to emit model impls
|
|
143
|
+
* @param context the context for the provided module
|
|
116
144
|
* @returns the union impls content or undefined
|
|
117
145
|
*/
|
|
118
|
-
function emitUnionImpls(
|
|
119
|
-
const use = new Use('modelsOther');
|
|
146
|
+
function emitUnionImpls(module, context) {
|
|
147
|
+
const use = new Use(module, 'modelsOther');
|
|
120
148
|
const entries = new Array();
|
|
121
|
-
for (const rustUnion of
|
|
149
|
+
for (const rustUnion of module.unions) {
|
|
150
|
+
if (rustUnion.kind !== 'discriminatedUnion')
|
|
151
|
+
continue;
|
|
122
152
|
const forReq = context.getTryFromForRequestContent(rustUnion, use);
|
|
123
153
|
// helpers aren't required for all types, so only
|
|
124
154
|
// add a use statement for a type if it has a helper
|
|
@@ -144,17 +174,19 @@ function emitUnionImpls(crate, context) {
|
|
|
144
174
|
* returns the content for unions_serde.rs.
|
|
145
175
|
* if no helpers are required, undefined is returned.
|
|
146
176
|
*
|
|
147
|
-
* @param
|
|
177
|
+
* @param module the module for which to emit model impls
|
|
148
178
|
* @returns the union serde helpers or undefined
|
|
149
179
|
*/
|
|
150
|
-
function emitUnionSerde(
|
|
151
|
-
if (
|
|
180
|
+
function emitUnionSerde(module) {
|
|
181
|
+
if (module.unions.length === 0) {
|
|
152
182
|
return undefined;
|
|
153
183
|
}
|
|
154
|
-
const use = new Use('modelsOther');
|
|
184
|
+
const use = new Use(module, 'modelsOther');
|
|
155
185
|
const indent = new helpers.indentation();
|
|
156
186
|
let body = '';
|
|
157
|
-
for (const rustUnion of
|
|
187
|
+
for (const rustUnion of module.unions) {
|
|
188
|
+
if (rustUnion.kind !== 'discriminatedUnion')
|
|
189
|
+
continue;
|
|
158
190
|
if (!isPolymorphicDU(rustUnion.unionKind) || rustUnion.unionKind.kind !== 'discriminatedUnionBase') {
|
|
159
191
|
continue;
|
|
160
192
|
}
|
|
@@ -176,21 +208,8 @@ function emitUnionSerde(crate) {
|
|
|
176
208
|
matchArms.push({
|
|
177
209
|
pattern: `${indent.get()}${rustUnion.name}::${getPolymorphicUnknownVariant(indent, use, unionBaseKind, rustUnion.discriminant, true)}`,
|
|
178
210
|
body: (indent) => {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
content += `${indent.get()}struct ${unknownVariantName}<'a> {\n`;
|
|
182
|
-
indent.push();
|
|
183
|
-
for (const field of unionBaseKind.baseType.fields) {
|
|
184
|
-
if (field.kind === 'additionalProperties') {
|
|
185
|
-
// TODO
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
content += `${indent.get()}#[serde(skip_serializing_if = "Option::is_none")]\n`;
|
|
189
|
-
content += `${indent.get()}${field.name}: &'a ${helpers.getTypeDeclaration(field.type)},\n`;
|
|
190
|
-
}
|
|
191
|
-
content += `${indent.pop().get()}}\n`;
|
|
192
|
-
content += `${indent.get()}${unknownVariantName}::serialize(&${unknownVariantName} { ${unionBaseKind.baseType.fields.map((field) => field.name).join(', ')} }, serializer)\n`;
|
|
193
|
-
return content;
|
|
211
|
+
use.addForType(unionBaseKind.baseType);
|
|
212
|
+
return `${indent.get()}${unionBaseKind.baseType.name}::serialize(&${unionBaseKind.baseType.name} { ${unionBaseKind.baseType.fields.map((field) => field.name).join(', ')} }, serializer)\n`;
|
|
194
213
|
},
|
|
195
214
|
});
|
|
196
215
|
body += `${indent.get()}${helpers.buildMatch(indent, 'self', matchArms)}\n`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unions.js","sourceRoot":"","sources":["../../../src/codegen/unions.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAc3C;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"unions.js","sourceRoot":"","sources":["../../../src/codegen/unions.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAc3C;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,MAA4B,EAAE,OAAgB;;IACvE,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IACzC,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAEnD,gFAAgF;I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,SAAS,CAAC,IAAI,CAAC;QAC5E,IAAI,IAAI,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,SAAS;QAC7C,IAAI,IAAI,OAAO,CAAC,CAAC,WAAW;IAC9B,CAAC;IAED,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QAChB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,OAAO,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IACxC,OAAO,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;IACtB,OAAO,IAAI,IAAI,CAAC;IAEhB,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,UAAU;KACvB,CAAC;AACJ,CAAC;AAED,4EAA4E;AAC5E,SAAS,eAAe,CAAC,MAAoC;IAC3D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,KAAK,CAAC;IACf,CAAC;IACD,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,wBAAwB,CAAC;QAC9B,KAAK,0BAA0B;YAC7B,OAAO,IAAI,CAAC;QACd;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -2,18 +2,20 @@ import * as helpers from './helpers.js';
|
|
|
2
2
|
import * as rust from '../codemodel/index.js';
|
|
3
3
|
/** used to generate use statements */
|
|
4
4
|
export declare class Use {
|
|
5
|
+
private readonly module;
|
|
5
6
|
private readonly trees;
|
|
6
7
|
private readonly scope;
|
|
7
8
|
/**
|
|
8
9
|
* instantiates a new instance of the Use type
|
|
9
10
|
*
|
|
11
|
+
* @param module the module that contains the files in scope
|
|
10
12
|
* @param scope indicates a scope in which use statements are constructed.
|
|
11
13
|
* this is only applicable when constructing the path to generated types.
|
|
12
14
|
* clients - we're in generated/clients
|
|
13
15
|
* models - we're in generated/models/models.rs
|
|
14
16
|
* modelsOther - we're in generated/models but not models.rs
|
|
15
17
|
*/
|
|
16
|
-
constructor(scope: 'clients' | 'models' | 'modelsOther');
|
|
18
|
+
constructor(module: rust.ModuleContainer, scope: 'clients' | 'models' | 'modelsOther');
|
|
17
19
|
/**
|
|
18
20
|
* adds the specified module and type if not already in the list
|
|
19
21
|
* e.g. ('azure_core', 'Context') or ('super::models', 'FooType')
|
|
@@ -29,7 +31,7 @@ export declare class Use {
|
|
|
29
31
|
*
|
|
30
32
|
* @param type the Rust type to add
|
|
31
33
|
*/
|
|
32
|
-
addForType(type: rust.Client | rust.
|
|
34
|
+
addForType(type: rust.Client | rust.ResponseHeadersTrait | rust.Type): void;
|
|
33
35
|
/**
|
|
34
36
|
* emits Rust use statements for the contents of this Use object
|
|
35
37
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../../src/codegen/use.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../../src/codegen/use.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAG9C,sCAAsC;AACtC,qBAAa,GAAG;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuB;IAC9C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiB;IACvC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuC;IAE7D;;;;;;;;;OASG;gBACS,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,aAAa;IAMrF;;;;;;;;OAQG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI;IAuBlD;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI;IA8F3E;;;;;OAKG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,GAAG,MAAM;CA0C3C"}
|
package/dist/src/codegen/use.js
CHANGED
|
@@ -4,18 +4,21 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import * as helpers from './helpers.js';
|
|
6
6
|
import { CodegenError } from './errors.js';
|
|
7
|
+
import * as utils from '../utils/utils.js';
|
|
7
8
|
/** used to generate use statements */
|
|
8
9
|
export class Use {
|
|
9
10
|
/**
|
|
10
11
|
* instantiates a new instance of the Use type
|
|
11
12
|
*
|
|
13
|
+
* @param module the module that contains the files in scope
|
|
12
14
|
* @param scope indicates a scope in which use statements are constructed.
|
|
13
15
|
* this is only applicable when constructing the path to generated types.
|
|
14
16
|
* clients - we're in generated/clients
|
|
15
17
|
* models - we're in generated/models/models.rs
|
|
16
18
|
* modelsOther - we're in generated/models but not models.rs
|
|
17
19
|
*/
|
|
18
|
-
constructor(scope) {
|
|
20
|
+
constructor(module, scope) {
|
|
21
|
+
this.module = module;
|
|
19
22
|
this.trees = new Array();
|
|
20
23
|
this.scope = scope;
|
|
21
24
|
}
|
|
@@ -59,12 +62,18 @@ export class Use {
|
|
|
59
62
|
return this.addForType(type.type);
|
|
60
63
|
case 'client': {
|
|
61
64
|
// client type are only referenced from other things in generated/clients so we ignore any scope
|
|
62
|
-
this.add(
|
|
65
|
+
this.add(`${utils.buildImportPath(this.module, type.module)}::clients`, type.name);
|
|
63
66
|
break;
|
|
64
67
|
}
|
|
65
68
|
case 'discriminatedUnion':
|
|
66
69
|
case 'enum':
|
|
67
|
-
|
|
70
|
+
case 'untaggedUnion':
|
|
71
|
+
if (this.scope === 'clients' || this.module !== type.module) {
|
|
72
|
+
this.add(`${utils.buildImportPath(this.module, type.module)}::models`, type.name);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
this.add('super', type.name);
|
|
76
|
+
}
|
|
68
77
|
break;
|
|
69
78
|
case 'enumValue':
|
|
70
79
|
this.addForType(type.type);
|
|
@@ -72,7 +81,8 @@ export class Use {
|
|
|
72
81
|
case 'marker':
|
|
73
82
|
switch (this.scope) {
|
|
74
83
|
case 'clients':
|
|
75
|
-
|
|
84
|
+
// marker types are always in the same module as their client method
|
|
85
|
+
this.add(`${utils.buildImportPath(this.module, this.module)}::models`, type.name);
|
|
76
86
|
break;
|
|
77
87
|
case 'modelsOther':
|
|
78
88
|
this.add('super', type.name);
|
|
@@ -84,16 +94,11 @@ export class Use {
|
|
|
84
94
|
}
|
|
85
95
|
break;
|
|
86
96
|
case 'model':
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// we're in models so no need to bring another model into scope
|
|
93
|
-
break;
|
|
94
|
-
case 'modelsOther':
|
|
95
|
-
this.add('super', type.name);
|
|
96
|
-
break;
|
|
97
|
+
if (this.scope === 'clients' || this.module !== type.module) {
|
|
98
|
+
this.add(`${utils.buildImportPath(this.module, type.module)}::models`, type.name);
|
|
99
|
+
}
|
|
100
|
+
else if (this.scope === 'modelsOther') {
|
|
101
|
+
this.add('super', type.name);
|
|
97
102
|
}
|
|
98
103
|
break;
|
|
99
104
|
case 'asyncResponse':
|
|
@@ -111,22 +116,12 @@ export class Use {
|
|
|
111
116
|
this.add('azure_core::http', type.type.format);
|
|
112
117
|
}
|
|
113
118
|
break;
|
|
114
|
-
case 'payload':
|
|
115
|
-
this.addForType(type.type);
|
|
116
|
-
break;
|
|
117
119
|
case 'requestContent':
|
|
118
120
|
if (type.format !== 'JsonFormat') {
|
|
119
121
|
// JsonFormat is the default so no need to bring it into scope
|
|
120
122
|
this.add('azure_core::http', type.format);
|
|
121
123
|
}
|
|
122
|
-
|
|
123
|
-
case 'bytes':
|
|
124
|
-
this.addForType(type.content);
|
|
125
|
-
break;
|
|
126
|
-
case 'payload':
|
|
127
|
-
this.addForType(type.content.type);
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
124
|
+
this.addForType(type.content);
|
|
130
125
|
break;
|
|
131
126
|
case 'response':
|
|
132
127
|
if (type.format !== 'JsonFormat') {
|
|
@@ -138,7 +133,8 @@ export class Use {
|
|
|
138
133
|
case 'responseHeadersTrait':
|
|
139
134
|
switch (this.scope) {
|
|
140
135
|
case 'clients':
|
|
141
|
-
|
|
136
|
+
// header response traits are always in the same module as their client method
|
|
137
|
+
this.add(`${utils.buildImportPath(this.module, this.module)}::models`, type.name);
|
|
142
138
|
break;
|
|
143
139
|
case 'models':
|
|
144
140
|
case 'modelsOther':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use.js","sourceRoot":"","sources":["../../../src/codegen/use.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"use.js","sourceRoot":"","sources":["../../../src/codegen/use.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,sCAAsC;AACtC,MAAM,OAAO,GAAG;IAKd;;;;;;;;;OASG;IACH,YAAY,MAA4B,EAAE,KAA2C;QACnF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,EAAW,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;;;;;;;OAQG;IACH,GAAG,CAAC,MAAc,EAAE,GAAG,KAAoB;QACzC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,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AC,KAAoB;QACzB,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACrB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;YACtD,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;gBACzB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC;YACD,IAAI,GAAG,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAED,2CAA2C;AAC3C,MAAM,OAAO;IAGX,YAAY,IAAY;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,IAAI,KAAc,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ModuleContainer } from './crate.js';
|
|
1
2
|
import * as method from './method.js';
|
|
2
3
|
import * as types from './types.js';
|
|
3
4
|
/** Client is a SDK client */
|
|
@@ -29,6 +30,8 @@ export interface Client {
|
|
|
29
30
|
fields: Array<types.StructField>;
|
|
30
31
|
/** all the methods for this client */
|
|
31
32
|
methods: Array<MethodType>;
|
|
33
|
+
/** the module to which this client belongs */
|
|
34
|
+
module: ModuleContainer;
|
|
32
35
|
/** the parent client in a hierarchical client */
|
|
33
36
|
parent?: Client;
|
|
34
37
|
}
|
|
@@ -135,7 +138,8 @@ export interface PageableMethod extends HTTPMethodBase {
|
|
|
135
138
|
export interface LroFinalResultStrategyOriginalUri {
|
|
136
139
|
kind: 'originalUri';
|
|
137
140
|
}
|
|
138
|
-
|
|
141
|
+
/** The header containing URL to read the LRO status from. Either a pre-defined common value, or a custom string name */
|
|
142
|
+
export type LroFinalResultStrategyHeaderName = 'operation-location' | 'azure-asyncoperation' | 'location' | (string & {});
|
|
139
143
|
/** LRO final result gets returned via the request sent to a URL that was returned in the first response, inside the */
|
|
140
144
|
export interface LroFinalResultStrategyHeader {
|
|
141
145
|
kind: 'header';
|
|
@@ -245,9 +249,17 @@ export interface HeaderScalarParameter extends HTTPParameterBase {
|
|
|
245
249
|
*/
|
|
246
250
|
isApiVersion: boolean;
|
|
247
251
|
}
|
|
248
|
-
/**
|
|
249
|
-
export interface
|
|
250
|
-
|
|
252
|
+
/** ParameterGroup is a group of parameters */
|
|
253
|
+
export interface ParameterGroup<T extends types.Option<types.Struct> | types.Struct> {
|
|
254
|
+
/** the name of the parameter */
|
|
255
|
+
name: string;
|
|
256
|
+
/** any docs for the parameter */
|
|
257
|
+
docs: types.Docs;
|
|
258
|
+
/**
|
|
259
|
+
* the parameter group's type. for the optional
|
|
260
|
+
* params group the type will be an Option<Struct>
|
|
261
|
+
*/
|
|
262
|
+
type: T;
|
|
251
263
|
}
|
|
252
264
|
/** PartialBodyParameter is a param that's a field within a type passed via the HTTP request body */
|
|
253
265
|
export interface PartialBodyParameter extends HTTPParameterBase {
|
|
@@ -258,7 +270,7 @@ export interface PartialBodyParameter extends HTTPParameterBase {
|
|
|
258
270
|
*/
|
|
259
271
|
paramType: types.Type;
|
|
260
272
|
/** the model in which the partial param is placed */
|
|
261
|
-
type: types.RequestContent<types.
|
|
273
|
+
type: types.RequestContent<types.Model>;
|
|
262
274
|
/** the name of the field over the wire in model.fields for this param */
|
|
263
275
|
serde: string;
|
|
264
276
|
}
|
|
@@ -391,6 +403,8 @@ export interface ResponseHeadersTrait {
|
|
|
391
403
|
docs: string;
|
|
392
404
|
/** indicates the visibility of the trait */
|
|
393
405
|
visibility: types.Visibility;
|
|
406
|
+
/** the module to which this trait belongs */
|
|
407
|
+
module: ModuleContainer;
|
|
394
408
|
}
|
|
395
409
|
interface ClientParameterBase {
|
|
396
410
|
/** the name of the parameter */
|
|
@@ -410,7 +424,7 @@ interface HTTPMethodBase extends method.Method<types.Type> {
|
|
|
410
424
|
/** the params passed to the method (excluding self). can be empty */
|
|
411
425
|
params: Array<HTTPParameterBase>;
|
|
412
426
|
/** the method options type for this method */
|
|
413
|
-
options:
|
|
427
|
+
options: ParameterGroup<types.Option<types.Struct>>;
|
|
414
428
|
/** the type returned by the method */
|
|
415
429
|
returns: types.Result;
|
|
416
430
|
/**
|
|
@@ -429,8 +443,10 @@ interface HTTPMethodBase extends method.Method<types.Type> {
|
|
|
429
443
|
interface HTTPParameterBase extends method.Parameter {
|
|
430
444
|
/** location of the parameter (e.g. client or method) */
|
|
431
445
|
location: ParameterLocation;
|
|
432
|
-
/** optional params go in the method's
|
|
446
|
+
/** optional params go in the method's ParameterGroup type */
|
|
433
447
|
optional: boolean;
|
|
448
|
+
/** set when this parameter belongs to a parameter group */
|
|
449
|
+
group?: ParameterGroup<types.Struct>;
|
|
434
450
|
}
|
|
435
451
|
declare class ClientParameterBase implements ClientParameterBase {
|
|
436
452
|
constructor(name: string, type: types.Type, optional: boolean);
|
|
@@ -442,13 +458,13 @@ declare class HTTPParameterBase extends method.Parameter {
|
|
|
442
458
|
constructor(name: string, location: ParameterLocation, optional: boolean, type: types.Type);
|
|
443
459
|
}
|
|
444
460
|
export declare class AsyncMethod extends HTTPMethodBase implements AsyncMethod {
|
|
445
|
-
constructor(name: string, languageIndependentName: string, client: Client, visibility: types.Visibility, options:
|
|
461
|
+
constructor(name: string, languageIndependentName: string, client: Client, visibility: types.Visibility, options: ParameterGroup<types.Option<types.Struct>>, httpMethod: HTTPMethod, httpPath: string);
|
|
446
462
|
}
|
|
447
463
|
export declare class BodyParameter extends HTTPParameterBase implements BodyParameter {
|
|
448
464
|
constructor(name: string, location: ParameterLocation, optional: boolean, type: types.RequestContent);
|
|
449
465
|
}
|
|
450
466
|
export declare class Client implements Client {
|
|
451
|
-
constructor(name: string);
|
|
467
|
+
constructor(name: string, module: ModuleContainer);
|
|
452
468
|
}
|
|
453
469
|
export declare class ClientAccessor extends method.Method<Client> implements ClientAccessor {
|
|
454
470
|
constructor(name: string, client: Client, returns: Client);
|
|
@@ -483,11 +499,8 @@ export declare class HeaderHashMapParameter extends HTTPParameterBase implements
|
|
|
483
499
|
export declare class HeaderScalarParameter extends HTTPParameterBase implements HeaderScalarParameter {
|
|
484
500
|
constructor(name: string, header: string, location: ParameterLocation, optional: boolean, type: HeaderScalarParameterType);
|
|
485
501
|
}
|
|
486
|
-
export declare class MethodOptions extends types.Option implements MethodOptions {
|
|
487
|
-
constructor(type: types.Struct);
|
|
488
|
-
}
|
|
489
502
|
export declare class PageableMethod extends HTTPMethodBase implements PageableMethod {
|
|
490
|
-
constructor(name: string, languageIndependentName: string, client: Client, visibility: types.Visibility, options:
|
|
503
|
+
constructor(name: string, languageIndependentName: string, client: Client, visibility: types.Visibility, options: ParameterGroup<types.Option<types.Struct>>, httpMethod: HTTPMethod, httpPath: string);
|
|
491
504
|
}
|
|
492
505
|
export declare class LroFinalResultStrategyOriginalUri implements LroFinalResultStrategyOriginalUri {
|
|
493
506
|
constructor();
|
|
@@ -496,7 +509,7 @@ export declare class LroFinalResultStrategyHeader implements LroFinalResultStrat
|
|
|
496
509
|
constructor(headerName: LroFinalResultStrategyHeaderName);
|
|
497
510
|
}
|
|
498
511
|
export declare class LroMethod extends HTTPMethodBase implements LroMethod {
|
|
499
|
-
constructor(name: string, languageIndependentName: string, client: Client, visibility: types.Visibility, options:
|
|
512
|
+
constructor(name: string, languageIndependentName: string, client: Client, visibility: types.Visibility, options: ParameterGroup<types.Option<types.Struct>>, httpMethod: HTTPMethod, httpPath: string, finalResultStrategy: LroFinalResultStrategyKind);
|
|
500
513
|
}
|
|
501
514
|
export declare class PageableStrategyContinuationToken implements PageableStrategyContinuationToken {
|
|
502
515
|
constructor(requestToken: HeaderScalarParameter | QueryScalarParameter, responseToken: ResponseHeaderScalar | PageableStrategyNextLink);
|
|
@@ -504,8 +517,11 @@ export declare class PageableStrategyContinuationToken implements PageableStrate
|
|
|
504
517
|
export declare class PageableStrategyNextLink implements PageableStrategyNextLink {
|
|
505
518
|
constructor(nextLinkPath: Array<types.ModelField>);
|
|
506
519
|
}
|
|
520
|
+
export declare class ParameterGroup<T extends types.Option<types.Struct> | types.Struct> implements ParameterGroup<T> {
|
|
521
|
+
constructor(name: string, type: T);
|
|
522
|
+
}
|
|
507
523
|
export declare class PartialBodyParameter extends HTTPParameterBase implements PartialBodyParameter {
|
|
508
|
-
constructor(name: string, location: ParameterLocation, optional: boolean, serde: string, paramType: types.Type, type: types.RequestContent<types.
|
|
524
|
+
constructor(name: string, location: ParameterLocation, optional: boolean, serde: string, paramType: types.Type, type: types.RequestContent<types.Model>);
|
|
509
525
|
}
|
|
510
526
|
export declare class PathCollectionParameter extends HTTPParameterBase implements PathCollectionParameter {
|
|
511
527
|
constructor(name: string, segment: string, location: ParameterLocation, optional: boolean, type: PathCollectionParameterType, encoded: boolean, style: ParameterStyle, explode: boolean);
|
|
@@ -532,7 +548,7 @@ export declare class ResponseHeaderScalar implements ResponseHeaderScalar {
|
|
|
532
548
|
constructor(name: string, header: string, type: types.WireType);
|
|
533
549
|
}
|
|
534
550
|
export declare class ResponseHeadersTrait implements ResponseHeadersTrait {
|
|
535
|
-
constructor(name: string, implFor: types.AsyncResponse<types.MarkerType> | types.Response<types.MarkerType | types.Model>, docs: string, visibility: types.Visibility);
|
|
551
|
+
constructor(name: string, implFor: types.AsyncResponse<types.MarkerType> | types.Response<types.MarkerType | types.Model>, docs: string, visibility: types.Visibility, module: ModuleContainer);
|
|
536
552
|
}
|
|
537
553
|
export declare class SupplementalEndpoint implements SupplementalEndpoint {
|
|
538
554
|
constructor(path: string);
|