@azure-tools/typespec-rust 0.1.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/LICENSE +21 -0
- package/README.md +16 -0
- package/dist/src/codegen/cargotoml.d.ts +3 -0
- package/dist/src/codegen/cargotoml.d.ts.map +1 -0
- package/dist/src/codegen/cargotoml.js +22 -0
- package/dist/src/codegen/cargotoml.js.map +1 -0
- package/dist/src/codegen/clients.d.ts +7 -0
- package/dist/src/codegen/clients.d.ts.map +1 -0
- package/dist/src/codegen/clients.js +514 -0
- package/dist/src/codegen/clients.js.map +1 -0
- package/dist/src/codegen/codeGenerator.d.ts +14 -0
- package/dist/src/codegen/codeGenerator.d.ts.map +1 -0
- package/dist/src/codegen/codeGenerator.js +46 -0
- package/dist/src/codegen/codeGenerator.js.map +1 -0
- package/dist/src/codegen/context.d.ts +10 -0
- package/dist/src/codegen/context.d.ts.map +1 -0
- package/dist/src/codegen/context.js +75 -0
- package/dist/src/codegen/context.js.map +1 -0
- package/dist/src/codegen/enums.d.ts +4 -0
- package/dist/src/codegen/enums.d.ts.map +1 -0
- package/dist/src/codegen/enums.js +48 -0
- package/dist/src/codegen/enums.js.map +1 -0
- package/dist/src/codegen/helpers.d.ts +18 -0
- package/dist/src/codegen/helpers.d.ts.map +1 -0
- package/dist/src/codegen/helpers.js +133 -0
- package/dist/src/codegen/helpers.js.map +1 -0
- package/dist/src/codegen/lib.d.ts +3 -0
- package/dist/src/codegen/lib.d.ts.map +1 -0
- package/dist/src/codegen/lib.js +37 -0
- package/dist/src/codegen/lib.js.map +1 -0
- package/dist/src/codegen/mod.d.ts +3 -0
- package/dist/src/codegen/mod.d.ts.map +1 -0
- package/dist/src/codegen/mod.js +20 -0
- package/dist/src/codegen/mod.js.map +1 -0
- package/dist/src/codegen/models.d.ts +4 -0
- package/dist/src/codegen/models.d.ts.map +1 -0
- package/dist/src/codegen/models.js +45 -0
- package/dist/src/codegen/models.js.map +1 -0
- package/dist/src/codegen/use.d.ts +11 -0
- package/dist/src/codegen/use.d.ts.map +1 -0
- package/dist/src/codegen/use.js +105 -0
- package/dist/src/codegen/use.js.map +1 -0
- package/dist/src/codemodel/client.d.ts +137 -0
- package/dist/src/codemodel/client.d.ts.map +1 -0
- package/dist/src/codemodel/client.js +146 -0
- package/dist/src/codemodel/client.js.map +1 -0
- package/dist/src/codemodel/crate.d.ts +24 -0
- package/dist/src/codemodel/crate.d.ts.map +1 -0
- package/dist/src/codemodel/crate.js +53 -0
- package/dist/src/codemodel/crate.js.map +1 -0
- package/dist/src/codemodel/index.d.ts +5 -0
- package/dist/src/codemodel/index.d.ts.map +1 -0
- package/dist/src/codemodel/index.js +9 -0
- package/dist/src/codemodel/index.js.map +1 -0
- package/dist/src/codemodel/method.d.ts +32 -0
- package/dist/src/codemodel/method.d.ts.map +1 -0
- package/dist/src/codemodel/method.js +33 -0
- package/dist/src/codemodel/method.js.map +1 -0
- package/dist/src/codemodel/types.d.ts +224 -0
- package/dist/src/codemodel/types.d.ts.map +1 -0
- package/dist/src/codemodel/types.js +248 -0
- package/dist/src/codemodel/types.js.map +1 -0
- package/dist/src/emitter.d.ts +5 -0
- package/dist/src/emitter.d.ts.map +1 -0
- package/dist/src/emitter.js +45 -0
- package/dist/src/emitter.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib.d.ts +13 -0
- package/dist/src/lib.d.ts.map +1 -0
- package/dist/src/lib.js +24 -0
- package/dist/src/lib.js.map +1 -0
- package/dist/src/tcgcadapter/adapter.d.ts +25 -0
- package/dist/src/tcgcadapter/adapter.d.ts.map +1 -0
- package/dist/src/tcgcadapter/adapter.js +617 -0
- package/dist/src/tcgcadapter/adapter.js.map +1 -0
- package/dist/src/tcgcadapter/helpers.d.ts +4 -0
- package/dist/src/tcgcadapter/helpers.d.ts.map +1 -0
- package/dist/src/tcgcadapter/helpers.js +45 -0
- package/dist/src/tcgcadapter/helpers.js.map +1 -0
- package/dist/src/tcgcadapter/naming.d.ts +2 -0
- package/dist/src/tcgcadapter/naming.d.ts.map +1 -0
- package/dist/src/tcgcadapter/naming.js +27 -0
- package/dist/src/tcgcadapter/naming.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { Crate } from './crate.js';
|
|
2
|
+
export interface Docs {
|
|
3
|
+
summary?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
}
|
|
6
|
+
export type Type = Arc | EncodedBytes | Enum | ExternalType | HashMap | ImplTrait | JsonValue | Literal | Model | OffsetDateTime | Option | RequestContent | Response | Result | Scalar | StringSlice | StringType | Struct | TokenCredential | Unit | Url | Vector;
|
|
7
|
+
export interface Arc extends StdType {
|
|
8
|
+
kind: 'arc';
|
|
9
|
+
type: Type;
|
|
10
|
+
}
|
|
11
|
+
export type BytesEncoding = 'std' | 'url';
|
|
12
|
+
export interface EncodedBytes {
|
|
13
|
+
kind: 'encodedBytes';
|
|
14
|
+
encoding: BytesEncoding;
|
|
15
|
+
}
|
|
16
|
+
export interface Enum {
|
|
17
|
+
kind: 'enum';
|
|
18
|
+
name: string;
|
|
19
|
+
docs: Docs;
|
|
20
|
+
pub: boolean;
|
|
21
|
+
values: Array<EnumValue>;
|
|
22
|
+
extensible: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface EnumValue {
|
|
25
|
+
name: string;
|
|
26
|
+
docs: Docs;
|
|
27
|
+
value: number | string;
|
|
28
|
+
}
|
|
29
|
+
export interface ExternalType extends External {
|
|
30
|
+
kind: 'external';
|
|
31
|
+
lifetime?: Lifetime;
|
|
32
|
+
}
|
|
33
|
+
export interface HashMap extends StdType {
|
|
34
|
+
kind: 'hashmap';
|
|
35
|
+
type: Type;
|
|
36
|
+
}
|
|
37
|
+
export interface ImplTrait {
|
|
38
|
+
kind: 'implTrait';
|
|
39
|
+
name: string;
|
|
40
|
+
type: Type;
|
|
41
|
+
}
|
|
42
|
+
export interface JsonValue extends External {
|
|
43
|
+
kind: 'jsonValue';
|
|
44
|
+
}
|
|
45
|
+
export interface Lifetime {
|
|
46
|
+
name: string;
|
|
47
|
+
}
|
|
48
|
+
export interface Literal {
|
|
49
|
+
kind: 'literal';
|
|
50
|
+
value: boolean | null | number | string;
|
|
51
|
+
}
|
|
52
|
+
export interface Model extends StructBase {
|
|
53
|
+
kind: 'model';
|
|
54
|
+
fields: Array<ModelField>;
|
|
55
|
+
}
|
|
56
|
+
export interface ModelField extends StructFieldBase {
|
|
57
|
+
serde: string;
|
|
58
|
+
}
|
|
59
|
+
export type DateTimeEncoding = 'rfc3339' | 'rfc7231' | 'unixTimestamp';
|
|
60
|
+
export interface OffsetDateTime extends External {
|
|
61
|
+
kind: 'offsetDateTime';
|
|
62
|
+
encoding: DateTimeEncoding;
|
|
63
|
+
}
|
|
64
|
+
export interface Option {
|
|
65
|
+
kind: 'option';
|
|
66
|
+
type: Type;
|
|
67
|
+
ref: boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface RequestContent extends External {
|
|
70
|
+
kind: 'requestContent';
|
|
71
|
+
type: Type;
|
|
72
|
+
format: SerdeFormat;
|
|
73
|
+
}
|
|
74
|
+
export interface Response extends External {
|
|
75
|
+
kind: 'response';
|
|
76
|
+
type: Type;
|
|
77
|
+
format?: SerdeFormat;
|
|
78
|
+
}
|
|
79
|
+
export interface Result extends External {
|
|
80
|
+
kind: 'result';
|
|
81
|
+
type: Response | Unit;
|
|
82
|
+
}
|
|
83
|
+
export type ScalarType = 'bool' | 'f32' | 'f64' | 'i8' | 'i16' | 'i32' | 'i64';
|
|
84
|
+
export interface Scalar {
|
|
85
|
+
kind: 'scalar';
|
|
86
|
+
type: ScalarType;
|
|
87
|
+
}
|
|
88
|
+
export type SerdeFormat = 'json';
|
|
89
|
+
export interface StringSlice {
|
|
90
|
+
kind: 'str';
|
|
91
|
+
}
|
|
92
|
+
export interface StringType {
|
|
93
|
+
kind: 'String';
|
|
94
|
+
}
|
|
95
|
+
export interface Struct extends StructBase {
|
|
96
|
+
kind: 'struct';
|
|
97
|
+
fields: Array<StructField>;
|
|
98
|
+
}
|
|
99
|
+
export interface StructField extends StructFieldBase {
|
|
100
|
+
}
|
|
101
|
+
export interface TokenCredential extends External {
|
|
102
|
+
kind: 'tokenCredential';
|
|
103
|
+
scopes: Array<string>;
|
|
104
|
+
}
|
|
105
|
+
export interface Unit {
|
|
106
|
+
kind: 'unit';
|
|
107
|
+
}
|
|
108
|
+
export interface Url extends External {
|
|
109
|
+
kind: 'Url';
|
|
110
|
+
}
|
|
111
|
+
export interface Vector {
|
|
112
|
+
kind: 'vector';
|
|
113
|
+
type: Type;
|
|
114
|
+
}
|
|
115
|
+
export interface External {
|
|
116
|
+
crate: string;
|
|
117
|
+
name: string;
|
|
118
|
+
namespace?: string;
|
|
119
|
+
}
|
|
120
|
+
export declare class External implements External {
|
|
121
|
+
constructor(crate: Crate, crateName: string, typeName: string, namespace?: string);
|
|
122
|
+
}
|
|
123
|
+
export interface StdType {
|
|
124
|
+
name: string;
|
|
125
|
+
use: string;
|
|
126
|
+
}
|
|
127
|
+
export declare class StdType implements StdType {
|
|
128
|
+
constructor(name: string, use: string);
|
|
129
|
+
}
|
|
130
|
+
interface StructBase {
|
|
131
|
+
kind: 'model' | 'struct';
|
|
132
|
+
name: string;
|
|
133
|
+
docs: Docs;
|
|
134
|
+
pub: boolean;
|
|
135
|
+
fields: Array<StructFieldBase>;
|
|
136
|
+
lifetime?: Lifetime;
|
|
137
|
+
}
|
|
138
|
+
interface StructFieldBase {
|
|
139
|
+
name: string;
|
|
140
|
+
docs: Docs;
|
|
141
|
+
pub: boolean;
|
|
142
|
+
type: Type;
|
|
143
|
+
defaultValue?: string;
|
|
144
|
+
}
|
|
145
|
+
export declare class Arc extends StdType implements Arc {
|
|
146
|
+
constructor(type: Type);
|
|
147
|
+
}
|
|
148
|
+
export declare class EncodedBytes implements EncodedBytes {
|
|
149
|
+
constructor(encoding: BytesEncoding);
|
|
150
|
+
}
|
|
151
|
+
export declare class Enum implements Enum {
|
|
152
|
+
constructor(name: string, pub: boolean, values: Array<EnumValue>, extensible: boolean);
|
|
153
|
+
}
|
|
154
|
+
export declare class EnumValue implements EnumValue {
|
|
155
|
+
constructor(name: string, value: number | string);
|
|
156
|
+
}
|
|
157
|
+
export declare class ExternalType extends External implements ExternalType {
|
|
158
|
+
constructor(crate: Crate, crateName: string, typeName: string);
|
|
159
|
+
}
|
|
160
|
+
export declare class HashMap extends StdType implements HashMap {
|
|
161
|
+
constructor(type: Type);
|
|
162
|
+
}
|
|
163
|
+
export declare class ImplTrait implements ImplTrait {
|
|
164
|
+
constructor(name: string, type: Type);
|
|
165
|
+
}
|
|
166
|
+
export declare class JsonValue extends External implements JsonValue {
|
|
167
|
+
constructor(crate: Crate);
|
|
168
|
+
}
|
|
169
|
+
export declare class Lifetime implements Lifetime {
|
|
170
|
+
constructor(name: string);
|
|
171
|
+
}
|
|
172
|
+
export declare class Literal implements Literal {
|
|
173
|
+
constructor(value: boolean | null | number | string);
|
|
174
|
+
}
|
|
175
|
+
export declare class Model implements Model {
|
|
176
|
+
constructor(name: string, pub: boolean);
|
|
177
|
+
}
|
|
178
|
+
export declare class ModelField implements ModelField {
|
|
179
|
+
constructor(name: string, serde: string, pub: boolean, type: Type);
|
|
180
|
+
}
|
|
181
|
+
export declare class OffsetDateTime extends External implements OffsetDateTime {
|
|
182
|
+
constructor(crate: Crate, encoding: DateTimeEncoding);
|
|
183
|
+
}
|
|
184
|
+
export declare class Option implements Option {
|
|
185
|
+
constructor(type: Type, ref: boolean);
|
|
186
|
+
}
|
|
187
|
+
export declare class RequestContent extends External implements RequestContent {
|
|
188
|
+
constructor(crate: Crate, type: Type, format: SerdeFormat);
|
|
189
|
+
}
|
|
190
|
+
export declare class Response extends External implements Response {
|
|
191
|
+
constructor(crate: Crate, type: Type, format?: SerdeFormat);
|
|
192
|
+
}
|
|
193
|
+
export declare class Result extends External implements Result {
|
|
194
|
+
constructor(crate: Crate, type: Response | Unit);
|
|
195
|
+
}
|
|
196
|
+
export declare class Scalar implements Scalar {
|
|
197
|
+
constructor(type: ScalarType);
|
|
198
|
+
}
|
|
199
|
+
export declare class StringSlice implements StringSlice {
|
|
200
|
+
constructor();
|
|
201
|
+
}
|
|
202
|
+
export declare class StringType implements StringType {
|
|
203
|
+
constructor();
|
|
204
|
+
}
|
|
205
|
+
export declare class Struct implements Struct {
|
|
206
|
+
constructor(name: string, pub: boolean);
|
|
207
|
+
}
|
|
208
|
+
export declare class StructField implements StructField {
|
|
209
|
+
constructor(name: string, pub: boolean, type: Type);
|
|
210
|
+
}
|
|
211
|
+
export declare class TokenCredential extends External implements TokenCredential {
|
|
212
|
+
constructor(crate: Crate, scopes: Array<string>);
|
|
213
|
+
}
|
|
214
|
+
export declare class Unit implements Unit {
|
|
215
|
+
constructor();
|
|
216
|
+
}
|
|
217
|
+
export declare class Url extends External implements Url {
|
|
218
|
+
constructor(crate: Crate);
|
|
219
|
+
}
|
|
220
|
+
export declare class Vector implements Vector {
|
|
221
|
+
constructor(type: Type);
|
|
222
|
+
}
|
|
223
|
+
export {};
|
|
224
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/codemodel/types.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAY,CAAC;AAGpD,MAAM,WAAW,IAAI;IAEnB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAGD,MAAM,MAAM,IAAI,GAAG,GAAG,GAAG,YAAY,GAAG,IAAI,GAAG,YAAY,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,cAAc,GAAG,MAAM,GAAG,cAAc,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GA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a,IAAK,YAAW,IAAI;;CAIhC;AAED,qBAAa,GAAI,SAAQ,QAAS,YAAW,GAAG;gBAClC,KAAK,EAAE,KAAK;CAIzB;AAED,qBAAa,MAAO,YAAW,MAAM;gBACvB,IAAI,EAAE,IAAI;CAIvB"}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { CrateDependency } from './crate.js';
|
|
6
|
+
export class External {
|
|
7
|
+
constructor(crate, crateName, typeName, namespace) {
|
|
8
|
+
crate.addDependency(new CrateDependency(crateName));
|
|
9
|
+
this.crate = crateName;
|
|
10
|
+
this.name = typeName;
|
|
11
|
+
this.namespace = namespace;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class StdType {
|
|
15
|
+
constructor(name, use) {
|
|
16
|
+
this.name = name;
|
|
17
|
+
this.use = use;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
21
|
+
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
22
|
+
export class Arc extends StdType {
|
|
23
|
+
constructor(type) {
|
|
24
|
+
super('Arc', 'std::sync');
|
|
25
|
+
this.kind = 'arc';
|
|
26
|
+
this.type = type;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export class EncodedBytes {
|
|
30
|
+
constructor(encoding) {
|
|
31
|
+
this.kind = 'encodedBytes';
|
|
32
|
+
this.encoding = encoding;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class Enum {
|
|
36
|
+
constructor(name, pub, values, extensible) {
|
|
37
|
+
this.kind = 'enum';
|
|
38
|
+
this.name = name;
|
|
39
|
+
this.pub = pub;
|
|
40
|
+
if (values.length < 1) {
|
|
41
|
+
throw new Error('must provide at least one enum value');
|
|
42
|
+
}
|
|
43
|
+
this.values = values;
|
|
44
|
+
this.extensible = extensible;
|
|
45
|
+
this.docs = {};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class EnumValue {
|
|
49
|
+
constructor(name, value) {
|
|
50
|
+
this.name = name;
|
|
51
|
+
this.value = value;
|
|
52
|
+
this.docs = {};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export class ExternalType extends External {
|
|
56
|
+
constructor(crate, crateName, typeName) {
|
|
57
|
+
super(crate, crateName, typeName);
|
|
58
|
+
this.kind = 'external';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export class HashMap extends StdType {
|
|
62
|
+
constructor(type) {
|
|
63
|
+
super('HashMap', 'std::collections');
|
|
64
|
+
this.kind = 'hashmap';
|
|
65
|
+
this.type = type;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export class ImplTrait {
|
|
69
|
+
constructor(name, type) {
|
|
70
|
+
this.kind = 'implTrait';
|
|
71
|
+
this.name = name;
|
|
72
|
+
this.type = type;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export class JsonValue extends External {
|
|
76
|
+
constructor(crate) {
|
|
77
|
+
super(crate, 'serde_json', 'Value');
|
|
78
|
+
this.kind = 'jsonValue';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export class Lifetime {
|
|
82
|
+
constructor(name) {
|
|
83
|
+
this.name = `'${name}`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export class Literal {
|
|
87
|
+
constructor(value) {
|
|
88
|
+
this.kind = 'literal';
|
|
89
|
+
this.value = value;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export class Model {
|
|
93
|
+
constructor(name, pub) {
|
|
94
|
+
this.kind = 'model';
|
|
95
|
+
this.name = name;
|
|
96
|
+
this.pub = pub;
|
|
97
|
+
this.fields = new Array();
|
|
98
|
+
this.docs = {};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export class ModelField {
|
|
102
|
+
constructor(name, serde, pub, type) {
|
|
103
|
+
this.name = name;
|
|
104
|
+
this.serde = serde;
|
|
105
|
+
this.pub = pub;
|
|
106
|
+
this.type = type;
|
|
107
|
+
this.docs = {};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export class OffsetDateTime extends External {
|
|
111
|
+
constructor(crate, encoding) {
|
|
112
|
+
super(crate, 'time', 'OffsetDateTime');
|
|
113
|
+
this.kind = 'offsetDateTime';
|
|
114
|
+
this.encoding = encoding;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export class Option {
|
|
118
|
+
constructor(type, ref) {
|
|
119
|
+
switch (type.kind) {
|
|
120
|
+
case 'String':
|
|
121
|
+
case 'encodedBytes':
|
|
122
|
+
case 'enum':
|
|
123
|
+
case 'external':
|
|
124
|
+
case 'hashmap':
|
|
125
|
+
case 'model':
|
|
126
|
+
case 'offsetDateTime':
|
|
127
|
+
case 'scalar':
|
|
128
|
+
case 'struct':
|
|
129
|
+
case 'Url':
|
|
130
|
+
case 'vector':
|
|
131
|
+
this.kind = 'option';
|
|
132
|
+
this.type = type;
|
|
133
|
+
this.ref = ref;
|
|
134
|
+
break;
|
|
135
|
+
default:
|
|
136
|
+
throw new Error(`unsupported Option generic type param kind ${type.kind}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export class RequestContent extends External {
|
|
141
|
+
constructor(crate, type, format) {
|
|
142
|
+
switch (type.kind) {
|
|
143
|
+
case 'String':
|
|
144
|
+
case 'enum':
|
|
145
|
+
case 'hashmap':
|
|
146
|
+
case 'model':
|
|
147
|
+
case 'scalar':
|
|
148
|
+
case 'vector':
|
|
149
|
+
super(crate, 'azure_core', 'RequestContent');
|
|
150
|
+
this.kind = 'requestContent';
|
|
151
|
+
this.type = type;
|
|
152
|
+
break;
|
|
153
|
+
default:
|
|
154
|
+
throw new Error(`unsupported RequestContent generic type param kind ${type.kind}`);
|
|
155
|
+
}
|
|
156
|
+
this.format = format;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
export class Response extends External {
|
|
160
|
+
constructor(crate, type, format) {
|
|
161
|
+
switch (type.kind) {
|
|
162
|
+
case 'String':
|
|
163
|
+
case 'enum':
|
|
164
|
+
case 'hashmap':
|
|
165
|
+
case 'jsonValue':
|
|
166
|
+
case 'model':
|
|
167
|
+
case 'offsetDateTime':
|
|
168
|
+
case 'scalar':
|
|
169
|
+
case 'unit':
|
|
170
|
+
case 'vector':
|
|
171
|
+
super(crate, 'azure_core', 'Response');
|
|
172
|
+
this.kind = 'response';
|
|
173
|
+
this.type = type;
|
|
174
|
+
break;
|
|
175
|
+
default:
|
|
176
|
+
throw new Error(`unsupported Response generic type param kind ${type.kind}`);
|
|
177
|
+
}
|
|
178
|
+
this.format = format;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
export class Result extends External {
|
|
182
|
+
constructor(crate, type) {
|
|
183
|
+
super(crate, 'azure_core', 'Result');
|
|
184
|
+
this.kind = 'result';
|
|
185
|
+
this.type = type;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
export class Scalar {
|
|
189
|
+
constructor(type) {
|
|
190
|
+
this.kind = 'scalar';
|
|
191
|
+
this.type = type;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
export class StringSlice {
|
|
195
|
+
constructor() {
|
|
196
|
+
this.kind = 'str';
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
export class StringType {
|
|
200
|
+
constructor() {
|
|
201
|
+
this.kind = 'String';
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
export class Struct {
|
|
205
|
+
constructor(name, pub) {
|
|
206
|
+
this.kind = 'struct';
|
|
207
|
+
this.name = name;
|
|
208
|
+
this.pub = pub;
|
|
209
|
+
this.fields = new Array();
|
|
210
|
+
this.docs = {};
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
export class StructField {
|
|
214
|
+
constructor(name, pub, type) {
|
|
215
|
+
this.name = name;
|
|
216
|
+
this.pub = pub;
|
|
217
|
+
this.type = type;
|
|
218
|
+
this.docs = {};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
export class TokenCredential extends External {
|
|
222
|
+
constructor(crate, scopes) {
|
|
223
|
+
if (scopes.length === 0) {
|
|
224
|
+
throw new Error('scopes must contain at least one entry');
|
|
225
|
+
}
|
|
226
|
+
super(crate, 'azure_core', 'TokenCredential', 'auth');
|
|
227
|
+
this.kind = 'tokenCredential';
|
|
228
|
+
this.scopes = scopes;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
export class Unit {
|
|
232
|
+
constructor() {
|
|
233
|
+
this.kind = 'unit';
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
export class Url extends External {
|
|
237
|
+
constructor(crate) {
|
|
238
|
+
super(crate, 'azure_core', 'Url');
|
|
239
|
+
this.kind = 'Url';
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
export class Vector {
|
|
243
|
+
constructor(type) {
|
|
244
|
+
this.kind = 'vector';
|
|
245
|
+
this.type = type;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +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;AAqQpD,MAAM,OAAO,QAAQ;IACnB,YAAY,KAAY,EAAE,SAAiB,EAAE,QAAgB,EAAE,SAAkB;QAC/E,KAAK,CAAC,aAAa,CAAC,IAAI,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;QACpD,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,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;QACD,KAAK,CAAC,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,CAAC,CAAC;QACtD,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,YAAY,EAAE,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;IACpB,CAAC;CACF;AAED,MAAM,OAAO,MAAM;IACjB,YAAY,IAAU;QACpB,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RustEmitterOptions } from './lib.js';
|
|
2
|
+
import { EmitContext } from '@typespec/compiler';
|
|
3
|
+
import 'source-map-support/register.js';
|
|
4
|
+
export declare function $onEmit(context: EmitContext<RustEmitterOptions>): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=emitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/emitter.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,gCAAgC,CAAC;AAExC,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,kBAAkB,CAAC,iBAkCrE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { CodeGenerator } from './codegen/codeGenerator.js';
|
|
6
|
+
import { Adapter } from './tcgcadapter/adapter.js';
|
|
7
|
+
import { mkdir, writeFile } from 'fs/promises';
|
|
8
|
+
import * as path from 'path';
|
|
9
|
+
import 'source-map-support/register.js';
|
|
10
|
+
export async function $onEmit(context) {
|
|
11
|
+
const adapter = await Adapter.create(context);
|
|
12
|
+
const crate = adapter.tcgcToCrate();
|
|
13
|
+
await mkdir(`${context.emitterOutputDir}/src`, { recursive: true });
|
|
14
|
+
const codegen = new CodeGenerator(crate);
|
|
15
|
+
// TODO: don't overwrite an existing Cargo.toml file
|
|
16
|
+
// will likely need to merge existing Cargo.toml file with generated content
|
|
17
|
+
// https://github.com/Azure/typespec-rust/issues/22
|
|
18
|
+
await writeFile(`${context.emitterOutputDir}/Cargo.toml`, codegen.emitCargoToml());
|
|
19
|
+
// TODO: this will overwrite an existing lib.rs file.
|
|
20
|
+
// we will likely need to support merging generated content with a preexisting lib.rs
|
|
21
|
+
// https://github.com/Azure/typespec-rust/issues/20
|
|
22
|
+
await writeFile(`${context.emitterOutputDir}/src/lib.rs`, codegen.emitLib());
|
|
23
|
+
await writeToGeneratedDir(context.emitterOutputDir, 'mod.rs', codegen.emitMod());
|
|
24
|
+
const models = codegen.emitModels();
|
|
25
|
+
if (models.length > 0) {
|
|
26
|
+
await writeToGeneratedDir(context.emitterOutputDir, 'models.rs', models);
|
|
27
|
+
}
|
|
28
|
+
const enums = codegen.emitEnums();
|
|
29
|
+
if (enums.length > 0) {
|
|
30
|
+
await writeToGeneratedDir(context.emitterOutputDir, 'enums.rs', enums);
|
|
31
|
+
}
|
|
32
|
+
const clientFiles = codegen.emitClients();
|
|
33
|
+
for (const clientFile of clientFiles) {
|
|
34
|
+
await writeToGeneratedDir(context.emitterOutputDir, clientFile.name, clientFile.content, 'clients');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function writeToGeneratedDir(outDir, filename, content, subdir) {
|
|
38
|
+
let srcGen = `${outDir}/src/generated`;
|
|
39
|
+
if (subdir) {
|
|
40
|
+
srcGen = path.join(srcGen, subdir);
|
|
41
|
+
}
|
|
42
|
+
await mkdir(srcGen, { recursive: true });
|
|
43
|
+
await writeFile(`${srcGen}/${filename}`, content);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=emitter.js.map
|
|
@@ -0,0 +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,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,gCAAgC,CAAC;AAExC,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAAwC;IACpE,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAEpC,MAAM,KAAK,CAAC,GAAG,OAAO,CAAC,gBAAgB,MAAM,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;IAElE,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;IAEzC,oDAAoD;IACpD,4EAA4E;IAC5E,mDAAmD;IACnD,MAAM,SAAS,CAAC,GAAG,OAAO,CAAC,gBAAgB,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAEnF,qDAAqD;IACrD,qFAAqF;IACrF,mDAAmD;IACnD,MAAM,SAAS,CAAC,GAAG,OAAO,CAAC,gBAAgB,aAAa,EAAE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.ts"],"names":[],"mappings":"AAKA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
export * from './emitter.js';
|
|
6
|
+
export { $lib } from './lib.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface RustEmitterOptions {
|
|
2
|
+
'crate-name': string;
|
|
3
|
+
'crate-version': string;
|
|
4
|
+
}
|
|
5
|
+
export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
|
|
6
|
+
[code: string]: import("@typespec/compiler").DiagnosticMessages;
|
|
7
|
+
}, RustEmitterOptions, never>;
|
|
8
|
+
export declare const reportDiagnostic: <C extends string | number, M extends keyof {
|
|
9
|
+
[code: string]: import("@typespec/compiler").DiagnosticMessages;
|
|
10
|
+
}[C]>(program: import("@typespec/compiler").Program, diag: import("@typespec/compiler").DiagnosticReport<{
|
|
11
|
+
[code: string]: import("@typespec/compiler").DiagnosticMessages;
|
|
12
|
+
}, C, M>) => void, createStateSymbol: (name: string) => symbol, getTracer: (program: import("@typespec/compiler").Program) => import("@typespec/compiler").Tracer;
|
|
13
|
+
//# sourceMappingURL=lib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CACzB;AAoBD,eAAO,MAAM,IAAI;;6BAAgC,CAAC;AAClD,eAAO,MAAQ,gBAAgB;;;;mBAAE,iBAAiB,4BAAE,SAAS,wFAAS,CAAC"}
|
package/dist/src/lib.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { createTypeSpecLibrary } from '@typespec/compiler';
|
|
6
|
+
const EmitterOptionsSchema = {
|
|
7
|
+
type: 'object',
|
|
8
|
+
additionalProperties: true,
|
|
9
|
+
properties: {
|
|
10
|
+
'crate-name': { type: 'string', nullable: false },
|
|
11
|
+
'crate-version': { type: 'string', nullable: false },
|
|
12
|
+
},
|
|
13
|
+
required: [],
|
|
14
|
+
};
|
|
15
|
+
const libDef = {
|
|
16
|
+
name: '@azure-tools/typespec-rust',
|
|
17
|
+
diagnostics: {},
|
|
18
|
+
emitter: {
|
|
19
|
+
options: EmitterOptionsSchema,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export const $lib = createTypeSpecLibrary(libDef);
|
|
23
|
+
export const { reportDiagnostic, createStateSymbol, getTracer } = $lib;
|
|
24
|
+
//# sourceMappingURL=lib.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,qBAAqB,EAAkB,MAAM,oBAAoB,CAAC;AAO3E,MAAM,oBAAoB,GAAuC;IAC/D,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,IAAI;IAC1B,UAAU,EAAE;QACV,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE;QACjD,eAAe,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE;KACrD;IACD,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,4BAA4B;IAClC,WAAW,EAAE,EAAE;IACf,OAAO,EAAE;QACP,OAAO,EAAsC,oBAAoB;KAClE;CACO,CAAC;AAEX,MAAM,CAAC,MAAM,IAAI,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAClD,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { EmitContext } from '@typespec/compiler';
|
|
2
|
+
import { RustEmitterOptions } from '../lib.js';
|
|
3
|
+
import * as rust from '../codemodel/index.js';
|
|
4
|
+
export declare class Adapter {
|
|
5
|
+
static create(context: EmitContext<RustEmitterOptions>): Promise<Adapter>;
|
|
6
|
+
private readonly crate;
|
|
7
|
+
private readonly ctx;
|
|
8
|
+
private readonly types;
|
|
9
|
+
private readonly clientMethodParams;
|
|
10
|
+
private constructor();
|
|
11
|
+
tcgcToCrate(): rust.Crate;
|
|
12
|
+
private adaptTypes;
|
|
13
|
+
private getEnum;
|
|
14
|
+
private getModel;
|
|
15
|
+
private getModelField;
|
|
16
|
+
private getType;
|
|
17
|
+
private getUnitType;
|
|
18
|
+
private getLiteral;
|
|
19
|
+
private adaptClients;
|
|
20
|
+
private recursiveAdaptClient;
|
|
21
|
+
private adaptMethod;
|
|
22
|
+
private adaptMethodParameter;
|
|
23
|
+
private adaptSerdeFormat;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/tcgcadapter/adapter.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAG9C,qBAAa,OAAO;WACL,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAK/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;IAEvE,OAAO;IAcP,WAAW,IAAI,IAAI,CAAC,KAAK;IAiBzB,OAAO,CAAC,UAAU;IAuBlB,OAAO,CAAC,OAAO;IAqBf,OAAO,CAAC,QAAQ;IA2BhB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,OAAO;IAiIf,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,oBAAoB;IA0J5B,OAAO,CAAC,WAAW;IAmGnB,OAAO,CAAC,oBAAoB;IA4E5B,OAAO,CAAC,gBAAgB;CASzB"}
|