@azure-tools/typespec-rust 0.1.0 → 0.2.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/cargotoml.d.ts +6 -0
- package/dist/src/codegen/cargotoml.d.ts.map +1 -1
- package/dist/src/codegen/cargotoml.js +6 -1
- package/dist/src/codegen/cargotoml.js.map +1 -1
- package/dist/src/codegen/clients.d.ts +19 -2
- package/dist/src/codegen/clients.d.ts.map +1 -1
- package/dist/src/codegen/clients.js +483 -250
- package/dist/src/codegen/clients.js.map +1 -1
- package/dist/src/codegen/codeGenerator.d.ts +29 -6
- package/dist/src/codegen/codeGenerator.d.ts.map +1 -1
- package/dist/src/codegen/codeGenerator.js +64 -25
- package/dist/src/codegen/codeGenerator.js.map +1 -1
- package/dist/src/codegen/context.d.ts +41 -0
- package/dist/src/codegen/context.d.ts.map +1 -1
- package/dist/src/codegen/context.js +94 -15
- package/dist/src/codegen/context.js.map +1 -1
- package/dist/src/codegen/enums.d.ts +9 -1
- package/dist/src/codegen/enums.d.ts.map +1 -1
- package/dist/src/codegen/enums.js +34 -20
- package/dist/src/codegen/enums.js.map +1 -1
- package/dist/src/codegen/helpers.d.ts +116 -2
- package/dist/src/codegen/helpers.d.ts.map +1 -1
- package/dist/src/codegen/helpers.js +148 -18
- package/dist/src/codegen/helpers.js.map +1 -1
- package/dist/src/codegen/lib.d.ts +7 -1
- package/dist/src/codegen/lib.d.ts.map +1 -1
- package/dist/src/codegen/lib.js +10 -5
- package/dist/src/codegen/lib.js.map +1 -1
- package/dist/src/codegen/mod.d.ts +6 -1
- package/dist/src/codegen/mod.d.ts.map +1 -1
- package/dist/src/codegen/mod.js +9 -10
- package/dist/src/codegen/mod.js.map +1 -1
- package/dist/src/codegen/models.d.ts +20 -1
- package/dist/src/codegen/models.d.ts.map +1 -1
- package/dist/src/codegen/models.js +250 -13
- package/dist/src/codegen/models.js.map +1 -1
- package/dist/src/codegen/use.d.ts +32 -0
- package/dist/src/codegen/use.d.ts.map +1 -1
- package/dist/src/codegen/use.js +42 -15
- package/dist/src/codegen/use.js.map +1 -1
- package/dist/src/codemodel/client.d.ts +150 -11
- package/dist/src/codemodel/client.d.ts.map +1 -1
- package/dist/src/codemodel/client.js +60 -17
- package/dist/src/codemodel/client.js.map +1 -1
- package/dist/src/codemodel/crate.d.ts +33 -0
- package/dist/src/codemodel/crate.d.ts.map +1 -1
- package/dist/src/codemodel/crate.js +17 -0
- package/dist/src/codemodel/crate.js.map +1 -1
- package/dist/src/codemodel/method.d.ts +17 -0
- package/dist/src/codemodel/method.d.ts.map +1 -1
- package/dist/src/codemodel/types.d.ts +152 -24
- package/dist/src/codemodel/types.d.ts.map +1 -1
- package/dist/src/codemodel/types.js +39 -25
- package/dist/src/codemodel/types.js.map +1 -1
- package/dist/src/emitter.d.ts +5 -0
- package/dist/src/emitter.d.ts.map +1 -1
- package/dist/src/emitter.js +20 -20
- package/dist/src/emitter.js.map +1 -1
- package/dist/src/lib.d.ts +1 -0
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +1 -0
- package/dist/src/lib.js.map +1 -1
- package/dist/src/tcgcadapter/adapter.d.ts +73 -1
- package/dist/src/tcgcadapter/adapter.d.ts.map +1 -1
- package/dist/src/tcgcadapter/adapter.js +338 -71
- package/dist/src/tcgcadapter/adapter.js.map +1 -1
- package/dist/src/tcgcadapter/helpers.d.ts +18 -0
- package/dist/src/tcgcadapter/helpers.d.ts.map +1 -1
- package/dist/src/tcgcadapter/helpers.js +23 -2
- package/dist/src/tcgcadapter/helpers.js.map +1 -1
- package/dist/src/tcgcadapter/naming.d.ts +8 -0
- package/dist/src/tcgcadapter/naming.d.ts.map +1 -1
- package/dist/src/tcgcadapter/naming.js +8 -5
- package/dist/src/tcgcadapter/naming.js.map +1 -1
- package/package.json +21 -23
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../src/codegen/enums.ts"],"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EhB,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,18 +1,132 @@
|
|
|
1
1
|
import * as rust from '../codemodel/index.js';
|
|
2
2
|
export declare const AnnotationNonExhaustive = "#[non_exhaustive]\n";
|
|
3
3
|
export declare const AnonymousLifetimeAnnotation = "<'_>";
|
|
4
|
+
/**
|
|
5
|
+
* returns the content preamble common to all emitted files
|
|
6
|
+
*
|
|
7
|
+
* @returns the preamble content
|
|
8
|
+
*/
|
|
4
9
|
export declare function contentPreamble(): string;
|
|
10
|
+
/**
|
|
11
|
+
* formats doc comments if available
|
|
12
|
+
*
|
|
13
|
+
* @param docs contains any doc comments
|
|
14
|
+
* @returns formatted doc comments or the empty string
|
|
15
|
+
*/
|
|
5
16
|
export declare function formatDocComment(docs: rust.Docs): string;
|
|
17
|
+
/**
|
|
18
|
+
* returns 'pub ' prefix as required
|
|
19
|
+
*
|
|
20
|
+
* @param pub true if the prefix is required
|
|
21
|
+
* @returns the prefix or the empty string
|
|
22
|
+
*/
|
|
6
23
|
export declare function emitPub(pub: boolean): string;
|
|
7
|
-
|
|
24
|
+
/**
|
|
25
|
+
* returns the type declaration string for the specified Rust type
|
|
26
|
+
*
|
|
27
|
+
* @param type is the Rust type for which to emit the declaration
|
|
28
|
+
* @param withAnonymousLifetime indicates if an existing lifetime annotation should be substituted with the anonymous lifetime
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
export declare function getTypeDeclaration(type: rust.Client | rust.Type, withAnonymousLifetime?: boolean): string;
|
|
32
|
+
/** helper for managing indentation levels */
|
|
8
33
|
export declare class indentation {
|
|
9
34
|
private level;
|
|
10
|
-
constructor();
|
|
35
|
+
constructor(level?: number);
|
|
36
|
+
/**
|
|
37
|
+
* returns spaces for the current indentation level
|
|
38
|
+
*
|
|
39
|
+
* @returns a string with the current indentation level
|
|
40
|
+
*/
|
|
11
41
|
get(): string;
|
|
42
|
+
/**
|
|
43
|
+
* increments the indentation level
|
|
44
|
+
*
|
|
45
|
+
* @returns this indentation instance
|
|
46
|
+
*/
|
|
12
47
|
push(): indentation;
|
|
48
|
+
/**
|
|
49
|
+
* decrements the indentation level
|
|
50
|
+
*
|
|
51
|
+
* @returns this indentation instance
|
|
52
|
+
*/
|
|
13
53
|
pop(): indentation;
|
|
14
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* emits the derive annotation with the standard and any additional values
|
|
57
|
+
*
|
|
58
|
+
* @param extra contains any extra derive values
|
|
59
|
+
* @returns a derive macro
|
|
60
|
+
*/
|
|
15
61
|
export declare function annotationDerive(...extra: Array<string>): string;
|
|
62
|
+
/**
|
|
63
|
+
* used to sort strings in ascending order
|
|
64
|
+
*
|
|
65
|
+
* @param a is the value on the left side
|
|
66
|
+
* @param b is the value on the right side
|
|
67
|
+
* @returns -1 if a < b, 1 if a > b, or 0 if they're equal
|
|
68
|
+
*/
|
|
16
69
|
export declare function sortAscending(a: string, b: string): number;
|
|
70
|
+
/**
|
|
71
|
+
* returns the generic lifetime annotation string for lifetime (e.g. <'a>)
|
|
72
|
+
*
|
|
73
|
+
* @param lifetime contains the Rust lifetime value
|
|
74
|
+
* @returns the properly formatted lifetime annotation
|
|
75
|
+
*/
|
|
17
76
|
export declare function getGenericLifetimeAnnotation(lifetime: rust.Lifetime): string;
|
|
77
|
+
/** the if condition in an if block */
|
|
78
|
+
export interface ifBlock {
|
|
79
|
+
/** the condition in the if block */
|
|
80
|
+
condition: string;
|
|
81
|
+
/** the body of the if block */
|
|
82
|
+
body: (indent: indentation) => string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* constructs an if block (can expand to include else if/else as necessary)
|
|
86
|
+
*
|
|
87
|
+
* @param indent the current indentation helper in scope
|
|
88
|
+
* @param ifBlock the if block definition
|
|
89
|
+
* @returns the text for the if block
|
|
90
|
+
*/
|
|
91
|
+
export declare function buildIfBlock(indent: indentation, ifBlock: ifBlock): string;
|
|
92
|
+
/** an arm in a match expression */
|
|
93
|
+
export interface matchArm {
|
|
94
|
+
/** the pattern being matched */
|
|
95
|
+
pattern: string;
|
|
96
|
+
/** optional return type for this match arm */
|
|
97
|
+
returns?: string;
|
|
98
|
+
/** the body of this match arm */
|
|
99
|
+
body: (indent: indentation) => string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* constructs a match expression at the provided indentation level
|
|
103
|
+
*
|
|
104
|
+
* @param indent the current indentation helper in scope
|
|
105
|
+
* @param expr the expression to match
|
|
106
|
+
* @param arms one or more match arms
|
|
107
|
+
* @returns the text for the match block
|
|
108
|
+
*/
|
|
109
|
+
export declare function buildMatch(indent: indentation, expr: string, arms: Array<matchArm>): string;
|
|
110
|
+
/**
|
|
111
|
+
* returns capitalized str
|
|
112
|
+
* e.g. foo -> Foo
|
|
113
|
+
*
|
|
114
|
+
* @param str the string to capitalize
|
|
115
|
+
* @returns the capitalized value
|
|
116
|
+
*/
|
|
117
|
+
export declare function capitalize(str: string): string;
|
|
118
|
+
/**
|
|
119
|
+
* if type is an Option<T>, returns the T, else returns type
|
|
120
|
+
*
|
|
121
|
+
* @param type is the type to unwrap
|
|
122
|
+
* @returns the wrapped type or the original type if it wasn't wrapped
|
|
123
|
+
*/
|
|
124
|
+
export declare function unwrapOption(type: rust.Type): rust.Type;
|
|
125
|
+
/**
|
|
126
|
+
* recursively unwraps a type. if type is an Option<Vec<T>>, returns the T
|
|
127
|
+
*
|
|
128
|
+
* @param type is the type to unwrap
|
|
129
|
+
* @returns the wrapped type or the original type if it wasn't wrapped
|
|
130
|
+
*/
|
|
131
|
+
export declare function unwrapType(type: rust.Type): rust.Type;
|
|
18
132
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/codegen/helpers.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAS9C,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AAE7D,eAAO,MA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AI,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,MAAM,CAAC;CACvC;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAK1E;AAED,mCAAmC;AACnC,MAAM,WAAW,QAAQ;IACvB,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAEhB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,iCAAiC;IACjC,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,MAAM,CAAC;CACvC;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,MAAM,CAa3F;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAKvD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CASrD"}
|
|
@@ -11,11 +11,20 @@ const headerText = `// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
11
11
|
`;
|
|
12
12
|
export const AnnotationNonExhaustive = '#[non_exhaustive]\n';
|
|
13
13
|
export const AnonymousLifetimeAnnotation = '<\'_>';
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* returns the content preamble common to all emitted files
|
|
16
|
+
*
|
|
17
|
+
* @returns the preamble content
|
|
18
|
+
*/
|
|
15
19
|
export function contentPreamble() {
|
|
16
20
|
return headerText;
|
|
17
21
|
}
|
|
18
|
-
|
|
22
|
+
/**
|
|
23
|
+
* formats doc comments if available
|
|
24
|
+
*
|
|
25
|
+
* @param docs contains any doc comments
|
|
26
|
+
* @returns formatted doc comments or the empty string
|
|
27
|
+
*/
|
|
19
28
|
export function formatDocComment(docs) {
|
|
20
29
|
if (!docs.summary && !docs.description) {
|
|
21
30
|
return '';
|
|
@@ -32,15 +41,28 @@ export function formatDocComment(docs) {
|
|
|
32
41
|
}
|
|
33
42
|
return docStr;
|
|
34
43
|
}
|
|
35
|
-
|
|
44
|
+
/**
|
|
45
|
+
* returns 'pub ' prefix as required
|
|
46
|
+
*
|
|
47
|
+
* @param pub true if the prefix is required
|
|
48
|
+
* @returns the prefix or the empty string
|
|
49
|
+
*/
|
|
36
50
|
export function emitPub(pub) {
|
|
37
51
|
return pub ? 'pub ' : '';
|
|
38
52
|
}
|
|
39
|
-
|
|
53
|
+
/**
|
|
54
|
+
* returns the type declaration string for the specified Rust type
|
|
55
|
+
*
|
|
56
|
+
* @param type is the Rust type for which to emit the declaration
|
|
57
|
+
* @param withAnonymousLifetime indicates if an existing lifetime annotation should be substituted with the anonymous lifetime
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
40
60
|
export function getTypeDeclaration(type, withAnonymousLifetime = false) {
|
|
41
61
|
switch (type.kind) {
|
|
42
62
|
case 'arc':
|
|
43
63
|
return `${type.name}<dyn ${getTypeDeclaration(type.type)}>`;
|
|
64
|
+
case 'client':
|
|
65
|
+
return type.name;
|
|
44
66
|
case 'encodedBytes':
|
|
45
67
|
return 'Vec<u8>';
|
|
46
68
|
case 'hashmap':
|
|
@@ -50,7 +72,9 @@ export function getTypeDeclaration(type, withAnonymousLifetime = false) {
|
|
|
50
72
|
case 'literal':
|
|
51
73
|
return `${type.value}`;
|
|
52
74
|
case 'option':
|
|
53
|
-
return `Option<${
|
|
75
|
+
return `Option<${getTypeDeclaration(type.type, withAnonymousLifetime)}>`;
|
|
76
|
+
case 'pager':
|
|
77
|
+
return `Pager<${getTypeDeclaration(type.type, withAnonymousLifetime)}>`;
|
|
54
78
|
case 'requestContent':
|
|
55
79
|
case 'response':
|
|
56
80
|
case 'result':
|
|
@@ -85,35 +109,57 @@ export function getTypeDeclaration(type, withAnonymousLifetime = false) {
|
|
|
85
109
|
}
|
|
86
110
|
// four spaces per indent level
|
|
87
111
|
const oneIndentation = ' ';
|
|
88
|
-
|
|
112
|
+
/** helper for managing indentation levels */
|
|
89
113
|
export class indentation {
|
|
90
|
-
constructor() {
|
|
91
|
-
|
|
92
|
-
|
|
114
|
+
constructor(level) {
|
|
115
|
+
if (level !== undefined) {
|
|
116
|
+
this.level = level;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
// default to one level of indentation
|
|
120
|
+
this.level = 1;
|
|
121
|
+
}
|
|
93
122
|
}
|
|
94
|
-
|
|
123
|
+
/**
|
|
124
|
+
* returns spaces for the current indentation level
|
|
125
|
+
*
|
|
126
|
+
* @returns a string with the current indentation level
|
|
127
|
+
*/
|
|
95
128
|
get() {
|
|
96
|
-
let indent =
|
|
97
|
-
for (let i =
|
|
129
|
+
let indent = '';
|
|
130
|
+
for (let i = 0; i < this.level; ++i) {
|
|
98
131
|
indent += oneIndentation;
|
|
99
132
|
}
|
|
100
133
|
return indent;
|
|
101
134
|
}
|
|
102
|
-
|
|
135
|
+
/**
|
|
136
|
+
* increments the indentation level
|
|
137
|
+
*
|
|
138
|
+
* @returns this indentation instance
|
|
139
|
+
*/
|
|
103
140
|
push() {
|
|
104
141
|
++this.level;
|
|
105
142
|
return this;
|
|
106
143
|
}
|
|
107
|
-
|
|
144
|
+
/**
|
|
145
|
+
* decrements the indentation level
|
|
146
|
+
*
|
|
147
|
+
* @returns this indentation instance
|
|
148
|
+
*/
|
|
108
149
|
pop() {
|
|
109
150
|
--this.level;
|
|
110
|
-
if (this.level <
|
|
151
|
+
if (this.level < 0) {
|
|
111
152
|
throw new Error('indentation stack underflow');
|
|
112
153
|
}
|
|
113
154
|
return this;
|
|
114
155
|
}
|
|
115
156
|
}
|
|
116
|
-
|
|
157
|
+
/**
|
|
158
|
+
* emits the derive annotation with the standard and any additional values
|
|
159
|
+
*
|
|
160
|
+
* @param extra contains any extra derive values
|
|
161
|
+
* @returns a derive macro
|
|
162
|
+
*/
|
|
117
163
|
export function annotationDerive(...extra) {
|
|
118
164
|
const derive = new Array('Clone', 'Debug', 'Deserialize', 'Serialize');
|
|
119
165
|
// remove any empty values
|
|
@@ -122,12 +168,96 @@ export function annotationDerive(...extra) {
|
|
|
122
168
|
derive.sort();
|
|
123
169
|
return `#[derive(${derive.join(', ')})]\n`;
|
|
124
170
|
}
|
|
125
|
-
|
|
171
|
+
/**
|
|
172
|
+
* used to sort strings in ascending order
|
|
173
|
+
*
|
|
174
|
+
* @param a is the value on the left side
|
|
175
|
+
* @param b is the value on the right side
|
|
176
|
+
* @returns -1 if a < b, 1 if a > b, or 0 if they're equal
|
|
177
|
+
*/
|
|
126
178
|
export function sortAscending(a, b) {
|
|
127
179
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
128
180
|
}
|
|
129
|
-
|
|
181
|
+
/**
|
|
182
|
+
* returns the generic lifetime annotation string for lifetime (e.g. <'a>)
|
|
183
|
+
*
|
|
184
|
+
* @param lifetime contains the Rust lifetime value
|
|
185
|
+
* @returns the properly formatted lifetime annotation
|
|
186
|
+
*/
|
|
130
187
|
export function getGenericLifetimeAnnotation(lifetime) {
|
|
131
188
|
return `<${lifetime.name}>`;
|
|
132
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* constructs an if block (can expand to include else if/else as necessary)
|
|
192
|
+
*
|
|
193
|
+
* @param indent the current indentation helper in scope
|
|
194
|
+
* @param ifBlock the if block definition
|
|
195
|
+
* @returns the text for the if block
|
|
196
|
+
*/
|
|
197
|
+
export function buildIfBlock(indent, ifBlock) {
|
|
198
|
+
let body = `if ${ifBlock.condition} {\n`;
|
|
199
|
+
body += ifBlock.body(indent.push());
|
|
200
|
+
body += `${indent.pop().get()}}`;
|
|
201
|
+
return body;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* constructs a match expression at the provided indentation level
|
|
205
|
+
*
|
|
206
|
+
* @param indent the current indentation helper in scope
|
|
207
|
+
* @param expr the expression to match
|
|
208
|
+
* @param arms one or more match arms
|
|
209
|
+
* @returns the text for the match block
|
|
210
|
+
*/
|
|
211
|
+
export function buildMatch(indent, expr, arms) {
|
|
212
|
+
let match = `match ${expr} {\n`;
|
|
213
|
+
indent.push();
|
|
214
|
+
for (const arm of arms) {
|
|
215
|
+
match += `${indent.get()}${arm.pattern} => ${arm.returns ? arm.returns + ' ' : ''}{\n`;
|
|
216
|
+
match += arm.body(indent.push());
|
|
217
|
+
// the comma after an arm block is optional depending on the number
|
|
218
|
+
// of lines in the block. we'll always emit it and rely on cargo fmt
|
|
219
|
+
// to remove it as required.
|
|
220
|
+
match += `${indent.pop().get()}},\n`;
|
|
221
|
+
}
|
|
222
|
+
match += `${indent.pop().get()}}`;
|
|
223
|
+
return match;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* returns capitalized str
|
|
227
|
+
* e.g. foo -> Foo
|
|
228
|
+
*
|
|
229
|
+
* @param str the string to capitalize
|
|
230
|
+
* @returns the capitalized value
|
|
231
|
+
*/
|
|
232
|
+
export function capitalize(str) {
|
|
233
|
+
return codegen.capitalize(str);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* if type is an Option<T>, returns the T, else returns type
|
|
237
|
+
*
|
|
238
|
+
* @param type is the type to unwrap
|
|
239
|
+
* @returns the wrapped type or the original type if it wasn't wrapped
|
|
240
|
+
*/
|
|
241
|
+
export function unwrapOption(type) {
|
|
242
|
+
if (type.kind === 'option') {
|
|
243
|
+
return type.type;
|
|
244
|
+
}
|
|
245
|
+
return type;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* recursively unwraps a type. if type is an Option<Vec<T>>, returns the T
|
|
249
|
+
*
|
|
250
|
+
* @param type is the type to unwrap
|
|
251
|
+
* @returns the wrapped type or the original type if it wasn't wrapped
|
|
252
|
+
*/
|
|
253
|
+
export function unwrapType(type) {
|
|
254
|
+
switch (type.kind) {
|
|
255
|
+
case 'option':
|
|
256
|
+
case 'hashmap':
|
|
257
|
+
case 'vector':
|
|
258
|
+
return unwrapType(type.type);
|
|
259
|
+
default:
|
|
260
|
+
return type;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
133
263
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/codegen/helpers.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAGhD,MAAM,UAAU,GAAG;;;;;CAKlB,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAE7D,MAAM,CAAC,MAAM,2BAA2B,GAAG,OAAO,CAAC;AAEnD
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/codegen/helpers.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAGhD,MAAM,UAAU,GAAG;;;;;CAKlB,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAE7D,MAAM,CAAC,MAAM,2BAA2B,GAAG,OAAO,CAAC;AAEnD;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAe;IAC9C,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACvC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAA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AI,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;IAClC,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAe;IAC1C,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,IAAe;IACxC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import * as rust from '../codemodel/index.js';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* emits the contents of the lib.rs file
|
|
4
|
+
*
|
|
5
|
+
* @param crate the crate for which to emit a lib.rs file
|
|
6
|
+
* @returns the contents of the lib.rs file
|
|
7
|
+
*/
|
|
8
|
+
export declare function emitLibRs(crate: rust.Crate): string;
|
|
3
9
|
//# sourceMappingURL=lib.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../../src/codegen/lib.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../../src/codegen/lib.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAE9C;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,MAAM,CAoCnD"}
|
package/dist/src/codegen/lib.js
CHANGED
|
@@ -4,8 +4,13 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import * as codegen from '@azure-tools/codegen';
|
|
6
6
|
import * as helpers from './helpers.js';
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* emits the contents of the lib.rs file
|
|
9
|
+
*
|
|
10
|
+
* @param crate the crate for which to emit a lib.rs file
|
|
11
|
+
* @returns the contents of the lib.rs file
|
|
12
|
+
*/
|
|
13
|
+
export function emitLibRs(crate) {
|
|
9
14
|
let content = helpers.contentPreamble();
|
|
10
15
|
content += 'mod generated;\n\n';
|
|
11
16
|
if (crate.clients.length > 0) {
|
|
@@ -16,12 +21,12 @@ export function emitLib(crate) {
|
|
|
16
21
|
closeModels = true;
|
|
17
22
|
content += 'pub mod models {\n';
|
|
18
23
|
}
|
|
19
|
-
const
|
|
24
|
+
const indent = new helpers.indentation();
|
|
20
25
|
if (crate.enums.length > 0) {
|
|
21
|
-
content += `${
|
|
26
|
+
content += `${indent.get()}pub use crate::generated::enums::*;\n`;
|
|
22
27
|
}
|
|
23
28
|
if (crate.models.length > 0) {
|
|
24
|
-
content += `${
|
|
29
|
+
content += `${indent.get()}pub use crate::generated::models::*;\n`;
|
|
25
30
|
}
|
|
26
31
|
if (closeModels) {
|
|
27
32
|
content += '}\n';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../../src/codegen/lib.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC
|
|
1
|
+
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../../src/codegen/l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AC,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC;QAC1F,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import * as rust from '../codemodel/index.js';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* emits the contents of a mod.rs file
|
|
4
|
+
* @param modules the list of modules to include in the mod.rs file
|
|
5
|
+
* @returns the contents of the mod.rs file
|
|
6
|
+
*/
|
|
7
|
+
export declare function emitModRs(modules: Array<rust.Module>): string;
|
|
3
8
|
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/codegen/mod.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/codegen/mod.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CAO7D"}
|
package/dist/src/codegen/mod.js
CHANGED
|
@@ -3,17 +3,16 @@
|
|
|
3
3
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import * as helpers from './helpers.js';
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* emits the contents of a mod.rs file
|
|
8
|
+
* @param modules the list of modules to include in the mod.rs file
|
|
9
|
+
* @returns the contents of the mod.rs file
|
|
10
|
+
*/
|
|
11
|
+
export function emitModRs(modules) {
|
|
12
|
+
modules.sort((a, b) => { return helpers.sortAscending(a.name, b.name); });
|
|
8
13
|
let content = helpers.contentPreamble();
|
|
9
|
-
|
|
10
|
-
content += 'pub mod
|
|
11
|
-
}
|
|
12
|
-
if (crate.enums.length > 0) {
|
|
13
|
-
content += 'pub mod enums;\n';
|
|
14
|
-
}
|
|
15
|
-
if (crate.models.length > 0) {
|
|
16
|
-
content += 'pub mod models;\n';
|
|
14
|
+
for (const module of modules) {
|
|
15
|
+
content += `${module.pub ? 'pub ' : ''}mod ${module.name};\n`;
|
|
17
16
|
}
|
|
18
17
|
return content;
|
|
19
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../../src/codegen/mod.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../../src/codegen/mod.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,OAA2B;IACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,IAAI,OAAO,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IACxC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,OAAO,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC;IAChE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
import { Context } from './context.js';
|
|
2
2
|
import * as rust from '../codemodel/index.js';
|
|
3
|
-
|
|
3
|
+
/** contains different types of models to emit */
|
|
4
|
+
export interface Models {
|
|
5
|
+
/** models that are part of public surface area */
|
|
6
|
+
public?: string;
|
|
7
|
+
/** serde helpers for public models */
|
|
8
|
+
serde?: string;
|
|
9
|
+
/** models that are for internal use only */
|
|
10
|
+
internal?: string;
|
|
11
|
+
/** XML-specific helpers for internal use only */
|
|
12
|
+
xmlHelpers?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* returns the emitted model types, or empty if the
|
|
16
|
+
* crate contains no model types.
|
|
17
|
+
*
|
|
18
|
+
* @param crate the crate for which to emit models
|
|
19
|
+
* @param context the context for the provided crate
|
|
20
|
+
* @returns the model content or empty
|
|
21
|
+
*/
|
|
22
|
+
export declare function emitModels(crate: rust.Crate, context: Context): Models;
|
|
4
23
|
//# sourceMappingURL=models.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../src/codegen/models.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../src/codegen/models.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAE9C,iDAAiD;AACjD,MAAM,WAAW,MAAM;IACrB,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAWtE"}
|