@ndla/types-taxonomy 1.0.48 → 1.0.50

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.
@@ -81,15 +81,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
81
81
  Object.defineProperty(exports, "__esModule", { value: true });
82
82
  var node_fs_1 = __importDefault(require("node:fs"));
83
83
  var openapi_typescript_1 = __importStar(require("openapi-typescript"));
84
- var typescript_1 = __importDefault(require("typescript"));
85
- if (process.argv.length !== 2) {
86
- throw new Error("Invalid use");
87
- }
88
- var BLOB = typescript_1.default.factory.createTypeReferenceNode(typescript_1.default.factory.createIdentifier("Blob"));
89
- var NULL = typescript_1.default.factory.createLiteralTypeNode(typescript_1.default.factory.createNull()); // `null`
90
- function generate_types(appName) {
84
+ function generate_types() {
91
85
  return __awaiter(this, void 0, void 0, function () {
92
- var jsonFile, schema, schemaContent, ast, outputPath, output, header, newFileContent, schemas, schemaNames, _i, schemaNames_1, schemaName, newFilePath;
86
+ var jsonFile, schema, schemaContent, ast, outputPath, output;
93
87
  return __generator(this, function (_a) {
94
88
  switch (_a.label) {
95
89
  case 0:
@@ -102,28 +96,20 @@ function generate_types(appName) {
102
96
  return [4 /*yield*/, (0, openapi_typescript_1.default)(schemaContent, {
103
97
  defaultNonNullable: false,
104
98
  exportType: true,
99
+ rootTypes: true,
100
+ rootTypesKeepCasing: true,
101
+ rootTypesNoSchemaPrefix: true,
105
102
  })];
106
103
  case 2:
107
104
  ast = _a.sent();
108
- outputPath = "./taxonomy-api-openapi.ts";
105
+ outputPath = "./taxonomy-api.ts";
109
106
  output = (0, openapi_typescript_1.astToString)(ast);
110
107
  console.log("Outputting to ".concat(outputPath));
111
108
  node_fs_1.default.writeFileSync(outputPath, output);
112
- header = "// This file is generated automatically. Do not edit.\n";
113
- newFileContent = "".concat(header, "import * as openapi from \"./taxonomy-api-openapi\";\ntype schemas = openapi.components[\"schemas\"];\nexport { openapi };\n\n");
114
- schemas = schemaContent.components.schemas;
115
- schemaNames = Object.keys(schemas);
116
- for (_i = 0, schemaNames_1 = schemaNames; _i < schemaNames_1.length; _i++) {
117
- schemaName = schemaNames_1[_i];
118
- newFileContent += "export type ".concat(schemaName, " = schemas[\"").concat(schemaName, "\"];\n");
119
- }
120
- newFilePath = "./taxonomy-api.ts";
121
- console.log("Outputting to ".concat(newFilePath));
122
- node_fs_1.default.writeFileSync(newFilePath, newFileContent);
123
109
  return [2 /*return*/];
124
110
  }
125
111
  });
126
112
  });
127
113
  }
128
- generate_types(process.argv[2]);
114
+ generate_types();
129
115
  //# sourceMappingURL=generate-openapi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-openapi.js","sourceRoot":"","sources":["../../scripts/generate-openapi.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAyB;AACzB,uEAA6E;AAC7E,0DAA0C;AAE1C,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IAC9B,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;AACjC,CAAC;AAED,IAAM,IAAI,GAAG,oBAAE,CAAC,OAAO,CAAC,uBAAuB,CAC7C,oBAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CACpC,CAAC;AACF,IAAM,IAAI,GAAG,oBAAE,CAAC,OAAO,CAAC,qBAAqB,CAAC,oBAAE,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS;AAEjF,SAAe,cAAc,CAAC,OAAe;;;;;;oBACrC,QAAQ,GAAG,gBAAgB,CAAC;oBAClC,OAAO,CAAC,GAAG,CAAC,kBAAW,QAAQ,qCAAkC,CAAC,CAAC;oBACpD,qBAAM,iBAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,E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