@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "extends": ["@exabyte-io/eslint-config"],
3
- "ignorePatterns": ["dist/js/**/*.js", "dist/js/**/*.ts"],
3
+ "ignorePatterns": ["dist/js/**/*.js", "dist/js/**/*.ts", "src/js/types.ts"],
4
4
  "settings": {
5
5
  "import/resolver": {
6
6
  "node": {
package/compile_ts.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import compileTS from "./src/js/scripts/compileTs";
2
2
 
3
- compileTS("./dist/js/schema", `./dist/js/types.ts`);
3
+ compileTS("./dist/js/schema", `./src/js/types.ts`);
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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 (typeof object === "object" && (object === null || object === void 0 ? void 0 : object.title) && !firstRun) {
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)(schema, schema.title || "", {
72
- unreachableDefinitions: true,
73
- additionalProperties: false,
74
- bannerComment: `/** Schema ${filePath} */`,
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
  }