equipped 5.0.0-beta.8 → 5.0.0-beta.9
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
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [5.0.0-beta.9](https://github.com/kevinand11/equipped/compare/v5.0.0-beta.8...v5.0.0-beta.9) (2024-05-31)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* generateJSONSchema ([39031fd](https://github.com/kevinand11/equipped/commit/39031fd7c8d0f18a93c55b3fc542fd33042e4e44))
|
|
11
|
+
|
|
5
12
|
## [5.0.0-beta.8](https://github.com/kevinand11/equipped/compare/v5.0.0-beta.7...v5.0.0-beta.8) (2024-05-31)
|
|
6
13
|
|
|
7
14
|
|
package/lib/instance/index.js
CHANGED
|
@@ -59,8 +59,9 @@ class Instance {
|
|
|
59
59
|
return __classPrivateFieldGet(this, _Instance_settings, "f");
|
|
60
60
|
}
|
|
61
61
|
static createLogger() {
|
|
62
|
+
const defaultLogLevel = 'info';
|
|
62
63
|
return (0, pino_1.default)({
|
|
63
|
-
level: _a.get()
|
|
64
|
+
level: __classPrivateFieldGet(_a, _a, "f", _Instance_initialized) ? _a.get().settings?.logLevel ?? defaultLogLevel : defaultLogLevel,
|
|
64
65
|
serializers: {
|
|
65
66
|
err: pino_1.default.stdSerializers.err,
|
|
66
67
|
req: pino_1.default.stdSerializers.req,
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
import { Options } from 'ts-oas';
|
|
1
2
|
import { RouteSchema } from '../server';
|
|
2
|
-
export declare function generateJSONSchema(patterns: (string | RegExp)[], paths: string[]
|
|
3
|
+
export declare function generateJSONSchema(patterns: (string | RegExp)[], paths: string[], options?: {
|
|
4
|
+
tsConfigPath?: string | Record<string, unknown>;
|
|
5
|
+
options?: Options;
|
|
6
|
+
}): Record<string, RouteSchema>;
|
|
@@ -27,16 +27,21 @@ exports.generateJSONSchema = void 0;
|
|
|
27
27
|
const ts_oas_1 = __importStar(require("ts-oas"));
|
|
28
28
|
const instance_1 = require("../instance");
|
|
29
29
|
const fileSchema = { type: 'string', format: 'binary' };
|
|
30
|
-
function generateJSONSchema(patterns, paths) {
|
|
31
|
-
const tsProgram = (0, ts_oas_1.createProgram)(paths,
|
|
32
|
-
const
|
|
30
|
+
function generateJSONSchema(patterns, paths, options) {
|
|
31
|
+
const tsProgram = (0, ts_oas_1.createProgram)(paths, options?.tsConfigPath);
|
|
32
|
+
const logger = instance_1.Instance.createLogger();
|
|
33
|
+
const tsoas = new ts_oas_1.default(tsProgram, {
|
|
34
|
+
ref: false,
|
|
35
|
+
nullableKeyword: false,
|
|
36
|
+
...(options?.options ?? {})
|
|
37
|
+
});
|
|
33
38
|
const jsonSchema = tsoas.getSchemas(patterns);
|
|
34
39
|
return Object.entries(jsonSchema)
|
|
35
40
|
.map(([name, { properties: def }]) => {
|
|
36
41
|
try {
|
|
37
42
|
const key = def?.key?.enum?.at(0) ?? name;
|
|
38
43
|
if (!def || !key || !def.method)
|
|
39
|
-
|
|
44
|
+
return [undefined, undefined];
|
|
40
45
|
const response = def.responses.properties ?? def.responses.anyOf?.reduce((acc, cur) => {
|
|
41
46
|
if (cur.properties)
|
|
42
47
|
return { ...acc, ...cur.properties };
|
|
@@ -58,27 +63,28 @@ function generateJSONSchema(patterns, paths) {
|
|
|
58
63
|
body.required.push(key);
|
|
59
64
|
});
|
|
60
65
|
}
|
|
61
|
-
const schema =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
: undefined;
|
|
66
|
+
const schema = {
|
|
67
|
+
body,
|
|
68
|
+
params: def.params,
|
|
69
|
+
querystring: def.query,
|
|
70
|
+
headers: def.headers,
|
|
71
|
+
response,
|
|
72
|
+
operationId: key,
|
|
73
|
+
summary: name,
|
|
74
|
+
};
|
|
72
75
|
return [key, schema];
|
|
73
76
|
}
|
|
74
77
|
catch (err) {
|
|
75
|
-
|
|
78
|
+
logger.warn(`Error parsing ${name}: ${err.message}. Skipping route`);
|
|
76
79
|
return [undefined, undefined];
|
|
77
80
|
}
|
|
78
81
|
})
|
|
79
82
|
.reduce((acc, [path, schema]) => {
|
|
80
|
-
if (path
|
|
81
|
-
acc
|
|
83
|
+
if (!path || !schema)
|
|
84
|
+
return acc;
|
|
85
|
+
if (acc[path])
|
|
86
|
+
logger.warn(`Duplicate route key '${path}' found for '${acc[path].summary}' & '${schema.summary}'. Make sure to use unique keys for all routes because only the last one will be used.`);
|
|
87
|
+
acc[path] = stripEmptyObjects(schema);
|
|
82
88
|
return acc;
|
|
83
89
|
}, {});
|
|
84
90
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClassPropertiesWrapper } from 'valleyed';
|
|
2
|
-
export declare class BaseEntity<Keys extends object = object, Ignored extends string =
|
|
2
|
+
export declare class BaseEntity<Keys extends object = object, Ignored extends string = never> extends ClassPropertiesWrapper<Keys> {
|
|
3
3
|
__hash: string;
|
|
4
4
|
__type: string;
|
|
5
5
|
readonly __ignoreInJSON: Ignored[];
|