axigen 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.
@@ -0,0 +1,131 @@
1
+ interface OpenAPISpec {
2
+ openapi?: string;
3
+ swagger?: string;
4
+ info: {
5
+ title: string;
6
+ version: string;
7
+ description?: string;
8
+ };
9
+ servers?: Array<{
10
+ url: string;
11
+ description?: string;
12
+ }>;
13
+ paths: Record<string, PathItem>;
14
+ components?: {
15
+ schemas?: Record<string, SchemaObject>;
16
+ parameters?: Record<string, ParameterObject>;
17
+ requestBodies?: Record<string, RequestBodyObject>;
18
+ responses?: Record<string, ResponseObject>;
19
+ };
20
+ }
21
+ type HttpMethod = "get" | "post" | "put" | "patch" | "delete" | "head" | "options";
22
+ type PathItem = {
23
+ [method in HttpMethod]?: OperationObject;
24
+ } & {
25
+ parameters?: ParameterObject[];
26
+ summary?: string;
27
+ description?: string;
28
+ };
29
+ interface OperationObject {
30
+ operationId?: string;
31
+ summary?: string;
32
+ description?: string;
33
+ tags?: string[];
34
+ parameters?: ParameterObject[];
35
+ requestBody?: RequestBodyObject;
36
+ responses: Record<string, ResponseObject>;
37
+ }
38
+ interface ParameterObject {
39
+ name: string;
40
+ in: "query" | "path" | "header" | "cookie";
41
+ required?: boolean;
42
+ description?: string;
43
+ schema?: SchemaObject;
44
+ $ref?: string;
45
+ }
46
+ interface RequestBodyObject {
47
+ required?: boolean;
48
+ description?: string;
49
+ content: Record<string, {
50
+ schema?: SchemaObject;
51
+ }>;
52
+ $ref?: string;
53
+ }
54
+ interface ResponseObject {
55
+ description?: string;
56
+ content?: Record<string, {
57
+ schema?: SchemaObject;
58
+ }>;
59
+ $ref?: string;
60
+ }
61
+ interface SchemaObject {
62
+ type?: "string" | "number" | "integer" | "boolean" | "array" | "object" | "null";
63
+ format?: string;
64
+ description?: string;
65
+ required?: string[];
66
+ properties?: Record<string, SchemaObject>;
67
+ items?: SchemaObject;
68
+ enum?: unknown[];
69
+ $ref?: string;
70
+ allOf?: SchemaObject[];
71
+ anyOf?: SchemaObject[];
72
+ oneOf?: SchemaObject[];
73
+ nullable?: boolean;
74
+ default?: unknown;
75
+ example?: unknown;
76
+ }
77
+ interface AxigenConfig {
78
+ input: string;
79
+ output: {
80
+ client: string;
81
+ types?: string;
82
+ };
83
+ axiosInstancePath: string;
84
+ axiosInstanceExport?: string;
85
+ language?: "ts" | "js";
86
+ jsdoc?: boolean;
87
+ tags?: string[];
88
+ }
89
+ interface ParsedEndpoint {
90
+ operationId: string;
91
+ method: HttpMethod;
92
+ path: string;
93
+ summary?: string;
94
+ description?: string;
95
+ tags: string[];
96
+ pathParams: ParsedParam[];
97
+ queryParams: ParsedParam[];
98
+ bodySchema?: SchemaObject;
99
+ bodyRequired: boolean;
100
+ responseSchema?: SchemaObject;
101
+ }
102
+ interface ParsedParam {
103
+ name: string;
104
+ required: boolean;
105
+ schema?: SchemaObject;
106
+ description?: string;
107
+ }
108
+
109
+ interface GenerateResult {
110
+ clientPath: string;
111
+ typesPath?: string;
112
+ endpointCount: number;
113
+ }
114
+ declare function generate(config: AxigenConfig, cwd: string): Promise<GenerateResult>;
115
+
116
+ declare function loadConfig(cwd: string, configPath?: string): Promise<AxigenConfig>;
117
+
118
+ declare function parseOpenAPIFile(filePath: string): OpenAPISpec;
119
+ declare function extractEndpoints(spec: OpenAPISpec, filterTags?: string[]): ParsedEndpoint[];
120
+
121
+ interface GenerateClientOptions {
122
+ endpoints: ParsedEndpoint[];
123
+ config: AxigenConfig;
124
+ /** مسیر نسبی فایل types نسبت به فایل client */
125
+ typesRelativePath?: string;
126
+ }
127
+ declare function generateClientFile(opts: GenerateClientOptions): string;
128
+
129
+ declare function generateTypesFile(endpoints: ParsedEndpoint[], schemas?: Record<string, SchemaObject>): string;
130
+
131
+ export { type AxigenConfig, type HttpMethod, type OpenAPISpec, type ParsedEndpoint, type ParsedParam, type SchemaObject, extractEndpoints, generate, generateClientFile, generateTypesFile, loadConfig, parseOpenAPIFile };
@@ -0,0 +1,131 @@
1
+ interface OpenAPISpec {
2
+ openapi?: string;
3
+ swagger?: string;
4
+ info: {
5
+ title: string;
6
+ version: string;
7
+ description?: string;
8
+ };
9
+ servers?: Array<{
10
+ url: string;
11
+ description?: string;
12
+ }>;
13
+ paths: Record<string, PathItem>;
14
+ components?: {
15
+ schemas?: Record<string, SchemaObject>;
16
+ parameters?: Record<string, ParameterObject>;
17
+ requestBodies?: Record<string, RequestBodyObject>;
18
+ responses?: Record<string, ResponseObject>;
19
+ };
20
+ }
21
+ type HttpMethod = "get" | "post" | "put" | "patch" | "delete" | "head" | "options";
22
+ type PathItem = {
23
+ [method in HttpMethod]?: OperationObject;
24
+ } & {
25
+ parameters?: ParameterObject[];
26
+ summary?: string;
27
+ description?: string;
28
+ };
29
+ interface OperationObject {
30
+ operationId?: string;
31
+ summary?: string;
32
+ description?: string;
33
+ tags?: string[];
34
+ parameters?: ParameterObject[];
35
+ requestBody?: RequestBodyObject;
36
+ responses: Record<string, ResponseObject>;
37
+ }
38
+ interface ParameterObject {
39
+ name: string;
40
+ in: "query" | "path" | "header" | "cookie";
41
+ required?: boolean;
42
+ description?: string;
43
+ schema?: SchemaObject;
44
+ $ref?: string;
45
+ }
46
+ interface RequestBodyObject {
47
+ required?: boolean;
48
+ description?: string;
49
+ content: Record<string, {
50
+ schema?: SchemaObject;
51
+ }>;
52
+ $ref?: string;
53
+ }
54
+ interface ResponseObject {
55
+ description?: string;
56
+ content?: Record<string, {
57
+ schema?: SchemaObject;
58
+ }>;
59
+ $ref?: string;
60
+ }
61
+ interface SchemaObject {
62
+ type?: "string" | "number" | "integer" | "boolean" | "array" | "object" | "null";
63
+ format?: string;
64
+ description?: string;
65
+ required?: string[];
66
+ properties?: Record<string, SchemaObject>;
67
+ items?: SchemaObject;
68
+ enum?: unknown[];
69
+ $ref?: string;
70
+ allOf?: SchemaObject[];
71
+ anyOf?: SchemaObject[];
72
+ oneOf?: SchemaObject[];
73
+ nullable?: boolean;
74
+ default?: unknown;
75
+ example?: unknown;
76
+ }
77
+ interface AxigenConfig {
78
+ input: string;
79
+ output: {
80
+ client: string;
81
+ types?: string;
82
+ };
83
+ axiosInstancePath: string;
84
+ axiosInstanceExport?: string;
85
+ language?: "ts" | "js";
86
+ jsdoc?: boolean;
87
+ tags?: string[];
88
+ }
89
+ interface ParsedEndpoint {
90
+ operationId: string;
91
+ method: HttpMethod;
92
+ path: string;
93
+ summary?: string;
94
+ description?: string;
95
+ tags: string[];
96
+ pathParams: ParsedParam[];
97
+ queryParams: ParsedParam[];
98
+ bodySchema?: SchemaObject;
99
+ bodyRequired: boolean;
100
+ responseSchema?: SchemaObject;
101
+ }
102
+ interface ParsedParam {
103
+ name: string;
104
+ required: boolean;
105
+ schema?: SchemaObject;
106
+ description?: string;
107
+ }
108
+
109
+ interface GenerateResult {
110
+ clientPath: string;
111
+ typesPath?: string;
112
+ endpointCount: number;
113
+ }
114
+ declare function generate(config: AxigenConfig, cwd: string): Promise<GenerateResult>;
115
+
116
+ declare function loadConfig(cwd: string, configPath?: string): Promise<AxigenConfig>;
117
+
118
+ declare function parseOpenAPIFile(filePath: string): OpenAPISpec;
119
+ declare function extractEndpoints(spec: OpenAPISpec, filterTags?: string[]): ParsedEndpoint[];
120
+
121
+ interface GenerateClientOptions {
122
+ endpoints: ParsedEndpoint[];
123
+ config: AxigenConfig;
124
+ /** مسیر نسبی فایل types نسبت به فایل client */
125
+ typesRelativePath?: string;
126
+ }
127
+ declare function generateClientFile(opts: GenerateClientOptions): string;
128
+
129
+ declare function generateTypesFile(endpoints: ParsedEndpoint[], schemas?: Record<string, SchemaObject>): string;
130
+
131
+ export { type AxigenConfig, type HttpMethod, type OpenAPISpec, type ParsedEndpoint, type ParsedParam, type SchemaObject, extractEndpoints, generate, generateClientFile, generateTypesFile, loadConfig, parseOpenAPIFile };