api-core-lib 12.0.82 → 12.0.83
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/dist/cli.cjs +20 -3
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -299,7 +299,22 @@ async function generateModuleFiles(module2, allSchemas, allEnums, outputDir) {
|
|
|
299
299
|
if (!import_fs.default.existsSync(moduleOutputPath)) import_fs.default.mkdirSync(moduleOutputPath, { recursive: true });
|
|
300
300
|
console.log(import_chalk.default.cyan(`
|
|
301
301
|
Generating module: ${import_chalk.default.bold(module2.moduleName)}`));
|
|
302
|
-
const
|
|
302
|
+
const BUILT_IN_TYPES = /* @__PURE__ */ new Set([
|
|
303
|
+
"string",
|
|
304
|
+
"number",
|
|
305
|
+
"boolean",
|
|
306
|
+
"void",
|
|
307
|
+
"undefined",
|
|
308
|
+
"unknown",
|
|
309
|
+
"any",
|
|
310
|
+
"Date",
|
|
311
|
+
"Promise",
|
|
312
|
+
"QueryOptions",
|
|
313
|
+
"Record<string, any>",
|
|
314
|
+
"Record<string, unknown>"
|
|
315
|
+
]);
|
|
316
|
+
const allCustomSchemaNames = [...module2.schemas].sort();
|
|
317
|
+
const schemasToImport = allCustomSchemaNames.filter((name) => !BUILT_IN_TYPES.has(name));
|
|
303
318
|
const enumsToImport = [...module2.enums].sort();
|
|
304
319
|
const indexContent = [`// This file is auto-generated. Do not edit directly.
|
|
305
320
|
|
|
@@ -308,8 +323,10 @@ export * from './config';`];
|
|
|
308
323
|
|
|
309
324
|
import type { ApiModuleConfig, ActionConfigModule } from 'api-core-lib';
|
|
310
325
|
`;
|
|
311
|
-
if (schemasToImport.length > 0)
|
|
326
|
+
if (schemasToImport.length > 0) {
|
|
327
|
+
configContent += `import type { ${schemasToImport.join(", ")} } from './types';
|
|
312
328
|
`;
|
|
329
|
+
}
|
|
313
330
|
const actionsType = Object.values(module2.actions).map((a) => ` ${a.name}: ActionConfigModule<${a.inputType}, ${a.outputType}>;`).join("\n");
|
|
314
331
|
const actionsValue = Object.values(module2.actions).map((a) => {
|
|
315
332
|
const { inputType, outputType, name, ...c } = a;
|
|
@@ -327,7 +344,7 @@ ${actionsValue}
|
|
|
327
344
|
`;
|
|
328
345
|
import_fs.default.writeFileSync(import_path.default.join(moduleOutputPath, "config.ts"), configContent.trim());
|
|
329
346
|
console.log(import_chalk.default.gray(` \u2713 config.ts`));
|
|
330
|
-
if (
|
|
347
|
+
if (allCustomSchemaNames.length > 0) {
|
|
331
348
|
if (enumsToImport.length > 0) {
|
|
332
349
|
let enumsContent = `// This file is auto-generated. Do not edit directly.
|
|
333
350
|
|