adorn-api 1.0.21 → 1.0.22

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 CHANGED
@@ -1649,6 +1649,14 @@ function analyzeQueryBuilderForSchema(methodDeclaration, checker, options = {})
1649
1649
  }
1650
1650
  return parseQueryBuilderChain(callChain, checker, options);
1651
1651
  }
1652
+ function analyzeQueryBuilderWithDetails(methodDeclaration, checker, options = {}, operationInfo) {
1653
+ const schema = analyzeQueryBuilderForSchema(methodDeclaration, checker, options);
1654
+ return {
1655
+ detected: schema !== null,
1656
+ schema,
1657
+ ...operationInfo
1658
+ };
1659
+ }
1652
1660
  function analyzeWithVariableTracking(body, checker, options) {
1653
1661
  let queryBuilderVar = null;
1654
1662
  let entityName = null;
@@ -2010,7 +2018,12 @@ function generateOpenAPI(controllers, checker, options = {}) {
2010
2018
  mode: "response"
2011
2019
  };
2012
2020
  const paths = {};
2013
- const { onProgress } = options;
2021
+ const { onProgress, onQueryBuilderProgress } = options;
2022
+ let totalOperations = 0;
2023
+ for (const controller of controllers) {
2024
+ totalOperations += controller.operations.length;
2025
+ }
2026
+ let currentOperation = 0;
2014
2027
  for (let i = 0; i < controllers.length; i++) {
2015
2028
  const controller = controllers[i];
2016
2029
  if (onProgress) {
@@ -2022,6 +2035,32 @@ function generateOpenAPI(controllers, checker, options = {}) {
2022
2035
  paths[fullPath] = {};
2023
2036
  }
2024
2037
  const method = operation.httpMethod.toLowerCase();
2038
+ const analysisResult = analyzeQueryBuilderWithDetails(
2039
+ operation.methodDeclaration,
2040
+ checker,
2041
+ {},
2042
+ {
2043
+ methodName: operation.operationId,
2044
+ httpMethod: operation.httpMethod,
2045
+ path: operation.path,
2046
+ operationId: operation.operationId
2047
+ }
2048
+ );
2049
+ if (onQueryBuilderProgress) {
2050
+ currentOperation++;
2051
+ onQueryBuilderProgress({
2052
+ controller: controller.className,
2053
+ operation: operation.operationId,
2054
+ method: operation.httpMethod,
2055
+ path: operation.path,
2056
+ queryBuilderDetected: analysisResult.detected,
2057
+ entityName: analysisResult.schema?.entityName,
2058
+ selectedFields: analysisResult.schema?.selectedFields,
2059
+ isPaged: analysisResult.schema?.isPaged,
2060
+ current: currentOperation,
2061
+ total: totalOperations
2062
+ });
2063
+ }
2025
2064
  paths[fullPath][method] = buildOperation(operation, ctx, controller.consumes);
2026
2065
  }
2027
2066
  }
@@ -4036,6 +4075,7 @@ async function buildCommand(args) {
4036
4075
  const verbose = args.includes("--verbose");
4037
4076
  const quiet = args.includes("--quiet");
4038
4077
  const split = args.includes("--split");
4078
+ const showQueryBuilder = args.includes("--show-query-builder");
4039
4079
  const splitStrategyIndex = args.indexOf("--split-strategy");
4040
4080
  const splitStrategy = splitStrategyIndex !== -1 ? args[splitStrategyIndex + 1] : void 0;
4041
4081
  const splitThresholdIndex = args.indexOf("--split-threshold");
@@ -4096,6 +4136,12 @@ async function buildCommand(args) {
4096
4136
  }
4097
4137
  }
4098
4138
  progress.startPhase("openapi", "Generating OpenAPI schema");
4139
+ const queryBuilderStats = {
4140
+ totalOperations,
4141
+ detected: 0,
4142
+ fallback: 0,
4143
+ operations: []
4144
+ };
4099
4145
  const openapiSpinner = new Spinner("Processing schemas");
4100
4146
  if (!quiet) openapiSpinner.start();
4101
4147
  const openapi = generateOpenAPI(controllers, checker, {
@@ -4105,6 +4151,31 @@ async function buildCommand(args) {
4105
4151
  if (!quiet) {
4106
4152
  openapiSpinner.setStatus(`${message} (${current}/${total})`);
4107
4153
  }
4154
+ },
4155
+ onQueryBuilderProgress: (info) => {
4156
+ if (info.queryBuilderDetected) {
4157
+ queryBuilderStats.detected++;
4158
+ } else {
4159
+ queryBuilderStats.fallback++;
4160
+ }
4161
+ queryBuilderStats.operations.push({
4162
+ operationId: info.operation,
4163
+ method: info.method,
4164
+ path: info.path,
4165
+ detected: info.queryBuilderDetected,
4166
+ entityName: info.entityName,
4167
+ selectedFields: info.selectedFields,
4168
+ isPaged: info.isPaged
4169
+ });
4170
+ if (showQueryBuilder || verbose) {
4171
+ if (info.queryBuilderDetected) {
4172
+ const fieldsStr = info.selectedFields && info.selectedFields.length > 0 ? ` [select: ${info.selectedFields.join(",")}]` : "";
4173
+ const pagedStr = info.isPaged ? " (paged)" : "";
4174
+ progress.verboseLog(` \u2713 Query builder: ${info.method} ${info.path} \u2192 ${info.entityName}${fieldsStr}${pagedStr}`);
4175
+ } else {
4176
+ progress.verboseLog(` \u25CB No query builder: ${info.method} ${info.path} \u2192 using full entity schema`);
4177
+ }
4178
+ }
4108
4179
  }
4109
4180
  });
4110
4181
  if (!quiet) {
@@ -4163,6 +4234,17 @@ async function buildCommand(args) {
4163
4234
  }
4164
4235
  }
4165
4236
  progress.completePhase("openapi", `Generated ${schemaCount} schema(s)${splitEnabled ? " (split into groups)" : ""}`);
4237
+ if (showQueryBuilder && totalOperations > 0) {
4238
+ log("");
4239
+ log("Query Builder Analysis:");
4240
+ log(` Operations analyzed: ${totalOperations}`);
4241
+ log(` Patterns detected: ${queryBuilderStats.detected} (${Math.round(queryBuilderStats.detected / totalOperations * 100)}%)`);
4242
+ log(` Full schemas used: ${queryBuilderStats.fallback} (${Math.round(queryBuilderStats.fallback / totalOperations * 100)}%)`);
4243
+ if (queryBuilderStats.detected > 0) {
4244
+ const totalFields = queryBuilderStats.operations.filter((op) => op.detected && op.selectedFields).reduce((sum, op) => sum + (op.selectedFields?.length || 0), 0);
4245
+ log(` Fields selected: ${totalFields} total (avg ${Math.round(totalFields / queryBuilderStats.detected)} per query)`);
4246
+ }
4247
+ }
4166
4248
  progress.startPhase("manifest", "Generating manifest");
4167
4249
  const manifest = generateManifest(controllers, checker, ADORN_VERSION, validationMode);
4168
4250
  progress.completePhase("manifest");
@@ -4244,7 +4326,12 @@ async function buildCommand(args) {
4244
4326
  schemas: schemaCount,
4245
4327
  sourceFiles: projectSourceFiles.length,
4246
4328
  artifactsWritten: artifacts.map((a) => a.name),
4247
- splitEnabled
4329
+ splitEnabled,
4330
+ queryBuilder: {
4331
+ detected: queryBuilderStats.detected,
4332
+ fallback: queryBuilderStats.fallback,
4333
+ total: totalOperations
4334
+ }
4248
4335
  };
4249
4336
  progress.printSummary(stats);
4250
4337
  progress.printArtifacts(artifacts);
@@ -4272,30 +4359,32 @@ if (command === "build") {
4272
4359
  console.log(`
4273
4360
  adorn-api CLI v${ADORN_VERSION}
4274
4361
 
4275
- Commands:
4276
- build Generate OpenAPI and manifest from TypeScript source
4277
- clean Remove generated artifacts
4362
+ Commands:
4363
+ build Generate OpenAPI and manifest from TypeScript source
4364
+ clean Remove generated artifacts
4278
4365
 
4279
- Options:
4280
- -p <path> Path to tsconfig.json (default: ./tsconfig.json)
4281
- --output <dir> Output directory (default: .adorn)
4282
- --if-stale Only rebuild if artifacts are stale
4283
- --validation-mode <mode> Validation mode: none, ajv-runtime, precompiled (default: ajv-runtime)
4284
- --split Enable automatic schema splitting (default: disabled)
4285
- --split-strategy <mode> Override splitting strategy: controller, dependency, size, auto (default: auto)
4286
- --split-threshold <num> Schema count threshold for auto-split (default: 50)
4287
- --verbose Show detailed progress information
4288
- --quiet Suppress non-essential output
4366
+ Options:
4367
+ -p <path> Path to tsconfig.json (default: ./tsconfig.json)
4368
+ --output <dir> Output directory (default: .adorn)
4369
+ --if-stale Only rebuild if artifacts are stale
4370
+ --validation-mode <mode> Validation mode: none, ajv-runtime, precompiled (default: ajv-runtime)
4371
+ --split Enable automatic schema splitting (default: disabled)
4372
+ --split-strategy <mode> Override splitting strategy: controller, dependency, size, auto (default: auto)
4373
+ --split-threshold <num> Schema count threshold for auto-split (default: 50)
4374
+ --verbose Show detailed progress information
4375
+ --quiet Suppress non-essential output
4376
+ --show-query-builder Show query builder inspection details and statistics
4289
4377
 
4290
- Examples:
4291
- adorn-api build -p ./tsconfig.json --output .adorn
4292
- adorn-api build --if-stale
4293
- adorn-api build --validation-mode precompiled
4294
- adorn-api build --verbose
4295
- adorn-api build --split # Enable split mode
4296
- adorn-api build --split-strategy controller # Force controller-based splitting
4297
- adorn-api build --split-threshold 100 # Increase threshold to 100
4298
- adorn-api clean
4299
- `);
4378
+ Examples:
4379
+ adorn-api build -p ./tsconfig.json --output .adorn
4380
+ adorn-api build --if-stale
4381
+ adorn-api build --validation-mode precompiled
4382
+ adorn-api build --verbose
4383
+ adorn-api build --show-query-builder # Show query builder analysis details
4384
+ adorn-api build --split # Enable split mode
4385
+ adorn-api build --split-strategy controller # Force controller-based splitting
4386
+ adorn-api build --split-threshold 100 # Increase threshold to 100
4387
+ adorn-api clean
4388
+ `);
4300
4389
  }
4301
4390
  //# sourceMappingURL=cli.cjs.map