adorn-api 1.0.12 → 1.0.13

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.
Files changed (43) hide show
  1. package/dist/adapter/express/bootstrap.d.ts.map +1 -1
  2. package/dist/adapter/express/merge.d.ts.map +1 -1
  3. package/dist/adapter/express/router.d.ts.map +1 -1
  4. package/dist/cli.cjs +799 -409
  5. package/dist/cli.cjs.map +1 -1
  6. package/dist/cli.js +799 -409
  7. package/dist/cli.js.map +1 -1
  8. package/dist/compiler/cache/isStale.d.ts.map +1 -1
  9. package/dist/compiler/cache/writeCache.d.ts.map +1 -1
  10. package/dist/compiler/schema/intersectionHandler.d.ts +7 -0
  11. package/dist/compiler/schema/intersectionHandler.d.ts.map +1 -0
  12. package/dist/compiler/schema/objectHandler.d.ts +20 -0
  13. package/dist/compiler/schema/objectHandler.d.ts.map +1 -0
  14. package/dist/compiler/schema/openapi.d.ts +1 -1
  15. package/dist/compiler/schema/openapi.d.ts.map +1 -1
  16. package/dist/compiler/schema/parameters.d.ts +18 -0
  17. package/dist/compiler/schema/parameters.d.ts.map +1 -0
  18. package/dist/compiler/schema/primitives.d.ts +10 -0
  19. package/dist/compiler/schema/primitives.d.ts.map +1 -0
  20. package/dist/compiler/schema/typeToJsonSchema.d.ts +2 -51
  21. package/dist/compiler/schema/typeToJsonSchema.d.ts.map +1 -1
  22. package/dist/compiler/schema/types.d.ts +54 -0
  23. package/dist/compiler/schema/types.d.ts.map +1 -0
  24. package/dist/compiler/schema/unionHandler.d.ts +10 -0
  25. package/dist/compiler/schema/unionHandler.d.ts.map +1 -0
  26. package/dist/express.cjs +41 -44
  27. package/dist/express.cjs.map +1 -1
  28. package/dist/express.js +41 -44
  29. package/dist/express.js.map +1 -1
  30. package/dist/http.d.ts +1 -2
  31. package/dist/http.d.ts.map +1 -1
  32. package/dist/index.cjs +1 -1
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/metal/index.cjs +2 -2
  37. package/dist/metal/index.cjs.map +1 -1
  38. package/dist/metal/index.js +2 -2
  39. package/dist/metal/index.js.map +1 -1
  40. package/dist/metal/listQuery.d.ts.map +1 -1
  41. package/dist/metal/queryOptions.d.ts.map +1 -1
  42. package/dist/metal/registerMetalEntities.d.ts.map +1 -1
  43. package/package.json +4 -1
@@ -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;A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,SAAS,WAAW,mBAAmB;AACvF,QAAI;AACF,YAAM,mBAAmB,MAAM,OAAO,iBAAAD,QAAK,KAAK,QAAQ,SAAS,WAAW,iBAAiB;AAC7F,mBAAa;AAAA,IACf,SAAS,KAAK;AACZ,cAAQ,KAAK,0CAA0C,GAAG,EAAE;AAAA,IAC9D;AAAA,EACF;AAEA,gBAAc,IAAI,UAAU;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,MACV,YAAY;AAAA,IACd;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,mBAAmB,QAAuB;AACxD,MAAI,QAAQ;AACV,UAAM,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"],"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 { 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 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","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 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\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,OAAO,eAAe;AACzB,WAAO,gBAAgB,CAAC;AAAA,EAC1B;AACA,SAAO;AACT;;;ACdO,SAAS,WAAW,UAAkB;AAC3C,SAAO,SACL,QACA,SACU;AACV,UAAM,SAAS,UAAU,QAAQ,QAAQ;AACzC,WAAO,WAAW;AAAA,EACpB;AACF;;;ACPA,SAAS,sBAAsB,YAAwBC,OA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C;AACF;","names":["ADORN_META","path","op","op","op","op","ADORN_META","Ajv","addFormats","path","ADORN_META","path","fs"]}
package/dist/index.js CHANGED
@@ -372,7 +372,7 @@ async function getMtime(filePath) {
372
372
  async function loadArtifacts(options) {
373
373
  const { outDir } = options;
374
374
  const cacheKey = path.resolve(outDir);
375
- let entry = artifactCache.get(cacheKey);
375
+ const entry = artifactCache.get(cacheKey);
376
376
  const openapiPath = path.join(outDir, "openapi.json");
377
377
  const manifestPath = path.join(outDir, "manifest.json");
378
378
  const validatorsPath = path.join(outDir, "validators.mjs");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../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":["// 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":";AAEC,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,OAAO,eAAe;AACzB,WAAO,gBAAgB,CAAC;AAAA,EAC1B;AACA,SAAO;AACT;;;ACdO,SAAS,WAAW,UAAkB;AAC3C,SAAO,SACL,QACA,SACU;AACV,UAAM,SAAS,UAAU,QAAQ,QAAQ;AACzC,WAAO,WAAW;AAAA,EACpB;AACF;;;ACPA,SAAS,sBAAsB,YAAwBA,OAAc;AACnE,SAAO,SACL,QACA,SACU;AACV,QAAI,QAAQ,W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AC1B,MAAM,OAAO,eAAe;AAE9B,QAAI,aAAa;AACf,UAAI,MAAM,WAAW,MAAM,UAAU;AACnC,eAAO;AAAA,UACL,SAAS,MAAM;AAAA,UACf,UAAU,MAAM;AAAA,UAChB,YAAY,MAAM;AAAA,QACpB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,iBAAiB,GAAG,aAAa,aAAa,OAAO;AAC3D,QAAM,kBAAkB,GAAG,aAAa,cAAc,OAAO;AAE7D,QAAM,UAAU,KAAK,MAAM,cAAc;AACzC,QAAM,WAAW,KAAK,MAAM,eAAe;AAE3C,MAAI,aAAqC;AAEzC,MAAI,SAAS,WAAW,SAAS,iBAAiB,SAAS,WAAW,mBAAmB;AACvF,QAAI;AACF,YAAM,mBAAmB,MAAM,OAAO,KAAK,KAAK,QAAQ,SAAS,WAAW,iBAAiB;AAC7F,mBAAa;AAAA,IACf,SAAS,KAAK;AACZ,cAAQ,KAAK,0CAA0C,GAAG,EAAE;AAAA,IAC9D;AAAA,EACF;AAEA,gBAAc,IAAI,UAAU;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,MACV,YAAY;AAAA,IACd;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,mBAAmB,QAAuB;AACxD,MAAI,QAAQ;AACV,UAAM,WAAW,KAAK,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":["path","op","op","op","op","ADORN_META","path","ADORN_META"]}
1
+ {"version":3,"sources":["../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":["// 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 { 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 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","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 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\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":";AAEC,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,OAAO,eAAe;AACzB,WAAO,gBAAgB,CAAC;AAAA,EAC1B;AACA,SAAO;AACT;;;ACdO,SAAS,WAAW,UAAkB;AAC3C,SAAO,SACL,QACA,SACU;AACV,UAAM,SAAS,UAAU,QAAQ,QAAQ;AACzC,WAAO,WAAW;AAAA,EACpB;AACF;;;ACPA,SAAS,sBAAsB,YAAwBA,OAAc;AACnE,SAAO,SACL,QACA,SACU;AACV,QAAI,QAAQ,WAAW,QAAQ,QAAQ;AACrC;AAAA,IACF;AAEA,UAAM,aAAa,OAAO,QAAQ,IAAI;AACtC,UAAM,SAAS,UAAU,QAAQ,QAAQ;AAEzC,QAAI,KAAK,OAAO,IAAI,KAAK,CAAAC,QAAMA,IAAG,eAAe,UAAU;AAC3D,QAAI,CAAC,IAAI;AACP,WAAK;AAAA,QACH;AAAA,QACA,MAAAD;AAAA,QACA;AAAA,MACF;AACA,aAAO,IAAI,KAAK,EAAE;AAAA,IACpB,OAAO;AACL,SAAG,aAAa;AAChB,SAAG,OAAOA;AAAA,IACZ;AAAA,EACF;AACF;AAEO,IAAM,MAAM,CAACA,UAAiB,sBAAsB,OAAOA,KAAI;AAC/D,IAAM,OAAO,CAACA,UAAiB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,YAAM,mBAAmB,MAAM,OAAO,KAAK,KAAK,QAAQ,SAAS,WAAW,iBAAiB;AAC7F,mBAAa;AAAA,IACf,SAAS,KAAK;AACZ,cAAQ,KAAK,0CAA0C,GAAG,EAAE;AAAA,IAC9D;AAAA,EACF;AAEA,gBAAc,IAAI,UAAU;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,MACV,YAAY;AAAA,IACd;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,mBAAmB,QAAuB;AACxD,MAAI,QAAQ;AACV,UAAM,WAAW,KAAK,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":["path","op","op","op","op","ADORN_META","path","ADORN_META"]}
@@ -130,7 +130,7 @@ function makeNullable(schema) {
130
130
  return schema;
131
131
  }
132
132
  function isGenerated(col) {
133
- return !!col.primary || !!col.autoIncrement || col.generated != null;
133
+ return !!col.primary || !!col.autoIncrement || col.generated !== null && col.generated !== void 0;
134
134
  }
135
135
  function shouldIncludeColumn(col, mode) {
136
136
  if (mode === "read") return true;
@@ -141,7 +141,7 @@ function shouldIncludeColumn(col, mode) {
141
141
  function shouldRequire(col, mode) {
142
142
  if (mode === "update") return false;
143
143
  if (!col.notNull) return false;
144
- if (mode === "create" && col.default != null) return false;
144
+ if (mode === "create" && (col.default !== null && col.default !== void 0)) return false;
145
145
  return true;
146
146
  }
147
147
  function schemaFromEntity(ctor, opts = {}) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/metal/index.ts","../../src/metal/symbolMetadata.ts","../../src/metal/readMetalBag.ts","../../src/metal/schemaFromEntity.ts","../../src/metal/registerMetalEntities.ts","../../src/metal/applyListQuery.ts"],"sourcesContent":["export { ensureSymbolMetadata } from \"./symbolMetadata.js\";\nexport { readMetalDecoratorBagFromConstructor, METAL_METADATA_KEY } from \"./readMetalBag.js\";\nexport { schemaFromEntity } from \"./schemaFromEntity.js\";\nexport { registerMetalEntities } from \"./registerMetalEntities.js\";\nexport type { ListQuery } from \"./listQuery.js\";\nexport { applyListQuery, normalizeSort, pagedOptions, parseSort } from \"./applyListQuery.js\";\n\nexport type { SchemaFromEntityOptions, EntitySchemaMode, JsonSchema } from \"./schemaFromEntity.js\";\nexport type { SearchWhere, SearchWhereDepth, SearchWhereOptions, SearchWherePath } from \"./searchWhere.js\";\nexport type { QueryOptions } from \"./queryOptions.js\";\n\nexport type { SortDirection, SortToken, ParseSortOptions } from \"./applyListQuery.js\";\n","export function ensureSymbolMetadata(): symbol {\n const s = Symbol as unknown as { metadata?: symbol };\n if (!s.metadata) {\n s.metadata = Symbol(\"Symbol.metadata\");\n }\n return s.metadata;\n}\n","import { ensureSymbolMetadata } from \"./symbolMetadata.js\";\n\nexport const METAL_METADATA_KEY = \"metal-orm:decorators\";\n\nexport type MetalColumnDef = {\n type: string;\n args?: unknown[];\n dialectTypes?: unknown;\n notNull?: boolean;\n primary?: boolean;\n tsType?: unknown;\n unique?: boolean;\n default?: unknown;\n autoIncrement?: boolean;\n generated?: unknown;\n check?: unknown;\n references?: unknown;\n comment?: string;\n};\n\nexport type MetalRelationMetadata = {\n kind: string;\n propertyKey: string;\n target?: (...args: any[]) => any;\n};\n\nexport type MetalDecoratorBag = {\n columns: Array<{ propertyName: string; column: MetalColumnDef }>;\n relations: Array<{ propertyName: string; relation: MetalRelationMetadata }>;\n};\n\nexport function readMetalDecoratorBagFromConstructor(ctor: object): MetalDecoratorBag | undefined {\n const metadataSymbol = ensureSymbolMetadata();\n const metadata = Reflect.get(ctor, metadataSymbol) as Record<PropertyKey, unknown> | undefined;\n return metadata?.[METAL_METADATA_KEY] as MetalDecoratorBag | undefined;\n}\n","import { readMetalDecoratorBagFromConstructor, type MetalColumnDef, type MetalDecoratorBag } from \"./readMetalBag.js\";\n\nexport type JsonSchema = Record<string, any>;\n\nexport type EntitySchemaMode = \"read\" | \"create\" | \"update\";\n\nexport interface SchemaFromEntityOptions {\n name?: string;\n stripEntitySuffix?: boolean;\n mode?: EntitySchemaMode;\n additionalProperties?: boolean;\n includeRelations?: \"none\" | \"inline\";\n}\n\nfunction defaultSchemaName(ctor: Function, strip: boolean) {\n const raw = ctor.name || \"AnonymousEntity\";\n return strip ? raw.replace(/Entity$/i, \"\") || raw : raw;\n}\n\nfunction columnTypeToSchema(col: MetalColumnDef): JsonSchema {\n const t = String(col.type).toLowerCase();\n const s: JsonSchema = {};\n\n if ([\"varchar\", \"text\", \"string\", \"char\", \"citext\"].includes(t)) {\n s.type = \"string\";\n const a0 = Array.isArray(col.args) ? col.args[0] : undefined;\n if (typeof a0 === \"number\" && Number.isFinite(a0) && a0 > 0) s.maxLength = a0;\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"uuid\"].includes(t)) {\n s.type = \"string\";\n s.format = \"uuid\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"timestamp\", \"timestamptz\", \"datetime\"].includes(t)) {\n s.type = \"string\";\n s.format = \"date-time\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n if ([\"date\"].includes(t)) {\n s.type = \"string\";\n s.format = \"date\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"bool\", \"boolean\"].includes(t)) {\n s.type = \"boolean\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"int\", \"int4\", \"integer\", \"smallint\", \"int2\", \"serial\", \"bigserial\"].includes(t)) {\n s.type = \"integer\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"bigint\", \"int8\"].includes(t)) {\n s.type = \"string\";\n s.format = \"int64\";\n s.pattern = \"^-?\\\\d+$\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"float\", \"float4\", \"float8\", \"double\", \"decimal\", \"numeric\", \"real\"].includes(t)) {\n s.type = \"number\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"json\", \"jsonb\"].includes(t)) {\n s.type = [\"object\", \"array\", \"string\", \"number\", \"boolean\", \"null\"];\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n s.type = \"string\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n}\n\nfunction isLiteralDefault(v: unknown) {\n return v === null || [\"string\", \"number\", \"boolean\"].includes(typeof v);\n}\n\nfunction makeNullable(schema: JsonSchema): JsonSchema {\n if (schema.type === \"null\") return schema;\n if (Array.isArray(schema.type)) {\n if (!schema.type.includes(\"null\")) schema.type = [...schema.type, \"null\"];\n return schema;\n }\n if (typeof schema.type === \"string\") {\n schema.type = [schema.type, \"null\"];\n } else {\n schema.type = [\"null\"];\n }\n return schema;\n}\n\nfunction isGenerated(col: MetalColumnDef) {\n return !!col.primary || !!col.autoIncrement || col.generated != null;\n}\n\nfunction shouldIncludeColumn(col: MetalColumnDef, mode: \"read\" | \"create\" | \"update\") {\n if (mode === \"read\") return true;\n if (mode === \"create\") return !isGenerated(col);\n if (mode === \"update\") return true;\n return true;\n}\n\nfunction shouldRequire(col: MetalColumnDef, mode: \"read\" | \"create\" | \"update\") {\n if (mode === \"update\") return false;\n if (!col.notNull) return false;\n if (mode === \"create\" && col.default != null) return false;\n return true;\n}\n\nexport function schemaFromEntity(ctor: Function, opts: SchemaFromEntityOptions = {}): JsonSchema | undefined {\n const bag = readMetalDecoratorBagFromConstructor(ctor);\n if (!bag || !Array.isArray(bag.columns) || bag.columns.length === 0) return undefined;\n\n const mode = opts.mode ?? \"read\";\n const name = opts.name ?? defaultSchemaName(ctor, opts.stripEntitySuffix ?? true);\n\n const schema: JsonSchema = {\n title: name,\n type: \"object\",\n properties: {},\n additionalProperties: opts.additionalProperties ?? true\n };\n\n const required: string[] = [];\n\n for (const entry of bag.columns) {\n const prop = entry.propertyName;\n const col = entry.column;\n\n if (!shouldIncludeColumn(col, mode)) continue;\n\n const propSchema = columnTypeToSchema(col);\n\n if (!col.notNull) makeNullable(propSchema);\n\n if (isLiteralDefault(col.default)) propSchema.default = col.default;\n\n if (mode === \"read\" && col.primary) propSchema.readOnly = true;\n\n (schema.properties as any)[prop] = propSchema;\n\n if (shouldRequire(col, mode)) required.push(prop);\n }\n\n if (required.length) schema.required = required;\n\n if ((opts.includeRelations ?? \"none\") === \"inline\") {\n for (const r of bag.relations ?? []) {\n const rel = r.relation;\n if (typeof rel?.target !== \"function\") continue;\n\n let target: any;\n try {\n target = rel.target();\n } catch {\n continue;\n }\n if (typeof target !== \"function\") continue;\n\n const targetName = defaultSchemaName(target, true);\n (schema.properties as any)[r.propertyName] = { $ref: `#/components/schemas/${targetName}` };\n }\n }\n\n return schema;\n}\n","import { schemaFromEntity, type SchemaFromEntityOptions, type JsonSchema } from \"./schemaFromEntity.js\";\n\nfunction deepMerge(a: any, b: any): any {\n if (Array.isArray(a) || Array.isArray(b)) return b ?? a;\n if (a && typeof a === \"object\" && b && typeof b === \"object\") {\n const out: any = { ...a };\n for (const [k, v] of Object.entries(b)) out[k] = deepMerge(out[k], v);\n return out;\n }\n return b ?? a;\n}\n\nexport interface RegisterMetalEntitiesOptions extends SchemaFromEntityOptions {\n merge?: \"override\" | \"merge\";\n}\n\nexport function registerMetalEntities(\n openapi: any,\n entities: Function[],\n opts: RegisterMetalEntitiesOptions = {}\n) {\n openapi.components ??= {};\n openapi.components.schemas ??= {};\n\n const mergeMode = opts.merge ?? \"merge\";\n\n for (const ctor of entities) {\n const s = schemaFromEntity(ctor, opts);\n if (!s) continue;\n\n const name = s.title || ctor.name;\n const existing = openapi.components.schemas[name];\n\n if (!existing || mergeMode === \"override\") {\n openapi.components.schemas[name] = s;\n } else {\n openapi.components.schemas[name] = deepMerge(existing, s);\n }\n }\n}\n","import type { ListQuery } from \"./listQuery.js\";\nimport type { SelectQueryBuilder } from \"metal-orm\";\nimport type { OrmSession } from \"metal-orm\";\nimport type { PaginatedResult } from \"metal-orm\";\n\nexport async function applyListQuery<TEntity extends object>(\n qb: SelectQueryBuilder<TEntity>,\n session: OrmSession,\n query?: ListQuery<TEntity>\n): Promise<PaginatedResult<TEntity>> {\n return qb.executePaged(session, pagedOptions(query));\n}\n\nexport function pagedOptions(query?: { page?: number; pageSize?: number }): {\n page: number;\n pageSize: number;\n} {\n return {\n page: query?.page ?? 1,\n pageSize: query?.pageSize ?? 10,\n };\n}\n\nexport function normalizeSort(sort: unknown): string[] {\n if (Array.isArray(sort)) {\n return sort.flatMap((v) => String(v).split(\",\"));\n }\n if (typeof sort === \"string\") {\n return sort.split(\",\");\n }\n return [];\n}\n\nexport type SortDirection = \"ASC\" | \"DESC\";\n\nexport type SortToken = {\n raw: string;\n field: string;\n path: string[];\n direction: SortDirection;\n isRelationField: boolean;\n};\n\nexport type ParseSortOptions = {\n max?: number;\n whitelist?: string[];\n};\n\nfunction matchWhitelist(path: string[], whitelist: string[]): boolean {\n const pathStr = path.join(\".\");\n\n for (const pattern of whitelist) {\n if (pattern === pathStr) return true;\n\n if (pattern.endsWith(\"*\")) {\n const prefix = pattern.slice(0, -1);\n if (pathStr.startsWith(prefix)) return true;\n }\n }\n\n return false;\n}\n\nexport function parseSort(sort: unknown, opts?: ParseSortOptions): SortToken[] {\n const max = opts?.max ?? 20;\n const whitelist = opts?.whitelist;\n\n const tokens = normalizeSort(sort)\n .map((s) => s.trim())\n .filter(Boolean)\n .slice(0, max)\n .map((raw) => {\n const direction: SortDirection = raw.startsWith(\"-\") ? \"DESC\" : \"ASC\";\n const field = raw.replace(/^[-+]/, \"\").trim();\n const path = field.split(\".\").map((p) => p.trim()).filter(Boolean);\n\n return {\n raw,\n field,\n path,\n direction,\n isRelationField: path.length > 1,\n };\n })\n .filter((t) => t.field.length > 0);\n\n if (whitelist && whitelist.length > 0) {\n return tokens.filter((t) => matchWhitelist(t.path, whitelist));\n }\n\n return tokens;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,uBAA+B;AAC7C,QAAM,IAAI;AACV,MAAI,CAAC,EAAE,UAAU;AACf,MAAE,WAAW,uBAAO,iBAAiB;AAAA,EACvC;AACA,SAAO,EAAE;AACX;;;ACJO,IAAM,qBAAqB;AA6B3B,SAAS,qCAAqC,MAA6C;AAChG,QAAM,iBAAiB,qBAAqB;AAC5C,QAAM,WAAW,QAAQ,IAAI,MAAM,cAAc;AACjD,SAAO,WAAW,kBAAkB;AACtC;;;ACrBA,SAAS,kBAAkB,MAAgB,OAAgB;AACzD,QAAM,MAAM,KAAK,QAAQ;AACzB,SAAO,QAAQ,IAAI,QAAQ,YAAY,EAAE,KAAK,MAAM;AACtD;AAEA,SAAS,mBAAmB,KAAiC;AAC3D,QAAM,IAAI,OAAO,IAAI,IAAI,EAAE,YAAY;AACvC,QAAM,IAAgB,CAAC;AAEvB,MAAI,CAAC,WAAW,QAAQ,UAAU,QAAQ,QAAQ,EAAE,SAAS,CAAC,GAAG;AAC/D,MAAE,OAAO;AACT,UAAM,KAAK,MAAM,QAAQ,IAAI,IAAI,IAAI,IAAI,KAAK,CAAC,IAAI;AACnD,QAAI,OAAO,OAAO,YAAY,OAAO,SAAS,EAAE,KAAK,KAAK,EAAG,GAAE,YAAY;AAC3E,QAAI,OAAO,IAAI,YAAY,SAAU,GAAE,cAAc,IAAI;AACzD,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG;AACxB,MAAE,OAAO;AACT,MAAE,SAAS;AACX,QAAI,OAAO,IAAI,YAAY,SAAU,GAAE,cAAc,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AY,QAAS,QAAO;AAEhC,QAAI,QAAQ,SAAS,GAAG,GAAG;AACzB,YAAM,SAAS,QAAQ,MAAM,GAAG,EAAE;AAClC,UAAI,QAAQ,WAAW,MAAM,EAAG,QAAO;AAAA,IACzC;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,UAAU,MAAe,MAAsC;AAC7E,QAAM,MAAM,MAAM,OAAO;AACzB,QAAM,YAAY,MAAM;AAExB,QAAM,SAAS,cAAc,IAAI,EAC9B,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO,EACd,MAAM,GAAG,GAAG,EACZ,IAAI,CAAC,QAAQ;AACZ,UAAM,YAA2B,IAAI,WAAW,GAAG,IAAI,SAAS;AAChE,UAAM,QAAQ,IAAI,QAAQ,SAAS,EAAE,EAAE,KAAK;AAC5C,UAAM,OAAO,MAAM,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,OAAO;AAEjE,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,iBAAiB,KAAK,SAAS;AAAA,IACjC;AAAA,EACF,CAAC,EACA,OAAO,CAAC,MAAM,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAI,aAAa,UAAU,SAAS,GAAG;AACrC,WAAO,OAAO,OAAO,CAAC,MAAM,eAAe,EAAE,MAAM,SAAS,CAAC;AAAA,EAC/D;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/metal/index.ts","../../src/metal/symbolMetadata.ts","../../src/metal/readMetalBag.ts","../../src/metal/schemaFromEntity.ts","../../src/metal/registerMetalEntities.ts","../../src/metal/applyListQuery.ts"],"sourcesContent":["export { ensureSymbolMetadata } from \"./symbolMetadata.js\";\nexport { readMetalDecoratorBagFromConstructor, METAL_METADATA_KEY } from \"./readMetalBag.js\";\nexport { schemaFromEntity } from \"./schemaFromEntity.js\";\nexport { registerMetalEntities } from \"./registerMetalEntities.js\";\nexport type { ListQuery } from \"./listQuery.js\";\nexport { applyListQuery, normalizeSort, pagedOptions, parseSort } from \"./applyListQuery.js\";\n\nexport type { SchemaFromEntityOptions, EntitySchemaMode, JsonSchema } from \"./schemaFromEntity.js\";\nexport type { SearchWhere, SearchWhereDepth, SearchWhereOptions, SearchWherePath } from \"./searchWhere.js\";\nexport type { QueryOptions } from \"./queryOptions.js\";\n\nexport type { SortDirection, SortToken, ParseSortOptions } from \"./applyListQuery.js\";\n","export function ensureSymbolMetadata(): symbol {\n const s = Symbol as unknown as { metadata?: symbol };\n if (!s.metadata) {\n s.metadata = Symbol(\"Symbol.metadata\");\n }\n return s.metadata;\n}\n","import { ensureSymbolMetadata } from \"./symbolMetadata.js\";\n\nexport const METAL_METADATA_KEY = \"metal-orm:decorators\";\n\nexport type MetalColumnDef = {\n type: string;\n args?: unknown[];\n dialectTypes?: unknown;\n notNull?: boolean;\n primary?: boolean;\n tsType?: unknown;\n unique?: boolean;\n default?: unknown;\n autoIncrement?: boolean;\n generated?: unknown;\n check?: unknown;\n references?: unknown;\n comment?: string;\n};\n\nexport type MetalRelationMetadata = {\n kind: string;\n propertyKey: string;\n target?: (...args: any[]) => any;\n};\n\nexport type MetalDecoratorBag = {\n columns: Array<{ propertyName: string; column: MetalColumnDef }>;\n relations: Array<{ propertyName: string; relation: MetalRelationMetadata }>;\n};\n\nexport function readMetalDecoratorBagFromConstructor(ctor: object): MetalDecoratorBag | undefined {\n const metadataSymbol = ensureSymbolMetadata();\n const metadata = Reflect.get(ctor, metadataSymbol) as Record<PropertyKey, unknown> | undefined;\n return metadata?.[METAL_METADATA_KEY] as MetalDecoratorBag | undefined;\n}\n","import { readMetalDecoratorBagFromConstructor, type MetalColumnDef } from \"./readMetalBag.js\";\n\nexport type JsonSchema = Record<string, any>;\n\nexport type EntitySchemaMode = \"read\" | \"create\" | \"update\";\n\nexport interface SchemaFromEntityOptions {\n name?: string;\n stripEntitySuffix?: boolean;\n mode?: EntitySchemaMode;\n additionalProperties?: boolean;\n includeRelations?: \"none\" | \"inline\";\n}\n\nfunction defaultSchemaName(ctor: Function, strip: boolean) {\n const raw = ctor.name || \"AnonymousEntity\";\n return strip ? raw.replace(/Entity$/i, \"\") || raw : raw;\n}\n\nfunction columnTypeToSchema(col: MetalColumnDef): JsonSchema {\n const t = String(col.type).toLowerCase();\n const s: JsonSchema = {};\n\n if ([\"varchar\", \"text\", \"string\", \"char\", \"citext\"].includes(t)) {\n s.type = \"string\";\n const a0 = Array.isArray(col.args) ? col.args[0] : undefined;\n if (typeof a0 === \"number\" && Number.isFinite(a0) && a0 > 0) s.maxLength = a0;\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"uuid\"].includes(t)) {\n s.type = \"string\";\n s.format = \"uuid\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"timestamp\", \"timestamptz\", \"datetime\"].includes(t)) {\n s.type = \"string\";\n s.format = \"date-time\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n if ([\"date\"].includes(t)) {\n s.type = \"string\";\n s.format = \"date\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"bool\", \"boolean\"].includes(t)) {\n s.type = \"boolean\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"int\", \"int4\", \"integer\", \"smallint\", \"int2\", \"serial\", \"bigserial\"].includes(t)) {\n s.type = \"integer\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"bigint\", \"int8\"].includes(t)) {\n s.type = \"string\";\n s.format = \"int64\";\n s.pattern = \"^-?\\\\d+$\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"float\", \"float4\", \"float8\", \"double\", \"decimal\", \"numeric\", \"real\"].includes(t)) {\n s.type = \"number\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"json\", \"jsonb\"].includes(t)) {\n s.type = [\"object\", \"array\", \"string\", \"number\", \"boolean\", \"null\"];\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n s.type = \"string\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n}\n\nfunction isLiteralDefault(v: unknown) {\n return v === null || [\"string\", \"number\", \"boolean\"].includes(typeof v);\n}\n\nfunction makeNullable(schema: JsonSchema): JsonSchema {\n if (schema.type === \"null\") return schema;\n if (Array.isArray(schema.type)) {\n if (!schema.type.includes(\"null\")) schema.type = [...schema.type, \"null\"];\n return schema;\n }\n if (typeof schema.type === \"string\") {\n schema.type = [schema.type, \"null\"];\n } else {\n schema.type = [\"null\"];\n }\n return schema;\n}\n\nfunction isGenerated(col: MetalColumnDef) {\n return !!col.primary || !!col.autoIncrement || (col.generated !== null && col.generated !== undefined);\n}\n\nfunction shouldIncludeColumn(col: MetalColumnDef, mode: \"read\" | \"create\" | \"update\") {\n if (mode === \"read\") return true;\n if (mode === \"create\") return !isGenerated(col);\n if (mode === \"update\") return true;\n return true;\n}\n\nfunction shouldRequire(col: MetalColumnDef, mode: \"read\" | \"create\" | \"update\") {\n if (mode === \"update\") return false;\n if (!col.notNull) return false;\n if (mode === \"create\" && (col.default !== null && col.default !== undefined)) return false;\n return true;\n}\n\nexport function schemaFromEntity(ctor: Function, opts: SchemaFromEntityOptions = {}): JsonSchema | undefined {\n const bag = readMetalDecoratorBagFromConstructor(ctor);\n if (!bag || !Array.isArray(bag.columns) || bag.columns.length === 0) return undefined;\n\n const mode = opts.mode ?? \"read\";\n const name = opts.name ?? defaultSchemaName(ctor, opts.stripEntitySuffix ?? true);\n\n const schema: JsonSchema = {\n title: name,\n type: \"object\",\n properties: {},\n additionalProperties: opts.additionalProperties ?? true\n };\n\n const required: string[] = [];\n\n for (const entry of bag.columns) {\n const prop = entry.propertyName;\n const col = entry.column;\n\n if (!shouldIncludeColumn(col, mode)) continue;\n\n const propSchema = columnTypeToSchema(col);\n\n if (!col.notNull) makeNullable(propSchema);\n\n if (isLiteralDefault(col.default)) propSchema.default = col.default;\n\n if (mode === \"read\" && col.primary) propSchema.readOnly = true;\n\n (schema.properties as any)[prop] = propSchema;\n\n if (shouldRequire(col, mode)) required.push(prop);\n }\n\n if (required.length) schema.required = required;\n\n if ((opts.includeRelations ?? \"none\") === \"inline\") {\n for (const r of bag.relations ?? []) {\n const rel = r.relation;\n if (typeof rel?.target !== \"function\") continue;\n\n let target: any;\n try {\n target = rel.target();\n } catch {\n continue;\n }\n if (typeof target !== \"function\") continue;\n\n const targetName = defaultSchemaName(target, true);\n (schema.properties as any)[r.propertyName] = { $ref: `#/components/schemas/${targetName}` };\n }\n }\n\n return schema;\n}\n","import { schemaFromEntity, type SchemaFromEntityOptions } from \"./schemaFromEntity.js\";\n\nfunction deepMerge(a: any, b: any): any {\n if (Array.isArray(a) || Array.isArray(b)) return b ?? a;\n if (a && typeof a === \"object\" && b && typeof b === \"object\") {\n const out: any = { ...a };\n for (const [k, v] of Object.entries(b)) out[k] = deepMerge(out[k], v);\n return out;\n }\n return b ?? a;\n}\n\nexport interface RegisterMetalEntitiesOptions extends SchemaFromEntityOptions {\n merge?: \"override\" | \"merge\";\n}\n\nexport function registerMetalEntities(\n openapi: any,\n entities: Function[],\n opts: RegisterMetalEntitiesOptions = {}\n) {\n openapi.components ??= {};\n openapi.components.schemas ??= {};\n\n const mergeMode = opts.merge ?? \"merge\";\n\n for (const ctor of entities) {\n const s = schemaFromEntity(ctor, opts);\n if (!s) continue;\n\n const name = s.title || ctor.name;\n const existing = openapi.components.schemas[name];\n\n if (!existing || mergeMode === \"override\") {\n openapi.components.schemas[name] = s;\n } else {\n openapi.components.schemas[name] = deepMerge(existing, s);\n }\n }\n}\n","import type { ListQuery } from \"./listQuery.js\";\nimport type { SelectQueryBuilder } from \"metal-orm\";\nimport type { OrmSession } from \"metal-orm\";\nimport type { PaginatedResult } from \"metal-orm\";\n\nexport async function applyListQuery<TEntity extends object>(\n qb: SelectQueryBuilder<TEntity>,\n session: OrmSession,\n query?: ListQuery<TEntity>\n): Promise<PaginatedResult<TEntity>> {\n return qb.executePaged(session, pagedOptions(query));\n}\n\nexport function pagedOptions(query?: { page?: number; pageSize?: number }): {\n page: number;\n pageSize: number;\n} {\n return {\n page: query?.page ?? 1,\n pageSize: query?.pageSize ?? 10,\n };\n}\n\nexport function normalizeSort(sort: unknown): string[] {\n if (Array.isArray(sort)) {\n return sort.flatMap((v) => String(v).split(\",\"));\n }\n if (typeof sort === \"string\") {\n return sort.split(\",\");\n }\n return [];\n}\n\nexport type SortDirection = \"ASC\" | \"DESC\";\n\nexport type SortToken = {\n raw: string;\n field: string;\n path: string[];\n direction: SortDirection;\n isRelationField: boolean;\n};\n\nexport type ParseSortOptions = {\n max?: number;\n whitelist?: string[];\n};\n\nfunction matchWhitelist(path: string[], whitelist: string[]): boolean {\n const pathStr = path.join(\".\");\n\n for (const pattern of whitelist) {\n if (pattern === pathStr) return true;\n\n if (pattern.endsWith(\"*\")) {\n const prefix = pattern.slice(0, -1);\n if (pathStr.startsWith(prefix)) return true;\n }\n }\n\n return false;\n}\n\nexport function parseSort(sort: unknown, opts?: ParseSortOptions): SortToken[] {\n const max = opts?.max ?? 20;\n const whitelist = opts?.whitelist;\n\n const tokens = normalizeSort(sort)\n .map((s) => s.trim())\n .filter(Boolean)\n .slice(0, max)\n .map((raw) => {\n const direction: SortDirection = raw.startsWith(\"-\") ? \"DESC\" : \"ASC\";\n const field = raw.replace(/^[-+]/, \"\").trim();\n const path = field.split(\".\").map((p) => p.trim()).filter(Boolean);\n\n return {\n raw,\n field,\n path,\n direction,\n isRelationField: path.length > 1,\n };\n })\n .filter((t) => t.field.length > 0);\n\n if (whitelist && whitelist.length > 0) {\n return tokens.filter((t) => matchWhitelist(t.path, whitelist));\n }\n\n return tokens;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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AsC;AAC7E,QAAM,MAAM,MAAM,OAAO;AACzB,QAAM,YAAY,MAAM;AAExB,QAAM,SAAS,cAAc,IAAI,EAC9B,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO,EACd,MAAM,GAAG,GAAG,EACZ,IAAI,CAAC,QAAQ;AACZ,UAAM,YAA2B,IAAI,WAAW,GAAG,IAAI,SAAS;AAChE,UAAM,QAAQ,IAAI,QAAQ,SAAS,EAAE,EAAE,KAAK;AAC5C,UAAM,OAAO,MAAM,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,OAAO;AAEjE,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,iBAAiB,KAAK,SAAS;AAAA,IACjC;AAAA,EACF,CAAC,EACA,OAAO,CAAC,MAAM,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAI,aAAa,UAAU,SAAS,GAAG;AACrC,WAAO,OAAO,OAAO,CAAC,MAAM,eAAe,EAAE,MAAM,SAAS,CAAC;AAAA,EAC/D;AAEA,SAAO;AACT;","names":[]}
@@ -96,7 +96,7 @@ function makeNullable(schema) {
96
96
  return schema;
97
97
  }
98
98
  function isGenerated(col) {
99
- return !!col.primary || !!col.autoIncrement || col.generated != null;
99
+ return !!col.primary || !!col.autoIncrement || col.generated !== null && col.generated !== void 0;
100
100
  }
101
101
  function shouldIncludeColumn(col, mode) {
102
102
  if (mode === "read") return true;
@@ -107,7 +107,7 @@ function shouldIncludeColumn(col, mode) {
107
107
  function shouldRequire(col, mode) {
108
108
  if (mode === "update") return false;
109
109
  if (!col.notNull) return false;
110
- if (mode === "create" && col.default != null) return false;
110
+ if (mode === "create" && (col.default !== null && col.default !== void 0)) return false;
111
111
  return true;
112
112
  }
113
113
  function schemaFromEntity(ctor, opts = {}) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/metal/symbolMetadata.ts","../../src/metal/readMetalBag.ts","../../src/metal/schemaFromEntity.ts","../../src/metal/registerMetalEntities.ts","../../src/metal/applyListQuery.ts"],"sourcesContent":["export function ensureSymbolMetadata(): symbol {\n const s = Symbol as unknown as { metadata?: symbol };\n if (!s.metadata) {\n s.metadata = Symbol(\"Symbol.metadata\");\n }\n return s.metadata;\n}\n","import { ensureSymbolMetadata } from \"./symbolMetadata.js\";\n\nexport const METAL_METADATA_KEY = \"metal-orm:decorators\";\n\nexport type MetalColumnDef = {\n type: string;\n args?: unknown[];\n dialectTypes?: unknown;\n notNull?: boolean;\n primary?: boolean;\n tsType?: unknown;\n unique?: boolean;\n default?: unknown;\n autoIncrement?: boolean;\n generated?: unknown;\n check?: unknown;\n references?: unknown;\n comment?: string;\n};\n\nexport type MetalRelationMetadata = {\n kind: string;\n propertyKey: string;\n target?: (...args: any[]) => any;\n};\n\nexport type MetalDecoratorBag = {\n columns: Array<{ propertyName: string; column: MetalColumnDef }>;\n relations: Array<{ propertyName: string; relation: MetalRelationMetadata }>;\n};\n\nexport function readMetalDecoratorBagFromConstructor(ctor: object): MetalDecoratorBag | undefined {\n const metadataSymbol = ensureSymbolMetadata();\n const metadata = Reflect.get(ctor, metadataSymbol) as Record<PropertyKey, unknown> | undefined;\n return metadata?.[METAL_METADATA_KEY] as MetalDecoratorBag | undefined;\n}\n","import { readMetalDecoratorBagFromConstructor, type MetalColumnDef, type MetalDecoratorBag } from \"./readMetalBag.js\";\n\nexport type JsonSchema = Record<string, any>;\n\nexport type EntitySchemaMode = \"read\" | \"create\" | \"update\";\n\nexport interface SchemaFromEntityOptions {\n name?: string;\n stripEntitySuffix?: boolean;\n mode?: EntitySchemaMode;\n additionalProperties?: boolean;\n includeRelations?: \"none\" | \"inline\";\n}\n\nfunction defaultSchemaName(ctor: Function, strip: boolean) {\n const raw = ctor.name || \"AnonymousEntity\";\n return strip ? raw.replace(/Entity$/i, \"\") || raw : raw;\n}\n\nfunction columnTypeToSchema(col: MetalColumnDef): JsonSchema {\n const t = String(col.type).toLowerCase();\n const s: JsonSchema = {};\n\n if ([\"varchar\", \"text\", \"string\", \"char\", \"citext\"].includes(t)) {\n s.type = \"string\";\n const a0 = Array.isArray(col.args) ? col.args[0] : undefined;\n if (typeof a0 === \"number\" && Number.isFinite(a0) && a0 > 0) s.maxLength = a0;\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"uuid\"].includes(t)) {\n s.type = \"string\";\n s.format = \"uuid\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"timestamp\", \"timestamptz\", \"datetime\"].includes(t)) {\n s.type = \"string\";\n s.format = \"date-time\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n if ([\"date\"].includes(t)) {\n s.type = \"string\";\n s.format = \"date\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"bool\", \"boolean\"].includes(t)) {\n s.type = \"boolean\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"int\", \"int4\", \"integer\", \"smallint\", \"int2\", \"serial\", \"bigserial\"].includes(t)) {\n s.type = \"integer\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"bigint\", \"int8\"].includes(t)) {\n s.type = \"string\";\n s.format = \"int64\";\n s.pattern = \"^-?\\\\d+$\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"float\", \"float4\", \"float8\", \"double\", \"decimal\", \"numeric\", \"real\"].includes(t)) {\n s.type = \"number\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"json\", \"jsonb\"].includes(t)) {\n s.type = [\"object\", \"array\", \"string\", \"number\", \"boolean\", \"null\"];\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n s.type = \"string\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n}\n\nfunction isLiteralDefault(v: unknown) {\n return v === null || [\"string\", \"number\", \"boolean\"].includes(typeof v);\n}\n\nfunction makeNullable(schema: JsonSchema): JsonSchema {\n if (schema.type === \"null\") return schema;\n if (Array.isArray(schema.type)) {\n if (!schema.type.includes(\"null\")) schema.type = [...schema.type, \"null\"];\n return schema;\n }\n if (typeof schema.type === \"string\") {\n schema.type = [schema.type, \"null\"];\n } else {\n schema.type = [\"null\"];\n }\n return schema;\n}\n\nfunction isGenerated(col: MetalColumnDef) {\n return !!col.primary || !!col.autoIncrement || col.generated != null;\n}\n\nfunction shouldIncludeColumn(col: MetalColumnDef, mode: \"read\" | \"create\" | \"update\") {\n if (mode === \"read\") return true;\n if (mode === \"create\") return !isGenerated(col);\n if (mode === \"update\") return true;\n return true;\n}\n\nfunction shouldRequire(col: MetalColumnDef, mode: \"read\" | \"create\" | \"update\") {\n if (mode === \"update\") return false;\n if (!col.notNull) return false;\n if (mode === \"create\" && col.default != null) return false;\n return true;\n}\n\nexport function schemaFromEntity(ctor: Function, opts: SchemaFromEntityOptions = {}): JsonSchema | undefined {\n const bag = readMetalDecoratorBagFromConstructor(ctor);\n if (!bag || !Array.isArray(bag.columns) || bag.columns.length === 0) return undefined;\n\n const mode = opts.mode ?? \"read\";\n const name = opts.name ?? defaultSchemaName(ctor, opts.stripEntitySuffix ?? true);\n\n const schema: JsonSchema = {\n title: name,\n type: \"object\",\n properties: {},\n additionalProperties: opts.additionalProperties ?? true\n };\n\n const required: string[] = [];\n\n for (const entry of bag.columns) {\n const prop = entry.propertyName;\n const col = entry.column;\n\n if (!shouldIncludeColumn(col, mode)) continue;\n\n const propSchema = columnTypeToSchema(col);\n\n if (!col.notNull) makeNullable(propSchema);\n\n if (isLiteralDefault(col.default)) propSchema.default = col.default;\n\n if (mode === \"read\" && col.primary) propSchema.readOnly = true;\n\n (schema.properties as any)[prop] = propSchema;\n\n if (shouldRequire(col, mode)) required.push(prop);\n }\n\n if (required.length) schema.required = required;\n\n if ((opts.includeRelations ?? \"none\") === \"inline\") {\n for (const r of bag.relations ?? []) {\n const rel = r.relation;\n if (typeof rel?.target !== \"function\") continue;\n\n let target: any;\n try {\n target = rel.target();\n } catch {\n continue;\n }\n if (typeof target !== \"function\") continue;\n\n const targetName = defaultSchemaName(target, true);\n (schema.properties as any)[r.propertyName] = { $ref: `#/components/schemas/${targetName}` };\n }\n }\n\n return schema;\n}\n","import { schemaFromEntity, type SchemaFromEntityOptions, type JsonSchema } from \"./schemaFromEntity.js\";\n\nfunction deepMerge(a: any, b: any): any {\n if (Array.isArray(a) || Array.isArray(b)) return b ?? a;\n if (a && typeof a === \"object\" && b && typeof b === \"object\") {\n const out: any = { ...a };\n for (const [k, v] of Object.entries(b)) out[k] = deepMerge(out[k], v);\n return out;\n }\n return b ?? a;\n}\n\nexport interface RegisterMetalEntitiesOptions extends SchemaFromEntityOptions {\n merge?: \"override\" | \"merge\";\n}\n\nexport function registerMetalEntities(\n openapi: any,\n entities: Function[],\n opts: RegisterMetalEntitiesOptions = {}\n) {\n openapi.components ??= {};\n openapi.components.schemas ??= {};\n\n const mergeMode = opts.merge ?? \"merge\";\n\n for (const ctor of entities) {\n const s = schemaFromEntity(ctor, opts);\n if (!s) continue;\n\n const name = s.title || ctor.name;\n const existing = openapi.components.schemas[name];\n\n if (!existing || mergeMode === \"override\") {\n openapi.components.schemas[name] = s;\n } else {\n openapi.components.schemas[name] = deepMerge(existing, s);\n }\n }\n}\n","import type { ListQuery } from \"./listQuery.js\";\nimport type { SelectQueryBuilder } from \"metal-orm\";\nimport type { OrmSession } from \"metal-orm\";\nimport type { PaginatedResult } from \"metal-orm\";\n\nexport async function applyListQuery<TEntity extends object>(\n qb: SelectQueryBuilder<TEntity>,\n session: OrmSession,\n query?: ListQuery<TEntity>\n): Promise<PaginatedResult<TEntity>> {\n return qb.executePaged(session, pagedOptions(query));\n}\n\nexport function pagedOptions(query?: { page?: number; pageSize?: number }): {\n page: number;\n pageSize: number;\n} {\n return {\n page: query?.page ?? 1,\n pageSize: query?.pageSize ?? 10,\n };\n}\n\nexport function normalizeSort(sort: unknown): string[] {\n if (Array.isArray(sort)) {\n return sort.flatMap((v) => String(v).split(\",\"));\n }\n if (typeof sort === \"string\") {\n return sort.split(\",\");\n }\n return [];\n}\n\nexport type SortDirection = \"ASC\" | \"DESC\";\n\nexport type SortToken = {\n raw: string;\n field: string;\n path: string[];\n direction: SortDirection;\n isRelationField: boolean;\n};\n\nexport type ParseSortOptions = {\n max?: number;\n whitelist?: string[];\n};\n\nfunction matchWhitelist(path: string[], whitelist: string[]): boolean {\n const pathStr = path.join(\".\");\n\n for (const pattern of whitelist) {\n if (pattern === pathStr) return true;\n\n if (pattern.endsWith(\"*\")) {\n const prefix = pattern.slice(0, -1);\n if (pathStr.startsWith(prefix)) return true;\n }\n }\n\n return false;\n}\n\nexport function parseSort(sort: unknown, opts?: ParseSortOptions): SortToken[] {\n const max = opts?.max ?? 20;\n const whitelist = opts?.whitelist;\n\n const tokens = normalizeSort(sort)\n .map((s) => s.trim())\n .filter(Boolean)\n .slice(0, max)\n .map((raw) => {\n const direction: SortDirection = raw.startsWith(\"-\") ? \"DESC\" : \"ASC\";\n const field = raw.replace(/^[-+]/, \"\").trim();\n const path = field.split(\".\").map((p) => p.trim()).filter(Boolean);\n\n return {\n raw,\n field,\n path,\n direction,\n isRelationField: path.length > 1,\n };\n })\n .filter((t) => t.field.length > 0);\n\n if (whitelist && whitelist.length > 0) {\n return tokens.filter((t) => matchWhitelist(t.path, whitelist));\n }\n\n return tokens;\n}\n"],"mappings":";AAAO,SAAS,uBAA+B;AAC7C,QAAM,IAAI;AACV,MAAI,CAAC,EAAE,UAAU;AACf,MAAE,WAAW,uBAAO,iBAAiB;AAAA,EACvC;AACA,SAAO,EAAE;AACX;;;ACJO,IAAM,qBAAqB;AA6B3B,SAAS,qCAAqC,MAA6C;AAChG,QAAM,iBAAiB,qBAAqB;AAC5C,QAAM,WAAW,QAAQ,IAAI,MAAM,cAAc;AACjD,SAAO,WAAW,kBAAkB;AACtC;;;ACrBA,SAAS,kBAAkB,MAAgB,OAAgB;A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AK,CAAC,EAAE,OAAO,OAAO;AAEjE,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,iBAAiB,KAAK,SAAS;AAAA,IACjC;AAAA,EACF,CAAC,EACA,OAAO,CAAC,MAAM,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAI,aAAa,UAAU,SAAS,GAAG;AACrC,WAAO,OAAO,OAAO,CAAC,MAAM,eAAe,EAAE,MAAM,SAAS,CAAC;AAAA,EAC/D;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/metal/symbolMetadata.ts","../../src/metal/readMetalBag.ts","../../src/metal/schemaFromEntity.ts","../../src/metal/registerMetalEntities.ts","../../src/metal/applyListQuery.ts"],"sourcesContent":["export function ensureSymbolMetadata(): symbol {\n const s = Symbol as unknown as { metadata?: symbol };\n if (!s.metadata) {\n s.metadata = Symbol(\"Symbol.metadata\");\n }\n return s.metadata;\n}\n","import { ensureSymbolMetadata } from \"./symbolMetadata.js\";\n\nexport const METAL_METADATA_KEY = \"metal-orm:decorators\";\n\nexport type MetalColumnDef = {\n type: string;\n args?: unknown[];\n dialectTypes?: unknown;\n notNull?: boolean;\n primary?: boolean;\n tsType?: unknown;\n unique?: boolean;\n default?: unknown;\n autoIncrement?: boolean;\n generated?: unknown;\n check?: unknown;\n references?: unknown;\n comment?: string;\n};\n\nexport type MetalRelationMetadata = {\n kind: string;\n propertyKey: string;\n target?: (...args: any[]) => any;\n};\n\nexport type MetalDecoratorBag = {\n columns: Array<{ propertyName: string; column: MetalColumnDef }>;\n relations: Array<{ propertyName: string; relation: MetalRelationMetadata }>;\n};\n\nexport function readMetalDecoratorBagFromConstructor(ctor: object): MetalDecoratorBag | undefined {\n const metadataSymbol = ensureSymbolMetadata();\n const metadata = Reflect.get(ctor, metadataSymbol) as Record<PropertyKey, unknown> | undefined;\n return metadata?.[METAL_METADATA_KEY] as MetalDecoratorBag | undefined;\n}\n","import { readMetalDecoratorBagFromConstructor, type MetalColumnDef } from \"./readMetalBag.js\";\n\nexport type JsonSchema = Record<string, any>;\n\nexport type EntitySchemaMode = \"read\" | \"create\" | \"update\";\n\nexport interface SchemaFromEntityOptions {\n name?: string;\n stripEntitySuffix?: boolean;\n mode?: EntitySchemaMode;\n additionalProperties?: boolean;\n includeRelations?: \"none\" | \"inline\";\n}\n\nfunction defaultSchemaName(ctor: Function, strip: boolean) {\n const raw = ctor.name || \"AnonymousEntity\";\n return strip ? raw.replace(/Entity$/i, \"\") || raw : raw;\n}\n\nfunction columnTypeToSchema(col: MetalColumnDef): JsonSchema {\n const t = String(col.type).toLowerCase();\n const s: JsonSchema = {};\n\n if ([\"varchar\", \"text\", \"string\", \"char\", \"citext\"].includes(t)) {\n s.type = \"string\";\n const a0 = Array.isArray(col.args) ? col.args[0] : undefined;\n if (typeof a0 === \"number\" && Number.isFinite(a0) && a0 > 0) s.maxLength = a0;\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"uuid\"].includes(t)) {\n s.type = \"string\";\n s.format = \"uuid\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"timestamp\", \"timestamptz\", \"datetime\"].includes(t)) {\n s.type = \"string\";\n s.format = \"date-time\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n if ([\"date\"].includes(t)) {\n s.type = \"string\";\n s.format = \"date\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"bool\", \"boolean\"].includes(t)) {\n s.type = \"boolean\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"int\", \"int4\", \"integer\", \"smallint\", \"int2\", \"serial\", \"bigserial\"].includes(t)) {\n s.type = \"integer\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"bigint\", \"int8\"].includes(t)) {\n s.type = \"string\";\n s.format = \"int64\";\n s.pattern = \"^-?\\\\d+$\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"float\", \"float4\", \"float8\", \"double\", \"decimal\", \"numeric\", \"real\"].includes(t)) {\n s.type = \"number\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n if ([\"json\", \"jsonb\"].includes(t)) {\n s.type = [\"object\", \"array\", \"string\", \"number\", \"boolean\", \"null\"];\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n }\n\n s.type = \"string\";\n if (typeof col.comment === \"string\") s.description = col.comment;\n return s;\n}\n\nfunction isLiteralDefault(v: unknown) {\n return v === null || [\"string\", \"number\", \"boolean\"].includes(typeof v);\n}\n\nfunction makeNullable(schema: JsonSchema): JsonSchema {\n if (schema.type === \"null\") return schema;\n if (Array.isArray(schema.type)) {\n if (!schema.type.includes(\"null\")) schema.type = [...schema.type, \"null\"];\n return schema;\n }\n if (typeof schema.type === \"string\") {\n schema.type = [schema.type, \"null\"];\n } else {\n schema.type = [\"null\"];\n }\n return schema;\n}\n\nfunction isGenerated(col: MetalColumnDef) {\n return !!col.primary || !!col.autoIncrement || (col.generated !== null && col.generated !== undefined);\n}\n\nfunction shouldIncludeColumn(col: MetalColumnDef, mode: \"read\" | \"create\" | \"update\") {\n if (mode === \"read\") return true;\n if (mode === \"create\") return !isGenerated(col);\n if (mode === \"update\") return true;\n return true;\n}\n\nfunction shouldRequire(col: MetalColumnDef, mode: \"read\" | \"create\" | \"update\") {\n if (mode === \"update\") return false;\n if (!col.notNull) return false;\n if (mode === \"create\" && (col.default !== null && col.default !== undefined)) return false;\n return true;\n}\n\nexport function schemaFromEntity(ctor: Function, opts: SchemaFromEntityOptions = {}): JsonSchema | undefined {\n const bag = readMetalDecoratorBagFromConstructor(ctor);\n if (!bag || !Array.isArray(bag.columns) || bag.columns.length === 0) return undefined;\n\n const mode = opts.mode ?? \"read\";\n const name = opts.name ?? defaultSchemaName(ctor, opts.stripEntitySuffix ?? true);\n\n const schema: JsonSchema = {\n title: name,\n type: \"object\",\n properties: {},\n additionalProperties: opts.additionalProperties ?? true\n };\n\n const required: string[] = [];\n\n for (const entry of bag.columns) {\n const prop = entry.propertyName;\n const col = entry.column;\n\n if (!shouldIncludeColumn(col, mode)) continue;\n\n const propSchema = columnTypeToSchema(col);\n\n if (!col.notNull) makeNullable(propSchema);\n\n if (isLiteralDefault(col.default)) propSchema.default = col.default;\n\n if (mode === \"read\" && col.primary) propSchema.readOnly = true;\n\n (schema.properties as any)[prop] = propSchema;\n\n if (shouldRequire(col, mode)) required.push(prop);\n }\n\n if (required.length) schema.required = required;\n\n if ((opts.includeRelations ?? \"none\") === \"inline\") {\n for (const r of bag.relations ?? []) {\n const rel = r.relation;\n if (typeof rel?.target !== \"function\") continue;\n\n let target: any;\n try {\n target = rel.target();\n } catch {\n continue;\n }\n if (typeof target !== \"function\") continue;\n\n const targetName = defaultSchemaName(target, true);\n (schema.properties as any)[r.propertyName] = { $ref: `#/components/schemas/${targetName}` };\n }\n }\n\n return schema;\n}\n","import { schemaFromEntity, type SchemaFromEntityOptions } from \"./schemaFromEntity.js\";\n\nfunction deepMerge(a: any, b: any): any {\n if (Array.isArray(a) || Array.isArray(b)) return b ?? a;\n if (a && typeof a === \"object\" && b && typeof b === \"object\") {\n const out: any = { ...a };\n for (const [k, v] of Object.entries(b)) out[k] = deepMerge(out[k], v);\n return out;\n }\n return b ?? a;\n}\n\nexport interface RegisterMetalEntitiesOptions extends SchemaFromEntityOptions {\n merge?: \"override\" | \"merge\";\n}\n\nexport function registerMetalEntities(\n openapi: any,\n entities: Function[],\n opts: RegisterMetalEntitiesOptions = {}\n) {\n openapi.components ??= {};\n openapi.components.schemas ??= {};\n\n const mergeMode = opts.merge ?? \"merge\";\n\n for (const ctor of entities) {\n const s = schemaFromEntity(ctor, opts);\n if (!s) continue;\n\n const name = s.title || ctor.name;\n const existing = openapi.components.schemas[name];\n\n if (!existing || mergeMode === \"override\") {\n openapi.components.schemas[name] = s;\n } else {\n openapi.components.schemas[name] = deepMerge(existing, s);\n }\n }\n}\n","import type { ListQuery } from \"./listQuery.js\";\nimport type { SelectQueryBuilder } from \"metal-orm\";\nimport type { OrmSession } from \"metal-orm\";\nimport type { PaginatedResult } from \"metal-orm\";\n\nexport async function applyListQuery<TEntity extends object>(\n qb: SelectQueryBuilder<TEntity>,\n session: OrmSession,\n query?: ListQuery<TEntity>\n): Promise<PaginatedResult<TEntity>> {\n return qb.executePaged(session, pagedOptions(query));\n}\n\nexport function pagedOptions(query?: { page?: number; pageSize?: number }): {\n page: number;\n pageSize: number;\n} {\n return {\n page: query?.page ?? 1,\n pageSize: query?.pageSize ?? 10,\n };\n}\n\nexport function normalizeSort(sort: unknown): string[] {\n if (Array.isArray(sort)) {\n return sort.flatMap((v) => String(v).split(\",\"));\n }\n if (typeof sort === \"string\") {\n return sort.split(\",\");\n }\n return [];\n}\n\nexport type SortDirection = \"ASC\" | \"DESC\";\n\nexport type SortToken = {\n raw: string;\n field: string;\n path: string[];\n direction: SortDirection;\n isRelationField: boolean;\n};\n\nexport type ParseSortOptions = {\n max?: number;\n whitelist?: string[];\n};\n\nfunction matchWhitelist(path: string[], whitelist: string[]): boolean {\n const pathStr = path.join(\".\");\n\n for (const pattern of whitelist) {\n if (pattern === pathStr) return true;\n\n if (pattern.endsWith(\"*\")) {\n const prefix = pattern.slice(0, -1);\n if (pathStr.startsWith(prefix)) return true;\n }\n }\n\n return false;\n}\n\nexport function parseSort(sort: unknown, opts?: ParseSortOptions): SortToken[] {\n const max = opts?.max ?? 20;\n const whitelist = opts?.whitelist;\n\n const tokens = normalizeSort(sort)\n .map((s) => s.trim())\n .filter(Boolean)\n .slice(0, max)\n .map((raw) => {\n const direction: SortDirection = raw.startsWith(\"-\") ? \"DESC\" : \"ASC\";\n const field = raw.replace(/^[-+]/, \"\").trim();\n const path = field.split(\".\").map((p) => p.trim()).filter(Boolean);\n\n return {\n raw,\n field,\n path,\n direction,\n isRelationField: path.length > 1,\n };\n })\n .filter((t) => t.field.length > 0);\n\n if (whitelist && whitelist.length > 0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AAAA,IACzC;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,UAAU,MAAe,MAAsC;AAC7E,QAAM,MAAM,MAAM,OAAO;AACzB,QAAM,YAAY,MAAM;AAExB,QAAM,SAAS,cAAc,IAAI,EAC9B,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO,EACd,MAAM,GAAG,GAAG,EACZ,IAAI,CAAC,QAAQ;AACZ,UAAM,YAA2B,IAAI,WAAW,GAAG,IAAI,SAAS;AAChE,UAAM,QAAQ,IAAI,QAAQ,SAAS,EAAE,EAAE,KAAK;AAC5C,UAAM,OAAO,MAAM,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,OAAO;AAEjE,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,iBAAiB,KAAK,SAAS;AAAA,IACjC;AAAA,EACF,CAAC,EACA,OAAO,CAAC,MAAM,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAI,aAAa,UAAU,SAAS,GAAG;AACrC,WAAO,OAAO,OAAO,CAAC,MAAM,eAAe,EAAE,MAAM,SAAS,CAAC;AAAA,EAC/D;AAEA,SAAO;AACT;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"listQuery.d.ts","sourceRoot":"","sources":["../../src/metal/listQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,MAAM,SAAS,CAAC,OAAO,SAAS,MAAM,EAAE,KAAK,SAAS,gBAAgB,GAAG,CAAC,IAAI,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG;IACjH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAA"}
1
+ {"version":3,"file":"listQuery.d.ts","sourceRoot":"","sources":["../../src/metal/listQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,MAAM,SAAS,CAAC,OAAO,SAAS,MAAM,EAAE,KAAK,SAAS,gBAAgB,GAAG,CAAC,IAAI,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG;IACjH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"queryOptions.d.ts","sourceRoot":"","sources":["../../src/metal/queryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAsB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE1F,MAAM,MAAM,YAAY,CACpB,OAAO,SAAS,MAAM,EACtB,KAAK,SAAS,gBAAgB,GAAG,CAAC,IAClC;IACA,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC;IAClD,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B,CAAC"}
1
+ {"version":3,"file":"queryOptions.d.ts","sourceRoot":"","sources":["../../src/metal/queryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEtE,MAAM,MAAM,YAAY,CACpB,OAAO,SAAS,MAAM,EACtB,KAAK,SAAS,gBAAgB,GAAG,CAAC,IAClC;IACA,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC;IAClD,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"registerMetalEntities.d.ts","sourceRoot":"","sources":["../../src/metal/registerMetalEntities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,uBAAuB,EAAmB,MAAM,uBAAuB,CAAC;AAYxG,MAAM,WAAW,4BAA6B,SAAQ,uBAAuB;IAC3E,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;CAC9B;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,QAAQ,EAAE,EACpB,IAAI,GAAE,4BAAiC,QAoBxC"}
1
+ {"version":3,"file":"registerMetalEntities.d.ts","sourceRoot":"","sources":["../../src/metal/registerMetalEntities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAYvF,MAAM,WAAW,4BAA6B,SAAQ,uBAAuB;IAC3E,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;CAC9B;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,QAAQ,EAAE,EACpB,IAAI,GAAE,4BAAiC,QAoBxC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adorn-api",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "Stage-3 decorator-first OpenAPI + routing toolkit",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -77,10 +77,13 @@
77
77
  }
78
78
  },
79
79
  "devDependencies": {
80
+ "@eslint/js": "^9.39.2",
80
81
  "@types/express": "^4.17.0",
81
82
  "@types/node": "^20.0.0",
82
83
  "@types/supertest": "^6.0.0",
83
84
  "@types/swagger-ui-express": "^4.1.6",
85
+ "@typescript-eslint/eslint-plugin": "^8.52.0",
86
+ "@typescript-eslint/parser": "^8.52.0",
84
87
  "eslint": "^9.39.2",
85
88
  "express": "^5.2.1",
86
89
  "rimraf": "^6.0.0",