adorn-api 1.0.17 → 1.0.19
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 +96 -24
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +96 -24
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/cli/progress.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAyC;IACvD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,WAAW,CAAa;gBAEpB,OAAO,GAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;IAMhE;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I;CAMnC"}
|
package/dist/cli.cjs
CHANGED
|
@@ -1591,7 +1591,12 @@ function generateOpenAPI(controllers, checker, options = {}) {
|
|
|
1591
1591
|
mode: "response"
|
|
1592
1592
|
};
|
|
1593
1593
|
const paths = {};
|
|
1594
|
-
|
|
1594
|
+
const { onProgress } = options;
|
|
1595
|
+
for (let i = 0; i < controllers.length; i++) {
|
|
1596
|
+
const controller = controllers[i];
|
|
1597
|
+
if (onProgress) {
|
|
1598
|
+
onProgress(`Processing controller ${controller.className}`, i + 1, controllers.length);
|
|
1599
|
+
}
|
|
1595
1600
|
for (const operation of controller.operations) {
|
|
1596
1601
|
const fullPath = convertToOpenApiPath(controller.basePath, operation.path);
|
|
1597
1602
|
if (!paths[fullPath]) {
|
|
@@ -1602,6 +1607,9 @@ function generateOpenAPI(controllers, checker, options = {}) {
|
|
|
1602
1607
|
}
|
|
1603
1608
|
}
|
|
1604
1609
|
const schemas = Object.fromEntries(components);
|
|
1610
|
+
if (onProgress) {
|
|
1611
|
+
onProgress("Generating and cleaning schemas", controllers.length, controllers.length);
|
|
1612
|
+
}
|
|
1605
1613
|
cleanupMetalOrmWrappers(schemas, paths);
|
|
1606
1614
|
return {
|
|
1607
1615
|
openapi: "3.1.0",
|
|
@@ -2391,7 +2399,7 @@ var ProgressTracker = class {
|
|
|
2391
2399
|
}
|
|
2392
2400
|
if (!this.quiet) {
|
|
2393
2401
|
const elapsed = phase ? this.formatElapsed(phase.startTime, phase.endTime) : "";
|
|
2394
|
-
const status = this.verbose ? `\u2713 ${message || name} ${elapsed}` : `\u2713 ${message || name}`;
|
|
2402
|
+
const status = this.verbose ? `\u2713 ${message || name} ${elapsed}` : `\u2713 ${message || name} ${elapsed}`;
|
|
2395
2403
|
this.log(status);
|
|
2396
2404
|
}
|
|
2397
2405
|
}
|
|
@@ -2463,7 +2471,6 @@ var ProgressTracker = class {
|
|
|
2463
2471
|
*/
|
|
2464
2472
|
printSummary(stats) {
|
|
2465
2473
|
if (this.quiet) return;
|
|
2466
|
-
const totalTime = this.getTotalElapsed();
|
|
2467
2474
|
this.log("");
|
|
2468
2475
|
this.log("Build Summary:");
|
|
2469
2476
|
this.log(` Controllers: ${stats.controllers}`);
|
|
@@ -2513,12 +2520,17 @@ var Spinner = class {
|
|
|
2513
2520
|
let frameIndex = 0;
|
|
2514
2521
|
this.interval = setInterval(() => {
|
|
2515
2522
|
const frame = this.frames[frameIndex];
|
|
2523
|
+
let output;
|
|
2516
2524
|
if (this.customStatus) {
|
|
2517
|
-
|
|
2525
|
+
output = `\r${frame} ${this.customStatus}`;
|
|
2518
2526
|
} else if (this.total > 0) {
|
|
2519
|
-
|
|
2527
|
+
output = `\r${frame} ${this.message} (${this.current}/${this.total})`;
|
|
2520
2528
|
} else {
|
|
2521
|
-
|
|
2529
|
+
output = `\r${frame} ${this.message}`;
|
|
2530
|
+
}
|
|
2531
|
+
import_node_process.default.stdout.write(output);
|
|
2532
|
+
if (import_node_process.default.stdout.writable) {
|
|
2533
|
+
import_node_process.default.stdout.write("");
|
|
2522
2534
|
}
|
|
2523
2535
|
frameIndex = (frameIndex + 1) % this.frames.length;
|
|
2524
2536
|
}, 80);
|
|
@@ -2535,6 +2547,11 @@ var Spinner = class {
|
|
|
2535
2547
|
*/
|
|
2536
2548
|
setStatus(status) {
|
|
2537
2549
|
this.customStatus = status;
|
|
2550
|
+
const frame = this.frames[this.current];
|
|
2551
|
+
import_node_process.default.stdout.write(`\r${frame} ${status}`);
|
|
2552
|
+
if (import_node_process.default.stdout.writable) {
|
|
2553
|
+
import_node_process.default.stdout.write("");
|
|
2554
|
+
}
|
|
2538
2555
|
}
|
|
2539
2556
|
/**
|
|
2540
2557
|
* Clear the custom status message.
|
|
@@ -2554,6 +2571,9 @@ var Spinner = class {
|
|
|
2554
2571
|
if (completedMessage) {
|
|
2555
2572
|
import_node_process.default.stdout.write(completedMessage + "\n");
|
|
2556
2573
|
}
|
|
2574
|
+
if (import_node_process.default.stdout.writable) {
|
|
2575
|
+
import_node_process.default.stdout.write("");
|
|
2576
|
+
}
|
|
2557
2577
|
}
|
|
2558
2578
|
/**
|
|
2559
2579
|
* Stop the spinner with a failure message.
|
|
@@ -2948,12 +2968,17 @@ function generateModularOpenAPI(openapi, partitioning, config) {
|
|
|
2948
2968
|
outputDir,
|
|
2949
2969
|
schemasDir = "schemas",
|
|
2950
2970
|
createIndexFile = true,
|
|
2951
|
-
prettyPrint = true
|
|
2971
|
+
prettyPrint = true,
|
|
2972
|
+
onProgress
|
|
2952
2973
|
} = config;
|
|
2953
2974
|
const indent = prettyPrint ? 2 : 0;
|
|
2954
2975
|
let totalSize = 0;
|
|
2955
2976
|
const schemaFiles = [];
|
|
2977
|
+
(0, import_node_fs5.mkdirSync)(outputDir, { recursive: true });
|
|
2956
2978
|
if (!partitioning.shouldSplit || partitioning.groups.length === 1) {
|
|
2979
|
+
if (onProgress) {
|
|
2980
|
+
onProgress("Writing single OpenAPI file", 1, 1);
|
|
2981
|
+
}
|
|
2957
2982
|
const mainPath2 = (0, import_node_path5.resolve)(outputDir, "openapi.json");
|
|
2958
2983
|
(0, import_node_fs5.writeFileSync)(mainPath2, JSON.stringify(openapi, null, indent));
|
|
2959
2984
|
totalSize = Buffer.byteLength(JSON.stringify(openapi));
|
|
@@ -2966,9 +2991,16 @@ function generateModularOpenAPI(openapi, partitioning, config) {
|
|
|
2966
2991
|
}
|
|
2967
2992
|
const schemasPath = (0, import_node_path5.resolve)(outputDir, schemasDir);
|
|
2968
2993
|
(0, import_node_fs5.mkdirSync)(schemasPath, { recursive: true });
|
|
2994
|
+
if (onProgress) {
|
|
2995
|
+
onProgress("Creating schemas directory", 0, partitioning.groups.length + 2);
|
|
2996
|
+
}
|
|
2969
2997
|
const schemaMap = collectAllSchemas(partitioning.groups);
|
|
2970
2998
|
const schemaToFile = /* @__PURE__ */ new Map();
|
|
2971
|
-
for (
|
|
2999
|
+
for (let i = 0; i < partitioning.groups.length; i++) {
|
|
3000
|
+
const group = partitioning.groups[i];
|
|
3001
|
+
if (onProgress) {
|
|
3002
|
+
onProgress(`Writing schema group ${group.name} (${group.schemas.size} schemas)`, i + 1, partitioning.groups.length + 2);
|
|
3003
|
+
}
|
|
2972
3004
|
const filename = getSchemaFilename(group);
|
|
2973
3005
|
const filePath = (0, import_node_path5.resolve)(outputDir, filename);
|
|
2974
3006
|
const content = generateSchemaFileContent(group, schemaMap);
|
|
@@ -2981,12 +3013,18 @@ function generateModularOpenAPI(openapi, partitioning, config) {
|
|
|
2981
3013
|
}
|
|
2982
3014
|
let indexFile;
|
|
2983
3015
|
if (createIndexFile) {
|
|
3016
|
+
if (onProgress) {
|
|
3017
|
+
onProgress("Generating index file", partitioning.groups.length + 1, partitioning.groups.length + 2);
|
|
3018
|
+
}
|
|
2984
3019
|
const indexPath = (0, import_node_path5.resolve)(outputDir, "schemas/index.json");
|
|
2985
3020
|
const indexContent = generateSchemaIndex(partitioning.groups, schemaMap);
|
|
2986
3021
|
(0, import_node_fs5.writeFileSync)(indexPath, JSON.stringify(indexContent, null, indent));
|
|
2987
3022
|
totalSize += Buffer.byteLength(JSON.stringify(indexContent));
|
|
2988
3023
|
indexFile = indexPath;
|
|
2989
3024
|
}
|
|
3025
|
+
if (onProgress) {
|
|
3026
|
+
onProgress("Generating main OpenAPI spec", partitioning.groups.length + 2, partitioning.groups.length + 2);
|
|
3027
|
+
}
|
|
2990
3028
|
const mainSpec = generateMainSpec(openapi, schemaMap, schemaToFile);
|
|
2991
3029
|
const mainPath = (0, import_node_path5.resolve)(outputDir, "openapi.json");
|
|
2992
3030
|
(0, import_node_fs5.writeFileSync)(mainPath, JSON.stringify(mainSpec, null, indent));
|
|
@@ -3319,22 +3357,40 @@ var import_typescript13 = __toESM(require("typescript"), 1);
|
|
|
3319
3357
|
var import_node_process2 = __toESM(require("process"), 1);
|
|
3320
3358
|
var import_meta2 = {};
|
|
3321
3359
|
var ADORN_VERSION = (() => {
|
|
3322
|
-
|
|
3323
|
-
const localPkgPath = (0, import_node_path6.resolve)(import_node_process2.default.cwd(), "package.json");
|
|
3360
|
+
const tryReadPackageJson = (filePath) => {
|
|
3324
3361
|
try {
|
|
3325
|
-
const
|
|
3326
|
-
|
|
3327
|
-
return localPkg.version ?? "0.0.0";
|
|
3328
|
-
}
|
|
3362
|
+
const pkg = JSON.parse((0, import_node_fs6.readFileSync)(filePath, "utf-8"));
|
|
3363
|
+
return pkg.version ?? null;
|
|
3329
3364
|
} catch {
|
|
3365
|
+
return null;
|
|
3366
|
+
}
|
|
3367
|
+
};
|
|
3368
|
+
const potentialPaths = [];
|
|
3369
|
+
try {
|
|
3370
|
+
const importMetaUrl = import_meta2?.url;
|
|
3371
|
+
if (importMetaUrl && typeof importMetaUrl === "string" && importMetaUrl.length > 0) {
|
|
3372
|
+
const cliDir = (0, import_node_path6.dirname)((0, import_node_url.fileURLToPath)(importMetaUrl));
|
|
3373
|
+
potentialPaths.push(
|
|
3374
|
+
(0, import_node_path6.resolve)(cliDir, "..", "package.json"),
|
|
3375
|
+
(0, import_node_path6.resolve)(cliDir, "package.json")
|
|
3376
|
+
);
|
|
3330
3377
|
}
|
|
3331
|
-
const cliDir = (0, import_node_path6.dirname)((0, import_node_url.fileURLToPath)(import_meta2.url));
|
|
3332
|
-
const bundledPkgPath = (0, import_node_path6.resolve)(cliDir, "..", "package.json");
|
|
3333
|
-
const bundledPkg = JSON.parse((0, import_node_fs6.readFileSync)(bundledPkgPath, "utf-8"));
|
|
3334
|
-
return bundledPkg.version ?? "0.0.0";
|
|
3335
3378
|
} catch {
|
|
3336
|
-
return "0.0.0";
|
|
3337
3379
|
}
|
|
3380
|
+
const cwd = import_node_process2.default.cwd();
|
|
3381
|
+
potentialPaths.push(
|
|
3382
|
+
(0, import_node_path6.resolve)(cwd, "package.json"),
|
|
3383
|
+
(0, import_node_path6.resolve)(cwd, "node_modules", "adorn-api", "package.json"),
|
|
3384
|
+
(0, import_node_path6.resolve)(cwd, "..", "package.json"),
|
|
3385
|
+
(0, import_node_path6.resolve)(cwd, "..", "..", "package.json")
|
|
3386
|
+
);
|
|
3387
|
+
for (const pkgPath of potentialPaths) {
|
|
3388
|
+
const version = tryReadPackageJson(pkgPath);
|
|
3389
|
+
if (version) {
|
|
3390
|
+
return version;
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
return "0.0.0";
|
|
3338
3394
|
})();
|
|
3339
3395
|
function log(msg, options) {
|
|
3340
3396
|
if (options?.indent) {
|
|
@@ -3530,9 +3586,15 @@ async function buildCommand(args) {
|
|
|
3530
3586
|
progress.startPhase("openapi", "Generating OpenAPI schema");
|
|
3531
3587
|
const openapiSpinner = new Spinner("Processing schemas");
|
|
3532
3588
|
if (!quiet) openapiSpinner.start();
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3589
|
+
const openapi = generateOpenAPI(controllers, checker, {
|
|
3590
|
+
title: "API",
|
|
3591
|
+
version: "1.0.0",
|
|
3592
|
+
onProgress: (message, current, total) => {
|
|
3593
|
+
if (!quiet) {
|
|
3594
|
+
openapiSpinner.setStatus(`${message} (${current}/${total})`);
|
|
3595
|
+
}
|
|
3596
|
+
}
|
|
3597
|
+
});
|
|
3536
3598
|
if (!quiet) {
|
|
3537
3599
|
openapiSpinner.setStatus(`Processed ${controllers.length} controllers, ${totalOperations} operations`);
|
|
3538
3600
|
}
|
|
@@ -3554,14 +3616,24 @@ async function buildCommand(args) {
|
|
|
3554
3616
|
if (splitEnabled) {
|
|
3555
3617
|
progress.verboseLog(`Partitioning result: ${partitioning.strategy} strategy`);
|
|
3556
3618
|
progress.verboseLog(`Recommendation: ${partitioning.recommendation}`);
|
|
3619
|
+
if (!quiet) {
|
|
3620
|
+
log(` Auto-split enabled: ${partitioning.strategy} strategy`);
|
|
3621
|
+
}
|
|
3622
|
+
const splitSpinner = new Spinner("Writing split schema files");
|
|
3623
|
+
if (!quiet) splitSpinner.start();
|
|
3557
3624
|
generateModularOpenAPI(openapi, partitioning, {
|
|
3558
3625
|
outputDir: outputPath,
|
|
3559
3626
|
schemasDir: "schemas",
|
|
3560
3627
|
createIndexFile: true,
|
|
3561
|
-
prettyPrint: true
|
|
3628
|
+
prettyPrint: true,
|
|
3629
|
+
onProgress: (step, index, total) => {
|
|
3630
|
+
if (!quiet) {
|
|
3631
|
+
progress.logSub(`${step} (${index}/${total})`);
|
|
3632
|
+
}
|
|
3633
|
+
}
|
|
3562
3634
|
});
|
|
3635
|
+
if (!quiet) splitSpinner.stop();
|
|
3563
3636
|
if (!quiet) {
|
|
3564
|
-
log(` Auto-split enabled: ${partitioning.strategy} strategy`);
|
|
3565
3637
|
log(` Schema groups: ${partitioning.groups.length}`);
|
|
3566
3638
|
}
|
|
3567
3639
|
} else {
|