@mat3ra/esse 2024.4.8-6 → 2024.4.9-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/.eslintrc.json +1 -1
- package/compile_ts.ts +1 -1
- package/dist/js/scripts/compileTs.js +21 -11
- package/dist/js/types.d.ts +32943 -0
- package/dist/js/types.js +21 -0
- package/package.json +2 -2
- package/src/js/scripts/compileTs.ts +1 -0
- package/dist/js/types.ts +0 -37307
package/.eslintrc.json
CHANGED
package/compile_ts.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __importDefault =
|
|
3
|
+
(this && this.__importDefault) ||
|
|
4
|
+
function (mod) {
|
|
5
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
|
+
};
|
|
5
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
8
|
const fs_1 = __importDefault(require("fs"));
|
|
7
9
|
const json_schema_to_typescript_1 = require("json-schema-to-typescript");
|
|
@@ -47,7 +49,11 @@ const filesystem_1 = require("../utils/filesystem");
|
|
|
47
49
|
function cleanSchema(schema) {
|
|
48
50
|
let firstRun = true;
|
|
49
51
|
return (0, schemaUtils_1.mapObjectDeep)(schema, (object) => {
|
|
50
|
-
if (
|
|
52
|
+
if (
|
|
53
|
+
typeof object === "object" &&
|
|
54
|
+
(object === null || object === void 0 ? void 0 : object.title) &&
|
|
55
|
+
!firstRun
|
|
56
|
+
) {
|
|
51
57
|
firstRun = false;
|
|
52
58
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
53
59
|
const { title, $schema, ...restObject } = object;
|
|
@@ -59,8 +65,7 @@ function cleanSchema(schema) {
|
|
|
59
65
|
async function compileTS(schemaPath, savePath) {
|
|
60
66
|
try {
|
|
61
67
|
await fs_1.default.promises.unlink(savePath);
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
68
|
+
} catch (err) {
|
|
64
69
|
console.log("File with types not exists");
|
|
65
70
|
}
|
|
66
71
|
await (0, filesystem_1.walkDir)(schemaPath, async (filePath) => {
|
|
@@ -68,11 +73,16 @@ async function compileTS(schemaPath, savePath) {
|
|
|
68
73
|
const schema = cleanSchema(JSON.parse(data));
|
|
69
74
|
console.log(`Compiling Typescript: ${filePath}`);
|
|
70
75
|
// @ts-ignore
|
|
71
|
-
const compiledSchema = await (0, json_schema_to_typescript_1.compile)(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
const compiledSchema = await (0, json_schema_to_typescript_1.compile)(
|
|
77
|
+
schema,
|
|
78
|
+
schema.title || "",
|
|
79
|
+
{
|
|
80
|
+
unreachableDefinitions: true,
|
|
81
|
+
additionalProperties: false,
|
|
82
|
+
enableConstEnums: false,
|
|
83
|
+
bannerComment: `/** Schema ${filePath} */`,
|
|
84
|
+
},
|
|
85
|
+
);
|
|
76
86
|
await fs_1.default.promises.appendFile(savePath, `${compiledSchema} \n`, { flag: "a+" });
|
|
77
87
|
});
|
|
78
88
|
}
|