@huanglangjian/specs 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/index.d.mts +864 -0
- package/dist/index.mjs +843 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +32 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,864 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/simplify.d.ts
|
|
2
|
+
/**
|
|
3
|
+
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
4
|
+
|
|
5
|
+
@example
|
|
6
|
+
```
|
|
7
|
+
import type {Simplify} from 'type-fest';
|
|
8
|
+
|
|
9
|
+
type PositionProps = {
|
|
10
|
+
top: number;
|
|
11
|
+
left: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type SizeProps = {
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
20
|
+
type Props = Simplify<PositionProps & SizeProps>;
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
|
24
|
+
|
|
25
|
+
If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
|
26
|
+
|
|
27
|
+
@example
|
|
28
|
+
```
|
|
29
|
+
import type {Simplify} from 'type-fest';
|
|
30
|
+
|
|
31
|
+
interface SomeInterface {
|
|
32
|
+
foo: number;
|
|
33
|
+
bar?: string;
|
|
34
|
+
baz: number | undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type SomeType = {
|
|
38
|
+
foo: number;
|
|
39
|
+
bar?: string;
|
|
40
|
+
baz: number | undefined;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
44
|
+
const someType: SomeType = literal;
|
|
45
|
+
const someInterface: SomeInterface = literal;
|
|
46
|
+
|
|
47
|
+
declare function fn(object: Record<string, unknown>): void;
|
|
48
|
+
|
|
49
|
+
fn(literal); // Good: literal object type is sealed
|
|
50
|
+
fn(someType); // Good: type is sealed
|
|
51
|
+
// @ts-expect-error
|
|
52
|
+
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
53
|
+
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
57
|
+
@see {@link SimplifyDeep}
|
|
58
|
+
@category Object
|
|
59
|
+
*/
|
|
60
|
+
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/schemas/json-schema-draft-2020-12.d.ts
|
|
63
|
+
interface JsonSchemaObject extends JsonSchemaCore, JsonSchemaApplicator, JsonSchemaUnevaluated, JsonSchemaValidation, JsonSchemaMetaData, JsonSchemaFormat, JsonSchemaContent {}
|
|
64
|
+
type JsonSchema = JsonSchemaObject | boolean | undefined;
|
|
65
|
+
interface JsonSchemaCore {
|
|
66
|
+
$id?: string;
|
|
67
|
+
$schema?: string;
|
|
68
|
+
$ref?: string;
|
|
69
|
+
$anchor?: string;
|
|
70
|
+
$dynamicRef?: string;
|
|
71
|
+
$dynamicAnchor?: string;
|
|
72
|
+
$vocabulary?: {
|
|
73
|
+
[key: string]: boolean;
|
|
74
|
+
};
|
|
75
|
+
$comment?: string;
|
|
76
|
+
$defs?: {
|
|
77
|
+
[key: string]: JsonSchema;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
interface JsonSchemaApplicator {
|
|
81
|
+
prefixItems?: JsonSchema[];
|
|
82
|
+
items?: JsonSchema;
|
|
83
|
+
contains?: JsonSchema;
|
|
84
|
+
additionalProperties?: JsonSchema;
|
|
85
|
+
properties?: {
|
|
86
|
+
[key: string]: JsonSchema;
|
|
87
|
+
};
|
|
88
|
+
patternProperties?: {
|
|
89
|
+
[key: string]: JsonSchema;
|
|
90
|
+
};
|
|
91
|
+
dependentSchemas?: {
|
|
92
|
+
[key: string]: JsonSchema;
|
|
93
|
+
};
|
|
94
|
+
propertyNames?: JsonSchema;
|
|
95
|
+
if?: JsonSchema;
|
|
96
|
+
then?: JsonSchema;
|
|
97
|
+
else?: JsonSchema;
|
|
98
|
+
allOf?: JsonSchema[];
|
|
99
|
+
anyOf?: JsonSchema[];
|
|
100
|
+
oneOf?: JsonSchema[];
|
|
101
|
+
not?: JsonSchema;
|
|
102
|
+
}
|
|
103
|
+
interface JsonSchemaUnevaluated {
|
|
104
|
+
unevaluatedItems?: JsonSchema;
|
|
105
|
+
unevaluatedProperties?: JsonSchema;
|
|
106
|
+
}
|
|
107
|
+
interface JsonSchemaValidation {
|
|
108
|
+
type?: SimpleType | SimpleType[];
|
|
109
|
+
const?: any;
|
|
110
|
+
enum?: any[];
|
|
111
|
+
multipleOf?: number;
|
|
112
|
+
maximum?: number;
|
|
113
|
+
exclusiveMaximum?: number;
|
|
114
|
+
minimum?: number;
|
|
115
|
+
exclusiveMinimum?: number;
|
|
116
|
+
maxLength?: number;
|
|
117
|
+
minLength?: number;
|
|
118
|
+
pattern?: string;
|
|
119
|
+
maxItems?: number;
|
|
120
|
+
minItems?: number;
|
|
121
|
+
uniqueItems?: boolean;
|
|
122
|
+
maxContains?: number;
|
|
123
|
+
minContains?: number;
|
|
124
|
+
maxProperties?: number;
|
|
125
|
+
minProperties?: number;
|
|
126
|
+
required?: string[];
|
|
127
|
+
dependentRequired?: {
|
|
128
|
+
[key: string]: string[];
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
interface JsonSchemaMetaData {
|
|
132
|
+
title?: string;
|
|
133
|
+
description?: string;
|
|
134
|
+
default?: any;
|
|
135
|
+
deprecated?: boolean;
|
|
136
|
+
readOnly?: boolean;
|
|
137
|
+
writeOnly?: boolean;
|
|
138
|
+
examples?: any[];
|
|
139
|
+
}
|
|
140
|
+
interface JsonSchemaFormat {
|
|
141
|
+
format?: FormatVariants | (string & {});
|
|
142
|
+
}
|
|
143
|
+
type FormatVariants = "date-time" | "date" | "time" | "duration" | "email" | "hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "uri-template" | "url" | "json-pointer" | "relative-json-pointer" | "regex" | "byte" | "binary" | "uuid" | "ipvfuture" | "int64" | "int32" | "float" | "double";
|
|
144
|
+
interface JsonSchemaContent {
|
|
145
|
+
contentEncoding?: string;
|
|
146
|
+
contentMediaType?: string;
|
|
147
|
+
contentSchema?: JsonSchema;
|
|
148
|
+
}
|
|
149
|
+
declare const SimpleTypes: readonly ["array", "boolean", "integer", "null", "number", "object", "string"];
|
|
150
|
+
type SimpleType = (typeof SimpleTypes)[number];
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/schemas/schema-variants.d.ts
|
|
153
|
+
interface StringSchema {
|
|
154
|
+
maxLength?: number;
|
|
155
|
+
minLength?: number;
|
|
156
|
+
pattern?: string;
|
|
157
|
+
format?: FormatVariants | (string & {});
|
|
158
|
+
}
|
|
159
|
+
interface NumberSchema {
|
|
160
|
+
multipleOf?: number;
|
|
161
|
+
maximum?: number;
|
|
162
|
+
exclusiveMaximum?: number;
|
|
163
|
+
minimum?: number;
|
|
164
|
+
exclusiveMinimum?: number;
|
|
165
|
+
}
|
|
166
|
+
interface ArraySchema {
|
|
167
|
+
maxItems?: number;
|
|
168
|
+
minItems?: number;
|
|
169
|
+
contains?: JsonSchemaObject;
|
|
170
|
+
maxContains?: number;
|
|
171
|
+
minContains?: number;
|
|
172
|
+
}
|
|
173
|
+
interface SetSchema {
|
|
174
|
+
maxItems?: number;
|
|
175
|
+
minItems?: number;
|
|
176
|
+
contains?: JsonSchemaObject;
|
|
177
|
+
maxContains?: number;
|
|
178
|
+
minContains?: number;
|
|
179
|
+
}
|
|
180
|
+
interface MapSchema {
|
|
181
|
+
maxProperties?: number;
|
|
182
|
+
minProperties?: number;
|
|
183
|
+
required?: string[];
|
|
184
|
+
dependentRequired?: {
|
|
185
|
+
[key: string]: string[];
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region src/type-system/basic.d.ts
|
|
190
|
+
interface BasicModel<T> {
|
|
191
|
+
id?: string;
|
|
192
|
+
title?: string;
|
|
193
|
+
description?: string;
|
|
194
|
+
examples?: T[];
|
|
195
|
+
default?: T;
|
|
196
|
+
deprecated?: boolean;
|
|
197
|
+
}
|
|
198
|
+
interface Int32Model extends BasicModel<number> {
|
|
199
|
+
kind: "int32";
|
|
200
|
+
schema?: NumberSchema;
|
|
201
|
+
}
|
|
202
|
+
interface Int32ModelOptions extends Omit<Int32Model, "kind"> {}
|
|
203
|
+
declare function int32(options?: Int32ModelOptions): Int32Model;
|
|
204
|
+
interface Int64Model extends BasicModel<string> {
|
|
205
|
+
kind: "int64";
|
|
206
|
+
schema?: StringSchema;
|
|
207
|
+
}
|
|
208
|
+
interface Int64ModelOptions extends Omit<Int64Model, "kind"> {}
|
|
209
|
+
declare function int64(options?: Int64ModelOptions): Int64Model;
|
|
210
|
+
interface Float32Model extends BasicModel<number> {
|
|
211
|
+
kind: "float32";
|
|
212
|
+
schema?: NumberSchema;
|
|
213
|
+
}
|
|
214
|
+
interface Float32ModelOptions extends Omit<Float32Model, "kind"> {}
|
|
215
|
+
declare function float32(options?: Float32ModelOptions): Float32Model;
|
|
216
|
+
interface Float64Model extends BasicModel<number> {
|
|
217
|
+
kind: "float64";
|
|
218
|
+
schema?: NumberSchema;
|
|
219
|
+
}
|
|
220
|
+
interface Float64ModelOptions extends Omit<Float64Model, "kind"> {}
|
|
221
|
+
declare function float64(options?: Float64ModelOptions): Float64Model;
|
|
222
|
+
interface BooleanModel extends BasicModel<boolean> {
|
|
223
|
+
kind: "boolean";
|
|
224
|
+
}
|
|
225
|
+
interface BooleanModelOptions extends Omit<BooleanModel, "kind"> {}
|
|
226
|
+
declare function boolean(options?: BooleanModelOptions): BooleanModel;
|
|
227
|
+
interface StringModel extends BasicModel<string> {
|
|
228
|
+
kind: "string";
|
|
229
|
+
schema?: StringSchema;
|
|
230
|
+
}
|
|
231
|
+
interface StringModelOptions extends Omit<StringModel, "kind"> {}
|
|
232
|
+
declare function string(options?: StringModelOptions): StringModel;
|
|
233
|
+
interface LiteralModel<T extends string | number | boolean> extends BasicModel<T> {
|
|
234
|
+
kind: "literal";
|
|
235
|
+
value: T;
|
|
236
|
+
}
|
|
237
|
+
interface LiteralModelOptions<T extends string | number | boolean> extends Omit<LiteralModel<T>, "kind"> {}
|
|
238
|
+
declare function literal<const T extends string | number | boolean>(options: LiteralModelOptions<T>): LiteralModel<T>;
|
|
239
|
+
/**
|
|
240
|
+
* 表示一个可选类型,代表"值可能存在也可能不存在"的语义。
|
|
241
|
+
*
|
|
242
|
+
* 设计理念:
|
|
243
|
+
* - 统一"空白"语义:将 `null`、`undefined` 和缺失值等多种"空"的概念合并为单一语义,
|
|
244
|
+
* 避免类型系统中存在多个含义模糊的"空"状态。
|
|
245
|
+
* - 序列化到 JSON 时,`Optional` 可以表示为 `null` 或完全省略(取决于上下文)。
|
|
246
|
+
* `InferModelJsonType<T> | null | undefined` 表示该值可以是基础类型、`null` 或 `undefined`。
|
|
247
|
+
* - 如果需要区分"显式设置为空"和"从未设置"等细分语义,应当另行设计专用类型。
|
|
248
|
+
*
|
|
249
|
+
* @template T 基础模型类型
|
|
250
|
+
*/
|
|
251
|
+
interface OptionalModel<T extends TypeModels> extends BasicModel<InferModelJsonType<T> | null | undefined> {
|
|
252
|
+
kind: "optional";
|
|
253
|
+
base: T;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* 将类型模型转换为可选类型。
|
|
257
|
+
*
|
|
258
|
+
* @template T 基础模型类型
|
|
259
|
+
*/
|
|
260
|
+
type Optionalize<T extends TypeModels> = T extends TypeModels ? OptionalModel<T> : never;
|
|
261
|
+
interface OptionalModelOptions<T extends TypeModels> extends Omit<OptionalModel<T>, "kind" | "base"> {}
|
|
262
|
+
/**
|
|
263
|
+
* 创建一个可选类型模型。
|
|
264
|
+
*
|
|
265
|
+
* @param base 基础模型类型
|
|
266
|
+
* @param options 可选配置选项
|
|
267
|
+
* @returns 可选类型模型
|
|
268
|
+
*/
|
|
269
|
+
declare function optional<T extends TypeModels>(base: T, options?: OptionalModelOptions<T>): OptionalModel<T>;
|
|
270
|
+
interface ArrayModel<T> extends BasicModel<InferModelJsonType<T>[]> {
|
|
271
|
+
kind: "array";
|
|
272
|
+
base: T;
|
|
273
|
+
schema?: ArraySchema;
|
|
274
|
+
}
|
|
275
|
+
interface ArrayModelOptions<T extends TypeModels> extends Omit<ArrayModel<T>, "kind" | "base"> {}
|
|
276
|
+
declare function array<T extends TypeModels>(base: T, options?: ArrayModelOptions<T>): ArrayModel<T>;
|
|
277
|
+
interface SetModel<T extends TypeModels> extends BasicModel<InferModelJsonType<T>[]> {
|
|
278
|
+
kind: "set";
|
|
279
|
+
base: T;
|
|
280
|
+
schema?: SetSchema;
|
|
281
|
+
}
|
|
282
|
+
interface SetModelOptions<T extends TypeModels> extends Omit<SetModel<T>, "kind" | "base"> {}
|
|
283
|
+
declare function set<T extends TypeModels>(base: T, options?: SetModelOptions<T>): SetModel<T>;
|
|
284
|
+
interface MapModel<T> extends BasicModel<{
|
|
285
|
+
[key: string]: InferModelJsonType<T>;
|
|
286
|
+
}> {
|
|
287
|
+
kind: "map";
|
|
288
|
+
base: T;
|
|
289
|
+
schema?: MapSchema;
|
|
290
|
+
}
|
|
291
|
+
interface MapModelOptions<T extends TypeModels> extends Omit<MapModel<T>, "kind" | "base"> {}
|
|
292
|
+
declare function map<T extends TypeModels>(base: T, options?: MapModelOptions<T>): MapModel<T>;
|
|
293
|
+
interface RecordModel<T extends {
|
|
294
|
+
[key: string]: TypeModels;
|
|
295
|
+
}> extends BasicModel<InferRecordJsonType<T>> {
|
|
296
|
+
kind: "record";
|
|
297
|
+
id: string;
|
|
298
|
+
properties: T;
|
|
299
|
+
}
|
|
300
|
+
type KeyOfOptional<T extends {
|
|
301
|
+
[key: string]: TypeModels;
|
|
302
|
+
}> = { [key in keyof T]: T[key] extends OptionalModel<TypeModels> ? key : never }[keyof T];
|
|
303
|
+
type InferRecordJsonType<T extends {
|
|
304
|
+
[key: string]: TypeModels;
|
|
305
|
+
}, O extends KeyOfOptional<T> = KeyOfOptional<T>> = Simplify<{ [key in Exclude<keyof T, O>]: InferModelJsonType<T[key]> } & { [key in O]?: InferModelJsonType<T[key]> }>;
|
|
306
|
+
interface RecordModelOptions<T extends {
|
|
307
|
+
[key: string]: TypeModels;
|
|
308
|
+
}> extends Omit<RecordModel<T>, "kind"> {}
|
|
309
|
+
declare function record<const T extends {
|
|
310
|
+
[key: string]: TypeModels;
|
|
311
|
+
}>(options: RecordModelOptions<T>): RecordModel<T>;
|
|
312
|
+
interface UnionModel<T extends {
|
|
313
|
+
[key: string]: TypeModels;
|
|
314
|
+
}> extends BasicModel<InferUnionJsonType<T>> {
|
|
315
|
+
kind: "union";
|
|
316
|
+
id: string;
|
|
317
|
+
variants: T;
|
|
318
|
+
}
|
|
319
|
+
type InferUnionJsonType<T extends {
|
|
320
|
+
[key: string]: TypeModels;
|
|
321
|
+
}> = { [key in keyof T]: { [k in key]: InferModelJsonType<T[key]> } }[keyof T];
|
|
322
|
+
interface UnionModelOptions<T extends {
|
|
323
|
+
[key: string]: TypeModels;
|
|
324
|
+
}> extends Omit<UnionModel<T>, "kind"> {}
|
|
325
|
+
declare function union<const T extends {
|
|
326
|
+
[key: string]: TypeModels;
|
|
327
|
+
}>(options: UnionModelOptions<T>): UnionModel<T>;
|
|
328
|
+
interface DatetimeModel extends BasicModel<string> {
|
|
329
|
+
kind: "datetime";
|
|
330
|
+
schema?: StringSchema;
|
|
331
|
+
}
|
|
332
|
+
interface DatetimeModelOptions extends Omit<DatetimeModel, "kind"> {}
|
|
333
|
+
declare function datetime(options?: DatetimeModelOptions): DatetimeModel;
|
|
334
|
+
interface DateModel extends BasicModel<string> {
|
|
335
|
+
kind: "date";
|
|
336
|
+
schema?: StringSchema;
|
|
337
|
+
}
|
|
338
|
+
interface DateModelOptions extends Omit<DateModel, "kind"> {}
|
|
339
|
+
declare function date(options?: DateModelOptions): DateModel;
|
|
340
|
+
interface DurationModel extends BasicModel<string> {
|
|
341
|
+
kind: "duration";
|
|
342
|
+
schema?: StringSchema;
|
|
343
|
+
}
|
|
344
|
+
interface DurationModelOptions extends Omit<DurationModel, "kind"> {}
|
|
345
|
+
declare function duration(options?: DurationModelOptions): DurationModel;
|
|
346
|
+
interface ErrorModel<Code extends string, Context extends {
|
|
347
|
+
[key: string]: TypeModels;
|
|
348
|
+
}> extends BasicModel<InferErrorModel<Code, Context>> {
|
|
349
|
+
kind: "error";
|
|
350
|
+
id: string;
|
|
351
|
+
code: Code;
|
|
352
|
+
context?: Context;
|
|
353
|
+
}
|
|
354
|
+
type InferErrorModel<Code extends string, Context extends {
|
|
355
|
+
[key: string]: TypeModels;
|
|
356
|
+
}> = [Context] extends [never] ? {
|
|
357
|
+
code: Code;
|
|
358
|
+
} : {
|
|
359
|
+
code: Code;
|
|
360
|
+
context: Context;
|
|
361
|
+
};
|
|
362
|
+
interface ErrorModelOptions<Code extends string, Context extends {
|
|
363
|
+
[key: string]: TypeModels;
|
|
364
|
+
}> extends Omit<ErrorModel<Code, Context>, "kind"> {}
|
|
365
|
+
declare function error<Code extends string, Context extends {
|
|
366
|
+
[key: string]: TypeModels;
|
|
367
|
+
}>(options: ErrorModelOptions<Code, Context>): ErrorModel<Code, Context>;
|
|
368
|
+
interface EnumsModel<T extends {
|
|
369
|
+
[key: string]: string;
|
|
370
|
+
}> extends BasicModel<T[keyof T]> {
|
|
371
|
+
id: string;
|
|
372
|
+
kind: "enums";
|
|
373
|
+
variants: T;
|
|
374
|
+
}
|
|
375
|
+
interface EnumsModelOptions<T extends {
|
|
376
|
+
[key: string]: string;
|
|
377
|
+
}> extends Omit<EnumsModel<T>, "kind"> {}
|
|
378
|
+
declare function enums<const T extends {
|
|
379
|
+
[key: string]: string;
|
|
380
|
+
}>(options: EnumsModelOptions<T>): EnumsModel<T>;
|
|
381
|
+
type TypeModels = Int32Model | Int64Model | Float32Model | Float64Model | BooleanModel | StringModel | LiteralModel<string | number | boolean> | OptionalModel<TypeModels> | ArrayModel<TypeModels> | SetModel<TypeModels> | MapModel<TypeModels> | RecordModel<{
|
|
382
|
+
[key: string]: TypeModels;
|
|
383
|
+
}> | UnionModel<{
|
|
384
|
+
[key: string]: TypeModels;
|
|
385
|
+
}> | DatetimeModel | DateModel | DurationModel | ErrorModel<string, {
|
|
386
|
+
[key: string]: TypeModels;
|
|
387
|
+
}> | EnumsModel<{
|
|
388
|
+
[key: string]: string;
|
|
389
|
+
}>;
|
|
390
|
+
type InferModelJsonType<T> = any extends T ? never : TypeModels extends T ? any : T extends Int32Model ? number : T extends Int64Model ? string : T extends Float32Model ? number : T extends Float64Model ? number : T extends BooleanModel ? boolean : T extends StringModel ? string : T extends LiteralModel<infer R> ? R : T extends ArrayModel<infer R> ? InferModelJsonType<R>[] : T extends SetModel<infer R> ? InferModelJsonType<R>[] : T extends MapModel<infer R> ? Record<string, InferModelJsonType<R>> : T extends RecordModel<infer R> ? InferRecordJsonType<R> : T extends UnionModel<infer R> ? InferUnionJsonType<R> : T extends DatetimeModel ? string : T extends DateModel ? string : T extends DurationModel ? string : T extends ErrorModel<infer Code, infer Context> ? InferErrorModel<Code, Context> : T extends EnumsModel<infer R> ? R[keyof R] : never;
|
|
391
|
+
interface ModelToJsonSchemaOptions {
|
|
392
|
+
model: TypeModels;
|
|
393
|
+
target?: "draft-2020-12";
|
|
394
|
+
reference?: "inline" | "json-schema" | "openapi";
|
|
395
|
+
depth?: number;
|
|
396
|
+
}
|
|
397
|
+
declare function generateJsonSchema(options: ModelToJsonSchemaOptions): JsonSchemaObject;
|
|
398
|
+
type NamedModel = RecordModel<{
|
|
399
|
+
[key: string]: TypeModels;
|
|
400
|
+
}> | EnumsModel<{
|
|
401
|
+
[key: string]: string;
|
|
402
|
+
}> | UnionModel<{
|
|
403
|
+
[key: string]: TypeModels;
|
|
404
|
+
}> | ErrorModel<string, {
|
|
405
|
+
[key: string]: TypeModels;
|
|
406
|
+
}>;
|
|
407
|
+
//#endregion
|
|
408
|
+
//#region src/schemas/openapi-schema.d.ts
|
|
409
|
+
interface OpenAPIObject {
|
|
410
|
+
openapi: string;
|
|
411
|
+
info: InfoObject;
|
|
412
|
+
SchemaObjectDialect?: string;
|
|
413
|
+
servers?: ServerObject[];
|
|
414
|
+
paths?: PathsObject;
|
|
415
|
+
webhooks?: {
|
|
416
|
+
[key: string]: PathItemObject;
|
|
417
|
+
};
|
|
418
|
+
components?: ComponentsObject;
|
|
419
|
+
security?: SecurityRequirementObject;
|
|
420
|
+
tags?: TagObject[];
|
|
421
|
+
externalDocs?: ExternalDocumentationObject;
|
|
422
|
+
}
|
|
423
|
+
interface InfoObject {
|
|
424
|
+
title: string;
|
|
425
|
+
summary?: string;
|
|
426
|
+
description?: string;
|
|
427
|
+
termsOfService?: string;
|
|
428
|
+
contact?: ContactObject;
|
|
429
|
+
license?: LicenseObject;
|
|
430
|
+
version: string;
|
|
431
|
+
}
|
|
432
|
+
interface ContactObject {
|
|
433
|
+
name?: string;
|
|
434
|
+
url?: string;
|
|
435
|
+
email?: string;
|
|
436
|
+
}
|
|
437
|
+
interface LicenseObject {
|
|
438
|
+
name: string;
|
|
439
|
+
identifier?: string;
|
|
440
|
+
url?: string;
|
|
441
|
+
}
|
|
442
|
+
interface ServerObject {
|
|
443
|
+
url: string;
|
|
444
|
+
description?: string;
|
|
445
|
+
variables?: {
|
|
446
|
+
[key: string]: ServerVariableObject;
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
interface ServerVariableObject {
|
|
450
|
+
enum?: string[];
|
|
451
|
+
default: string;
|
|
452
|
+
description?: string;
|
|
453
|
+
}
|
|
454
|
+
interface ComponentsObject {
|
|
455
|
+
schemas?: {
|
|
456
|
+
[key: string]: SchemaObject;
|
|
457
|
+
};
|
|
458
|
+
responses?: {
|
|
459
|
+
[key: string]: ResponseObject | ReferenceObject;
|
|
460
|
+
};
|
|
461
|
+
parameters?: {
|
|
462
|
+
[key: string]: ParameterObject | ReferenceObject;
|
|
463
|
+
};
|
|
464
|
+
examples?: {
|
|
465
|
+
[key: string]: ExampleObject | ReferenceObject;
|
|
466
|
+
};
|
|
467
|
+
requestBodies?: {
|
|
468
|
+
[key: string]: RequestBodyObject | ReferenceObject;
|
|
469
|
+
};
|
|
470
|
+
headers?: {
|
|
471
|
+
[key: string]: HeaderObject | ReferenceObject;
|
|
472
|
+
};
|
|
473
|
+
securitySchemes?: {
|
|
474
|
+
[key: string]: SecuritySchemeObject | ReferenceObject;
|
|
475
|
+
};
|
|
476
|
+
links?: {
|
|
477
|
+
[key: string]: LinkObject | ReferenceObject;
|
|
478
|
+
};
|
|
479
|
+
callbacks?: {
|
|
480
|
+
[key: string]: CallbackObject | ReferenceObject;
|
|
481
|
+
};
|
|
482
|
+
pathItems?: {
|
|
483
|
+
[key: string]: PathItemObject | ReferenceObject;
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
interface PathsObject {
|
|
487
|
+
[key: string]: PathItemObject;
|
|
488
|
+
}
|
|
489
|
+
interface PathItemObject {
|
|
490
|
+
$ref?: string;
|
|
491
|
+
summary?: string;
|
|
492
|
+
description?: string;
|
|
493
|
+
get?: OperationObject;
|
|
494
|
+
put?: OperationObject;
|
|
495
|
+
post?: OperationObject;
|
|
496
|
+
delete?: OperationObject;
|
|
497
|
+
options?: OperationObject;
|
|
498
|
+
head?: OperationObject;
|
|
499
|
+
patch?: OperationObject;
|
|
500
|
+
trace?: OperationObject;
|
|
501
|
+
servers?: ServerObject[];
|
|
502
|
+
parameters?: Array<ParameterObject | ReferenceObject>;
|
|
503
|
+
}
|
|
504
|
+
interface OperationObject {
|
|
505
|
+
tags?: string[];
|
|
506
|
+
summary?: string;
|
|
507
|
+
description?: string;
|
|
508
|
+
externalDocs?: ExternalDocumentationObject;
|
|
509
|
+
operationId?: string;
|
|
510
|
+
parameters?: Array<ParameterObject | ReferenceObject>;
|
|
511
|
+
requestBody?: RequestBodyObject | ReferenceObject;
|
|
512
|
+
responses?: ResponsesObject;
|
|
513
|
+
callbacks?: {
|
|
514
|
+
[key: string]: CallbackObject | ReferenceObject;
|
|
515
|
+
};
|
|
516
|
+
deprecated?: boolean;
|
|
517
|
+
security?: SecurityRequirementObject[];
|
|
518
|
+
servers?: ServerObject[];
|
|
519
|
+
}
|
|
520
|
+
interface ExternalDocumentationObject {
|
|
521
|
+
url: string;
|
|
522
|
+
description?: string;
|
|
523
|
+
}
|
|
524
|
+
interface ParameterObjectCommon {
|
|
525
|
+
name: string;
|
|
526
|
+
in: string;
|
|
527
|
+
description?: string;
|
|
528
|
+
required: boolean;
|
|
529
|
+
deprecated?: boolean;
|
|
530
|
+
/** @deprecated Deprecated in Openapi 3.1*/
|
|
531
|
+
allowEmptyValue?: boolean;
|
|
532
|
+
}
|
|
533
|
+
interface ParameterObjectAsSchema extends ParameterObjectCommon {
|
|
534
|
+
schema: SchemaObject;
|
|
535
|
+
style?: StyleValues;
|
|
536
|
+
explode?: boolean;
|
|
537
|
+
allowReserved?: boolean;
|
|
538
|
+
example?: any;
|
|
539
|
+
examples?: {
|
|
540
|
+
[key: string]: ExampleObject | ReferenceObject;
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
interface ParameterObjectAsContent extends ParameterObjectCommon {
|
|
544
|
+
content: {
|
|
545
|
+
[key: string]: MediaTypeObject;
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
type ParameterObject = ParameterObjectAsSchema | ParameterObjectAsContent;
|
|
549
|
+
type StyleValues = "matrix" | "label" | "simple" | "form" | "spaceDelimited" | "pipeDelimited" | "deepObject";
|
|
550
|
+
interface RequestBodyObject {
|
|
551
|
+
description?: string;
|
|
552
|
+
content: {
|
|
553
|
+
[key: string]: MediaTypeObject;
|
|
554
|
+
};
|
|
555
|
+
required?: boolean;
|
|
556
|
+
}
|
|
557
|
+
interface MediaTypeObject {
|
|
558
|
+
schema?: SchemaObject;
|
|
559
|
+
itemSchema?: SchemaObject;
|
|
560
|
+
itemEncoding?: {
|
|
561
|
+
contentType: string;
|
|
562
|
+
};
|
|
563
|
+
example?: any;
|
|
564
|
+
examples?: {
|
|
565
|
+
[key: string]: ExampleObject | ReferenceObject;
|
|
566
|
+
};
|
|
567
|
+
encoding?: {
|
|
568
|
+
[key: string]: EncodingObject;
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
interface EncodingObjectCommon {
|
|
572
|
+
contentType?: string;
|
|
573
|
+
headers?: {
|
|
574
|
+
[key: string]: HeaderObject | ReferenceObject;
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
interface EncodingObjectAsRFC6570 extends EncodingObjectCommon {
|
|
578
|
+
style?: string;
|
|
579
|
+
explode?: boolean;
|
|
580
|
+
allowReserved?: boolean;
|
|
581
|
+
}
|
|
582
|
+
type EncodingObject = EncodingObjectCommon | EncodingObjectAsRFC6570;
|
|
583
|
+
interface ResponsesObject {
|
|
584
|
+
[key: string]: ResponseObject | ReferenceObject;
|
|
585
|
+
}
|
|
586
|
+
interface ResponseObject {
|
|
587
|
+
description: string;
|
|
588
|
+
headers?: {
|
|
589
|
+
[key: string]: HeaderObject | ReferenceObject;
|
|
590
|
+
};
|
|
591
|
+
content?: {
|
|
592
|
+
[key: string]: MediaTypeObject;
|
|
593
|
+
};
|
|
594
|
+
links?: {
|
|
595
|
+
[key: string]: LinkObject | ReferenceObject;
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
interface CallbackObject {
|
|
599
|
+
[key: string]: PathItemObject;
|
|
600
|
+
}
|
|
601
|
+
interface ExampleObject {
|
|
602
|
+
summary?: string;
|
|
603
|
+
description?: string;
|
|
604
|
+
value?: any;
|
|
605
|
+
externalValue?: string;
|
|
606
|
+
}
|
|
607
|
+
interface LinkObject {
|
|
608
|
+
operationRef?: string;
|
|
609
|
+
operationId?: string;
|
|
610
|
+
parameters?: {
|
|
611
|
+
[key: string]: any;
|
|
612
|
+
};
|
|
613
|
+
requestBody?: any;
|
|
614
|
+
description?: string;
|
|
615
|
+
server?: ServerObject;
|
|
616
|
+
}
|
|
617
|
+
interface HeaderObjectCommon {
|
|
618
|
+
description?: string;
|
|
619
|
+
required?: boolean;
|
|
620
|
+
deprecated?: boolean;
|
|
621
|
+
}
|
|
622
|
+
interface HeaderObjectAsSchema extends HeaderObjectCommon {
|
|
623
|
+
schema: SchemaObject | ReferenceObject;
|
|
624
|
+
style?: string;
|
|
625
|
+
explode?: boolean;
|
|
626
|
+
example?: any;
|
|
627
|
+
examples?: {
|
|
628
|
+
[key: string]: ExampleObject | ReferenceObject;
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
interface HeaderObjectAsContent extends HeaderObjectCommon {
|
|
632
|
+
content: {
|
|
633
|
+
[key: string]: MediaTypeObject;
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
type HeaderObject = HeaderObjectAsSchema | HeaderObjectAsContent;
|
|
637
|
+
interface TagObject {
|
|
638
|
+
name: string;
|
|
639
|
+
description?: string;
|
|
640
|
+
externalDocs?: ExternalDocumentationObject;
|
|
641
|
+
}
|
|
642
|
+
interface ReferenceObject {
|
|
643
|
+
$ref: string;
|
|
644
|
+
summary?: string;
|
|
645
|
+
description?: string;
|
|
646
|
+
}
|
|
647
|
+
type SchemaObject = JsonSchema;
|
|
648
|
+
type SecuritySchemeObject = ApiKeySecurityScheme | HttpSecurityScheme | OAuth2SecurityScheme | OpenIdConnectSecurityScheme;
|
|
649
|
+
interface ApiKeySecurityScheme {
|
|
650
|
+
type: "apiKey";
|
|
651
|
+
name: string;
|
|
652
|
+
in: "query" | "header" | "cookie";
|
|
653
|
+
description?: string;
|
|
654
|
+
}
|
|
655
|
+
interface HttpSecurityScheme {
|
|
656
|
+
type: "http";
|
|
657
|
+
scheme: string;
|
|
658
|
+
bearerFormat?: string;
|
|
659
|
+
description?: string;
|
|
660
|
+
}
|
|
661
|
+
interface OAuth2SecurityScheme {
|
|
662
|
+
type: "oauth2";
|
|
663
|
+
flows: OAuthFlowsObject;
|
|
664
|
+
description?: string;
|
|
665
|
+
}
|
|
666
|
+
interface OpenIdConnectSecurityScheme {
|
|
667
|
+
type: "openIdConnect";
|
|
668
|
+
openIdConnectUrl: string;
|
|
669
|
+
description?: string;
|
|
670
|
+
}
|
|
671
|
+
interface AuthorizationCodeFlowObject {
|
|
672
|
+
authorizationUrl: string;
|
|
673
|
+
tokenUrl: string;
|
|
674
|
+
refreshUrl?: string;
|
|
675
|
+
scopes: {
|
|
676
|
+
[key: string]: string;
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
interface PasswordFlowObject {
|
|
680
|
+
tokenUrl: string;
|
|
681
|
+
refreshUrl?: string;
|
|
682
|
+
scopes: {
|
|
683
|
+
[key: string]: string;
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
interface ClientCredentialsFlowObject {
|
|
687
|
+
tokenUrl: string;
|
|
688
|
+
refreshUrl?: string;
|
|
689
|
+
scopes: {
|
|
690
|
+
[key: string]: string;
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
interface OAuthFlowsObject {
|
|
694
|
+
authorizationCode?: AuthorizationCodeFlowObject;
|
|
695
|
+
password?: PasswordFlowObject;
|
|
696
|
+
clientCredentials?: ClientCredentialsFlowObject;
|
|
697
|
+
}
|
|
698
|
+
interface SecurityRequirementObject {
|
|
699
|
+
[key: string]: string[];
|
|
700
|
+
}
|
|
701
|
+
//#endregion
|
|
702
|
+
//#region src/utils/index.d.ts
|
|
703
|
+
type ExtractPathParams<Path extends string> = string extends Path ? string : Path extends `${infer _Start}/{${infer Param}}/${infer Rest}` ? Param | ExtractPathParams<`/${Rest}`> : Path extends `${infer _Start}/{${infer Param}}` ? Param : never;
|
|
704
|
+
//#endregion
|
|
705
|
+
//#region src/type-system/http.d.ts
|
|
706
|
+
type AllowedHttpValue = StringModel | Int32Model | Int64Model | BooleanModel | LiteralModel<string | number | boolean> | Optionalize<StringModel | Int32Model | Int64Model | BooleanModel | LiteralModel<string | number | boolean>>;
|
|
707
|
+
type PartialOf<T extends {
|
|
708
|
+
[key: string]: any;
|
|
709
|
+
}, K extends keyof T> = Simplify<{ [key in Exclude<keyof T, K>]: T[key] } & { [key in K]?: T[key] }>;
|
|
710
|
+
interface GenerateOpenapiOptions {
|
|
711
|
+
info: OpenAPIObject["info"];
|
|
712
|
+
routes: HttpRouteModel[];
|
|
713
|
+
securitySchemes?: NonNullable<OpenAPIObject["components"]>["securitySchemes"];
|
|
714
|
+
tags?: OpenAPIObject["tags"];
|
|
715
|
+
servers?: OpenAPIObject["servers"];
|
|
716
|
+
}
|
|
717
|
+
declare function generateOpenapi(options: GenerateOpenapiOptions): OpenAPIObject;
|
|
718
|
+
declare function collectModelFromRoutes(routes: HttpRouteModel[]): Map<string, TypeModels>;
|
|
719
|
+
declare function collectModelDeep(model: TypeModels): Map<string, TypeModels>;
|
|
720
|
+
interface HttpResponseModel {
|
|
721
|
+
status: number;
|
|
722
|
+
description?: string;
|
|
723
|
+
content?: HttpContentModel;
|
|
724
|
+
headers?: {
|
|
725
|
+
[key: string]: AllowedHttpValue | OptionalModel<AllowedHttpValue>;
|
|
726
|
+
};
|
|
727
|
+
cookies?: {
|
|
728
|
+
[key: string]: AllowedHttpValue | OptionalModel<AllowedHttpValue>;
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
interface HttpRouteModel<Path extends string = string> {
|
|
732
|
+
kind: "http-route";
|
|
733
|
+
id: string;
|
|
734
|
+
path: Path;
|
|
735
|
+
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS" | "HEAD" | "TRACE";
|
|
736
|
+
description?: string;
|
|
737
|
+
summary?: string;
|
|
738
|
+
variables: { [key in ExtractPathParams<Path>]: AllowedHttpValue };
|
|
739
|
+
queries?: {
|
|
740
|
+
[key: string]: AllowedHttpValue | OptionalModel<AllowedHttpValue>;
|
|
741
|
+
};
|
|
742
|
+
cookies?: {
|
|
743
|
+
[key: string]: AllowedHttpValue | OptionalModel<AllowedHttpValue>;
|
|
744
|
+
};
|
|
745
|
+
headers?: {
|
|
746
|
+
[key: string]: AllowedHttpValue | OptionalModel<AllowedHttpValue>;
|
|
747
|
+
};
|
|
748
|
+
content?: HttpContentModel;
|
|
749
|
+
responses?: {
|
|
750
|
+
[key: string]: HttpResponseModel;
|
|
751
|
+
};
|
|
752
|
+
tags?: string[];
|
|
753
|
+
security?: {
|
|
754
|
+
[key: string]: string[];
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
interface HttpRouteModelOptions<Path extends string> extends Omit<HttpRouteModel<Path>, "kind"> {}
|
|
758
|
+
declare function route<const Path extends string>(options: HttpRouteModelOptions<Path>): HttpRouteModel<Path>;
|
|
759
|
+
interface PlainTextContentModel {
|
|
760
|
+
kind: "plain-text-content";
|
|
761
|
+
type: PlainTextLikeContentType;
|
|
762
|
+
model?: StringModel;
|
|
763
|
+
}
|
|
764
|
+
interface PlainTextContentOptions extends Omit<PlainTextContentModel, "kind"> {}
|
|
765
|
+
declare function plainText(options: PlainTextContentOptions): PlainTextContentModel;
|
|
766
|
+
interface JsonContentModel {
|
|
767
|
+
kind: "json-content";
|
|
768
|
+
type: JsonLikeContentType;
|
|
769
|
+
model: TypeModels;
|
|
770
|
+
}
|
|
771
|
+
interface JsonContentOptions extends Omit<JsonContentModel, "kind"> {}
|
|
772
|
+
declare function json(options: JsonContentOptions): JsonContentModel;
|
|
773
|
+
interface PlainTextStreamContentModel {
|
|
774
|
+
kind: "plain-text-stream-content";
|
|
775
|
+
type: PlainTextLikeContentType;
|
|
776
|
+
model?: StringModel;
|
|
777
|
+
description?: string;
|
|
778
|
+
}
|
|
779
|
+
interface PlainTextStreamContentOptions extends Omit<PlainTextStreamContentModel, "kind"> {}
|
|
780
|
+
declare function plainTextStream(options: PlainTextStreamContentOptions): PlainTextStreamContentModel;
|
|
781
|
+
interface JsonStreamContentModel {
|
|
782
|
+
kind: "json-stream-content";
|
|
783
|
+
type: JsonStreamLikeContentType;
|
|
784
|
+
model: TypeModels;
|
|
785
|
+
description?: string;
|
|
786
|
+
}
|
|
787
|
+
interface JsonStreamContentOptions extends Omit<JsonStreamContentModel, "kind"> {}
|
|
788
|
+
declare function jsonStream(options: JsonStreamContentOptions): JsonStreamContentModel;
|
|
789
|
+
interface BinaryStreamContentModel {
|
|
790
|
+
kind: "binary-stream-content";
|
|
791
|
+
type: BinaryLikeContentType;
|
|
792
|
+
description?: string;
|
|
793
|
+
}
|
|
794
|
+
interface BinaryStreamContentOptions extends Omit<BinaryStreamContentModel, "kind"> {}
|
|
795
|
+
declare function binary(options: BinaryStreamContentOptions): BinaryStreamContentModel;
|
|
796
|
+
interface FormContentModel<T extends {
|
|
797
|
+
[key: string]: AllowedHttpValue | OptionalModel<AllowedHttpValue>;
|
|
798
|
+
}> {
|
|
799
|
+
kind: "form-content";
|
|
800
|
+
type: FormLikeContentType;
|
|
801
|
+
model: RecordModel<T>;
|
|
802
|
+
}
|
|
803
|
+
interface FormContentOptions<T extends {
|
|
804
|
+
[key: string]: AllowedHttpValue;
|
|
805
|
+
}> extends Omit<FormContentModel<T>, "kind"> {}
|
|
806
|
+
declare function form<T extends {
|
|
807
|
+
[key: string]: AllowedHttpValue;
|
|
808
|
+
}>(options: FormContentOptions<T>): FormContentModel<T>;
|
|
809
|
+
type HttpContentModel = PlainTextContentModel | JsonContentModel | PlainTextStreamContentModel | JsonStreamContentModel | BinaryStreamContentModel | FormContentModel<{
|
|
810
|
+
[key: string]: AllowedHttpValue;
|
|
811
|
+
}>;
|
|
812
|
+
type PlainTextLikeContentType = (string & {}) | "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "text/csv";
|
|
813
|
+
type JsonLikeContentType = (string & {}) | "application/json" | "application/json; charset=utf-8" | "application/ld+json" | "application/hal+json" | "application/vnd.api+json" | "application/problem+json" | "application/schema+json";
|
|
814
|
+
type PlainTextStreamLikeContentType = (string & {}) | "text/event-stream";
|
|
815
|
+
type JsonStreamLikeContentType = (string & {}) | "application/ndjson" | "application/x-ndjson" | "application/jsonl" | "application/json-seq" | "application/stream+json";
|
|
816
|
+
type BinaryLikeContentType = (string & {}) | "application/octet-stream" | "application/pdf" | "application/zip" | "application/gzip" | "image/jpeg" | "image/png" | "image/gif" | "image/webp" | "image/svg+xml" | "audio/mpeg" | "audio/wav" | "video/mp4" | "video/webm";
|
|
817
|
+
type FormLikeContentType = (string & {}) | "application/x-www-form-urlencoded" | "multipart/form-data";
|
|
818
|
+
//#endregion
|
|
819
|
+
//#region src/generator/java.d.ts
|
|
820
|
+
interface GenerateJavaClassOptions {
|
|
821
|
+
package: string;
|
|
822
|
+
model: NamedModel;
|
|
823
|
+
}
|
|
824
|
+
declare function generateJavaClass(options: GenerateJavaClassOptions): string;
|
|
825
|
+
declare function formatJava(code: string): Promise<string>;
|
|
826
|
+
interface GenerateJavaOptions {
|
|
827
|
+
package: string;
|
|
828
|
+
srcDir: string;
|
|
829
|
+
routes?: HttpRouteModel[];
|
|
830
|
+
models?: TypeModels[];
|
|
831
|
+
}
|
|
832
|
+
declare function generateJavaCodes(options: GenerateJavaOptions): Promise<{
|
|
833
|
+
path: string;
|
|
834
|
+
code: string;
|
|
835
|
+
}[]>;
|
|
836
|
+
//#endregion
|
|
837
|
+
//#region src/generator/rust.d.ts
|
|
838
|
+
interface GenerateRustCodeOptions {
|
|
839
|
+
module_name: string;
|
|
840
|
+
model: RecordModel<{
|
|
841
|
+
[key: string]: TypeModels;
|
|
842
|
+
}> | UnionModel<{
|
|
843
|
+
[key: string]: TypeModels;
|
|
844
|
+
}> | EnumsModel<{
|
|
845
|
+
[key: string]: string;
|
|
846
|
+
}> | ErrorModel<string, {
|
|
847
|
+
[key: string]: TypeModels;
|
|
848
|
+
}>;
|
|
849
|
+
}
|
|
850
|
+
declare function generateRustCode(options: GenerateRustCodeOptions): string;
|
|
851
|
+
declare function formatRust(code: string): Promise<string>;
|
|
852
|
+
interface GenerateRustOptions {
|
|
853
|
+
module_name: string;
|
|
854
|
+
srcDir: string;
|
|
855
|
+
routes?: HttpRouteModel[];
|
|
856
|
+
models?: TypeModels[];
|
|
857
|
+
}
|
|
858
|
+
declare function generateRustCodes(options: GenerateRustOptions): Promise<{
|
|
859
|
+
path: string;
|
|
860
|
+
code: string;
|
|
861
|
+
}[]>;
|
|
862
|
+
//#endregion
|
|
863
|
+
export { AllowedHttpValue, ArrayModel, ArrayModelOptions, BasicModel, BinaryLikeContentType, BinaryStreamContentModel, BinaryStreamContentOptions, BooleanModel, BooleanModelOptions, DateModel, DateModelOptions, DatetimeModel, DatetimeModelOptions, DurationModel, DurationModelOptions, EnumsModel, EnumsModelOptions, ErrorModel, ErrorModelOptions, Float32Model, Float32ModelOptions, Float64Model, Float64ModelOptions, FormContentModel, FormContentOptions, FormLikeContentType, GenerateJavaClassOptions, GenerateJavaOptions, GenerateOpenapiOptions, GenerateRustCodeOptions, GenerateRustOptions, HttpContentModel, HttpResponseModel, HttpRouteModel, HttpRouteModelOptions, InferErrorModel, InferModelJsonType, InferRecordJsonType, InferUnionJsonType, Int32Model, Int32ModelOptions, Int64Model, Int64ModelOptions, JsonContentModel, JsonContentOptions, JsonLikeContentType, JsonStreamContentModel, JsonStreamContentOptions, JsonStreamLikeContentType, LiteralModel, LiteralModelOptions, MapModel, MapModelOptions, ModelToJsonSchemaOptions, NamedModel, OptionalModel, OptionalModelOptions, Optionalize, PartialOf, PlainTextContentModel, PlainTextContentOptions, PlainTextLikeContentType, PlainTextStreamContentModel, PlainTextStreamContentOptions, PlainTextStreamLikeContentType, RecordModel, RecordModelOptions, SetModel, SetModelOptions, StringModel, StringModelOptions, TypeModels, UnionModel, UnionModelOptions, array, binary, boolean, collectModelDeep, collectModelFromRoutes, date, datetime, duration, enums, error, float32, float64, form, formatJava, formatRust, generateJavaClass, generateJavaCodes, generateJsonSchema, generateOpenapi, generateRustCode, generateRustCodes, int32, int64, json, jsonStream, literal, map, optional, plainText, plainTextStream, record, route, set, string, union };
|
|
864
|
+
//# sourceMappingURL=index.d.mts.map
|