@ndla/types-taxonomy 1.0.49 → 1.0.51

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.
@@ -1,40 +1,3 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.openapi = void 0;
37
- // This file is generated automatically. Do not edit.
38
- var openapi = __importStar(require("./taxonomy-api-openapi"));
39
- exports.openapi = openapi;
40
3
  //# sourceMappingURL=taxonomy-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"taxonomy-api.js","sourceRoot":"","sources":["../taxonomy-api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAqD;AACrD,8DAAkD;AAEzC,0BAAO"}
1
+ {"version":3,"file":"taxonomy-api.js","sourceRoot":"","sources":["../taxonomy-api.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -17,10 +17,10 @@
17
17
  "main": "taxonomy-api.js",
18
18
  "devDependencies": {
19
19
  "@types/node": "^22.13.16",
20
- "openapi-typescript": "^7.10.1",
21
- "tsx": "^4.19.3",
22
- "typescript": "^5.3.3"
20
+ "openapi-typescript": "^7.13.0",
21
+ "tsx": "^4.21.0",
22
+ "typescript": "^5.9.3"
23
23
  },
24
- "version": "1.0.49",
24
+ "version": "1.0.51",
25
25
  "packageManager": "yarn@4.10.3"
26
26
  }
@@ -7,19 +7,9 @@
7
7
  */
8
8
 
9
9
  import fs from "node:fs";
10
- import openapiTS, { astToString, TransformObject } from "openapi-typescript";
11
- import ts, { TypeNode } from "typescript";
10
+ import openapiTS, { astToString } from "openapi-typescript";
12
11
 
13
- if (process.argv.length !== 2) {
14
- throw new Error("Invalid use");
15
- }
16
-
17
- const BLOB = ts.factory.createTypeReferenceNode(
18
- ts.factory.createIdentifier("Blob"),
19
- );
20
- const NULL = ts.factory.createLiteralTypeNode(ts.factory.createNull()); // `null`
21
-
22
- async function generate_types(appName: string) {
12
+ async function generate_types() {
23
13
  const jsonFile = `./openapi.json`;
24
14
  console.log(`Parsing ${jsonFile} to generate typescript files...`);
25
15
  const schema = await fs.promises.readFile(jsonFile, "utf8");
@@ -28,35 +18,18 @@ async function generate_types(appName: string) {
28
18
  const ast = await openapiTS(schemaContent, {
29
19
  defaultNonNullable: false,
30
20
  exportType: true,
21
+ rootTypes: true,
22
+ rootTypesKeepCasing: true,
23
+ rootTypesNoSchemaPrefix: true,
31
24
  });
32
25
 
33
- const outputPath = `./taxonomy-api-openapi.ts`;
26
+ const outputPath = `./taxonomy-api.ts`;
34
27
 
35
28
  const output = astToString(ast);
36
29
 
37
30
  console.log(`Outputting to ${outputPath}`);
38
31
 
39
32
  fs.writeFileSync(outputPath, output);
40
-
41
- const header = `// This file is generated automatically. Do not edit.
42
- `;
43
- let newFileContent = `${header}import * as openapi from "./taxonomy-api-openapi";
44
- type schemas = openapi.components["schemas"];
45
- export { openapi };
46
-
47
- `;
48
-
49
- const schemas = schemaContent.components.schemas;
50
- const schemaNames = Object.keys(schemas);
51
- for (const schemaName of schemaNames) {
52
- newFileContent += `export type ${schemaName} = schemas["${schemaName}"];\n`;
53
- }
54
-
55
- const newFilePath = `./taxonomy-api.ts`;
56
-
57
- console.log(`Outputting to ${newFilePath}`);
58
-
59
- fs.writeFileSync(newFilePath, newFileContent);
60
33
  }
61
34
 
62
- generate_types(process.argv[2]);
35
+ generate_types();