adorn-api 1.0.17 → 1.0.18
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/progress.d.ts.map +1 -1
- package/dist/cli.cjs +83 -26
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +83 -26
- package/dist/cli.js.map +1 -1
- package/dist/compiler/schema/openapi.d.ts +8 -0
- package/dist/compiler/schema/openapi.d.ts.map +1 -1
- package/dist/compiler/schema/splitOpenapi.d.ts +7 -0
- package/dist/compiler/schema/splitOpenapi.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1574,7 +1574,12 @@ function generateOpenAPI(controllers, checker, options = {}) {
|
|
|
1574
1574
|
mode: "response"
|
|
1575
1575
|
};
|
|
1576
1576
|
const paths = {};
|
|
1577
|
-
|
|
1577
|
+
const { onProgress } = options;
|
|
1578
|
+
for (let i = 0; i < controllers.length; i++) {
|
|
1579
|
+
const controller = controllers[i];
|
|
1580
|
+
if (onProgress) {
|
|
1581
|
+
onProgress(`Processing controller ${controller.className}`, i + 1, controllers.length);
|
|
1582
|
+
}
|
|
1578
1583
|
for (const operation of controller.operations) {
|
|
1579
1584
|
const fullPath = convertToOpenApiPath(controller.basePath, operation.path);
|
|
1580
1585
|
if (!paths[fullPath]) {
|
|
@@ -1585,6 +1590,9 @@ function generateOpenAPI(controllers, checker, options = {}) {
|
|
|
1585
1590
|
}
|
|
1586
1591
|
}
|
|
1587
1592
|
const schemas = Object.fromEntries(components);
|
|
1593
|
+
if (onProgress) {
|
|
1594
|
+
onProgress("Generating and cleaning schemas", controllers.length, controllers.length);
|
|
1595
|
+
}
|
|
1588
1596
|
cleanupMetalOrmWrappers(schemas, paths);
|
|
1589
1597
|
return {
|
|
1590
1598
|
openapi: "3.1.0",
|
|
@@ -2373,7 +2381,7 @@ var ProgressTracker = class {
|
|
|
2373
2381
|
}
|
|
2374
2382
|
if (!this.quiet) {
|
|
2375
2383
|
const elapsed = phase ? this.formatElapsed(phase.startTime, phase.endTime) : "";
|
|
2376
|
-
const status = this.verbose ? `\u2713 ${message || name} ${elapsed}` : `\u2713 ${message || name}`;
|
|
2384
|
+
const status = this.verbose ? `\u2713 ${message || name} ${elapsed}` : `\u2713 ${message || name} ${elapsed}`;
|
|
2377
2385
|
this.log(status);
|
|
2378
2386
|
}
|
|
2379
2387
|
}
|
|
@@ -2445,7 +2453,6 @@ var ProgressTracker = class {
|
|
|
2445
2453
|
*/
|
|
2446
2454
|
printSummary(stats) {
|
|
2447
2455
|
if (this.quiet) return;
|
|
2448
|
-
const totalTime = this.getTotalElapsed();
|
|
2449
2456
|
this.log("");
|
|
2450
2457
|
this.log("Build Summary:");
|
|
2451
2458
|
this.log(` Controllers: ${stats.controllers}`);
|
|
@@ -2495,12 +2502,17 @@ var Spinner = class {
|
|
|
2495
2502
|
let frameIndex = 0;
|
|
2496
2503
|
this.interval = setInterval(() => {
|
|
2497
2504
|
const frame = this.frames[frameIndex];
|
|
2505
|
+
let output;
|
|
2498
2506
|
if (this.customStatus) {
|
|
2499
|
-
|
|
2507
|
+
output = `\r${frame} ${this.customStatus}`;
|
|
2500
2508
|
} else if (this.total > 0) {
|
|
2501
|
-
|
|
2509
|
+
output = `\r${frame} ${this.message} (${this.current}/${this.total})`;
|
|
2502
2510
|
} else {
|
|
2503
|
-
|
|
2511
|
+
output = `\r${frame} ${this.message}`;
|
|
2512
|
+
}
|
|
2513
|
+
process.stdout.write(output);
|
|
2514
|
+
if (process.stdout.writable) {
|
|
2515
|
+
process.stdout.write("");
|
|
2504
2516
|
}
|
|
2505
2517
|
frameIndex = (frameIndex + 1) % this.frames.length;
|
|
2506
2518
|
}, 80);
|
|
@@ -2517,6 +2529,11 @@ var Spinner = class {
|
|
|
2517
2529
|
*/
|
|
2518
2530
|
setStatus(status) {
|
|
2519
2531
|
this.customStatus = status;
|
|
2532
|
+
const frame = this.frames[this.current];
|
|
2533
|
+
process.stdout.write(`\r${frame} ${status}`);
|
|
2534
|
+
if (process.stdout.writable) {
|
|
2535
|
+
process.stdout.write("");
|
|
2536
|
+
}
|
|
2520
2537
|
}
|
|
2521
2538
|
/**
|
|
2522
2539
|
* Clear the custom status message.
|
|
@@ -2536,6 +2553,9 @@ var Spinner = class {
|
|
|
2536
2553
|
if (completedMessage) {
|
|
2537
2554
|
process.stdout.write(completedMessage + "\n");
|
|
2538
2555
|
}
|
|
2556
|
+
if (process.stdout.writable) {
|
|
2557
|
+
process.stdout.write("");
|
|
2558
|
+
}
|
|
2539
2559
|
}
|
|
2540
2560
|
/**
|
|
2541
2561
|
* Stop the spinner with a failure message.
|
|
@@ -2930,12 +2950,17 @@ function generateModularOpenAPI(openapi, partitioning, config) {
|
|
|
2930
2950
|
outputDir,
|
|
2931
2951
|
schemasDir = "schemas",
|
|
2932
2952
|
createIndexFile = true,
|
|
2933
|
-
prettyPrint = true
|
|
2953
|
+
prettyPrint = true,
|
|
2954
|
+
onProgress
|
|
2934
2955
|
} = config;
|
|
2935
2956
|
const indent = prettyPrint ? 2 : 0;
|
|
2936
2957
|
let totalSize = 0;
|
|
2937
2958
|
const schemaFiles = [];
|
|
2959
|
+
mkdirSync(outputDir, { recursive: true });
|
|
2938
2960
|
if (!partitioning.shouldSplit || partitioning.groups.length === 1) {
|
|
2961
|
+
if (onProgress) {
|
|
2962
|
+
onProgress("Writing single OpenAPI file", 1, 1);
|
|
2963
|
+
}
|
|
2939
2964
|
const mainPath2 = resolve2(outputDir, "openapi.json");
|
|
2940
2965
|
writeFileSync(mainPath2, JSON.stringify(openapi, null, indent));
|
|
2941
2966
|
totalSize = Buffer.byteLength(JSON.stringify(openapi));
|
|
@@ -2948,9 +2973,16 @@ function generateModularOpenAPI(openapi, partitioning, config) {
|
|
|
2948
2973
|
}
|
|
2949
2974
|
const schemasPath = resolve2(outputDir, schemasDir);
|
|
2950
2975
|
mkdirSync(schemasPath, { recursive: true });
|
|
2976
|
+
if (onProgress) {
|
|
2977
|
+
onProgress("Creating schemas directory", 0, partitioning.groups.length + 2);
|
|
2978
|
+
}
|
|
2951
2979
|
const schemaMap = collectAllSchemas(partitioning.groups);
|
|
2952
2980
|
const schemaToFile = /* @__PURE__ */ new Map();
|
|
2953
|
-
for (
|
|
2981
|
+
for (let i = 0; i < partitioning.groups.length; i++) {
|
|
2982
|
+
const group = partitioning.groups[i];
|
|
2983
|
+
if (onProgress) {
|
|
2984
|
+
onProgress(`Writing schema group ${group.name} (${group.schemas.size} schemas)`, i + 1, partitioning.groups.length + 2);
|
|
2985
|
+
}
|
|
2954
2986
|
const filename = getSchemaFilename(group);
|
|
2955
2987
|
const filePath = resolve2(outputDir, filename);
|
|
2956
2988
|
const content = generateSchemaFileContent(group, schemaMap);
|
|
@@ -2963,12 +2995,18 @@ function generateModularOpenAPI(openapi, partitioning, config) {
|
|
|
2963
2995
|
}
|
|
2964
2996
|
let indexFile;
|
|
2965
2997
|
if (createIndexFile) {
|
|
2998
|
+
if (onProgress) {
|
|
2999
|
+
onProgress("Generating index file", partitioning.groups.length + 1, partitioning.groups.length + 2);
|
|
3000
|
+
}
|
|
2966
3001
|
const indexPath = resolve2(outputDir, "schemas/index.json");
|
|
2967
3002
|
const indexContent = generateSchemaIndex(partitioning.groups, schemaMap);
|
|
2968
3003
|
writeFileSync(indexPath, JSON.stringify(indexContent, null, indent));
|
|
2969
3004
|
totalSize += Buffer.byteLength(JSON.stringify(indexContent));
|
|
2970
3005
|
indexFile = indexPath;
|
|
2971
3006
|
}
|
|
3007
|
+
if (onProgress) {
|
|
3008
|
+
onProgress("Generating main OpenAPI spec", partitioning.groups.length + 2, partitioning.groups.length + 2);
|
|
3009
|
+
}
|
|
2972
3010
|
const mainSpec = generateMainSpec(openapi, schemaMap, schemaToFile);
|
|
2973
3011
|
const mainPath = resolve2(outputDir, "openapi.json");
|
|
2974
3012
|
writeFileSync(mainPath, JSON.stringify(mainSpec, null, indent));
|
|
@@ -3300,22 +3338,25 @@ var SchemaGraph = class {
|
|
|
3300
3338
|
import ts13 from "typescript";
|
|
3301
3339
|
import process2 from "process";
|
|
3302
3340
|
var ADORN_VERSION = (() => {
|
|
3303
|
-
|
|
3304
|
-
const localPkgPath = resolve3(process2.cwd(), "package.json");
|
|
3341
|
+
const tryReadPackageJson = (filePath) => {
|
|
3305
3342
|
try {
|
|
3306
|
-
const
|
|
3307
|
-
|
|
3308
|
-
return localPkg.version ?? "0.0.0";
|
|
3309
|
-
}
|
|
3343
|
+
const pkg = JSON.parse(readFileSync3(filePath, "utf-8"));
|
|
3344
|
+
return pkg.version ?? null;
|
|
3310
3345
|
} catch {
|
|
3346
|
+
return null;
|
|
3311
3347
|
}
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3348
|
+
};
|
|
3349
|
+
const cliDir = dirname3(fileURLToPath(import.meta.url));
|
|
3350
|
+
const bundledPkgPath = resolve3(cliDir, "..", "package.json");
|
|
3351
|
+
const bundledVersion = tryReadPackageJson(bundledPkgPath);
|
|
3352
|
+
if (bundledVersion) return bundledVersion;
|
|
3353
|
+
const localPkgPath = resolve3(process2.cwd(), "package.json");
|
|
3354
|
+
const localVersion = tryReadPackageJson(localPkgPath);
|
|
3355
|
+
if (localVersion) return localVersion;
|
|
3356
|
+
const nodeModulesPath = resolve3(cliDir, "..", "package.json");
|
|
3357
|
+
const nodeModulesVersion = tryReadPackageJson(nodeModulesPath);
|
|
3358
|
+
if (nodeModulesVersion) return nodeModulesVersion;
|
|
3359
|
+
return "0.0.0";
|
|
3319
3360
|
})();
|
|
3320
3361
|
function log(msg, options) {
|
|
3321
3362
|
if (options?.indent) {
|
|
@@ -3511,9 +3552,15 @@ async function buildCommand(args) {
|
|
|
3511
3552
|
progress.startPhase("openapi", "Generating OpenAPI schema");
|
|
3512
3553
|
const openapiSpinner = new Spinner("Processing schemas");
|
|
3513
3554
|
if (!quiet) openapiSpinner.start();
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3555
|
+
const openapi = generateOpenAPI(controllers, checker, {
|
|
3556
|
+
title: "API",
|
|
3557
|
+
version: "1.0.0",
|
|
3558
|
+
onProgress: (message, current, total) => {
|
|
3559
|
+
if (!quiet) {
|
|
3560
|
+
openapiSpinner.setStatus(`${message} (${current}/${total})`);
|
|
3561
|
+
}
|
|
3562
|
+
}
|
|
3563
|
+
});
|
|
3517
3564
|
if (!quiet) {
|
|
3518
3565
|
openapiSpinner.setStatus(`Processed ${controllers.length} controllers, ${totalOperations} operations`);
|
|
3519
3566
|
}
|
|
@@ -3535,14 +3582,24 @@ async function buildCommand(args) {
|
|
|
3535
3582
|
if (splitEnabled) {
|
|
3536
3583
|
progress.verboseLog(`Partitioning result: ${partitioning.strategy} strategy`);
|
|
3537
3584
|
progress.verboseLog(`Recommendation: ${partitioning.recommendation}`);
|
|
3585
|
+
if (!quiet) {
|
|
3586
|
+
log(` Auto-split enabled: ${partitioning.strategy} strategy`);
|
|
3587
|
+
}
|
|
3588
|
+
const splitSpinner = new Spinner("Writing split schema files");
|
|
3589
|
+
if (!quiet) splitSpinner.start();
|
|
3538
3590
|
generateModularOpenAPI(openapi, partitioning, {
|
|
3539
3591
|
outputDir: outputPath,
|
|
3540
3592
|
schemasDir: "schemas",
|
|
3541
3593
|
createIndexFile: true,
|
|
3542
|
-
prettyPrint: true
|
|
3594
|
+
prettyPrint: true,
|
|
3595
|
+
onProgress: (step, index, total) => {
|
|
3596
|
+
if (!quiet) {
|
|
3597
|
+
progress.logSub(`${step} (${index}/${total})`);
|
|
3598
|
+
}
|
|
3599
|
+
}
|
|
3543
3600
|
});
|
|
3601
|
+
if (!quiet) splitSpinner.stop();
|
|
3544
3602
|
if (!quiet) {
|
|
3545
|
-
log(` Auto-split enabled: ${partitioning.strategy} strategy`);
|
|
3546
3603
|
log(` Schema groups: ${partitioning.groups.length}`);
|
|
3547
3604
|
}
|
|
3548
3605
|
} else {
|