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 +114 -25
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +114 -25
- package/dist/cli.js.map +1 -1
- package/dist/compiler/schema/openapi.d.ts +29 -0
- package/dist/compiler/schema/openapi.d.ts.map +1 -1
- package/dist/compiler/schema/queryBuilderAnalyzer.d.ts +33 -0
- package/dist/compiler/schema/queryBuilderAnalyzer.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1632,6 +1632,14 @@ function analyzeQueryBuilderForSchema(methodDeclaration, checker, options = {})
|
|
|
1632
1632
|
}
|
|
1633
1633
|
return parseQueryBuilderChain(callChain, checker, options);
|
|
1634
1634
|
}
|
|
1635
|
+
function analyzeQueryBuilderWithDetails(methodDeclaration, checker, options = {}, operationInfo) {
|
|
1636
|
+
const schema = analyzeQueryBuilderForSchema(methodDeclaration, checker, options);
|
|
1637
|
+
return {
|
|
1638
|
+
detected: schema !== null,
|
|
1639
|
+
schema,
|
|
1640
|
+
...operationInfo
|
|
1641
|
+
};
|
|
1642
|
+
}
|
|
1635
1643
|
function analyzeWithVariableTracking(body, checker, options) {
|
|
1636
1644
|
let queryBuilderVar = null;
|
|
1637
1645
|
let entityName = null;
|
|
@@ -1993,7 +2001,12 @@ function generateOpenAPI(controllers, checker, options = {}) {
|
|
|
1993
2001
|
mode: "response"
|
|
1994
2002
|
};
|
|
1995
2003
|
const paths = {};
|
|
1996
|
-
const { onProgress } = options;
|
|
2004
|
+
const { onProgress, onQueryBuilderProgress } = options;
|
|
2005
|
+
let totalOperations = 0;
|
|
2006
|
+
for (const controller of controllers) {
|
|
2007
|
+
totalOperations += controller.operations.length;
|
|
2008
|
+
}
|
|
2009
|
+
let currentOperation = 0;
|
|
1997
2010
|
for (let i = 0; i < controllers.length; i++) {
|
|
1998
2011
|
const controller = controllers[i];
|
|
1999
2012
|
if (onProgress) {
|
|
@@ -2005,6 +2018,32 @@ function generateOpenAPI(controllers, checker, options = {}) {
|
|
|
2005
2018
|
paths[fullPath] = {};
|
|
2006
2019
|
}
|
|
2007
2020
|
const method = operation.httpMethod.toLowerCase();
|
|
2021
|
+
const analysisResult = analyzeQueryBuilderWithDetails(
|
|
2022
|
+
operation.methodDeclaration,
|
|
2023
|
+
checker,
|
|
2024
|
+
{},
|
|
2025
|
+
{
|
|
2026
|
+
methodName: operation.operationId,
|
|
2027
|
+
httpMethod: operation.httpMethod,
|
|
2028
|
+
path: operation.path,
|
|
2029
|
+
operationId: operation.operationId
|
|
2030
|
+
}
|
|
2031
|
+
);
|
|
2032
|
+
if (onQueryBuilderProgress) {
|
|
2033
|
+
currentOperation++;
|
|
2034
|
+
onQueryBuilderProgress({
|
|
2035
|
+
controller: controller.className,
|
|
2036
|
+
operation: operation.operationId,
|
|
2037
|
+
method: operation.httpMethod,
|
|
2038
|
+
path: operation.path,
|
|
2039
|
+
queryBuilderDetected: analysisResult.detected,
|
|
2040
|
+
entityName: analysisResult.schema?.entityName,
|
|
2041
|
+
selectedFields: analysisResult.schema?.selectedFields,
|
|
2042
|
+
isPaged: analysisResult.schema?.isPaged,
|
|
2043
|
+
current: currentOperation,
|
|
2044
|
+
total: totalOperations
|
|
2045
|
+
});
|
|
2046
|
+
}
|
|
2008
2047
|
paths[fullPath][method] = buildOperation(operation, ctx, controller.consumes);
|
|
2009
2048
|
}
|
|
2010
2049
|
}
|
|
@@ -4017,6 +4056,7 @@ async function buildCommand(args) {
|
|
|
4017
4056
|
const verbose = args.includes("--verbose");
|
|
4018
4057
|
const quiet = args.includes("--quiet");
|
|
4019
4058
|
const split = args.includes("--split");
|
|
4059
|
+
const showQueryBuilder = args.includes("--show-query-builder");
|
|
4020
4060
|
const splitStrategyIndex = args.indexOf("--split-strategy");
|
|
4021
4061
|
const splitStrategy = splitStrategyIndex !== -1 ? args[splitStrategyIndex + 1] : void 0;
|
|
4022
4062
|
const splitThresholdIndex = args.indexOf("--split-threshold");
|
|
@@ -4077,6 +4117,12 @@ async function buildCommand(args) {
|
|
|
4077
4117
|
}
|
|
4078
4118
|
}
|
|
4079
4119
|
progress.startPhase("openapi", "Generating OpenAPI schema");
|
|
4120
|
+
const queryBuilderStats = {
|
|
4121
|
+
totalOperations,
|
|
4122
|
+
detected: 0,
|
|
4123
|
+
fallback: 0,
|
|
4124
|
+
operations: []
|
|
4125
|
+
};
|
|
4080
4126
|
const openapiSpinner = new Spinner("Processing schemas");
|
|
4081
4127
|
if (!quiet) openapiSpinner.start();
|
|
4082
4128
|
const openapi = generateOpenAPI(controllers, checker, {
|
|
@@ -4086,6 +4132,31 @@ async function buildCommand(args) {
|
|
|
4086
4132
|
if (!quiet) {
|
|
4087
4133
|
openapiSpinner.setStatus(`${message} (${current}/${total})`);
|
|
4088
4134
|
}
|
|
4135
|
+
},
|
|
4136
|
+
onQueryBuilderProgress: (info) => {
|
|
4137
|
+
if (info.queryBuilderDetected) {
|
|
4138
|
+
queryBuilderStats.detected++;
|
|
4139
|
+
} else {
|
|
4140
|
+
queryBuilderStats.fallback++;
|
|
4141
|
+
}
|
|
4142
|
+
queryBuilderStats.operations.push({
|
|
4143
|
+
operationId: info.operation,
|
|
4144
|
+
method: info.method,
|
|
4145
|
+
path: info.path,
|
|
4146
|
+
detected: info.queryBuilderDetected,
|
|
4147
|
+
entityName: info.entityName,
|
|
4148
|
+
selectedFields: info.selectedFields,
|
|
4149
|
+
isPaged: info.isPaged
|
|
4150
|
+
});
|
|
4151
|
+
if (showQueryBuilder || verbose) {
|
|
4152
|
+
if (info.queryBuilderDetected) {
|
|
4153
|
+
const fieldsStr = info.selectedFields && info.selectedFields.length > 0 ? ` [select: ${info.selectedFields.join(",")}]` : "";
|
|
4154
|
+
const pagedStr = info.isPaged ? " (paged)" : "";
|
|
4155
|
+
progress.verboseLog(` \u2713 Query builder: ${info.method} ${info.path} \u2192 ${info.entityName}${fieldsStr}${pagedStr}`);
|
|
4156
|
+
} else {
|
|
4157
|
+
progress.verboseLog(` \u25CB No query builder: ${info.method} ${info.path} \u2192 using full entity schema`);
|
|
4158
|
+
}
|
|
4159
|
+
}
|
|
4089
4160
|
}
|
|
4090
4161
|
});
|
|
4091
4162
|
if (!quiet) {
|
|
@@ -4144,6 +4215,17 @@ async function buildCommand(args) {
|
|
|
4144
4215
|
}
|
|
4145
4216
|
}
|
|
4146
4217
|
progress.completePhase("openapi", `Generated ${schemaCount} schema(s)${splitEnabled ? " (split into groups)" : ""}`);
|
|
4218
|
+
if (showQueryBuilder && totalOperations > 0) {
|
|
4219
|
+
log("");
|
|
4220
|
+
log("Query Builder Analysis:");
|
|
4221
|
+
log(` Operations analyzed: ${totalOperations}`);
|
|
4222
|
+
log(` Patterns detected: ${queryBuilderStats.detected} (${Math.round(queryBuilderStats.detected / totalOperations * 100)}%)`);
|
|
4223
|
+
log(` Full schemas used: ${queryBuilderStats.fallback} (${Math.round(queryBuilderStats.fallback / totalOperations * 100)}%)`);
|
|
4224
|
+
if (queryBuilderStats.detected > 0) {
|
|
4225
|
+
const totalFields = queryBuilderStats.operations.filter((op) => op.detected && op.selectedFields).reduce((sum, op) => sum + (op.selectedFields?.length || 0), 0);
|
|
4226
|
+
log(` Fields selected: ${totalFields} total (avg ${Math.round(totalFields / queryBuilderStats.detected)} per query)`);
|
|
4227
|
+
}
|
|
4228
|
+
}
|
|
4147
4229
|
progress.startPhase("manifest", "Generating manifest");
|
|
4148
4230
|
const manifest = generateManifest(controllers, checker, ADORN_VERSION, validationMode);
|
|
4149
4231
|
progress.completePhase("manifest");
|
|
@@ -4225,7 +4307,12 @@ async function buildCommand(args) {
|
|
|
4225
4307
|
schemas: schemaCount,
|
|
4226
4308
|
sourceFiles: projectSourceFiles.length,
|
|
4227
4309
|
artifactsWritten: artifacts.map((a) => a.name),
|
|
4228
|
-
splitEnabled
|
|
4310
|
+
splitEnabled,
|
|
4311
|
+
queryBuilder: {
|
|
4312
|
+
detected: queryBuilderStats.detected,
|
|
4313
|
+
fallback: queryBuilderStats.fallback,
|
|
4314
|
+
total: totalOperations
|
|
4315
|
+
}
|
|
4229
4316
|
};
|
|
4230
4317
|
progress.printSummary(stats);
|
|
4231
4318
|
progress.printArtifacts(artifacts);
|
|
@@ -4253,30 +4340,32 @@ if (command === "build") {
|
|
|
4253
4340
|
console.log(`
|
|
4254
4341
|
adorn-api CLI v${ADORN_VERSION}
|
|
4255
4342
|
|
|
4256
|
-
Commands:
|
|
4257
|
-
|
|
4258
|
-
|
|
4343
|
+
Commands:
|
|
4344
|
+
build Generate OpenAPI and manifest from TypeScript source
|
|
4345
|
+
clean Remove generated artifacts
|
|
4259
4346
|
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4347
|
+
Options:
|
|
4348
|
+
-p <path> Path to tsconfig.json (default: ./tsconfig.json)
|
|
4349
|
+
--output <dir> Output directory (default: .adorn)
|
|
4350
|
+
--if-stale Only rebuild if artifacts are stale
|
|
4351
|
+
--validation-mode <mode> Validation mode: none, ajv-runtime, precompiled (default: ajv-runtime)
|
|
4352
|
+
--split Enable automatic schema splitting (default: disabled)
|
|
4353
|
+
--split-strategy <mode> Override splitting strategy: controller, dependency, size, auto (default: auto)
|
|
4354
|
+
--split-threshold <num> Schema count threshold for auto-split (default: 50)
|
|
4355
|
+
--verbose Show detailed progress information
|
|
4356
|
+
--quiet Suppress non-essential output
|
|
4357
|
+
--show-query-builder Show query builder inspection details and statistics
|
|
4270
4358
|
|
|
4271
|
-
Examples:
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4359
|
+
Examples:
|
|
4360
|
+
adorn-api build -p ./tsconfig.json --output .adorn
|
|
4361
|
+
adorn-api build --if-stale
|
|
4362
|
+
adorn-api build --validation-mode precompiled
|
|
4363
|
+
adorn-api build --verbose
|
|
4364
|
+
adorn-api build --show-query-builder # Show query builder analysis details
|
|
4365
|
+
adorn-api build --split # Enable split mode
|
|
4366
|
+
adorn-api build --split-strategy controller # Force controller-based splitting
|
|
4367
|
+
adorn-api build --split-threshold 100 # Increase threshold to 100
|
|
4368
|
+
adorn-api clean
|
|
4369
|
+
`);
|
|
4281
4370
|
}
|
|
4282
4371
|
//# sourceMappingURL=cli.js.map
|