adorn-api 1.0.16 → 1.0.17

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.js CHANGED
@@ -8,7 +8,8 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
8
8
 
9
9
  // src/cli.ts
10
10
  import { writeFileSync as writeFileSync2, mkdirSync as mkdirSync2, rmSync, existsSync as existsSync2, readFileSync as readFileSync3, statSync } from "fs";
11
- import { resolve as resolve3 } from "path";
11
+ import { resolve as resolve3, dirname as dirname3 } from "path";
12
+ import { fileURLToPath } from "url";
12
13
 
13
14
  // src/compiler/runner/createProgram.ts
14
15
  import ts from "typescript";
@@ -977,7 +978,7 @@ function handleMetalOrmWrapper(type, ctx) {
977
978
  required: ["id"]
978
979
  };
979
980
  if (wrapperName === "ManyToManyCollection" && typeArgs?.[1]) {
980
- wrapperRel.pivot = typeArgs[1];
981
+ wrapperRel.pivot = ctx.checker.typeToString(typeArgs[1]);
981
982
  }
982
983
  return {
983
984
  type: "array",
@@ -987,7 +988,7 @@ function handleMetalOrmWrapper(type, ctx) {
987
988
  }
988
989
  const items = targetType ? typeToJsonSchema(targetType, ctx) : {};
989
990
  if (wrapperName === "ManyToManyCollection" && typeArgs?.[1]) {
990
- wrapperRel.pivot = typeArgs[1];
991
+ wrapperRel.pivot = ctx.checker.typeToString(typeArgs[1]);
991
992
  }
992
993
  return {
993
994
  type: "array",
@@ -2481,6 +2482,9 @@ var Spinner = class {
2481
2482
  frames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u28B0", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
2482
2483
  interval;
2483
2484
  message;
2485
+ current = 0;
2486
+ total = 0;
2487
+ customStatus;
2484
2488
  constructor(message = "") {
2485
2489
  this.message = message;
2486
2490
  }
@@ -2491,10 +2495,35 @@ var Spinner = class {
2491
2495
  let frameIndex = 0;
2492
2496
  this.interval = setInterval(() => {
2493
2497
  const frame = this.frames[frameIndex];
2494
- process.stdout.write(`\r${frame} ${this.message}`);
2498
+ if (this.customStatus) {
2499
+ process.stdout.write(`\r${frame} ${this.customStatus}`);
2500
+ } else if (this.total > 0) {
2501
+ process.stdout.write(`\r${frame} ${this.message} (${this.current}/${this.total})`);
2502
+ } else {
2503
+ process.stdout.write(`\r${frame} ${this.message}`);
2504
+ }
2495
2505
  frameIndex = (frameIndex + 1) % this.frames.length;
2496
2506
  }, 80);
2497
2507
  }
2508
+ /**
2509
+ * Set progress counters.
2510
+ */
2511
+ setProgress(current, total) {
2512
+ this.current = current;
2513
+ this.total = total;
2514
+ }
2515
+ /**
2516
+ * Set a custom status message (overrides counters).
2517
+ */
2518
+ setStatus(status) {
2519
+ this.customStatus = status;
2520
+ }
2521
+ /**
2522
+ * Clear the custom status message.
2523
+ */
2524
+ clearStatus() {
2525
+ this.customStatus = void 0;
2526
+ }
2498
2527
  /**
2499
2528
  * Stop the spinner with a completion message.
2500
2529
  */
@@ -2503,7 +2532,7 @@ var Spinner = class {
2503
2532
  clearInterval(this.interval);
2504
2533
  this.interval = void 0;
2505
2534
  }
2506
- process.stdout.write("\r" + " ".repeat(50) + "\r");
2535
+ process.stdout.write("\r" + " ".repeat(60) + "\r");
2507
2536
  if (completedMessage) {
2508
2537
  process.stdout.write(completedMessage + "\n");
2509
2538
  }
@@ -3270,7 +3299,24 @@ var SchemaGraph = class {
3270
3299
  // src/cli.ts
3271
3300
  import ts13 from "typescript";
3272
3301
  import process2 from "process";
3273
- var ADORN_VERSION = "0.1.0";
3302
+ var ADORN_VERSION = (() => {
3303
+ try {
3304
+ const localPkgPath = resolve3(process2.cwd(), "package.json");
3305
+ try {
3306
+ const localPkg = JSON.parse(readFileSync3(localPkgPath, "utf-8"));
3307
+ if (localPkg.bin?.["adorn-api"] || localPkg.name === "adorn-api") {
3308
+ return localPkg.version ?? "0.0.0";
3309
+ }
3310
+ } catch {
3311
+ }
3312
+ const cliDir = dirname3(fileURLToPath(import.meta.url));
3313
+ const bundledPkgPath = resolve3(cliDir, "..", "package.json");
3314
+ const bundledPkg = JSON.parse(readFileSync3(bundledPkgPath, "utf-8"));
3315
+ return bundledPkg.version ?? "0.0.0";
3316
+ } catch {
3317
+ return "0.0.0";
3318
+ }
3319
+ })();
3274
3320
  function log(msg, options) {
3275
3321
  if (options?.indent) {
3276
3322
  process2.stdout.write(" " + msg + "\n");
@@ -3463,10 +3509,15 @@ async function buildCommand(args) {
3463
3509
  }
3464
3510
  }
3465
3511
  progress.startPhase("openapi", "Generating OpenAPI schema");
3466
- if (verbose) {
3467
- progress.verboseLog("Processing schemas from type definitions");
3468
- }
3512
+ const openapiSpinner = new Spinner("Processing schemas");
3513
+ if (!quiet) openapiSpinner.start();
3514
+ let processedControllers = 0;
3515
+ let processedOperations = 0;
3469
3516
  const openapi = generateOpenAPI(controllers, checker, { title: "API", version: "1.0.0" });
3517
+ if (!quiet) {
3518
+ openapiSpinner.setStatus(`Processed ${controllers.length} controllers, ${totalOperations} operations`);
3519
+ }
3520
+ if (!quiet) openapiSpinner.stop();
3470
3521
  const schemaCount = Object.keys(openapi.components?.schemas || {}).length;
3471
3522
  let splitEnabled = false;
3472
3523
  if (!noSplit && schemaCount >= splitThreshold) {