adorn-api 1.0.12 → 1.0.14
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/adapter/express/auth.d.ts +8 -0
- package/dist/adapter/express/auth.d.ts.map +1 -1
- package/dist/adapter/express/bootstrap.d.ts +12 -0
- package/dist/adapter/express/bootstrap.d.ts.map +1 -1
- package/dist/adapter/express/coercion.d.ts +81 -1
- package/dist/adapter/express/coercion.d.ts.map +1 -1
- package/dist/adapter/express/index.d.ts +1 -0
- package/dist/adapter/express/index.d.ts.map +1 -1
- package/dist/adapter/express/merge.d.ts +17 -0
- package/dist/adapter/express/merge.d.ts.map +1 -1
- package/dist/adapter/express/openapi.d.ts +55 -0
- package/dist/adapter/express/openapi.d.ts.map +1 -1
- package/dist/adapter/express/router.d.ts +6 -0
- package/dist/adapter/express/router.d.ts.map +1 -1
- package/dist/adapter/express/swagger.d.ts +6 -0
- package/dist/adapter/express/swagger.d.ts.map +1 -1
- package/dist/adapter/express/types.d.ts +26 -0
- package/dist/adapter/express/types.d.ts.map +1 -1
- package/dist/adapter/express/validation.d.ts +19 -2
- package/dist/adapter/express/validation.d.ts.map +1 -1
- package/dist/cli.cjs +1016 -445
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1016 -445
- package/dist/cli.js.map +1 -1
- package/dist/compiler/analyze/index.d.ts +5 -0
- package/dist/compiler/analyze/index.d.ts.map +1 -0
- package/dist/compiler/analyze/scanControllers.d.ts +52 -0
- package/dist/compiler/analyze/scanControllers.d.ts.map +1 -1
- package/dist/compiler/cache/isStale.d.ts +26 -0
- package/dist/compiler/cache/isStale.d.ts.map +1 -1
- package/dist/compiler/cache/loadArtifacts.d.ts +36 -0
- package/dist/compiler/cache/loadArtifacts.d.ts.map +1 -1
- package/dist/compiler/cache/schema.d.ts +14 -0
- package/dist/compiler/cache/schema.d.ts.map +1 -1
- package/dist/compiler/cache/writeCache.d.ts +6 -0
- package/dist/compiler/cache/writeCache.d.ts.map +1 -1
- package/dist/compiler/gems.d.ts +75 -0
- package/dist/compiler/gems.d.ts.map +1 -0
- package/dist/compiler/generator/index.d.ts +7 -0
- package/dist/compiler/generator/index.d.ts.map +1 -0
- package/dist/compiler/generator/manifest.d.ts +23 -0
- package/dist/compiler/generator/manifest.d.ts.map +1 -0
- package/dist/compiler/generator/openapi.d.ts +118 -0
- package/dist/compiler/generator/openapi.d.ts.map +1 -0
- package/dist/compiler/graph/builder.d.ts +24 -0
- package/dist/compiler/graph/builder.d.ts.map +1 -0
- package/dist/compiler/graph/index.d.ts +7 -0
- package/dist/compiler/graph/index.d.ts.map +1 -0
- package/dist/compiler/graph/schemaGraph.d.ts +67 -0
- package/dist/compiler/graph/schemaGraph.d.ts.map +1 -0
- package/dist/compiler/graph/types.d.ts +203 -0
- package/dist/compiler/graph/types.d.ts.map +1 -0
- package/dist/compiler/index.d.ts +12 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/ir/index.d.ts +7 -0
- package/dist/compiler/ir/index.d.ts.map +1 -0
- package/dist/compiler/ir/pipeline.d.ts +82 -0
- package/dist/compiler/ir/pipeline.d.ts.map +1 -0
- package/dist/compiler/ir/stages.d.ts +40 -0
- package/dist/compiler/ir/stages.d.ts.map +1 -0
- package/dist/compiler/ir/visitor.d.ts +98 -0
- package/dist/compiler/ir/visitor.d.ts.map +1 -0
- package/dist/compiler/manifest/emit.d.ts +14 -0
- package/dist/compiler/manifest/emit.d.ts.map +1 -1
- package/dist/compiler/manifest/format.d.ts +42 -0
- package/dist/compiler/manifest/format.d.ts.map +1 -1
- package/dist/compiler/manifest/index.d.ts +6 -0
- package/dist/compiler/manifest/index.d.ts.map +1 -0
- package/dist/compiler/runner/createProgram.d.ts +16 -0
- package/dist/compiler/runner/createProgram.d.ts.map +1 -1
- package/dist/compiler/runner/index.d.ts +5 -0
- package/dist/compiler/runner/index.d.ts.map +1 -0
- package/dist/compiler/schema/extractAnnotations.d.ts +47 -0
- package/dist/compiler/schema/extractAnnotations.d.ts.map +1 -1
- package/dist/compiler/schema/index.d.ts +6 -0
- package/dist/compiler/schema/index.d.ts.map +1 -0
- package/dist/compiler/schema/intersectionHandler.d.ts +44 -0
- package/dist/compiler/schema/intersectionHandler.d.ts.map +1 -0
- package/dist/compiler/schema/objectHandler.d.ts +106 -0
- package/dist/compiler/schema/objectHandler.d.ts.map +1 -0
- package/dist/compiler/schema/openapi.d.ts +16 -1
- package/dist/compiler/schema/openapi.d.ts.map +1 -1
- package/dist/compiler/schema/parameters.d.ts +90 -0
- package/dist/compiler/schema/parameters.d.ts.map +1 -0
- package/dist/compiler/schema/primitives.d.ts +68 -0
- package/dist/compiler/schema/primitives.d.ts.map +1 -0
- package/dist/compiler/schema/typeToJsonSchema.d.ts +22 -51
- package/dist/compiler/schema/typeToJsonSchema.d.ts.map +1 -1
- package/dist/compiler/schema/types.d.ts +69 -0
- package/dist/compiler/schema/types.d.ts.map +1 -0
- package/dist/compiler/schema/unionHandler.d.ts +70 -0
- package/dist/compiler/schema/unionHandler.d.ts.map +1 -0
- package/dist/compiler/transform/dedup.d.ts +35 -0
- package/dist/compiler/transform/dedup.d.ts.map +1 -0
- package/dist/compiler/transform/flatten.d.ts +50 -0
- package/dist/compiler/transform/flatten.d.ts.map +1 -0
- package/dist/compiler/transform/index.d.ts +7 -0
- package/dist/compiler/transform/index.d.ts.map +1 -0
- package/dist/compiler/transform/inline.d.ts +46 -0
- package/dist/compiler/transform/inline.d.ts.map +1 -0
- package/dist/compiler/validation/emitPrecompiledValidators.d.ts +16 -0
- package/dist/compiler/validation/emitPrecompiledValidators.d.ts.map +1 -1
- package/dist/compiler/validation/index.d.ts +5 -0
- package/dist/compiler/validation/index.d.ts.map +1 -0
- package/dist/decorators/Auth.d.ts +17 -0
- package/dist/decorators/Auth.d.ts.map +1 -1
- package/dist/decorators/Controller.d.ts +15 -0
- package/dist/decorators/Controller.d.ts.map +1 -1
- package/dist/decorators/Public.d.ts +13 -0
- package/dist/decorators/Public.d.ts.map +1 -1
- package/dist/decorators/Use.d.ts +18 -0
- package/dist/decorators/Use.d.ts.map +1 -1
- package/dist/decorators/methods.d.ts +20 -0
- package/dist/decorators/methods.d.ts.map +1 -1
- package/dist/express.cjs +73 -54
- package/dist/express.cjs.map +1 -1
- package/dist/express.js +73 -54
- package/dist/express.js.map +1 -1
- package/dist/http.d.ts +1 -2
- package/dist/http.d.ts.map +1 -1
- package/dist/index.cjs +161 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +156 -3
- package/dist/index.js.map +1 -1
- package/dist/metal/applyListQuery.d.ts +73 -0
- package/dist/metal/applyListQuery.d.ts.map +1 -1
- package/dist/metal/index.cjs +2 -2
- package/dist/metal/index.cjs.map +1 -1
- package/dist/metal/index.d.ts +4 -0
- package/dist/metal/index.d.ts.map +1 -1
- package/dist/metal/index.js +2 -2
- package/dist/metal/index.js.map +1 -1
- package/dist/metal/listQuery.d.ts +19 -0
- package/dist/metal/listQuery.d.ts.map +1 -1
- package/dist/metal/queryOptions.d.ts +8 -0
- package/dist/metal/queryOptions.d.ts.map +1 -1
- package/dist/metal/readMetalBag.d.ts +36 -0
- package/dist/metal/readMetalBag.d.ts.map +1 -1
- package/dist/metal/registerMetalEntities.d.ts +20 -0
- package/dist/metal/registerMetalEntities.d.ts.map +1 -1
- package/dist/metal/schemaFromEntity.d.ts +30 -0
- package/dist/metal/schemaFromEntity.d.ts.map +1 -1
- package/dist/metal/searchWhere.d.ts +39 -0
- package/dist/metal/searchWhere.d.ts.map +1 -1
- package/dist/metal/symbolMetadata.d.ts +6 -0
- package/dist/metal/symbolMetadata.d.ts.map +1 -1
- package/dist/runtime/auth/runtime.d.ts +155 -6
- package/dist/runtime/auth/runtime.d.ts.map +1 -1
- package/dist/runtime/metadata/bucket.d.ts +1 -2
- package/dist/runtime/metadata/bucket.d.ts.map +1 -1
- package/dist/runtime/metadata/key.d.ts +1 -1
- package/dist/runtime/metadata/key.d.ts.map +1 -1
- package/dist/runtime/metadata/read.d.ts +1 -2
- package/dist/runtime/metadata/read.d.ts.map +1 -1
- package/dist/runtime/metadata/types.d.ts +74 -0
- package/dist/runtime/metadata/types.d.ts.map +1 -1
- package/dist/runtime/polyfill.d.ts +1 -1
- package/dist/runtime/polyfill.d.ts.map +1 -1
- package/dist/runtime/upload.d.ts +37 -0
- package/dist/runtime/upload.d.ts.map +1 -1
- package/dist/runtime/validation/ajv.d.ts +100 -0
- package/dist/runtime/validation/ajv.d.ts.map +1 -1
- package/dist/runtime/validation/index.d.ts +9 -0
- package/dist/runtime/validation/index.d.ts.map +1 -1
- package/dist/scripts/adorn-example.cjs +238 -6
- package/dist/scripts/adorn-example.cjs.map +1 -1
- package/dist/utils/port.d.ts +9 -0
- package/dist/utils/port.d.ts.map +1 -0
- package/package.json +4 -1
package/dist/index.cjs
CHANGED
|
@@ -72,10 +72,14 @@ __export(index_exports, {
|
|
|
72
72
|
ValidationErrorResponse: () => ValidationErrorResponse,
|
|
73
73
|
clearArtifactCache: () => clearArtifactCache,
|
|
74
74
|
createValidator: () => createValidator,
|
|
75
|
+
findProcessOnPort: () => findProcessOnPort,
|
|
75
76
|
formatValidationErrors: () => formatValidationErrors,
|
|
76
77
|
getArtifactCacheStats: () => getArtifactCacheStats,
|
|
78
|
+
isPortAvailable: () => isPortAvailable,
|
|
79
|
+
killProcess: () => killProcess,
|
|
77
80
|
loadArtifacts: () => loadArtifacts,
|
|
78
|
-
readAdornBucket: () => readAdornBucket
|
|
81
|
+
readAdornBucket: () => readAdornBucket,
|
|
82
|
+
waitForPort: () => waitForPort
|
|
79
83
|
});
|
|
80
84
|
module.exports = __toCommonJS(index_exports);
|
|
81
85
|
|
|
@@ -368,11 +372,25 @@ function Union(mode) {
|
|
|
368
372
|
var import_ajv = __toESM(require("ajv"), 1);
|
|
369
373
|
var import_ajv_formats = __toESM(require("ajv-formats"), 1);
|
|
370
374
|
var ValidationErrorResponse = class extends Error {
|
|
375
|
+
/**
|
|
376
|
+
* HTTP status code for validation errors.
|
|
377
|
+
*/
|
|
378
|
+
statusCode;
|
|
379
|
+
/**
|
|
380
|
+
* Detailed validation errors.
|
|
381
|
+
*/
|
|
382
|
+
errors;
|
|
383
|
+
/**
|
|
384
|
+
* Creates a new ValidationErrorResponse.
|
|
385
|
+
*
|
|
386
|
+
* @param statusCode - HTTP status code (typically 400)
|
|
387
|
+
* @param errors - Array of validation errors
|
|
388
|
+
*/
|
|
371
389
|
constructor(statusCode, errors) {
|
|
372
390
|
super("Validation failed");
|
|
391
|
+
this.name = "ValidationErrorResponse";
|
|
373
392
|
this.statusCode = statusCode;
|
|
374
393
|
this.errors = errors;
|
|
375
|
-
this.name = "ValidationErrorResponse";
|
|
376
394
|
}
|
|
377
395
|
};
|
|
378
396
|
function createValidator() {
|
|
@@ -453,7 +471,7 @@ async function getMtime(filePath) {
|
|
|
453
471
|
async function loadArtifacts(options) {
|
|
454
472
|
const { outDir } = options;
|
|
455
473
|
const cacheKey = import_node_path.default.resolve(outDir);
|
|
456
|
-
|
|
474
|
+
const entry = artifactCache.get(cacheKey);
|
|
457
475
|
const openapiPath = import_node_path.default.join(outDir, "openapi.json");
|
|
458
476
|
const manifestPath = import_node_path.default.join(outDir, "manifest.json");
|
|
459
477
|
const validatorsPath = import_node_path.default.join(outDir, "validators.mjs");
|
|
@@ -515,6 +533,141 @@ function getArtifactCacheStats() {
|
|
|
515
533
|
keys: Array.from(artifactCache.keys())
|
|
516
534
|
};
|
|
517
535
|
}
|
|
536
|
+
|
|
537
|
+
// src/utils/port.ts
|
|
538
|
+
var import_net = require("net");
|
|
539
|
+
var import_child_process = require("child_process");
|
|
540
|
+
var import_util = require("util");
|
|
541
|
+
var execAsync = (0, import_util.promisify)(import_child_process.exec);
|
|
542
|
+
async function isPortAvailable(port, host = "0.0.0.0") {
|
|
543
|
+
return new Promise((resolve) => {
|
|
544
|
+
const server = (0, import_net.createServer)();
|
|
545
|
+
server.on("error", (err) => {
|
|
546
|
+
if (err.code === "EADDRINUSE") {
|
|
547
|
+
resolve(false);
|
|
548
|
+
} else {
|
|
549
|
+
resolve(false);
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
server.once("listening", () => {
|
|
553
|
+
server.close(() => {
|
|
554
|
+
resolve(true);
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
server.listen(port, host);
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
async function findProcessOnPort(port) {
|
|
561
|
+
try {
|
|
562
|
+
const platform = process.platform;
|
|
563
|
+
if (platform === "win32") {
|
|
564
|
+
const { stdout } = await execAsync(`netstat -ano | findstr :${port}`);
|
|
565
|
+
for (const line of stdout.split("\n")) {
|
|
566
|
+
const trimmed = line.trim();
|
|
567
|
+
if (!trimmed || trimmed.includes("PID")) continue;
|
|
568
|
+
const parts = trimmed.split(/\s+/);
|
|
569
|
+
if (parts.length >= 5) {
|
|
570
|
+
const address = parts[1];
|
|
571
|
+
const pid = parseInt(parts[parts.length - 1], 10);
|
|
572
|
+
if (address.includes(`:${port}`) && !isNaN(pid)) {
|
|
573
|
+
const command = await getProcessNameOnWindows(pid);
|
|
574
|
+
return { pid, command };
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
} else {
|
|
579
|
+
const { stdout } = await execAsync(`lsof -ti:${port}`);
|
|
580
|
+
const pids = stdout.trim().split("\n").filter(Boolean).map(Number);
|
|
581
|
+
if (pids.length > 0) {
|
|
582
|
+
const pid = pids[0];
|
|
583
|
+
const command = await getProcessNameOnUnix(pid);
|
|
584
|
+
return { pid, command };
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return null;
|
|
588
|
+
} catch (error) {
|
|
589
|
+
if (error.message.includes("matches found")) {
|
|
590
|
+
return null;
|
|
591
|
+
}
|
|
592
|
+
return null;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
async function getProcessNameOnWindows(pid) {
|
|
596
|
+
try {
|
|
597
|
+
const { stdout } = await execAsync(`tasklist /FI "PID eq ${pid}" /FO CSV /NH`);
|
|
598
|
+
const line = stdout.trim().split("\n")[0];
|
|
599
|
+
if (line) {
|
|
600
|
+
const parts = line.split('","');
|
|
601
|
+
if (parts.length >= 2) {
|
|
602
|
+
return parts[0].replace(/"/g, "");
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
} catch {
|
|
606
|
+
return void 0;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
async function getProcessNameOnUnix(pid) {
|
|
610
|
+
try {
|
|
611
|
+
const { stdout } = await execAsync(`ps -p ${pid} -o comm=`);
|
|
612
|
+
return stdout.trim() || void 0;
|
|
613
|
+
} catch {
|
|
614
|
+
return void 0;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
async function killProcess(pid) {
|
|
618
|
+
try {
|
|
619
|
+
process.kill(pid, "SIGTERM");
|
|
620
|
+
await new Promise((resolve, reject) => {
|
|
621
|
+
const timeout = setTimeout(() => {
|
|
622
|
+
reject(new Error("Process did not terminate gracefully"));
|
|
623
|
+
}, 5e3);
|
|
624
|
+
const check = () => {
|
|
625
|
+
try {
|
|
626
|
+
process.kill(pid, 0);
|
|
627
|
+
setTimeout(check, 500);
|
|
628
|
+
} catch {
|
|
629
|
+
clearInterval(interval);
|
|
630
|
+
clearTimeout(timeout);
|
|
631
|
+
resolve();
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
const interval = setInterval(check, 500);
|
|
635
|
+
});
|
|
636
|
+
return true;
|
|
637
|
+
} catch {
|
|
638
|
+
try {
|
|
639
|
+
process.kill(pid, "SIGKILL");
|
|
640
|
+
await new Promise((resolve, reject) => {
|
|
641
|
+
const timeout = setTimeout(() => {
|
|
642
|
+
reject(new Error("Process did not terminate"));
|
|
643
|
+
}, 3e3);
|
|
644
|
+
setTimeout(() => {
|
|
645
|
+
try {
|
|
646
|
+
process.kill(pid, 0);
|
|
647
|
+
clearTimeout(timeout);
|
|
648
|
+
reject(new Error("Process still running"));
|
|
649
|
+
} catch {
|
|
650
|
+
clearTimeout(timeout);
|
|
651
|
+
resolve();
|
|
652
|
+
}
|
|
653
|
+
}, 1e3);
|
|
654
|
+
});
|
|
655
|
+
return true;
|
|
656
|
+
} catch {
|
|
657
|
+
return false;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
async function waitForPort(port, host = "0.0.0.0", timeout = 5e3) {
|
|
662
|
+
const start = Date.now();
|
|
663
|
+
while (Date.now() - start < timeout) {
|
|
664
|
+
if (await isPortAvailable(port, host)) {
|
|
665
|
+
return true;
|
|
666
|
+
}
|
|
667
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
668
|
+
}
|
|
669
|
+
return false;
|
|
670
|
+
}
|
|
518
671
|
// Annotate the CommonJS export names for ESM import in node:
|
|
519
672
|
0 && (module.exports = {
|
|
520
673
|
ADORN_META,
|
|
@@ -559,9 +712,13 @@ function getArtifactCacheStats() {
|
|
|
559
712
|
ValidationErrorResponse,
|
|
560
713
|
clearArtifactCache,
|
|
561
714
|
createValidator,
|
|
715
|
+
findProcessOnPort,
|
|
562
716
|
formatValidationErrors,
|
|
563
717
|
getArtifactCacheStats,
|
|
718
|
+
isPortAvailable,
|
|
719
|
+
killProcess,
|
|
564
720
|
loadArtifacts,
|
|
565
|
-
readAdornBucket
|
|
721
|
+
readAdornBucket,
|
|
722
|
+
waitForPort
|
|
566
723
|
});
|
|
567
724
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/runtime/polyfill.ts","../src/runtime/metadata/key.ts","../src/runtime/metadata/bucket.ts","../src/decorators/Controller.ts","../src/decorators/methods.ts","../src/decorators/Use.ts","../src/decorators/Auth.ts","../src/decorators/Public.ts","../src/runtime/metadata/read.ts","../src/schema/decorators.ts","../src/runtime/validation/ajv.ts","../src/http.ts","../src/compiler/cache/loadArtifacts.ts"],"sourcesContent":["import \"./runtime/polyfill.js\";\n\nexport { Controller, Get, Post, Put, Patch, Delete, Use, Auth, Public } from \"./decorators/index.js\";\nexport { readAdornBucket } from \"./runtime/metadata/read.js\";\nexport type { HttpMethod, RouteOperation, AdornBucket, AuthMeta, ExpressMw } from \"./runtime/metadata/types.js\";\nexport type { AuthSchemeRuntime, AuthResult } from \"./runtime/auth/runtime.js\";\nexport * from \"./schema/index.js\";\nexport { createValidator, formatValidationErrors, ValidationErrorResponse } from \"./runtime/validation/index.js\";\nexport { PartType, File, PartType as PartType2, Consumes, Produces } from \"./http.js\";\nexport type { Query, Body, Headers, Cookies, PaginationParams, PaginatedResponse, HttpMetadata, FilePartOptions } from \"./http.js\";\nexport type { UploadFile } from \"./runtime/upload.js\";\nexport { loadArtifacts, clearArtifactCache, getArtifactCacheStats } from \"./compiler/cache/loadArtifacts.js\";\n","// Polyfill Symbol.metadata for environments that don't support it\n// Must run before any decorated classes are imported\n(Symbol as any).metadata ??= Symbol(\"Symbol.metadata\");\n\n// Export a symbol to prevent tree-shaking\nexport const ADORN_POLYFILL = Symbol(\"adorn-polyfill\");\n","export const ADORN_META = Symbol.for(\"adorn-api/meta\");\n","import { ADORN_META } from \"./key.js\";\nimport type { AdornBucket } from \"./types.js\";\n\nexport function getBucket(metadata: DecoratorMetadata): AdornBucket {\n if (!metadata) {\n throw new Error(\"Decorator context.metadata is undefined. Ensure Symbol.metadata polyfill runs before decorators.\");\n }\n let bucket = metadata[ADORN_META] as AdornBucket | undefined;\n if (!bucket) {\n bucket = { ops: [], controllerUse: [] };\n metadata[ADORN_META] = bucket;\n }\n if (!bucket.controllerUse) {\n bucket.controllerUse = [];\n }\n return bucket;\n}\n","import { getBucket } from \"../runtime/metadata/bucket.js\";\n\nexport function Controller(basePath: string) {\n return function <T extends new (...args: any[]) => any>(\n target: T,\n context: ClassDecoratorContext<T>\n ): T | void {\n const bucket = getBucket(context.metadata);\n bucket.basePath = basePath;\n };\n}\n","import { getBucket } from \"../runtime/metadata/bucket.js\";\nimport type { HttpMethod } from \"../runtime/metadata/types.js\";\n\nfunction createMethodDecorator(httpMethod: HttpMethod, path: string) {\n return function <T extends (...args: any[]) => any>(\n target: T,\n context: ClassMethodDecoratorContext<any, T>\n ): T | void {\n if (context.private || context.static) {\n return;\n }\n\n const methodName = String(context.name);\n const bucket = getBucket(context.metadata);\n\n let op = bucket.ops.find(op => op.methodName === methodName);\n if (!op) {\n op = {\n httpMethod,\n path,\n methodName,\n };\n bucket.ops.push(op);\n } else {\n op.httpMethod = httpMethod;\n op.path = path;\n }\n };\n}\n\nexport const Get = (path: string) => createMethodDecorator(\"GET\", path);\nexport const Post = (path: string) => createMethodDecorator(\"POST\", path);\nexport const Put = (path: string) => createMethodDecorator(\"PUT\", path);\nexport const Patch = (path: string) => createMethodDecorator(\"PATCH\", path);\nexport const Delete = (path: string) => createMethodDecorator(\"DELETE\", path);\n","import { getBucket } from \"../runtime/metadata/bucket.js\";\nimport type { ExpressMw, HttpMethod } from \"../runtime/metadata/types.js\";\n\ntype UseTarget = string | ExpressMw;\n\nexport function Use(...middleware: UseTarget[]) {\n return function (\n target: any,\n context: ClassDecoratorContext | ClassMethodDecoratorContext\n ) {\n if (context.kind === \"class\") {\n const bucket = getBucket(context.metadata);\n if (!bucket.controllerUse) {\n bucket.controllerUse = [];\n }\n bucket.controllerUse.push(...middleware);\n } else if (context.kind === \"method\") {\n const methodName = String(context.name);\n const bucket = getBucket(context.metadata);\n let op = bucket.ops.find(op => op.methodName === methodName);\n if (!op) {\n op = {\n httpMethod: \"GET\" as HttpMethod,\n path: \"/\",\n methodName,\n };\n bucket.ops.push(op);\n }\n if (!op.use) {\n op.use = [];\n }\n op.use.push(...middleware);\n } else {\n throw new Error(\"@Use decorator can only be applied to classes or methods\");\n }\n };\n}\n","import { getBucket } from \"../runtime/metadata/bucket.js\";\nimport type { AuthMeta, HttpMethod } from \"../runtime/metadata/types.js\";\n\nexport function Auth(scheme: string, options?: { scopes?: string[]; optional?: boolean }) {\n return function (\n target: any,\n context: ClassMethodDecoratorContext\n ) {\n if (context.kind !== \"method\") {\n throw new Error(\"@Auth decorator can only be applied to methods\");\n }\n\n const methodName = String(context.name);\n const bucket = getBucket(context.metadata);\n let op = bucket.ops.find(op => op.methodName === methodName);\n if (!op) {\n op = {\n httpMethod: \"GET\" as HttpMethod,\n path: \"/\",\n methodName,\n };\n bucket.ops.push(op);\n }\n\n op.auth = {\n scheme,\n scopes: options?.scopes,\n optional: options?.optional ?? false,\n };\n };\n}\n","import { getBucket } from \"../runtime/metadata/bucket.js\";\nimport type { HttpMethod } from \"../runtime/metadata/types.js\";\n\nexport function Public() {\n return function (\n target: any,\n context: ClassMethodDecoratorContext\n ) {\n if (context.kind !== \"method\") {\n throw new Error(\"@Public decorator can only be applied to methods\");\n }\n\n const methodName = String(context.name);\n const bucket = getBucket(context.metadata);\n let op = bucket.ops.find(op => op.methodName === methodName);\n if (!op) {\n op = {\n httpMethod: \"GET\" as HttpMethod,\n path: \"/\",\n methodName,\n };\n bucket.ops.push(op);\n }\n\n op.auth = \"public\";\n };\n}\n","import { ADORN_META } from \"./key.js\";\nimport type { AdornBucket } from \"./types.js\";\n\nexport function readAdornBucket(ctor: Function): AdornBucket | null {\n const metaSym = (Symbol as any).metadata as symbol | undefined;\n if (!metaSym) {\n return null;\n }\n\n const classMetadata = (ctor as any)[metaSym] as DecoratorMetadata | undefined;\n if (!classMetadata) {\n return null;\n }\n\n const bucket = classMetadata[ADORN_META] as AdornBucket | undefined;\n return bucket ?? null;\n}\n","const ADORN_META = Symbol.for(\"adorn-api.metadata\");\n\ninterface SchemaFrag {\n [key: string]: unknown;\n}\n\ninterface SchemaMetadata {\n schema: {\n props: Record<string, SchemaFrag[]>;\n };\n}\n\nfunction getOrCreateMetadata(metadata: Record<PropertyKey, unknown>): SchemaMetadata {\n const meta = (metadata[ADORN_META] ??= {}) as SchemaMetadata;\n meta.schema ??= { props: {} };\n return meta;\n}\n\nfunction pushSchemaFrag(\n target: Object,\n propertyKey: string | symbol,\n metadata: Record<PropertyKey, unknown>,\n frag: SchemaFrag\n): void {\n const meta = getOrCreateMetadata(metadata);\n const props = meta.schema.props;\n (props[propertyKey as string] ??= []).push(frag);\n}\n\ntype PropertyDecorator = (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void;\n\nexport function Schema(frag: SchemaFrag): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, frag);\n };\n}\n\nexport function Min(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { minimum: n });\n };\n}\n\nexport function Max(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { maximum: n });\n };\n}\n\nexport function ExclusiveMin(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { exclusiveMinimum: n });\n };\n}\n\nexport function ExclusiveMax(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { exclusiveMaximum: n });\n };\n}\n\nexport function MinLength(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { minLength: n });\n };\n}\n\nexport function MaxLength(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { maxLength: n });\n };\n}\n\nexport function Pattern(re: RegExp | string): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { pattern: typeof re === \"string\" ? re : re.source });\n };\n}\n\nexport function Format(fmt: string): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { format: fmt });\n };\n}\n\nexport function MinItems(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { minItems: n });\n };\n}\n\nexport function MaxItems(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { maxItems: n });\n };\n}\n\nexport function MinProperties(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { minProperties: n });\n };\n}\n\nexport function MaxProperties(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { maxProperties: n });\n };\n}\n\nexport function MultipleOf(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { multipleOf: n });\n };\n}\n\nexport function Example(value: unknown): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { example: value });\n };\n}\n\nexport function Examples(values: unknown[]): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { examples: values });\n };\n}\n\nexport function Description(desc: string): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { description: desc });\n };\n}\n\nexport function Enum<T extends string | number>(vals: T[]): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { enum: vals });\n };\n}\n\nexport function Const<T>(val: T): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { const: val });\n };\n}\n\nexport function Default<T>(val: T): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { default: val });\n };\n}\n\nexport function AdditionalProperties(value: boolean | Record<string, unknown>): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { additionalProperties: value });\n };\n}\n\nexport function Closed(): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { additionalProperties: false });\n };\n}\n\nexport function ClosedUnevaluated(): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { unevaluatedProperties: false });\n };\n}\n\nexport function Union(mode: \"anyOf\" | \"oneOf\" | \"allOf\"): ClassDecorator {\n return function (target: Function): void {\n (target as any)[ADORN_META] = (target as any)[ADORN_META] ?? {};\n const meta = (target as any)[ADORN_META] as SchemaMetadata;\n meta.schema = meta.schema ?? { props: {} };\n (meta.schema as any).unionMode = mode;\n };\n}\n\nexport { ADORN_META };\nexport type { SchemaFrag, SchemaMetadata };\n","import Ajv from \"ajv\";\nimport addFormats from \"ajv-formats\";\nimport type { ErrorObject } from \"ajv\";\n\nexport interface ValidationError {\n path: string;\n message: string;\n keyword: string;\n params: Record<string, unknown>;\n}\n\nexport interface ValidationResult {\n valid: boolean;\n errors: ValidationError[] | null;\n}\n\nexport class ValidationErrorResponse extends Error {\n constructor(\n public statusCode: number,\n public errors: ValidationError[]\n ) {\n super(\"Validation failed\");\n this.name = \"ValidationErrorResponse\";\n }\n}\n\nexport function createValidator() {\n const ajv = new Ajv.default({\n allErrors: true,\n coerceTypes: false,\n strict: false,\n validateFormats: true,\n });\n\n addFormats.default(ajv);\n\n ajv.addFormat(\"br-phone\", /^\\(\\d{2}\\)\\s\\d{5}-\\d{4}$/);\n\n return ajv;\n}\n\nexport function validateData(\n ajv: ReturnType<typeof createValidator>,\n data: unknown,\n schema: Record<string, unknown>,\n dataPath: string = \"#\"\n): ValidationResult {\n const validate = ajv.compile(schema);\n const valid = validate(data);\n\n if (valid) {\n return { valid: true, errors: null };\n }\n\n const errors: ValidationError[] = (validate.errors || []).map((err: ErrorObject) => ({\n path: formatErrorPath(dataPath, err),\n message: err.message || \"Invalid value\",\n keyword: err.keyword,\n params: err.params as Record<string, unknown>,\n }));\n\n return { valid: false, errors };\n}\n\nfunction formatErrorPath(basePath: string, err: ErrorObject): string {\n const instancePath = err.instancePath;\n\n if (!instancePath || instancePath === \"\") {\n return basePath;\n }\n\n if (basePath === \"#\" || basePath.endsWith(\"/\")) {\n return `${basePath}${instancePath.slice(1)}`;\n }\n\n return `${basePath}${instancePath}`;\n}\n\nexport function formatValidationErrors(errors: ValidationError[]): Record<string, unknown> {\n const formatted: Record<string, string[]> = {};\n\n for (const error of errors) {\n const path = error.path || \"body\";\n if (!formatted[path]) {\n formatted[path] = [];\n }\n formatted[path].push(error.message);\n }\n\n return {\n error: \"Validation failed\",\n details: formatted,\n };\n}\n","import \"./runtime/polyfill.js\";\n\nconst ADORN_META = Symbol.for(\"adorn-api.metadata\");\n\ninterface HttpMetadata {\n consumes?: string[];\n produces?: string[];\n fileParts?: Record<string, FilePartOptions>;\n cookies?: Record<string, boolean>;\n}\n\ninterface FilePartOptions {\n contentType?: string;\n headers?: Record<string, string>;\n}\n\ntype DecoratorMetadata = Record<PropertyKey, unknown> & { [ADORN_META]?: HttpMetadata };\n\nfunction getMetadata(target: Object | DecoratorMetadata): HttpMetadata {\n const host = target as DecoratorMetadata;\n const metadata = host[ADORN_META] ?? {};\n host[ADORN_META] = metadata;\n return metadata;\n}\n\nexport type PartType = FilePartOptions;\n\nexport function PartType(contentTypeOrOptions: string | FilePartOptions): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n const metadata = getMetadata(target);\n const options: FilePartOptions = typeof contentTypeOrOptions === \"string\"\n ? { contentType: contentTypeOrOptions }\n : contentTypeOrOptions;\n metadata.fileParts ??= {};\n metadata.fileParts[propertyKey.toString()] = options;\n };\n}\n\nexport function File(): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n const metadata = getMetadata(target);\n metadata.fileParts ??= {};\n metadata.fileParts[propertyKey.toString()] = metadata.fileParts[propertyKey.toString()] ?? {};\n };\n}\n\nexport function Consumes(...contentTypes: string[]): ClassDecorator {\n return function (target: Function): void {\n const metadata = getMetadata(target.prototype);\n metadata.consumes = contentTypes;\n };\n}\n\nexport function Produces(...contentTypes: string[]): ClassDecorator {\n return function (target: Function): void {\n const metadata = getMetadata(target.prototype);\n metadata.produces = contentTypes;\n };\n}\n\nexport type Query<T = any> = T;\nexport type Body<T = any> = T;\nexport type Headers<T = any> = T;\nexport type Cookies<T = any> = T;\n\nexport interface PaginationParams {\n page: number;\n pageSize: number;\n}\n\nexport type PaginatedResponse<T> = {\n items: T[];\n totalItems: number;\n page: number;\n pageSize: number;\n};\n\nexport { ADORN_META };\nexport type { HttpMetadata, FilePartOptions };\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { stat } from \"node:fs/promises\";\n\ninterface OpenApi {\n openapi: string;\n components?: {\n schemas?: Record<string, unknown>;\n };\n paths?: Record<string, unknown>;\n info?: Record<string, unknown>;\n security?: Array<Record<string, string[]>>;\n}\n\ninterface Manifest {\n manifestVersion: number;\n generatedAt: string;\n generator: {\n name: string;\n version: string;\n typescript: string;\n };\n schemas: {\n kind: string;\n file: string;\n componentsSchemasPointer: string;\n };\n validation: {\n mode: \"none\" | \"ajv-runtime\" | \"precompiled\";\n precompiledModule: string | null;\n };\n controllers: Array<{\n controllerId: string;\n basePath: string;\n operations: Array<{\n operationId: string;\n http: {\n method: string;\n path: string;\n };\n handler: {\n methodName: string;\n };\n args: {\n body: {\n index: number;\n required: boolean;\n contentType: string;\n schemaRef: string;\n } | null;\n path: Array<{\n name: string;\n index: number;\n required: boolean;\n schemaRef: string;\n schemaType?: string | string[];\n }>;\n query: Array<{\n name: string;\n index: number;\n required: boolean;\n schemaRef: string;\n schemaType?: string | string[];\n }>;\n headers: Array<{\n name: string;\n index: number;\n required: boolean;\n schemaRef: string;\n schemaType?: string | string[];\n }>;\n cookies: Array<{\n name: string;\n index: number;\n required: boolean;\n schemaRef: string;\n schemaType?: string | string[];\n }>;\n };\n responses: Array<{\n status: number;\n contentType: string;\n schemaRef: string;\n isArray?: boolean;\n }>;\n }>;\n }>;\n}\n\ninterface ValidatorModule {\n validators: Record<string, {\n body?: (data: unknown) => boolean;\n response: Record<string, (data: unknown) => boolean>;\n }>;\n validateBody: (operationId: string, data: unknown) => { ok: boolean; errors: unknown[] | null };\n validateResponse: (operationId: string, status: number, contentType: string, data: unknown) => { ok: boolean; errors: unknown[] | null };\n}\n\ninterface ArtifactCacheEntry {\n openapi: OpenApi | null;\n manifest: Manifest | null;\n validators: ValidatorModule | null;\n mtimes: {\n openapi: number | null;\n manifest: number | null;\n validators: number | null;\n };\n}\n\nconst artifactCache = new Map<string, ArtifactCacheEntry>();\n\nasync function getMtime(filePath: string): Promise<number | null> {\n try {\n const stats = await stat(filePath);\n return stats.mtimeMs;\n } catch {\n return null;\n }\n}\n\nexport interface LoadArtifactsOptions {\n outDir: string;\n}\n\nexport interface LoadedArtifacts {\n openapi: OpenApi;\n manifest: Manifest;\n validators: ValidatorModule | null;\n}\n\nexport async function loadArtifacts(options: LoadArtifactsOptions): Promise<LoadedArtifacts> {\n const { outDir } = options;\n const cacheKey = path.resolve(outDir);\n\n let entry = artifactCache.get(cacheKey);\n\n const openapiPath = path.join(outDir, \"openapi.json\");\n const manifestPath = path.join(outDir, \"manifest.json\");\n const validatorsPath = path.join(outDir, \"validators.mjs\");\n\n const openapiMtime = await getMtime(openapiPath);\n const manifestMtime = await getMtime(manifestPath);\n const validatorsMtime = await getMtime(validatorsPath);\n\n if (entry) {\n const mtimesMatch = \n entry.mtimes.openapi === openapiMtime &&\n entry.mtimes.manifest === manifestMtime &&\n entry.mtimes.validators === validatorsMtime;\n\n if (mtimesMatch) {\n if (entry.openapi && entry.manifest) {\n return {\n openapi: entry.openapi,\n manifest: entry.manifest,\n validators: entry.validators,\n };\n }\n }\n }\n\n const openapiContent = fs.readFileSync(openapiPath, \"utf-8\");\n const manifestContent = fs.readFileSync(manifestPath, \"utf-8\");\n\n const openapi = JSON.parse(openapiContent) as OpenApi;\n const manifest = JSON.parse(manifestContent) as Manifest;\n\n let validators: ValidatorModule | null = null;\n\n if (manifest.validation.mode === \"precompiled\" && manifest.validation.precompiledModule) {\n try {\n const validatorsModule = await import(path.join(outDir, manifest.validation.precompiledModule));\n validators = validatorsModule as ValidatorModule;\n } catch (err) {\n console.warn(`Failed to load precompiled validators: ${err}`);\n }\n }\n\n artifactCache.set(cacheKey, {\n openapi,\n manifest,\n validators,\n mtimes: {\n openapi: openapiMtime,\n manifest: manifestMtime,\n validators: validatorsMtime,\n },\n });\n\n return {\n openapi,\n manifest,\n validators,\n };\n}\n\nexport function clearArtifactCache(outDir?: string): void {\n if (outDir) {\n const cacheKey = path.resolve(outDir);\n artifactCache.delete(cacheKey);\n } else {\n artifactCache.clear();\n }\n}\n\nexport function getArtifactCacheStats(): { size: number; keys: string[] } {\n return {\n size: artifactCache.size,\n keys: Array.from(artifactCache.keys()),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,oBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEC,OAAe,aAAa,uBAAO,iBAAiB;;;ACF9C,IAAM,aAAa,uBAAO,IAAI,gBAAgB;;;ACG9C,SAAS,UAAU,UAA0C;AAClE,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,kGAAkG;AAAA,EACpH;AACA,MAAI,SAAS,SAAS,UAAU;AAChC,MAAI,CAAC,QAAQ;AACX,aAAS,EAAE,KAAK,CAAC,GAAG,eAAe,CAAC,EAAE;AACtC,aAAS,UAAU,IAAI;AAAA,EACzB;AACA,MAAI,CAAC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AM,WAAW,iBAAAA,QAAK,QAAQ,MAAM;AACpC,kBAAc,OAAO,QAAQ;AAAA,EAC/B,OAAO;AACL,kBAAc,MAAM;AAAA,EACtB;AACF;AAEO,SAAS,wBAA0D;AACxE,SAAO;AAAA,IACL,MAAM,cAAc;AAAA,IACpB,MAAM,MAAM,KAAK,cAAc,KAAK,CAAC;AAAA,EACvC;AACF;","names":["ADORN_META","path","op","op","op","op","ADORN_META","Ajv","addFormats","path","ADORN_META","path","fs"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/runtime/polyfill.ts","../src/runtime/metadata/key.ts","../src/runtime/metadata/bucket.ts","../src/decorators/Controller.ts","../src/decorators/methods.ts","../src/decorators/Use.ts","../src/decorators/Auth.ts","../src/decorators/Public.ts","../src/runtime/metadata/read.ts","../src/schema/decorators.ts","../src/runtime/validation/ajv.ts","../src/http.ts","../src/compiler/cache/loadArtifacts.ts","../src/utils/port.ts"],"sourcesContent":["import \"./runtime/polyfill.js\";\n\nexport { Controller, Get, Post, Put, Patch, Delete, Use, Auth, Public } from \"./decorators/index.js\";\nexport { readAdornBucket } from \"./runtime/metadata/read.js\";\nexport type { HttpMethod, RouteOperation, AdornBucket, AuthMeta, ExpressMw } from \"./runtime/metadata/types.js\";\nexport type { AuthSchemeRuntime, AuthResult } from \"./runtime/auth/runtime.js\";\nexport * from \"./schema/index.js\";\nexport { createValidator, formatValidationErrors, ValidationErrorResponse } from \"./runtime/validation/index.js\";\nexport { PartType, File, PartType as PartType2, Consumes, Produces } from \"./http.js\";\nexport type { Query, Body, Headers, Cookies, PaginationParams, PaginatedResponse, HttpMetadata, FilePartOptions } from \"./http.js\";\nexport type { UploadFile } from \"./runtime/upload.js\";\nexport { loadArtifacts, clearArtifactCache, getArtifactCacheStats } from \"./compiler/cache/loadArtifacts.js\";\nexport { isPortAvailable, findProcessOnPort, killProcess, waitForPort } from \"./utils/port.js\";\nexport type { ProcessInfo } from \"./utils/port.js\";\n","/**\n * Polyfill for Symbol.metadata in environments that don't natively support it.\n * This polyfill must run before any decorated classes are imported to ensure\n * the metadata API is available for decorator metadata storage.\n * \n * @remarks\n * This module provides a global polyfill for the `Symbol.metadata` well-known symbol.\n * Some JavaScript environments (like older browsers or non-standard runtimes) may not\n * natively support this symbol, which is required by the adorn-api decorator system.\n * \n * @example\n * ```typescript\n * // Import this first before any decorated classes\n * import \"adorn-api/runtime/polyfill\";\n * \n * // Now decorators can safely use Symbol.metadata\n * @Controller()\n * class MyController { }\n * ```\n * \n * @package\n */\n(Symbol as any).metadata ??= Symbol(\"Symbol.metadata\");\n\n/**\n * Export symbol to prevent tree-shaking of the polyfill module.\n * This ensures the polyfill code is retained in production builds.\n * \n * @internal\n */\nexport const ADORN_POLYFILL = Symbol(\"adorn-polyfill\");\n","/**\n * Symbol key used to store Adorn metadata in class decorator metadata.\n * \n * @remarks\n * This Symbol.for() call creates a global symbol that is used as the key\n * for storing Adorn-specific metadata in the decorator metadata store.\n * Using Symbol.for() ensures the same symbol is used across different\n * module loads.\n * \n * @internal\n */\nexport const ADORN_META = Symbol.for(\"adorn-api/meta\");\n","import { ADORN_META } from \"./key.js\";\nimport type { AdornBucket } from \"./types.js\";\n\n/**\n * Retrieves the AdornBucket from decorator metadata, creating it if necessary.\n * \n * @remarks\n * This function safely accesses the AdornBucket stored in decorator metadata.\n * If the bucket doesn't exist, it creates a new one with default values.\n * The bucket is stored under the ADORN_META symbol key.\n * \n * @param metadata - The decorator context metadata object\n * @returns The AdornBucket for the decorated class\n * @throws Error if metadata is undefined (polyfill not loaded)\n * \n * @internal\n */\nexport function getBucket(metadata: DecoratorMetadata): AdornBucket {\n if (!metadata) {\n throw new Error(\"Decorator context.metadata is undefined. Ensure Symbol.metadata polyfill runs before decorators.\");\n }\n let bucket = metadata[ADORN_META] as AdornBucket | undefined;\n if (!bucket) {\n bucket = { ops: [], controllerUse: [] };\n metadata[ADORN_META] = bucket;\n }\n if (!bucket.controllerUse) {\n bucket.controllerUse = [];\n }\n return bucket;\n}\n","import { getBucket } from \"../runtime/metadata/bucket.js\";\n\n/**\n * Decorator to mark a class as a controller with a base path.\n * All methods in the controller will be relative to this base path.\n * \n * @param basePath - The base path for all routes in this controller\n * \n * @example\n * ```ts\n * @Controller(\"/users\")\n * export class UsersController {\n * @Get(\"/:id\")\n * getUser() { }\n * }\n * ```\n */\nexport function Controller(basePath: string) {\n return function <T extends new (...args: any[]) => any>(\n target: T,\n context: ClassDecoratorContext<T>\n ): T | void {\n const bucket = getBucket(context.metadata);\n bucket.basePath = basePath;\n };\n}\n","import { getBucket } from \"../runtime/metadata/bucket.js\";\nimport type { HttpMethod } from \"../runtime/metadata/types.js\";\n\nfunction createMethodDecorator(httpMethod: HttpMethod, path: string) {\n return function <T extends (...args: any[]) => any>(\n target: T,\n context: ClassMethodDecoratorContext<any, T>\n ): T | void {\n if (context.private || context.static) {\n return;\n }\n\n const methodName = String(context.name);\n const bucket = getBucket(context.metadata);\n\n let op = bucket.ops.find(op => op.methodName === methodName);\n if (!op) {\n op = {\n httpMethod,\n path,\n methodName,\n };\n bucket.ops.push(op);\n } else {\n op.httpMethod = httpMethod;\n op.path = path;\n }\n };\n}\n\n/**\n * Creates a method decorator for HTTP GET requests.\n * @param path - The route path for this endpoint\n */\nexport const Get = (path: string) => createMethodDecorator(\"GET\", path);\n\n/**\n * Creates a method decorator for HTTP POST requests.\n * @param path - The route path for this endpoint\n */\nexport const Post = (path: string) => createMethodDecorator(\"POST\", path);\n\n/**\n * Creates a method decorator for HTTP PUT requests.\n * @param path - The route path for this endpoint\n */\nexport const Put = (path: string) => createMethodDecorator(\"PUT\", path);\n\n/**\n * Creates a method decorator for HTTP PATCH requests.\n * @param path - The route path for this endpoint\n */\nexport const Patch = (path: string) => createMethodDecorator(\"PATCH\", path);\n\n/**\n * Creates a method decorator for HTTP DELETE requests.\n * @param path - The route path for this endpoint\n */\nexport const Delete = (path: string) => createMethodDecorator(\"DELETE\", path);\n","import { getBucket } from \"../runtime/metadata/bucket.js\";\nimport type { ExpressMw, HttpMethod } from \"../runtime/metadata/types.js\";\n\ntype UseTarget = string | ExpressMw;\n\n/**\n * Decorator to apply middleware to a controller class or individual methods.\n * \n * @param middleware - One or more middleware functions or paths (for path-specific middleware)\n * \n * @example\n * ```ts\n * // Apply to entire controller\n * @Use(cors(), helmet())\n * @Controller(\"/api\")\n * class ApiController { }\n * \n * // Apply to specific method\n * @Use(express.json())\n * @Post(\"/upload\")\n * uploadFile() { }\n * ```\n */\nexport function Use(...middleware: UseTarget[]) {\n return function (\n target: any,\n context: ClassDecoratorContext | ClassMethodDecoratorContext\n ) {\n if (context.kind === \"class\") {\n const bucket = getBucket(context.metadata);\n if (!bucket.controllerUse) {\n bucket.controllerUse = [];\n }\n bucket.controllerUse.push(...middleware);\n } else if (context.kind === \"method\") {\n const methodName = String(context.name);\n const bucket = getBucket(context.metadata);\n let op = bucket.ops.find(op => op.methodName === methodName);\n if (!op) {\n op = {\n httpMethod: \"GET\" as HttpMethod,\n path: \"/\",\n methodName,\n };\n bucket.ops.push(op);\n }\n if (!op.use) {\n op.use = [];\n }\n op.use.push(...middleware);\n } else {\n throw new Error(\"@Use decorator can only be applied to classes or methods\");\n }\n };\n}\n","import { getBucket } from \"../runtime/metadata/bucket.js\";\nimport type { HttpMethod } from \"../runtime/metadata/types.js\";\n\n/**\n * Decorator to mark a method as requiring authentication.\n * \n * @param scheme - The authentication scheme to use (e.g., \"Bearer\", \"Basic\")\n * @param options - Optional authentication configuration\n * @param options.scopes - Required permission scopes for this endpoint\n * @param options.optional - If true, authentication is optional (useful for mixed auth endpoints)\n * \n * @example\n * ```ts\n * @Auth(\"Bearer\", { scopes: [\"admin\"] })\n * @Delete(\"/users/:id\")\n * deleteUser() {\n * // Implementation\n * }\n * ```\n */\nexport function Auth(scheme: string, options?: { scopes?: string[]; optional?: boolean }) {\n return function (\n target: any,\n context: ClassMethodDecoratorContext\n ) {\n if (context.kind !== \"method\") {\n throw new Error(\"@Auth decorator can only be applied to methods\");\n }\n\n const methodName = String(context.name);\n const bucket = getBucket(context.metadata);\n let op = bucket.ops.find(op => op.methodName === methodName);\n if (!op) {\n op = {\n httpMethod: \"GET\" as HttpMethod,\n path: \"/\",\n methodName,\n };\n bucket.ops.push(op);\n }\n\n op.auth = {\n scheme,\n scopes: options?.scopes,\n optional: options?.optional ?? false,\n };\n };\n}\n","import { getBucket } from \"../runtime/metadata/bucket.js\";\nimport type { HttpMethod } from \"../runtime/metadata/types.js\";\n\n/**\n * Decorator to mark a method as public (no authentication required).\n * Use this to explicitly allow unauthenticated access to specific endpoints.\n * \n * @example\n * ```ts\n * @Public()\n * @Get(\"/health\")\n * healthCheck() {\n * return { status: \"ok\" };\n * }\n * ```\n */\nexport function Public() {\n return function (\n target: any,\n context: ClassMethodDecoratorContext\n ) {\n if (context.kind !== \"method\") {\n throw new Error(\"@Public decorator can only be applied to methods\");\n }\n\n const methodName = String(context.name);\n const bucket = getBucket(context.metadata);\n let op = bucket.ops.find(op => op.methodName === methodName);\n if (!op) {\n op = {\n httpMethod: \"GET\" as HttpMethod,\n path: \"/\",\n methodName,\n };\n bucket.ops.push(op);\n }\n\n op.auth = \"public\";\n };\n}\n","import { ADORN_META } from \"./key.js\";\nimport type { AdornBucket } from \"./types.js\";\n\n/**\n * Reads the AdornBucket metadata from a class constructor.\n * \n * @remarks\n * This function retrieves the AdornBucket stored on a class via the\n * Symbol.metadata mechanism. It safely handles cases where metadata\n * is not available (e.g., polyfill not loaded or class not decorated).\n * \n * @param ctor - The class constructor to read metadata from\n * @returns The AdornBucket if found, or null if not available\n * \n * @example\n * ```typescript\n * @Controller()\n * class MyController { }\n * \n * const bucket = readAdornBucket(MyController);\n * if (bucket) {\n * console.log(bucket.ops);\n * }\n * ```\n * \n * @internal\n */\nexport function readAdornBucket(ctor: Function): AdornBucket | null {\n const metaSym = (Symbol as any).metadata as symbol | undefined;\n if (!metaSym) {\n return null;\n }\n\n const classMetadata = (ctor as any)[metaSym] as DecoratorMetadata | undefined;\n if (!classMetadata) {\n return null;\n }\n\n const bucket = classMetadata[ADORN_META] as AdornBucket | undefined;\n return bucket ?? null;\n}\n","const ADORN_META = Symbol.for(\"adorn-api.metadata\");\n\ninterface SchemaFrag {\n [key: string]: unknown;\n}\n\ninterface SchemaMetadata {\n schema: {\n props: Record<string, SchemaFrag[]>;\n };\n}\n\nfunction getOrCreateMetadata(metadata: Record<PropertyKey, unknown>): SchemaMetadata {\n const meta = (metadata[ADORN_META] ??= {}) as SchemaMetadata;\n meta.schema ??= { props: {} };\n return meta;\n}\n\nfunction pushSchemaFrag(\n target: Object,\n propertyKey: string | symbol,\n metadata: Record<PropertyKey, unknown>,\n frag: SchemaFrag\n): void {\n const meta = getOrCreateMetadata(metadata);\n const props = meta.schema.props;\n (props[propertyKey as string] ??= []).push(frag);\n}\n\ntype PropertyDecorator = (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void;\n\nexport function Schema(frag: SchemaFrag): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, frag);\n };\n}\n\nexport function Min(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { minimum: n });\n };\n}\n\nexport function Max(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { maximum: n });\n };\n}\n\nexport function ExclusiveMin(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { exclusiveMinimum: n });\n };\n}\n\nexport function ExclusiveMax(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { exclusiveMaximum: n });\n };\n}\n\nexport function MinLength(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { minLength: n });\n };\n}\n\nexport function MaxLength(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { maxLength: n });\n };\n}\n\nexport function Pattern(re: RegExp | string): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { pattern: typeof re === \"string\" ? re : re.source });\n };\n}\n\nexport function Format(fmt: string): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { format: fmt });\n };\n}\n\nexport function MinItems(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { minItems: n });\n };\n}\n\nexport function MaxItems(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { maxItems: n });\n };\n}\n\nexport function MinProperties(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { minProperties: n });\n };\n}\n\nexport function MaxProperties(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { maxProperties: n });\n };\n}\n\nexport function MultipleOf(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { multipleOf: n });\n };\n}\n\nexport function Example(value: unknown): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { example: value });\n };\n}\n\nexport function Examples(values: unknown[]): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { examples: values });\n };\n}\n\nexport function Description(desc: string): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { description: desc });\n };\n}\n\nexport function Enum<T extends string | number>(vals: T[]): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { enum: vals });\n };\n}\n\nexport function Const<T>(val: T): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { const: val });\n };\n}\n\nexport function Default<T>(val: T): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { default: val });\n };\n}\n\nexport function AdditionalProperties(value: boolean | Record<string, unknown>): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { additionalProperties: value });\n };\n}\n\nexport function Closed(): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { additionalProperties: false });\n };\n}\n\nexport function ClosedUnevaluated(): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { unevaluatedProperties: false });\n };\n}\n\nexport function Union(mode: \"anyOf\" | \"oneOf\" | \"allOf\"): ClassDecorator {\n return function (target: Function): void {\n (target as any)[ADORN_META] = (target as any)[ADORN_META] ?? {};\n const meta = (target as any)[ADORN_META] as SchemaMetadata;\n meta.schema = meta.schema ?? { props: {} };\n (meta.schema as any).unionMode = mode;\n };\n}\n\nexport { ADORN_META };\nexport type { SchemaFrag, SchemaMetadata };\n","import Ajv from \"ajv\";\nimport addFormats from \"ajv-formats\";\nimport type { ErrorObject } from \"ajv\";\n\n/**\n * Runtime validation module using AJV.\n * \n * @remarks\n * This module provides validation utilities using the AJV JSON schema validator.\n * It includes interfaces for validation results, errors, and helper functions\n * for creating validators and formatting error messages.\n * \n * @package\n */\n\n/**\n * Represents a single validation error with details.\n * \n * @public\n */\nexport interface ValidationError {\n /**\n * The JSON path to the invalid property.\n */\n path: string;\n \n /**\n * Human-readable error message.\n */\n message: string;\n \n /**\n * The AJV keyword that failed validation.\n */\n keyword: string;\n \n /**\n * Additional parameters from the validation error.\n */\n params: Record<string, unknown>;\n}\n\n/**\n * Result of a validation operation.\n * \n * @public\n */\nexport interface ValidationResult {\n /**\n * Whether the data passed validation.\n */\n valid: boolean;\n \n /**\n * Array of validation errors if validation failed, null otherwise.\n */\n errors: ValidationError[] | null;\n}\n\n/**\n * Error thrown when request validation fails.\n * \n * @public\n */\nexport class ValidationErrorResponse extends Error {\n /**\n * HTTP status code for validation errors.\n */\n statusCode: number;\n \n /**\n * Detailed validation errors.\n */\n errors: ValidationError[];\n\n /**\n * Creates a new ValidationErrorResponse.\n * \n * @param statusCode - HTTP status code (typically 400)\n * @param errors - Array of validation errors\n */\n constructor(statusCode: number, errors: ValidationError[]) {\n super(\"Validation failed\");\n this.name = \"ValidationErrorResponse\";\n this.statusCode = statusCode;\n this.errors = errors;\n }\n}\n\n/**\n * Creates a configured AJV validator instance.\n * \n * @remarks\n * This function creates an AJV validator with adorn-api's default configuration,\n * including support for custom formats like \"br-phone\" for Brazilian phone numbers.\n * \n * @returns A configured AJV validator instance\n * \n * @example\n * ```typescript\n * const validator = createValidator();\n * const validate = validator.compile(mySchema);\n * const result = validate(myData);\n * ```\n * \n * @public\n */\nexport function createValidator() {\n const ajv = new Ajv.default({\n allErrors: true,\n coerceTypes: false,\n strict: false,\n validateFormats: true,\n });\n\n addFormats.default(ajv);\n\n ajv.addFormat(\"br-phone\", /^\\(\\d{2}\\)\\s\\d{5}-\\d{4}$/);\n\n return ajv;\n}\n\n/**\n * Validates data against a JSON schema.\n * \n * @remarks\n * This function compiles the schema and validates the data, returning a\n * structured result with formatted error messages.\n * \n * @param ajv - The AJV validator instance\n * @param data - The data to validate\n * @param schema - The JSON schema to validate against\n * @param dataPath - Base path for error messages (default: \"#\")\n * @returns ValidationResult with validity and any errors\n * \n * @public\n */\nexport function validateData(\n ajv: ReturnType<typeof createValidator>,\n data: unknown,\n schema: Record<string, unknown>,\n dataPath: string = \"#\"\n): ValidationResult {\n const validate = ajv.compile(schema);\n const valid = validate(data);\n\n if (valid) {\n return { valid: true, errors: null };\n }\n\n const errors: ValidationError[] = (validate.errors || []).map((err: ErrorObject) => ({\n path: formatErrorPath(dataPath, err),\n message: err.message || \"Invalid value\",\n keyword: err.keyword,\n params: err.params as Record<string, unknown>,\n }));\n\n return { valid: false, errors };\n}\n\n/**\n * Formats an error path for display.\n * \n * @internal\n */\nfunction formatErrorPath(basePath: string, err: ErrorObject): string {\n const instancePath = err.instancePath;\n\n if (!instancePath || instancePath === \"\") {\n return basePath;\n }\n\n if (basePath === \"#\" || basePath.endsWith(\"/\")) {\n return `${basePath}${instancePath.slice(1)}`;\n }\n\n return `${basePath}${instancePath}`;\n}\n\n/**\n * Formats validation errors into a structured API response.\n * \n * @remarks\n * This function converts validation errors into a format suitable for API\n * responses, grouping errors by their path.\n * \n * @param errors - Array of validation errors\n * @returns Formatted error response object\n * \n * @public\n */\nexport function formatValidationErrors(errors: ValidationError[]): Record<string, unknown> {\n const formatted: Record<string, string[]> = {};\n\n for (const error of errors) {\n const path = error.path || \"body\";\n if (!formatted[path]) {\n formatted[path] = [];\n }\n formatted[path].push(error.message);\n }\n\n return {\n error: \"Validation failed\",\n details: formatted,\n };\n}\n","import \"./runtime/polyfill.js\";\n\nconst ADORN_META = Symbol.for(\"adorn-api.metadata\");\n\ninterface HttpMetadata {\n consumes?: string[];\n produces?: string[];\n fileParts?: Record<string, FilePartOptions>;\n cookies?: Record<string, boolean>;\n}\n\ninterface FilePartOptions {\n contentType?: string;\n headers?: Record<string, string>;\n}\n\ntype DecoratorMetadata = Record<PropertyKey, unknown> & { [ADORN_META]?: HttpMetadata };\n\nfunction getMetadata(target: Object | DecoratorMetadata): HttpMetadata {\n const host = target as DecoratorMetadata;\n const metadata = host[ADORN_META] ?? {};\n host[ADORN_META] = metadata;\n return metadata;\n}\n\nexport function PartType(contentTypeOrOptions: string | FilePartOptions): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n const metadata = getMetadata(target);\n const options: FilePartOptions = typeof contentTypeOrOptions === \"string\"\n ? { contentType: contentTypeOrOptions }\n : contentTypeOrOptions;\n metadata.fileParts ??= {};\n metadata.fileParts[propertyKey.toString()] = options;\n };\n}\n\nexport function File(): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n const metadata = getMetadata(target);\n metadata.fileParts ??= {};\n metadata.fileParts[propertyKey.toString()] = metadata.fileParts[propertyKey.toString()] ?? {};\n };\n}\n\nexport function Consumes(...contentTypes: string[]): ClassDecorator {\n return function (target: Function): void {\n const metadata = getMetadata(target.prototype);\n metadata.consumes = contentTypes;\n };\n}\n\nexport function Produces(...contentTypes: string[]): ClassDecorator {\n return function (target: Function): void {\n const metadata = getMetadata(target.prototype);\n metadata.produces = contentTypes;\n };\n}\n\nexport type Query<T = any> = T;\nexport type Body<T = any> = T;\nexport type Headers<T = any> = T;\nexport type Cookies<T = any> = T;\n\nexport interface PaginationParams {\n page: number;\n pageSize: number;\n}\n\nexport type PaginatedResponse<T> = {\n items: T[];\n totalItems: number;\n page: number;\n pageSize: number;\n};\n\nexport { ADORN_META };\nexport type { HttpMetadata, FilePartOptions, PartType as PartType2 };\n","/**\n * Cache management module for compiled artifacts.\n * Loads OpenAPI specs, manifests, and validators from the output directory.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { stat } from \"node:fs/promises\";\n\n/**\n * OpenAPI specification interface as loaded from openapi.json\n */\ninterface OpenApi {\n openapi: string;\n components?: {\n schemas?: Record<string, unknown>;\n };\n paths?: Record<string, unknown>;\n info?: Record<string, unknown>;\n security?: Array<Record<string, string[]>>;\n}\n\n/**\n * Manifest interface describing the compiled API structure.\n * Contains metadata about the generation process and all controllers/operations.\n */\ninterface Manifest {\n manifestVersion: number;\n generatedAt: string;\n generator: {\n name: string;\n version: string;\n typescript: string;\n };\n schemas: {\n kind: string;\n file: string;\n componentsSchemasPointer: string;\n };\n validation: {\n mode: \"none\" | \"ajv-runtime\" | \"precompiled\";\n precompiledModule: string | null;\n };\n controllers: Array<{\n controllerId: string;\n basePath: string;\n operations: Array<{\n operationId: string;\n http: {\n method: string;\n path: string;\n };\n handler: {\n methodName: string;\n };\n args: {\n body: {\n index: number;\n required: boolean;\n contentType: string;\n schemaRef: string;\n } | null;\n path: Array<{\n name: string;\n index: number;\n required: boolean;\n schemaRef: string;\n schemaType?: string | string[];\n }>;\n query: Array<{\n name: string;\n index: number;\n required: boolean;\n schemaRef: string;\n schemaType?: string | string[];\n }>;\n headers: Array<{\n name: string;\n index: number;\n required: boolean;\n schemaRef: string;\n schemaType?: string | string[];\n }>;\n cookies: Array<{\n name: string;\n index: number;\n required: boolean;\n schemaRef: string;\n schemaType?: string | string[];\n }>;\n };\n responses: Array<{\n status: number;\n contentType: string;\n schemaRef: string;\n isArray?: boolean;\n }>;\n }>;\n }>;\n}\n\n/**\n * Validator module interface for precompiled validation logic.\n */\ninterface ValidatorModule {\n validators: Record<string, {\n body?: (data: unknown) => boolean;\n response: Record<string, (data: unknown) => boolean>;\n }>;\n validateBody: (operationId: string, data: unknown) => { ok: boolean; errors: unknown[] | null };\n validateResponse: (operationId: string, status: number, contentType: string, data: unknown) => { ok: boolean; errors: unknown[] | null };\n}\n\n/**\n * Internal cache entry for tracking loaded artifacts and their modification times.\n */\ninterface ArtifactCacheEntry {\n openapi: OpenApi | null;\n manifest: Manifest | null;\n validators: ValidatorModule | null;\n mtimes: {\n openapi: number | null;\n manifest: number | null;\n validators: number | null;\n };\n}\n\nconst artifactCache = new Map<string, ArtifactCacheEntry>();\n\nasync function getMtime(filePath: string): Promise<number | null> {\n try {\n const stats = await stat(filePath);\n return stats.mtimeMs;\n } catch {\n return null;\n }\n}\n\n/**\n * Options for loading artifacts from the output directory.\n */\nexport interface LoadArtifactsOptions {\n outDir: string;\n}\n\n/**\n * Result of loading artifacts from the output directory.\n */\nexport interface LoadedArtifacts {\n openapi: OpenApi;\n manifest: Manifest;\n validators: ValidatorModule | null;\n}\n\n/**\n * Loads OpenAPI spec, manifest, and validators from the output directory.\n * Results are cached in memory to avoid repeated file I/O.\n * \n * @param options - Object containing the output directory path\n * @returns Promise resolving to loaded artifacts including OpenAPI spec, manifest, and validators\n */\nexport async function loadArtifacts(options: LoadArtifactsOptions): Promise<LoadedArtifacts> {\n const { outDir } = options;\n const cacheKey = path.resolve(outDir);\n\n const entry = artifactCache.get(cacheKey);\n\n const openapiPath = path.join(outDir, \"openapi.json\");\n const manifestPath = path.join(outDir, \"manifest.json\");\n const validatorsPath = path.join(outDir, \"validators.mjs\");\n\n const openapiMtime = await getMtime(openapiPath);\n const manifestMtime = await getMtime(manifestPath);\n const validatorsMtime = await getMtime(validatorsPath);\n\n if (entry) {\n const mtimesMatch = \n entry.mtimes.openapi === openapiMtime &&\n entry.mtimes.manifest === manifestMtime &&\n entry.mtimes.validators === validatorsMtime;\n\n if (mtimesMatch) {\n if (entry.openapi && entry.manifest) {\n return {\n openapi: entry.openapi,\n manifest: entry.manifest,\n validators: entry.validators,\n };\n }\n }\n }\n\n const openapiContent = fs.readFileSync(openapiPath, \"utf-8\");\n const manifestContent = fs.readFileSync(manifestPath, \"utf-8\");\n\n const openapi = JSON.parse(openapiContent) as OpenApi;\n const manifest = JSON.parse(manifestContent) as Manifest;\n\n let validators: ValidatorModule | null = null;\n\n if (manifest.validation.mode === \"precompiled\" && manifest.validation.precompiledModule) {\n try {\n const validatorsModule = await import(path.join(outDir, manifest.validation.precompiledModule));\n validators = validatorsModule as ValidatorModule;\n } catch (err) {\n console.warn(`Failed to load precompiled validators: ${err}`);\n }\n }\n\n artifactCache.set(cacheKey, {\n openapi,\n manifest,\n validators,\n mtimes: {\n openapi: openapiMtime,\n manifest: manifestMtime,\n validators: validatorsMtime,\n },\n });\n\n return {\n openapi,\n manifest,\n validators,\n };\n}\n\n/**\n * Clears the in-memory artifact cache.\n * If an output directory is specified, only that entry is removed.\n * Otherwise, the entire cache is cleared.\n * \n * @param outDir - Optional specific output directory to clear from cache\n */\nexport function clearArtifactCache(outDir?: string): void {\n if (outDir) {\n const cacheKey = path.resolve(outDir);\n artifactCache.delete(cacheKey);\n } else {\n artifactCache.clear();\n }\n}\n\n/**\n * Returns statistics about the current artifact cache state.\n * Useful for debugging and monitoring cache behavior.\n * \n * @returns Object containing cache size and array of cached keys\n */\nexport function getArtifactCacheStats(): { size: number; keys: string[] } {\n return {\n size: artifactCache.size,\n keys: Array.from(artifactCache.keys()),\n };\n}\n","import { createServer, Server } from \"net\";\nimport { exec } from \"child_process\";\nimport { promisify } from \"util\";\n\nconst execAsync = promisify(exec);\n\nexport interface ProcessInfo {\n pid: number;\n command?: string;\n}\n\nexport async function isPortAvailable(port: number, host: string = \"0.0.0.0\"): Promise<boolean> {\n return new Promise<boolean>((resolve) => {\n const server: Server = createServer();\n\n server.on(\"error\", (err: any) => {\n if (err.code === \"EADDRINUSE\") {\n resolve(false);\n } else {\n resolve(false);\n }\n });\n\n server.once(\"listening\", () => {\n server.close(() => {\n resolve(true);\n });\n });\n\n server.listen(port, host);\n });\n}\n\nexport async function findProcessOnPort(port: number): Promise<ProcessInfo | null> {\n try {\n const platform = process.platform;\n\n if (platform === \"win32\") {\n const { stdout } = await execAsync(`netstat -ano | findstr :${port}`);\n \n for (const line of stdout.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.includes(\"PID\")) continue;\n \n const parts = trimmed.split(/\\s+/);\n if (parts.length >= 5) {\n const address = parts[1];\n const pid = parseInt(parts[parts.length - 1], 10);\n \n if (address.includes(`:${port}`) && !isNaN(pid)) {\n const command = await getProcessNameOnWindows(pid);\n return { pid, command };\n }\n }\n }\n } else {\n const { stdout } = await execAsync(`lsof -ti:${port}`);\n const pids = stdout.trim().split(\"\\n\").filter(Boolean).map(Number);\n \n if (pids.length > 0) {\n const pid = pids[0];\n const command = await getProcessNameOnUnix(pid);\n return { pid, command };\n }\n }\n\n return null;\n } catch (error: any) {\n if (error.message.includes(\"matches found\")) {\n return null;\n }\n return null;\n }\n}\n\nasync function getProcessNameOnWindows(pid: number): Promise<string | undefined> {\n try {\n const { stdout } = await execAsync(`tasklist /FI \"PID eq ${pid}\" /FO CSV /NH`);\n const line = stdout.trim().split(\"\\n\")[0];\n if (line) {\n const parts = line.split('\",\"');\n if (parts.length >= 2) {\n return parts[0].replace(/\"/g, \"\");\n }\n }\n } catch {\n return undefined;\n }\n}\n\nasync function getProcessNameOnUnix(pid: number): Promise<string | undefined> {\n try {\n const { stdout } = await execAsync(`ps -p ${pid} -o comm=`);\n return stdout.trim() || undefined;\n } catch {\n return undefined;\n }\n}\n\nexport async function killProcess(pid: number): Promise<boolean> {\n try {\n process.kill(pid, \"SIGTERM\");\n \n await new Promise<void>((resolve, reject) => {\n const timeout = setTimeout(() => {\n reject(new Error(\"Process did not terminate gracefully\"));\n }, 5000);\n \n const check = () => {\n try {\n process.kill(pid, 0);\n setTimeout(check, 500);\n } catch {\n clearInterval(interval);\n clearTimeout(timeout);\n resolve();\n }\n };\n \n const interval = setInterval(check, 500);\n });\n \n return true;\n } catch {\n try {\n process.kill(pid, \"SIGKILL\");\n await new Promise<void>((resolve, reject) => {\n const timeout = setTimeout(() => {\n reject(new Error(\"Process did not terminate\"));\n }, 3000);\n \n setTimeout(() => {\n try {\n process.kill(pid, 0);\n clearTimeout(timeout);\n reject(new Error(\"Process still running\"));\n } catch {\n clearTimeout(timeout);\n resolve();\n }\n }, 1000);\n });\n \n return true;\n } catch {\n return false;\n }\n }\n}\n\nexport async function waitForPort(port: number, host: string = \"0.0.0.0\", timeout: number = 5000): Promise<boolean> {\n const start = Date.now();\n \n while (Date.now() - start < timeout) {\n if (await isPortAvailable(port, host)) {\n return true;\n }\n await new Promise(resolve => setTimeout(resolve, 200));\n }\n \n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,oBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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,mBAAO,IAAI,MAAM,uBAAuB,CAAC;AAAA,UAC3C,QAAQ;AACN,yBAAa,OAAO;AACpB,oBAAQ;AAAA,UACV;AAAA,QACF,GAAG,GAAI;AAAA,MACT,CAAC;AAED,aAAO;AAAA,IACT,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEA,eAAsB,YAAY,MAAc,OAAe,WAAW,UAAkB,KAAwB;AAClH,QAAM,QAAQ,KAAK,IAAI;AAEvB,SAAO,KAAK,IAAI,IAAI,QAAQ,SAAS;AACnC,QAAI,MAAM,gBAAgB,MAAM,IAAI,GAAG;AACrC,aAAO;AAAA,IACT;AACA,UAAM,IAAI,QAAQ,aAAW,WAAW,SAAS,GAAG,CAAC;AAAA,EACvD;AAEA,SAAO;AACT;","names":["ADORN_META","path","op","op","op","op","ADORN_META","Ajv","addFormats","path","ADORN_META","path","fs"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,4 +9,6 @@ export { PartType, File, PartType as PartType2, Consumes, Produces } from "./htt
|
|
|
9
9
|
export type { Query, Body, Headers, Cookies, PaginationParams, PaginatedResponse, HttpMetadata, FilePartOptions } from "./http.js";
|
|
10
10
|
export type { UploadFile } from "./runtime/upload.js";
|
|
11
11
|
export { loadArtifacts, clearArtifactCache, getArtifactCacheStats } from "./compiler/cache/loadArtifacts.js";
|
|
12
|
+
export { isPortAvailable, findProcessOnPort, killProcess, waitForPort } from "./utils/port.js";
|
|
13
|
+
export type { ProcessInfo } from "./utils/port.js";
|
|
12
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,E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O,EAAE,eAAe,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACjH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,IAAI,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACtF,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACnI,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC7G,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC/F,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -287,11 +287,25 @@ function Union(mode) {
|
|
|
287
287
|
import Ajv from "ajv";
|
|
288
288
|
import addFormats from "ajv-formats";
|
|
289
289
|
var ValidationErrorResponse = class extends Error {
|
|
290
|
+
/**
|
|
291
|
+
* HTTP status code for validation errors.
|
|
292
|
+
*/
|
|
293
|
+
statusCode;
|
|
294
|
+
/**
|
|
295
|
+
* Detailed validation errors.
|
|
296
|
+
*/
|
|
297
|
+
errors;
|
|
298
|
+
/**
|
|
299
|
+
* Creates a new ValidationErrorResponse.
|
|
300
|
+
*
|
|
301
|
+
* @param statusCode - HTTP status code (typically 400)
|
|
302
|
+
* @param errors - Array of validation errors
|
|
303
|
+
*/
|
|
290
304
|
constructor(statusCode, errors) {
|
|
291
305
|
super("Validation failed");
|
|
306
|
+
this.name = "ValidationErrorResponse";
|
|
292
307
|
this.statusCode = statusCode;
|
|
293
308
|
this.errors = errors;
|
|
294
|
-
this.name = "ValidationErrorResponse";
|
|
295
309
|
}
|
|
296
310
|
};
|
|
297
311
|
function createValidator() {
|
|
@@ -372,7 +386,7 @@ async function getMtime(filePath) {
|
|
|
372
386
|
async function loadArtifacts(options) {
|
|
373
387
|
const { outDir } = options;
|
|
374
388
|
const cacheKey = path.resolve(outDir);
|
|
375
|
-
|
|
389
|
+
const entry = artifactCache.get(cacheKey);
|
|
376
390
|
const openapiPath = path.join(outDir, "openapi.json");
|
|
377
391
|
const manifestPath = path.join(outDir, "manifest.json");
|
|
378
392
|
const validatorsPath = path.join(outDir, "validators.mjs");
|
|
@@ -434,6 +448,141 @@ function getArtifactCacheStats() {
|
|
|
434
448
|
keys: Array.from(artifactCache.keys())
|
|
435
449
|
};
|
|
436
450
|
}
|
|
451
|
+
|
|
452
|
+
// src/utils/port.ts
|
|
453
|
+
import { createServer } from "net";
|
|
454
|
+
import { exec } from "child_process";
|
|
455
|
+
import { promisify } from "util";
|
|
456
|
+
var execAsync = promisify(exec);
|
|
457
|
+
async function isPortAvailable(port, host = "0.0.0.0") {
|
|
458
|
+
return new Promise((resolve) => {
|
|
459
|
+
const server = createServer();
|
|
460
|
+
server.on("error", (err) => {
|
|
461
|
+
if (err.code === "EADDRINUSE") {
|
|
462
|
+
resolve(false);
|
|
463
|
+
} else {
|
|
464
|
+
resolve(false);
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
server.once("listening", () => {
|
|
468
|
+
server.close(() => {
|
|
469
|
+
resolve(true);
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
server.listen(port, host);
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
async function findProcessOnPort(port) {
|
|
476
|
+
try {
|
|
477
|
+
const platform = process.platform;
|
|
478
|
+
if (platform === "win32") {
|
|
479
|
+
const { stdout } = await execAsync(`netstat -ano | findstr :${port}`);
|
|
480
|
+
for (const line of stdout.split("\n")) {
|
|
481
|
+
const trimmed = line.trim();
|
|
482
|
+
if (!trimmed || trimmed.includes("PID")) continue;
|
|
483
|
+
const parts = trimmed.split(/\s+/);
|
|
484
|
+
if (parts.length >= 5) {
|
|
485
|
+
const address = parts[1];
|
|
486
|
+
const pid = parseInt(parts[parts.length - 1], 10);
|
|
487
|
+
if (address.includes(`:${port}`) && !isNaN(pid)) {
|
|
488
|
+
const command = await getProcessNameOnWindows(pid);
|
|
489
|
+
return { pid, command };
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
} else {
|
|
494
|
+
const { stdout } = await execAsync(`lsof -ti:${port}`);
|
|
495
|
+
const pids = stdout.trim().split("\n").filter(Boolean).map(Number);
|
|
496
|
+
if (pids.length > 0) {
|
|
497
|
+
const pid = pids[0];
|
|
498
|
+
const command = await getProcessNameOnUnix(pid);
|
|
499
|
+
return { pid, command };
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return null;
|
|
503
|
+
} catch (error) {
|
|
504
|
+
if (error.message.includes("matches found")) {
|
|
505
|
+
return null;
|
|
506
|
+
}
|
|
507
|
+
return null;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
async function getProcessNameOnWindows(pid) {
|
|
511
|
+
try {
|
|
512
|
+
const { stdout } = await execAsync(`tasklist /FI "PID eq ${pid}" /FO CSV /NH`);
|
|
513
|
+
const line = stdout.trim().split("\n")[0];
|
|
514
|
+
if (line) {
|
|
515
|
+
const parts = line.split('","');
|
|
516
|
+
if (parts.length >= 2) {
|
|
517
|
+
return parts[0].replace(/"/g, "");
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
} catch {
|
|
521
|
+
return void 0;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
async function getProcessNameOnUnix(pid) {
|
|
525
|
+
try {
|
|
526
|
+
const { stdout } = await execAsync(`ps -p ${pid} -o comm=`);
|
|
527
|
+
return stdout.trim() || void 0;
|
|
528
|
+
} catch {
|
|
529
|
+
return void 0;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
async function killProcess(pid) {
|
|
533
|
+
try {
|
|
534
|
+
process.kill(pid, "SIGTERM");
|
|
535
|
+
await new Promise((resolve, reject) => {
|
|
536
|
+
const timeout = setTimeout(() => {
|
|
537
|
+
reject(new Error("Process did not terminate gracefully"));
|
|
538
|
+
}, 5e3);
|
|
539
|
+
const check = () => {
|
|
540
|
+
try {
|
|
541
|
+
process.kill(pid, 0);
|
|
542
|
+
setTimeout(check, 500);
|
|
543
|
+
} catch {
|
|
544
|
+
clearInterval(interval);
|
|
545
|
+
clearTimeout(timeout);
|
|
546
|
+
resolve();
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
const interval = setInterval(check, 500);
|
|
550
|
+
});
|
|
551
|
+
return true;
|
|
552
|
+
} catch {
|
|
553
|
+
try {
|
|
554
|
+
process.kill(pid, "SIGKILL");
|
|
555
|
+
await new Promise((resolve, reject) => {
|
|
556
|
+
const timeout = setTimeout(() => {
|
|
557
|
+
reject(new Error("Process did not terminate"));
|
|
558
|
+
}, 3e3);
|
|
559
|
+
setTimeout(() => {
|
|
560
|
+
try {
|
|
561
|
+
process.kill(pid, 0);
|
|
562
|
+
clearTimeout(timeout);
|
|
563
|
+
reject(new Error("Process still running"));
|
|
564
|
+
} catch {
|
|
565
|
+
clearTimeout(timeout);
|
|
566
|
+
resolve();
|
|
567
|
+
}
|
|
568
|
+
}, 1e3);
|
|
569
|
+
});
|
|
570
|
+
return true;
|
|
571
|
+
} catch {
|
|
572
|
+
return false;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
async function waitForPort(port, host = "0.0.0.0", timeout = 5e3) {
|
|
577
|
+
const start = Date.now();
|
|
578
|
+
while (Date.now() - start < timeout) {
|
|
579
|
+
if (await isPortAvailable(port, host)) {
|
|
580
|
+
return true;
|
|
581
|
+
}
|
|
582
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
583
|
+
}
|
|
584
|
+
return false;
|
|
585
|
+
}
|
|
437
586
|
export {
|
|
438
587
|
ADORN_META2 as ADORN_META,
|
|
439
588
|
AdditionalProperties,
|
|
@@ -477,9 +626,13 @@ export {
|
|
|
477
626
|
ValidationErrorResponse,
|
|
478
627
|
clearArtifactCache,
|
|
479
628
|
createValidator,
|
|
629
|
+
findProcessOnPort,
|
|
480
630
|
formatValidationErrors,
|
|
481
631
|
getArtifactCacheStats,
|
|
632
|
+
isPortAvailable,
|
|
633
|
+
killProcess,
|
|
482
634
|
loadArtifacts,
|
|
483
|
-
readAdornBucket
|
|
635
|
+
readAdornBucket,
|
|
636
|
+
waitForPort
|
|
484
637
|
};
|
|
485
638
|
//# sourceMappingURL=index.js.map
|