@rsdk/cli.cmd.autodoc 6.0.0-next.7 → 6.0.0-next.8
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/CHANGELOG.md +382 -0
- package/TODO.MD +24 -0
- package/dist/commands/autodoc.cmd.js +8 -10
- package/dist/commands/autodoc.cmd.js.map +1 -1
- package/dist/commands/openapi.variation.js +1 -2
- package/dist/commands/openapi.variation.js.map +1 -1
- package/dist/generators/file-generator.interface.d.ts +1 -1
- package/dist/generators/openapi-json/config.schema.d.ts +16 -139
- package/dist/generators/openapi-json/config.schema.js +19 -128
- package/dist/generators/openapi-json/config.schema.js.map +1 -1
- package/dist/generators/openapi-json/openapi-json.generator.d.ts +4 -5
- package/dist/generators/openapi-json/openapi-json.generator.js +12 -109
- package/dist/generators/openapi-json/openapi-json.generator.js.map +1 -1
- package/jest.config.e2e.js +1 -0
- package/jest.config.js +1 -0
- package/jest.config.unit.js +1 -0
- package/package.json +15 -32
- package/src/base/app.loader.ts +39 -0
- package/src/base/document.file.ts +33 -0
- package/src/base/index.ts +2 -0
- package/src/commands/autodoc.cmd.ts +93 -0
- package/src/commands/openapi.variation.ts +172 -0
- package/src/generators/autodoc-md/autodoc-md.generator.ts +56 -0
- package/src/generators/autodoc-md/formatters.ts +9 -0
- package/src/generators/autodoc-md/fragments/document-fragment.abstract.ts +6 -0
- package/src/generators/autodoc-md/fragments/extractor/document.extractor.ts +73 -0
- package/src/generators/autodoc-md/fragments/implementations/additional-sources.fragment.ts +41 -0
- package/src/generators/autodoc-md/fragments/implementations/app-metadata.fragment.ts +18 -0
- package/src/generators/autodoc-md/fragments/implementations/autodoc.fragment.ts +30 -0
- package/src/generators/autodoc-md/fragments/implementations/config-section.fragment.ts +148 -0
- package/src/generators/autodoc-md/fragments/implementations/header.fragment.ts +18 -0
- package/src/generators/autodoc-md/fragments/implementations/plugin.fragment.ts +21 -0
- package/src/generators/autodoc-md/fragments/implementations/transports.fragment.ts +36 -0
- package/src/generators/autodoc-md/fragments/index.ts +9 -0
- package/src/generators/autodoc-md/index.ts +1 -0
- package/src/generators/file-generator.interface.ts +22 -0
- package/src/generators/index.ts +4 -0
- package/src/generators/openapi-json/config.schema.spec.ts +265 -0
- package/src/generators/openapi-json/config.schema.ts +37 -0
- package/src/generators/openapi-json/index.ts +2 -0
- package/src/generators/openapi-json/openapi-json.generator.ts +53 -0
- package/src/generators/rsdk-json/index.ts +1 -0
- package/src/generators/rsdk-json/rsdk-json.generator.ts +24 -0
- package/src/index.ts +1 -0
- package/tsconfig.build.json +12 -0
- package/tsconfig.json +7 -0
|
@@ -1,116 +1,4 @@
|
|
|
1
1
|
import type { Static } from '@sinclair/typebox';
|
|
2
|
-
/**
|
|
3
|
-
* HTTP Authentication scheme (Basic or Bearer).
|
|
4
|
-
* @example
|
|
5
|
-
* {
|
|
6
|
-
* "type": "http",
|
|
7
|
-
* "scheme": "bearer",
|
|
8
|
-
* "bearerFormat": "JWT",
|
|
9
|
-
* "name": "JWT Auth"
|
|
10
|
-
* }
|
|
11
|
-
*/
|
|
12
|
-
export declare const HttpSecurityScheme: import("@sinclair/typebox").TObject<{
|
|
13
|
-
type: import("@sinclair/typebox").TLiteral<"http">;
|
|
14
|
-
schemaName: import("@sinclair/typebox").TString;
|
|
15
|
-
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
16
|
-
scheme: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"basic">, import("@sinclair/typebox").TLiteral<"bearer">]>;
|
|
17
|
-
bearerFormat: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
18
|
-
}>;
|
|
19
|
-
/**
|
|
20
|
-
* API Key Authentication scheme.
|
|
21
|
-
* The API key can be passed in a header, query parameter, or cookie.
|
|
22
|
-
* @example
|
|
23
|
-
* {
|
|
24
|
-
* "type": "apiKey",
|
|
25
|
-
* "name": "api_key",
|
|
26
|
-
* "in": "header",
|
|
27
|
-
* "description": "API Key Authentication"
|
|
28
|
-
* }
|
|
29
|
-
*/
|
|
30
|
-
export declare const ApiKeySecurityScheme: import("@sinclair/typebox").TObject<{
|
|
31
|
-
type: import("@sinclair/typebox").TLiteral<"apiKey">;
|
|
32
|
-
schemaName: import("@sinclair/typebox").TString;
|
|
33
|
-
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
34
|
-
name: import("@sinclair/typebox").TString;
|
|
35
|
-
in: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"query">, import("@sinclair/typebox").TLiteral<"header">, import("@sinclair/typebox").TLiteral<"cookie">]>;
|
|
36
|
-
}>;
|
|
37
|
-
/**
|
|
38
|
-
* OAuth2 Authentication scheme.
|
|
39
|
-
* Supports multiple OAuth2 flows (implicit, password, clientCredentials, authorizationCode).
|
|
40
|
-
* @example
|
|
41
|
-
* {
|
|
42
|
-
* "type": "oauth2",
|
|
43
|
-
* "name": "OAuth2",
|
|
44
|
-
* "flows": {
|
|
45
|
-
* "implicit": {
|
|
46
|
-
* "authorizationUrl": "https://example.com/oauth/authorize",
|
|
47
|
-
* "scopes": {
|
|
48
|
-
* "read": "Read access",
|
|
49
|
-
* "write": "Write access"
|
|
50
|
-
* }
|
|
51
|
-
* }
|
|
52
|
-
* }
|
|
53
|
-
* }
|
|
54
|
-
*/
|
|
55
|
-
export declare const OAuth2SecurityScheme: import("@sinclair/typebox").TObject<{
|
|
56
|
-
type: import("@sinclair/typebox").TLiteral<"oauth2">;
|
|
57
|
-
schemaName: import("@sinclair/typebox").TString;
|
|
58
|
-
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
59
|
-
flows: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TObject<{
|
|
60
|
-
scopes: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>;
|
|
61
|
-
authorizationUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
62
|
-
tokenUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
63
|
-
refreshUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
64
|
-
}>>;
|
|
65
|
-
}>;
|
|
66
|
-
/**
|
|
67
|
-
* Mutual TLS Authentication scheme.
|
|
68
|
-
* Used when clients must present valid certificates to access the API.
|
|
69
|
-
* @example
|
|
70
|
-
* {
|
|
71
|
-
* "type": "mutualTLS",
|
|
72
|
-
* "name": "mtls",
|
|
73
|
-
* "description": "Client certificate required"
|
|
74
|
-
* }
|
|
75
|
-
*/
|
|
76
|
-
export declare const MutualTLSSecurityScheme: import("@sinclair/typebox").TObject<{
|
|
77
|
-
type: import("@sinclair/typebox").TLiteral<"mutualTLS">;
|
|
78
|
-
schemaName: import("@sinclair/typebox").TString;
|
|
79
|
-
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
80
|
-
name: import("@sinclair/typebox").TString;
|
|
81
|
-
}>;
|
|
82
|
-
/**
|
|
83
|
-
* Union of all supported security schemes.
|
|
84
|
-
* Can be one of: HTTP (Basic/Bearer), API Key, OAuth2, or Mutual TLS.
|
|
85
|
-
*/
|
|
86
|
-
export declare const SecurityScheme: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
87
|
-
type: import("@sinclair/typebox").TLiteral<"http">;
|
|
88
|
-
schemaName: import("@sinclair/typebox").TString;
|
|
89
|
-
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
90
|
-
scheme: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"basic">, import("@sinclair/typebox").TLiteral<"bearer">]>;
|
|
91
|
-
bearerFormat: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
92
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
93
|
-
type: import("@sinclair/typebox").TLiteral<"apiKey">;
|
|
94
|
-
schemaName: import("@sinclair/typebox").TString;
|
|
95
|
-
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
96
|
-
name: import("@sinclair/typebox").TString;
|
|
97
|
-
in: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"query">, import("@sinclair/typebox").TLiteral<"header">, import("@sinclair/typebox").TLiteral<"cookie">]>;
|
|
98
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
99
|
-
type: import("@sinclair/typebox").TLiteral<"oauth2">;
|
|
100
|
-
schemaName: import("@sinclair/typebox").TString;
|
|
101
|
-
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
102
|
-
flows: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TObject<{
|
|
103
|
-
scopes: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>;
|
|
104
|
-
authorizationUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
105
|
-
tokenUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
106
|
-
refreshUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
107
|
-
}>>;
|
|
108
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
109
|
-
type: import("@sinclair/typebox").TLiteral<"mutualTLS">;
|
|
110
|
-
schemaName: import("@sinclair/typebox").TString;
|
|
111
|
-
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
112
|
-
name: import("@sinclair/typebox").TString;
|
|
113
|
-
}>]>;
|
|
114
2
|
/**
|
|
115
3
|
* Configuration schema for OpenAPI document generation.
|
|
116
4
|
* @example
|
|
@@ -122,45 +10,34 @@ export declare const SecurityScheme: import("@sinclair/typebox").TUnion<[import(
|
|
|
122
10
|
* "description": "API Description",
|
|
123
11
|
* "includeZones": ["public"],
|
|
124
12
|
* "excludeZones": ["internal"],
|
|
125
|
-
* "security":
|
|
126
|
-
* "
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
13
|
+
* "security": {
|
|
14
|
+
* "jwt": {
|
|
15
|
+
* "type": "http",
|
|
16
|
+
* "scheme": "bearer",
|
|
17
|
+
* "bearerFormat": "JWT",
|
|
18
|
+
* "name": "JWT Auth"
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
131
21
|
* }
|
|
132
22
|
*/
|
|
133
|
-
export declare const OpenApiConfigSchema: import("@sinclair/typebox").TObject<{
|
|
134
|
-
/** Output file path for the generated OpenAPI document */
|
|
135
|
-
out: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
136
|
-
/** Path to the application file (usually `dist/app.js`) */
|
|
137
|
-
app: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
138
|
-
/** API title */
|
|
23
|
+
export declare const OpenApiConfigSchema: import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
|
|
139
24
|
title: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
140
|
-
/** API version */
|
|
141
25
|
version: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
142
|
-
/** API description */
|
|
143
26
|
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
144
|
-
/** List of zones to include in the documentation */
|
|
145
27
|
includeZones: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
146
|
-
/** List of zones to exclude from the documentation */
|
|
147
28
|
excludeZones: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
148
|
-
|
|
149
|
-
security: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
29
|
+
security: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
150
30
|
type: import("@sinclair/typebox").TLiteral<"http">;
|
|
151
|
-
schemaName: import("@sinclair/typebox").TString;
|
|
152
31
|
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
153
32
|
scheme: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"basic">, import("@sinclair/typebox").TLiteral<"bearer">]>;
|
|
154
33
|
bearerFormat: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
155
34
|
}>, import("@sinclair/typebox").TObject<{
|
|
156
35
|
type: import("@sinclair/typebox").TLiteral<"apiKey">;
|
|
157
|
-
schemaName: import("@sinclair/typebox").TString;
|
|
158
36
|
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
159
37
|
name: import("@sinclair/typebox").TString;
|
|
160
38
|
in: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"query">, import("@sinclair/typebox").TLiteral<"header">, import("@sinclair/typebox").TLiteral<"cookie">]>;
|
|
161
39
|
}>, import("@sinclair/typebox").TObject<{
|
|
162
40
|
type: import("@sinclair/typebox").TLiteral<"oauth2">;
|
|
163
|
-
schemaName: import("@sinclair/typebox").TString;
|
|
164
41
|
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
165
42
|
flows: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TObject<{
|
|
166
43
|
scopes: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>;
|
|
@@ -168,11 +45,11 @@ export declare const OpenApiConfigSchema: import("@sinclair/typebox").TObject<{
|
|
|
168
45
|
tokenUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
169
46
|
refreshUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
170
47
|
}>>;
|
|
171
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
172
|
-
type: import("@sinclair/typebox").TLiteral<"mutualTLS">;
|
|
173
|
-
schemaName: import("@sinclair/typebox").TString;
|
|
174
|
-
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
175
|
-
name: import("@sinclair/typebox").TString;
|
|
176
48
|
}>]>>>;
|
|
177
|
-
}
|
|
49
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
50
|
+
/** Output file path for the generated OpenAPI document */
|
|
51
|
+
out: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
52
|
+
/** Path to the application file (usually `dist/app.js`) */
|
|
53
|
+
app: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
54
|
+
}>]>;
|
|
178
55
|
export type OpenApiConfigSchema = Static<typeof OpenApiConfigSchema>;
|
|
@@ -1,110 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OpenApiConfigSchema =
|
|
3
|
+
exports.OpenApiConfigSchema = void 0;
|
|
4
|
+
const http_openapi_1 = require("@rsdk/http.openapi");
|
|
4
5
|
const typebox_1 = require("@sinclair/typebox");
|
|
5
|
-
typebox_1.FormatRegistry.Set('uri', (value) => {
|
|
6
|
-
try {
|
|
7
|
-
new URL(value);
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
catch {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
/**
|
|
15
|
-
* HTTP Authentication scheme (Basic or Bearer).
|
|
16
|
-
* @example
|
|
17
|
-
* {
|
|
18
|
-
* "type": "http",
|
|
19
|
-
* "scheme": "bearer",
|
|
20
|
-
* "bearerFormat": "JWT",
|
|
21
|
-
* "name": "JWT Auth"
|
|
22
|
-
* }
|
|
23
|
-
*/
|
|
24
|
-
exports.HttpSecurityScheme = typebox_1.Type.Object({
|
|
25
|
-
type: typebox_1.Type.Literal('http'),
|
|
26
|
-
schemaName: typebox_1.Type.String(),
|
|
27
|
-
description: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
28
|
-
scheme: typebox_1.Type.Union([typebox_1.Type.Literal('basic'), typebox_1.Type.Literal('bearer')]),
|
|
29
|
-
bearerFormat: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
30
|
-
});
|
|
31
|
-
/**
|
|
32
|
-
* API Key Authentication scheme.
|
|
33
|
-
* The API key can be passed in a header, query parameter, or cookie.
|
|
34
|
-
* @example
|
|
35
|
-
* {
|
|
36
|
-
* "type": "apiKey",
|
|
37
|
-
* "name": "api_key",
|
|
38
|
-
* "in": "header",
|
|
39
|
-
* "description": "API Key Authentication"
|
|
40
|
-
* }
|
|
41
|
-
*/
|
|
42
|
-
exports.ApiKeySecurityScheme = typebox_1.Type.Object({
|
|
43
|
-
type: typebox_1.Type.Literal('apiKey'),
|
|
44
|
-
schemaName: typebox_1.Type.String(),
|
|
45
|
-
description: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
46
|
-
name: typebox_1.Type.String(),
|
|
47
|
-
in: typebox_1.Type.Union([
|
|
48
|
-
typebox_1.Type.Literal('query'),
|
|
49
|
-
typebox_1.Type.Literal('header'),
|
|
50
|
-
typebox_1.Type.Literal('cookie'),
|
|
51
|
-
]),
|
|
52
|
-
});
|
|
53
|
-
/**
|
|
54
|
-
* OAuth2 Authentication scheme.
|
|
55
|
-
* Supports multiple OAuth2 flows (implicit, password, clientCredentials, authorizationCode).
|
|
56
|
-
* @example
|
|
57
|
-
* {
|
|
58
|
-
* "type": "oauth2",
|
|
59
|
-
* "name": "OAuth2",
|
|
60
|
-
* "flows": {
|
|
61
|
-
* "implicit": {
|
|
62
|
-
* "authorizationUrl": "https://example.com/oauth/authorize",
|
|
63
|
-
* "scopes": {
|
|
64
|
-
* "read": "Read access",
|
|
65
|
-
* "write": "Write access"
|
|
66
|
-
* }
|
|
67
|
-
* }
|
|
68
|
-
* }
|
|
69
|
-
* }
|
|
70
|
-
*/
|
|
71
|
-
exports.OAuth2SecurityScheme = typebox_1.Type.Object({
|
|
72
|
-
type: typebox_1.Type.Literal('oauth2'),
|
|
73
|
-
schemaName: typebox_1.Type.String(),
|
|
74
|
-
description: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
75
|
-
flows: typebox_1.Type.Record(typebox_1.Type.String(), typebox_1.Type.Object({
|
|
76
|
-
scopes: typebox_1.Type.Record(typebox_1.Type.String(), typebox_1.Type.String()),
|
|
77
|
-
authorizationUrl: typebox_1.Type.Optional(typebox_1.Type.String({ format: 'uri' })),
|
|
78
|
-
tokenUrl: typebox_1.Type.Optional(typebox_1.Type.String({ format: 'uri' })),
|
|
79
|
-
refreshUrl: typebox_1.Type.Optional(typebox_1.Type.String({ format: 'uri' })),
|
|
80
|
-
})),
|
|
81
|
-
});
|
|
82
|
-
/**
|
|
83
|
-
* Mutual TLS Authentication scheme.
|
|
84
|
-
* Used when clients must present valid certificates to access the API.
|
|
85
|
-
* @example
|
|
86
|
-
* {
|
|
87
|
-
* "type": "mutualTLS",
|
|
88
|
-
* "name": "mtls",
|
|
89
|
-
* "description": "Client certificate required"
|
|
90
|
-
* }
|
|
91
|
-
*/
|
|
92
|
-
exports.MutualTLSSecurityScheme = typebox_1.Type.Object({
|
|
93
|
-
type: typebox_1.Type.Literal('mutualTLS'),
|
|
94
|
-
schemaName: typebox_1.Type.String(),
|
|
95
|
-
description: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
96
|
-
name: typebox_1.Type.String(),
|
|
97
|
-
});
|
|
98
|
-
/**
|
|
99
|
-
* Union of all supported security schemes.
|
|
100
|
-
* Can be one of: HTTP (Basic/Bearer), API Key, OAuth2, or Mutual TLS.
|
|
101
|
-
*/
|
|
102
|
-
exports.SecurityScheme = typebox_1.Type.Union([
|
|
103
|
-
exports.HttpSecurityScheme,
|
|
104
|
-
exports.ApiKeySecurityScheme,
|
|
105
|
-
exports.OAuth2SecurityScheme,
|
|
106
|
-
exports.MutualTLSSecurityScheme,
|
|
107
|
-
]);
|
|
108
6
|
/**
|
|
109
7
|
* Configuration schema for OpenAPI document generation.
|
|
110
8
|
* @example
|
|
@@ -116,30 +14,23 @@ exports.SecurityScheme = typebox_1.Type.Union([
|
|
|
116
14
|
* "description": "API Description",
|
|
117
15
|
* "includeZones": ["public"],
|
|
118
16
|
* "excludeZones": ["internal"],
|
|
119
|
-
* "security":
|
|
120
|
-
* "
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
17
|
+
* "security": {
|
|
18
|
+
* "jwt": {
|
|
19
|
+
* "type": "http",
|
|
20
|
+
* "scheme": "bearer",
|
|
21
|
+
* "bearerFormat": "JWT",
|
|
22
|
+
* "name": "JWT Auth"
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
125
25
|
* }
|
|
126
26
|
*/
|
|
127
|
-
exports.OpenApiConfigSchema = typebox_1.Type.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
/** API description */
|
|
137
|
-
description: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
138
|
-
/** List of zones to include in the documentation */
|
|
139
|
-
includeZones: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.String())),
|
|
140
|
-
/** List of zones to exclude from the documentation */
|
|
141
|
-
excludeZones: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.String())),
|
|
142
|
-
/** Security schemes configuration */
|
|
143
|
-
security: typebox_1.Type.Optional(typebox_1.Type.Array(exports.SecurityScheme)),
|
|
144
|
-
});
|
|
27
|
+
exports.OpenApiConfigSchema = typebox_1.Type.Intersect([
|
|
28
|
+
typebox_1.Type.Partial(http_openapi_1.OpenApiOptions),
|
|
29
|
+
typebox_1.Type.Object({
|
|
30
|
+
/** Output file path for the generated OpenAPI document */
|
|
31
|
+
out: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
32
|
+
/** Path to the application file (usually `dist/app.js`) */
|
|
33
|
+
app: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
34
|
+
}),
|
|
35
|
+
]);
|
|
145
36
|
//# sourceMappingURL=config.schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.schema.js","sourceRoot":"","sources":["../../../src/generators/openapi-json/config.schema.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"config.schema.js","sourceRoot":"","sources":["../../../src/generators/openapi-json/config.schema.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAEpD,+CAAyC;AAEzC;;;;;;;;;;;;;;;;;;;;GAoBG;AACU,QAAA,mBAAmB,GAAG,cAAI,CAAC,SAAS,CAAC;IAChD,cAAI,CAAC,OAAO,CAAC,6BAAc,CAAC;IAC5B,cAAI,CAAC,MAAM,CAAC;QACV,0DAA0D;QAC1D,GAAG,EAAE,cAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,MAAM,EAAE,CAAC;QAEjC,2DAA2D;QAC3D,GAAG,EAAE,cAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,MAAM,EAAE,CAAC;KAClC,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { PlatformApp } from '@rsdk/core';
|
|
1
|
+
import type { PlatformApp } from '@rsdk/core';
|
|
2
2
|
import { FileGenerator } from '../file-generator.interface';
|
|
3
|
-
import { OpenApiConfigSchema } from './config.schema';
|
|
3
|
+
import type { OpenApiConfigSchema } from './config.schema';
|
|
4
4
|
/**
|
|
5
5
|
* Here we don't need `out` and `app`,
|
|
6
6
|
* but `title`, `version` and `description` are required.
|
|
7
7
|
*/
|
|
8
8
|
export type OpenApiGeneratorOptions = Omit<OpenApiConfigSchema, 'out' | 'app'> & Required<Pick<OpenApiConfigSchema, 'title' | 'version' | 'description'>>;
|
|
9
|
-
export declare class
|
|
10
|
-
private readonly
|
|
9
|
+
export declare class OpenApiFileGenerator extends FileGenerator {
|
|
10
|
+
private readonly context;
|
|
11
11
|
private readonly options;
|
|
12
12
|
constructor(app: PlatformApp, options?: Partial<OpenApiGeneratorOptions>);
|
|
13
13
|
protected getContent(): Promise<string>;
|
|
14
|
-
private clearController;
|
|
15
14
|
private resolveOptions;
|
|
16
15
|
}
|
|
@@ -1,124 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
10
|
-
const
|
|
11
|
-
const core_1 = require("@nestjs/core");
|
|
12
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
13
|
-
const core_2 = require("@rsdk/core");
|
|
3
|
+
exports.OpenApiFileGenerator = void 0;
|
|
4
|
+
const http_openapi_1 = require("@rsdk/http.openapi");
|
|
14
5
|
const logging_1 = require("@rsdk/logging");
|
|
15
|
-
const nest_tools_1 = require("@rsdk/nest-tools");
|
|
16
|
-
const zones_1 = require("@rsdk/zones");
|
|
17
6
|
const file_generator_interface_1 = require("../file-generator.interface");
|
|
18
|
-
class
|
|
19
|
-
|
|
7
|
+
class OpenApiFileGenerator extends file_generator_interface_1.FileGenerator {
|
|
8
|
+
context;
|
|
20
9
|
options;
|
|
21
10
|
constructor(app, options = {}) {
|
|
22
|
-
super(logging_1.LoggerFactory.create(
|
|
23
|
-
this.
|
|
11
|
+
super(logging_1.LoggerFactory.create(OpenApiFileGenerator));
|
|
12
|
+
this.context = app.context;
|
|
24
13
|
this.options = options;
|
|
25
14
|
}
|
|
26
15
|
async getContent() {
|
|
27
|
-
const transports = this.app.context.options.transports;
|
|
28
|
-
if (!transports?.length) {
|
|
29
|
-
throw new Error('transports not found');
|
|
30
|
-
}
|
|
31
|
-
const httpTransport = transports?.find?.(core_2.isHttpTransport);
|
|
32
|
-
if (!httpTransport) {
|
|
33
|
-
throw new Error('http transport not found');
|
|
34
|
-
}
|
|
35
16
|
this.logger.info('Generate openapi starting');
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const controllers = [];
|
|
40
|
-
const { includeZones, excludeZones } = options;
|
|
41
|
-
/**
|
|
42
|
-
* TODO: А может надо на основании чего-то другого, кроме тегов ещё?
|
|
43
|
-
* Просто теги могут быть с пробелами и с другими приколами... как вариант
|
|
44
|
-
* можно на основании имён контроллеров?
|
|
45
|
-
*/
|
|
46
|
-
this.logger.info(`includeZones: ${includeZones}`);
|
|
47
|
-
this.logger.info(`excludeZones: ${excludeZones}`);
|
|
48
|
-
for await (const controller of iterator) {
|
|
49
|
-
const zone = zones_1.Zone.getForController(controller);
|
|
50
|
-
this.logger.info(`${controller.name} zone: ${zone || 'none'}`);
|
|
51
|
-
/**
|
|
52
|
-
* Исключаем контроллеры, c зоной из excludeZones
|
|
53
|
-
*/
|
|
54
|
-
if (excludeZones && excludeZones.includes(zone)) {
|
|
55
|
-
this.logger.info(`${controller.name} excluded`);
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Включаем только те контроллеры, которые имеют хотя бы один из тегов из includeTags
|
|
60
|
-
*/
|
|
61
|
-
if (includeZones && !includeZones.includes(zone)) {
|
|
62
|
-
this.logger.info(`${controller.name} skipped`);
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
this.logger.info(`${controller.name} included`);
|
|
66
|
-
controllers.push(this.clearController(controller));
|
|
67
|
-
}
|
|
68
|
-
let OpenApiModule = class OpenApiModule {
|
|
69
|
-
};
|
|
70
|
-
OpenApiModule = __decorate([
|
|
71
|
-
(0, common_1.Module)({ controllers })
|
|
72
|
-
], OpenApiModule);
|
|
73
|
-
const createOptions = await this.app.context.getNestFactoryCreateOptions();
|
|
74
|
-
const app = await core_1.NestFactory.create(OpenApiModule, ...createOptions);
|
|
75
|
-
const { title, version, description, security } = options;
|
|
76
|
-
const builder = new swagger_1.DocumentBuilder()
|
|
77
|
-
.setTitle(title)
|
|
78
|
-
.setVersion(version)
|
|
79
|
-
.setDescription(description);
|
|
80
|
-
if (security) {
|
|
81
|
-
for (const scheme of security) {
|
|
82
|
-
switch (scheme.type) {
|
|
83
|
-
case 'http':
|
|
84
|
-
if (scheme.scheme === 'bearer') {
|
|
85
|
-
builder.addBearerAuth(scheme, scheme.schemaName);
|
|
86
|
-
}
|
|
87
|
-
else if (scheme.scheme === 'basic') {
|
|
88
|
-
builder.addBasicAuth(scheme, scheme.schemaName);
|
|
89
|
-
}
|
|
90
|
-
break;
|
|
91
|
-
case 'oauth2':
|
|
92
|
-
builder.addOAuth2(scheme, scheme.schemaName);
|
|
93
|
-
break;
|
|
94
|
-
case 'apiKey':
|
|
95
|
-
builder.addApiKey(scheme, scheme.schemaName);
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const openApiConfig = builder.build();
|
|
101
|
-
const document = swagger_1.SwaggerModule.createDocument(app, openApiConfig);
|
|
17
|
+
const options = await this.resolveOptions(this.context, this.options);
|
|
18
|
+
const generator = new http_openapi_1.OpenApiGenerator(this.context, options);
|
|
19
|
+
const document = await generator.generate();
|
|
102
20
|
this.logger.info('Generate openapi finished');
|
|
103
|
-
await app.close();
|
|
104
21
|
return JSON.stringify(document, null, 2);
|
|
105
22
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
const keysForRedefine = ['design:paramtypes', 'self:paramtypes'];
|
|
110
|
-
for (const forRedefineMetadataKey of keysForRedefine) {
|
|
111
|
-
Reflect.defineMetadata(forRedefineMetadataKey, [], ClearedController);
|
|
112
|
-
}
|
|
113
|
-
// Влияет на `operationId` в генерации
|
|
114
|
-
Object.defineProperty(ClearedController, 'name', {
|
|
115
|
-
value: controller.name,
|
|
116
|
-
writable: false,
|
|
117
|
-
});
|
|
118
|
-
return ClearedController;
|
|
119
|
-
}
|
|
120
|
-
async resolveOptions(app, passed) {
|
|
121
|
-
const appMetadata = await app.context.getMetadata();
|
|
23
|
+
async resolveOptions(context, passed) {
|
|
24
|
+
const appMetadata = await context.getMetadata();
|
|
122
25
|
const defaults = {
|
|
123
26
|
title: appMetadata.name,
|
|
124
27
|
version: appMetadata.version,
|
|
@@ -127,5 +30,5 @@ class OpenapiGenerator extends file_generator_interface_1.FileGenerator {
|
|
|
127
30
|
return { ...defaults, ...passed };
|
|
128
31
|
}
|
|
129
32
|
}
|
|
130
|
-
exports.
|
|
33
|
+
exports.OpenApiFileGenerator = OpenApiFileGenerator;
|
|
131
34
|
//# sourceMappingURL=openapi-json.generator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-json.generator.js","sourceRoot":"","sources":["../../../src/generators/openapi-json/openapi-json.generator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"openapi-json.generator.js","sourceRoot":"","sources":["../../../src/generators/openapi-json/openapi-json.generator.ts"],"names":[],"mappings":";;;AACA,qDAAsD;AACtD,2CAA8C;AAE9C,0EAA4D;AAW5D,MAAa,oBAAqB,SAAQ,wCAAa;IACpC,OAAO,CAAkB;IACzB,OAAO,CAAmC;IAE3D,YACE,GAAgB,EAChB,UAA4C,EAAE;QAE9C,KAAK,CAAC,uBAAa,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAClD,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAES,KAAK,CAAC,UAAU;QACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAE9C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACtE,MAAM,SAAS,GAAG,IAAI,+BAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9D,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,QAAQ,EAAE,CAAC;QAE5C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3C,CAAC;IAEO,KAAK,CAAC,cAAc,CAC1B,OAAwB,EACxB,MAAwC;QAExC,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,WAAW,EAAE,CAAC;QAChD,MAAM,QAAQ,GAA4B;YACxC,KAAK,EAAE,WAAW,CAAC,IAAI;YACvB,OAAO,EAAE,WAAW,CAAC,OAAO;YAC5B,WAAW,EAAE,WAAW,CAAC,WAAW;SACrC,CAAC;QAEF,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC;IACpC,CAAC;CACF;AArCD,oDAqCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('@rsdk/jest/jest.config.e2e');
|
package/jest.config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('@rsdk/jest/jest.config');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('@rsdk/jest/jest.config.unit');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/cli.cmd.autodoc",
|
|
3
|
-
"version": "6.0.0-next.
|
|
3
|
+
"version": "6.0.0-next.8",
|
|
4
4
|
"description": "autodoc your app!",
|
|
5
5
|
"homepage": "https://github.com/R-Vision/rsdk",
|
|
6
6
|
"license": "Apache License 2.0",
|
|
@@ -8,40 +8,23 @@
|
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
10
|
"main": "dist/index.js",
|
|
11
|
-
"
|
|
12
|
-
"dist"
|
|
13
|
-
],
|
|
14
|
-
"repository": {
|
|
15
|
-
"type": "git",
|
|
16
|
-
"url": "https://github.com/R-Vision/rsdk"
|
|
17
|
-
},
|
|
18
|
-
"scripts": {
|
|
19
|
-
"prepublishOnly": "npm run build"
|
|
20
|
-
},
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
21
12
|
"dependencies": {
|
|
22
|
-
"@sinclair/typebox": "^0.34.9",
|
|
23
|
-
"commander": "^12.1.0",
|
|
24
|
-
"lodash": "^4.17.21",
|
|
25
|
-
"log-update": "4.0.0",
|
|
26
|
-
"markdown-table": "2.0.0",
|
|
27
|
-
"pino-pretty": "^10.3.1",
|
|
28
|
-
"rxjs": "^7.8.1"
|
|
29
|
-
},
|
|
30
|
-
"peerDependencies": {
|
|
31
13
|
"@nestjs/common": "^10.0.0",
|
|
32
14
|
"@nestjs/core": "^10.0.0",
|
|
33
15
|
"@nestjs/swagger": "^7.0.0 || ^8.0.0",
|
|
34
|
-
"@
|
|
35
|
-
"@rsdk/
|
|
36
|
-
"@rsdk/
|
|
37
|
-
"@rsdk/common": "
|
|
38
|
-
"@rsdk/
|
|
39
|
-
"@rsdk/
|
|
40
|
-
"@rsdk/logging": "
|
|
41
|
-
"@rsdk/
|
|
42
|
-
"@rsdk/
|
|
43
|
-
"@
|
|
44
|
-
"
|
|
16
|
+
"@rsdk/cli.common": "6.0.0-next.8",
|
|
17
|
+
"@rsdk/cli.core": "6.0.0-next.8",
|
|
18
|
+
"@rsdk/common": "6.0.0-next.8",
|
|
19
|
+
"@rsdk/common.node": "6.0.0-next.8",
|
|
20
|
+
"@rsdk/core": "6.0.0-next.8",
|
|
21
|
+
"@rsdk/http.openapi": "6.0.0-next.8",
|
|
22
|
+
"@rsdk/logging": "6.0.0-next.8",
|
|
23
|
+
"@rsdk/nest-tools": "6.0.0-next.8",
|
|
24
|
+
"@rsdk/zones": "6.0.0-next.8",
|
|
25
|
+
"@sinclair/typebox": "^0.34.9",
|
|
26
|
+
"lodash": "^4.17.21",
|
|
27
|
+
"yaml": "^2.6.1"
|
|
45
28
|
},
|
|
46
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "3d0d13e78842a0d57124a5246d00c77718be0045"
|
|
47
30
|
}
|