@znight/openapi 0.0.0-stage → 0.1.1

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 (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +572 -2
  3. package/dist/build-BTUC96mY.d.mts +174 -0
  4. package/dist/build-DXunOzlI.mjs +733 -0
  5. package/dist/build-DXunOzlI.mjs.map +1 -0
  6. package/dist/compiler.d.mts +16 -0
  7. package/dist/compiler.mjs +2639 -0
  8. package/dist/compiler.mjs.map +1 -0
  9. package/dist/emit-child.d.mts +1 -0
  10. package/dist/emit-child.mjs +124 -0
  11. package/dist/emit-child.mjs.map +1 -0
  12. package/dist/emit.d.mts +2 -0
  13. package/dist/emit.mjs +252 -0
  14. package/dist/emit.mjs.map +1 -0
  15. package/dist/index-CqQ6IRnN.d.mts +60 -0
  16. package/dist/index.d.mts +260 -0
  17. package/dist/index.mjs +777 -0
  18. package/dist/index.mjs.map +1 -0
  19. package/dist/openapi-CQk5dHqc.mjs +39 -0
  20. package/dist/openapi-CQk5dHqc.mjs.map +1 -0
  21. package/dist/shared-BZxtyaB0.mjs +147 -0
  22. package/dist/shared-BZxtyaB0.mjs.map +1 -0
  23. package/dist/testing.d.mts +39 -0
  24. package/dist/testing.mjs +155 -0
  25. package/dist/testing.mjs.map +1 -0
  26. package/dist/types-VzBexMKj.d.mts +213 -0
  27. package/dist/vite.d.mts +24 -0
  28. package/dist/vite.mjs +64 -0
  29. package/dist/vite.mjs.map +1 -0
  30. package/package.json +115 -4
  31. package/src/build.ts +898 -0
  32. package/src/compiler/analyze.ts +81 -0
  33. package/src/compiler/document.ts +612 -0
  34. package/src/compiler/generate.ts +79 -0
  35. package/src/compiler/index.ts +47 -0
  36. package/src/compiler/model.ts +141 -0
  37. package/src/compiler/operations.ts +1475 -0
  38. package/src/compiler/schemas.ts +706 -0
  39. package/src/compiler/validate.ts +102 -0
  40. package/src/compiler/values.ts +81 -0
  41. package/src/converters.ts +137 -0
  42. package/src/decorators.ts +187 -0
  43. package/src/emit/child.ts +144 -0
  44. package/src/emit/index.ts +377 -0
  45. package/src/emit/protocol.ts +35 -0
  46. package/src/index.ts +94 -0
  47. package/src/metadata.ts +112 -0
  48. package/src/openapi.ts +55 -0
  49. package/src/plugin.ts +810 -0
  50. package/src/shared.ts +154 -0
  51. package/src/testing.ts +224 -0
  52. package/src/types.ts +240 -0
  53. package/src/ui.ts +215 -0
  54. package/src/vite.ts +126 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.mjs","names":[],"sources":["../src/compiler/model.ts","../src/compiler/analyze.ts","../src/compiler/values.ts","../src/compiler/document.ts","../src/compiler/operations.ts","../src/compiler/schemas.ts","../src/compiler/validate.ts","../src/compiler/generate.ts","../src/compiler/index.ts"],"sourcesContent":["/**\n * Identities, codes and the data model of the `@znight/openapi` compiler extension. Pure: types and\n * constants only.\n */\nimport type { Location, ValueRef } from '@znight/compiler'\n\n/** Name of the extension (key of `metadata.extensions`). */\nexport const EXTENSION_NAME = 'openapi'\n\n/** Canonical identities of the decorators and functions of `@znight/openapi`. */\nexport const Ids: {\n readonly OpenApiDocument: string\n readonly ApiOperation: string\n readonly ApiTags: string\n readonly ApiResponse: string\n readonly ApiBody: string\n readonly ApiQuery: string\n readonly ApiHeader: string\n readonly ApiSecurity: string\n readonly ApiExclude: string\n readonly securityScheme: string\n} = Object.freeze({\n OpenApiDocument: '@znight/openapi#OpenApiDocument',\n ApiOperation: '@znight/openapi#ApiOperation',\n ApiTags: '@znight/openapi#ApiTags',\n ApiResponse: '@znight/openapi#ApiResponse',\n ApiBody: '@znight/openapi#ApiBody',\n ApiQuery: '@znight/openapi#ApiQuery',\n ApiHeader: '@znight/openapi#ApiHeader',\n ApiSecurity: '@znight/openapi#ApiSecurity',\n ApiExclude: '@znight/openapi#ApiExclude',\n securityScheme: '@znight/openapi#securityScheme',\n})\n\n/** Identities of `@znight/http` read by the extension. */\nexport const HttpIds: {\n readonly Controller: string\n readonly createRouteDecorator: string\n readonly HttpResponse: string\n readonly FileBody: string\n readonly SseEvent: string\n readonly SseBody: string\n} = Object.freeze({\n Controller: '@znight/http#Controller',\n createRouteDecorator: '@znight/http#createRouteDecorator',\n HttpResponse: '@znight/http#HttpResponse',\n FileBody: '@znight/http#FileBody',\n SseEvent: '@znight/http#SseEvent',\n SseBody: '@znight/http#SseBody',\n})\n\n/** Route method decorators of `@znight/http` (a method carrying one is a route handler). */\nexport const ROUTE_DECORATORS: ReadonlySet<string> = new Set([\n '@znight/http#Get',\n '@znight/http#Post',\n '@znight/http#Put',\n '@znight/http#Patch',\n '@znight/http#Delete',\n '@znight/http#Head',\n '@znight/http#Options',\n '@znight/http#All',\n '@znight/http#Sse',\n])\n\n/** Error codes used by the extension (see `ErrorCode` in `@znight/core`). */\nexport const Codes: {\n readonly InvalidDecorator: 'ZNIGHT005'\n readonly InvalidOpenApiDefinition: 'ZNIGHT030'\n readonly UndocumentedResponse: 'ZNIGHT031'\n readonly UnrepresentableType: 'ZNIGHT032'\n readonly DuplicateOperationId: 'ZNIGHT033'\n readonly SchemaNameConflict: 'ZNIGHT034'\n readonly InconsistentOperation: 'ZNIGHT035'\n readonly InvalidSecurityRequirement: 'ZNIGHT036'\n} = Object.freeze({\n InvalidDecorator: 'ZNIGHT005',\n InvalidOpenApiDefinition: 'ZNIGHT030',\n UndocumentedResponse: 'ZNIGHT031',\n UnrepresentableType: 'ZNIGHT032',\n DuplicateOperationId: 'ZNIGHT033',\n SchemaNameConflict: 'ZNIGHT034',\n InconsistentOperation: 'ZNIGHT035',\n InvalidSecurityRequirement: 'ZNIGHT036',\n})\n\n/** Generic aliases meaning \"the Standard Schema S\" (`z.output<typeof S>`), checked against the installed libraries. */\nexport const SCHEMA_ALIASES: Readonly<Record<string, 'input' | 'output'>> = Object.freeze({\n 'zod#output': 'output',\n 'zod#infer': 'output',\n 'zod#input': 'input',\n 'zod/v4#output': 'output',\n 'zod/v4#infer': 'output',\n 'zod/v4#input': 'input',\n 'valibot#InferOutput': 'output',\n 'valibot#InferInput': 'input',\n '@znight/http#InferSchemaOutput': 'output',\n '@znight/http#InferSchemaInput': 'input',\n '@standard-schema/spec#StandardSchemaV1.InferOutput': 'output',\n '@standard-schema/spec#StandardSchemaV1.InferInput': 'input',\n})\n\n/** ArkType: `typeof S.infer` / `typeof S.inferIn`. */\nexport const SCHEMA_MEMBERS: Readonly<Record<string, 'input' | 'output'>> = Object.freeze({\n infer: 'output',\n inferIn: 'input',\n})\n\n/** Types kept as references by the shape resolver (bodies of special responses). */\nexport const KEEP: readonly string[] = Object.freeze([\n HttpIds.HttpResponse,\n HttpIds.FileBody,\n HttpIds.SseEvent,\n HttpIds.SseBody,\n 'globalThis#AsyncIterable',\n 'globalThis#AsyncIterableIterator',\n 'globalThis#AsyncGenerator',\n 'globalThis#Response',\n])\n\n/** Data stored by `analyzeClass`. */\nexport type OpenApiStored =\n | {\n readonly kind: 'document'\n readonly identity: string\n readonly displayName: string\n readonly location: Location\n }\n | {\n readonly kind: 'controller'\n readonly identity: string\n readonly displayName: string\n }\n\n/** A Standard Schema to convert at assembly. */\nexport interface SlotData {\n readonly name: string\n readonly ref: ValueRef\n readonly io: Set<'input' | 'output'>\n /** The declaration of the schema (the reference when it cannot be found). */\n readonly location: Location\n}\n","/**\n * `analyzeClass`: records the `@OpenApiDocument` class and the controllers carrying `@Api*`\n * decorators, and reports misplaced decorators (ZNIGHT030). The operations are built in\n * `validate`, from the route table of the http extension.\n */\nimport type { AnalyzeContext, ClassInfo, DecoratorInfo } from '@znight/compiler'\nimport type { OpenApiStored } from './model.ts'\n\nimport { Codes, EXTENSION_NAME, HttpIds, Ids, ROUTE_DECORATORS } from './model.ts'\n\n/** `analyzeClass` of the extension. */\nexport function analyzeOpenApiClass(cls: ClassInfo, ctx: AnalyzeContext<OpenApiStored>): void {\n const owned = (decorators: readonly DecoratorInfo[]): DecoratorInfo[] =>\n decorators.filter(decorator => decorator.owner === EXTENSION_NAME)\n const document = cls.decorators.find(decorator => decorator.identity === Ids.OpenApiDocument)\n const controller = cls.decorators.some(decorator => decorator.identity === HttpIds.Controller)\n const members = [\n ...cls.methods.map(method => ({ decorators: owned(method.decorators), method })),\n ...cls.properties.map(property => ({ decorators: owned(property.decorators), method: undefined })),\n ]\n const misplaced = (decorator: DecoratorInfo, message: string, hints: readonly string[]): void => {\n ctx.report({\n code: Codes.InvalidOpenApiDefinition,\n severity: 'error',\n message,\n location: decorator.location,\n hints,\n })\n }\n if (document !== undefined) {\n if (controller) {\n misplaced(document, `@OpenApiDocument goes on a class of its own, not on the controller ${cls.displayName}`, [\n 'Declare it on an empty class: @OpenApiDocument({...}) export class Api {}',\n ])\n }\n for (const decorator of owned(cls.decorators)) {\n if (decorator !== document && !controller) {\n misplaced(\n decorator,\n `@${decorator.name} applies to controllers and route handlers, not to the @OpenApiDocument class`,\n [],\n )\n }\n }\n ctx.store({ kind: 'document', identity: cls.identity, displayName: cls.displayName, location: document.location })\n if (!controller) return\n }\n if (!controller) {\n const consumer = cls.decorators.some(decorator => decorator.identity === '@znight/messaging#Consumer')\n const hints = consumer\n ? ['Message consumers are not documented by OpenAPI (AsyncAPI is not supported in v0.1)']\n : ['Add @Controller() to the class, or remove the decorator']\n for (const decorator of owned(cls.decorators)) {\n misplaced(decorator, `@${decorator.name} applies to controllers: ${cls.displayName} is not a @Controller`, hints)\n }\n for (const member of members) {\n for (const decorator of member.decorators) {\n misplaced(\n decorator,\n `@${decorator.name} applies to route handlers: ${cls.displayName} is not a @Controller`,\n hints,\n )\n }\n }\n return\n }\n for (const member of members) {\n const handler = member.method?.decorators.some(\n decorator => decorator.identity !== undefined && ROUTE_DECORATORS.has(decorator.identity),\n )\n if (handler === true) continue\n for (const decorator of member.decorators) {\n misplaced(\n decorator,\n `@${decorator.name} applies to route handlers: ${cls.displayName}.${member.method?.name ?? 'this member'} has no route decorator (@Get, @Post...)`,\n ['Add a route decorator, or move the decorator to a route handler'],\n )\n }\n }\n ctx.store({ kind: 'controller', identity: cls.identity, displayName: cls.displayName })\n}\n","/**\n * Reading statically evaluated values (`StaticValue`) without importing the compiler: references\n * to exported bindings (`ValueRef`) are recognised structurally.\n */\nimport type { StaticValue, ValueRef } from '@znight/compiler'\nimport type { JsonValue } from '../types.ts'\n\n/** `true` for a `ValueRef` (a reference to an exported binding, nested in an evaluated value). */\nexport function isRef(value: unknown): value is ValueRef {\n if (typeof value !== 'object' || value === null) return false\n const prototype = Object.getPrototypeOf(value)\n return prototype !== Object.prototype && prototype !== null && (value as { kind?: unknown }).kind === 'ref'\n}\n\n/** `true` for an evaluated object literal (not an array, not a reference). */\nexport function isRecord(value: unknown): value is Readonly<Record<string, StaticValue>> {\n return typeof value === 'object' && value !== null && !Array.isArray(value) && !isRef(value)\n}\n\n/** The value when it is JSON (no `undefined` inside objects is kept, no bigint, no reference). */\nexport function toJson(value: StaticValue): JsonValue | undefined {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return value\n if (typeof value === 'number') return Number.isFinite(value) ? value : undefined\n if (value === undefined || typeof value === 'bigint' || isRef(value)) return undefined\n if (Array.isArray(value)) {\n const items: JsonValue[] = []\n for (const item of value as readonly StaticValue[]) {\n const json = toJson(item)\n if (json === undefined) return undefined\n items.push(json)\n }\n return items\n }\n const result: Record<string, JsonValue> = {}\n for (const [key, item] of Object.entries(value as Readonly<Record<string, StaticValue>>)) {\n if (item === undefined) continue\n const json = toJson(item)\n if (json === undefined) return undefined\n result[key] = json\n }\n return result\n}\n\n/** The first `$znight` key found in a value (reserved), as a path (`info.x.$znight`). */\nexport function findReservedKey(value: StaticValue, path = ''): string | undefined {\n if (Array.isArray(value)) {\n for (const [index, item] of (value as readonly StaticValue[]).entries()) {\n const found = findReservedKey(item, `${path}[${index}]`)\n if (found !== undefined) return found\n }\n return undefined\n }\n if (!isRecord(value)) return undefined\n for (const [key, item] of Object.entries(value)) {\n const where = path === '' ? key : `${path}.${key}`\n if (key === '$znight') return where\n const found = findReservedKey(item, where)\n if (found !== undefined) return found\n }\n return undefined\n}\n\n/** A short description for messages. */\nexport function describe(value: StaticValue): string {\n if (value === null) return 'null'\n if (Array.isArray(value)) return 'an array'\n if (isRef(value)) return `a reference to '${value.text}'`\n if (typeof value === 'object') return 'an object'\n if (typeof value === 'string') return JSON.stringify(value)\n return String(value)\n}\n\n/** Absolute URL (`https://...`, `mailto:`...). */\nexport function isAbsoluteUrl(value: string): boolean {\n return URL.canParse(value)\n}\n\n/** Absolute or relative URL (servers: `/api`, `https://api.example.com/v1`). */\nexport function isUrlReference(value: string): boolean {\n return value !== '' && !/\\s/.test(value) && (URL.canParse(value) || URL.canParse(value, 'https://example.com'))\n}\n","/**\n * `@OpenApiDocument` options and `securityScheme()` definitions, read statically and checked\n * (ZNIGHT030 for malformed values, ZNIGHT036 for security requirements).\n */\nimport type { DefinitionInfo, Location, StaticValue, ValidateContext, ValueRef } from '@znight/compiler'\nimport type { InfoObject, JsonValue, SecurityRequirementObject, SecuritySchemeObject, TagObject } from '../types.ts'\nimport type { OpenApiStored } from './model.ts'\n\nimport { OPENAPI_VERSION } from '../shared.ts'\nimport { Codes, HttpIds, Ids } from './model.ts'\nimport { describe, findReservedKey, isAbsoluteUrl, isRecord, isRef, isUrlReference, toJson } from './values.ts'\n\ntype Context = ValidateContext<OpenApiStored>\n\n/** Style of default operation ids. */\nexport type OperationIdStyle = 'controller.handler' | 'handler' | 'Controller_handler'\n\n/** A resolved `securityScheme()`. */\nexport interface SchemeModel {\n readonly identity: string\n readonly name: string\n readonly definition: SecuritySchemeObject\n readonly location: Location\n /** Scopes declared by the flows (oauth2), `undefined` when the scheme takes no scope check. */\n readonly scopes: ReadonlySet<string> | undefined\n readonly scoped: boolean\n}\n\n/** A requirement input resolved to schemes (AND), each with its scopes. */\nexport type RequirementModel = readonly {\n readonly scheme: SchemeModel\n readonly scopes: readonly string[] | undefined\n}[]\n\n/** A `decisions` entry. */\nexport interface DecisionModel {\n readonly identity: string\n readonly text: string\n readonly location: Location\n readonly security: readonly RequirementModel[]\n readonly scopesFromValue: boolean\n used: boolean\n}\n\n/** The checked document options. */\nexport interface DocumentModel {\n readonly identity: string | undefined\n readonly location: Location | undefined\n readonly info: InfoObject\n readonly servers: readonly JsonValue[] | undefined\n readonly tags: readonly TagObject[]\n readonly externalDocs: JsonValue | undefined\n readonly security: readonly RequirementModel[] | undefined\n readonly decisions: readonly DecisionModel[]\n readonly operationIds: OperationIdStyle\n readonly errors: false | { readonly contentType: string; readonly schema: ValueRef | undefined }\n readonly strict: boolean\n readonly jsdoc: boolean\n readonly extensions: Readonly<Record<string, JsonValue>>\n}\n\nconst OPTION_KEYS = new Set([\n 'info',\n 'servers',\n 'tags',\n 'externalDocs',\n 'security',\n 'decisions',\n 'operationIds',\n 'errors',\n 'strict',\n 'jsdoc',\n 'extensions',\n])\nconst INFO_KEYS = new Set(['title', 'version', 'summary', 'description', 'termsOfService', 'contact', 'license'])\nconst SPDX = /^[A-Za-z0-9.+-]+(?:\\s+(?:AND|OR|WITH)\\s+[A-Za-z0-9.+-]+)*$/\n\n/** Security schemes declared with `securityScheme(name, definition)`, by identity of their `const`. */\nexport class SchemeRegistry {\n readonly #ctx: Context\n readonly #schemes = new Map<string, SchemeModel | null>()\n readonly #byName = new Map<string, SchemeModel>()\n readonly #definitions: ReadonlyMap<string, DefinitionInfo>\n /** Schemes referenced by the document, by name. */\n readonly used: Map<string, SchemeModel> = new Map()\n\n constructor(ctx: Context) {\n this.#ctx = ctx\n this.#definitions = new Map(\n ctx.definitionsOf(Ids.securityScheme).map(definition => [definition.identity, definition]),\n )\n }\n\n /** The scheme a reference points to (`undefined` and a ZNIGHT036 when it is not a scheme). */\n resolve(ref: ValueRef): SchemeModel | undefined {\n const identity = ref.identity\n if (identity !== undefined && this.#schemes.has(identity)) return this.#schemes.get(identity) ?? undefined\n const definition = identity === undefined ? undefined : this.#definitions.get(identity)\n if (definition === undefined || identity === undefined) {\n this.#ctx.report({\n code: Codes.InvalidSecurityRequirement,\n severity: 'error',\n message: `${ref.text} is not a security scheme declared with securityScheme()`,\n location: ref.location,\n hints: [\n \"Declare it: export const ApiKey = securityScheme('apiKey', { type: 'apiKey', in: 'header', name: 'x-api-key' })\",\n ],\n })\n return undefined\n }\n const scheme = this.#parse(definition)\n this.#schemes.set(identity, scheme ?? null)\n return scheme\n }\n\n #parse(definition: DefinitionInfo): SchemeModel | undefined {\n const [nameArg, definitionArg] = definition.args\n const name = nameArg?.evaluated ? nameArg.value : undefined\n const value = definitionArg?.evaluated ? definitionArg.value : undefined\n const malformed = (message: string, location: Location = definition.call): undefined => {\n this.#ctx.report({\n code: Codes.InvalidOpenApiDefinition,\n severity: 'error',\n message: `Invalid security scheme ${definition.displayName}: ${message}`,\n location,\n hints: ['securityScheme(name, definition) takes a static name and an OpenAPI Security Scheme Object'],\n })\n return undefined\n }\n if (typeof name !== 'string' || !/^[A-Za-z0-9._-]+$/.test(name)) {\n return malformed('the name must be a static string of [A-Za-z0-9._-]', nameArg?.location)\n }\n if (!isRecord(value)) return malformed('the definition must be a static object', definitionArg?.location)\n const reserved = findReservedKey(value)\n if (reserved !== undefined) return malformed(`\"$znight\" is a reserved key (${reserved})`, definitionArg?.location)\n const json = toJson(value)\n if (!isRecord(json)) return malformed('the definition must be JSON', definitionArg?.location)\n const where = definitionArg?.location\n const text = (key: string, required: boolean): string | undefined => {\n const field = json[key]\n if (field === undefined && !required) return undefined\n if (typeof field !== 'string' || field === '') throw new SchemeError(`\"${key}\" must be a non-empty string`)\n return field\n }\n let scopes: Set<string> | undefined\n try {\n for (const key of Object.keys(json)) {\n if (!ALLOWED_SCHEME_KEYS[String(json['type'])]?.has(key) && !key.startsWith('x-') && key !== 'description') {\n throw new SchemeError(`unknown field \"${key}\" for a ${String(json['type'])} scheme`)\n }\n }\n switch (json['type']) {\n case 'apiKey': {\n text('name', true)\n const location = text('in', true)\n if (location !== 'query' && location !== 'header' && location !== 'cookie') {\n throw new SchemeError('\"in\" must be \"query\", \"header\" or \"cookie\"')\n }\n break\n }\n case 'http':\n text('scheme', true)\n text('bearerFormat', false)\n break\n case 'oauth2': {\n const flows = json['flows']\n if (!isRecord(flows) || Object.keys(flows).length === 0) throw new SchemeError('\"flows\" must declare a flow')\n scopes = new Set()\n for (const [flow, body] of Object.entries(flows)) {\n if (!FLOW_URLS[flow]) throw new SchemeError(`unknown flow \"${flow}\"`)\n if (!isRecord(body) || !isRecord(body['scopes'])) throw new SchemeError(`the ${flow} flow needs \"scopes\"`)\n for (const url of FLOW_URLS[flow] ?? []) {\n const field = body[url]\n if (typeof field !== 'string' || !isUrlReference(field)) {\n throw new SchemeError(`the ${flow} flow needs a \"${url}\" URL`)\n }\n }\n for (const scope of Object.keys(body['scopes'])) scopes.add(scope)\n }\n break\n }\n case 'openIdConnect': {\n const url = text('openIdConnectUrl', true) as string\n if (!isUrlReference(url)) throw new SchemeError('\"openIdConnectUrl\" must be a URL')\n break\n }\n case 'mutualTLS':\n break\n default:\n throw new SchemeError('\"type\" must be \"apiKey\", \"http\", \"oauth2\", \"openIdConnect\" or \"mutualTLS\"')\n }\n } catch (error) {\n if (error instanceof SchemeError) return malformed(error.message, where)\n throw error\n }\n const scheme: SchemeModel = {\n identity: definition.identity,\n name,\n definition: json as unknown as SecuritySchemeObject,\n location: definition.location,\n scopes,\n scoped: json['type'] === 'oauth2' || json['type'] === 'openIdConnect',\n }\n const other = this.#byName.get(name)\n if (other !== undefined && JSON.stringify(other.definition) !== JSON.stringify(scheme.definition)) {\n this.#ctx.report({\n code: Codes.InvalidSecurityRequirement,\n severity: 'error',\n message: `Two security schemes are named \"${name}\" with different definitions: ${definition.displayName} and ${other.identity}`,\n location: definition.location,\n related: [{ message: 'the other scheme', location: other.location }],\n hints: ['Give each scheme its own name, or reuse one declaration'],\n })\n return undefined\n }\n this.#byName.set(name, scheme)\n return scheme\n }\n\n /**\n * Resolves a requirement input (`ApiKey`, `[Bearer, Tenant]`, `{ scheme, scopes }`) to schemes.\n * Reports ZNIGHT036 and returns `undefined` when it is invalid.\n */\n requirement(value: StaticValue, location: Location): RequirementModel | undefined {\n const report = (message: string, hints: readonly string[] = REQUIREMENT_HINTS): undefined => {\n this.#ctx.report({ code: Codes.InvalidSecurityRequirement, severity: 'error', message, location, hints })\n return undefined\n }\n const one = (item: StaticValue, scopes: readonly string[] | undefined): RequirementModel[number] | undefined => {\n if (!isRef(item)) return report(`${describe(item)} is not a security scheme declared with securityScheme()`)\n const scheme = this.resolve(item)\n if (scheme === undefined) return undefined\n if (scopes !== undefined && scopes.length > 0) {\n if (!scheme.scoped) {\n return report(\n `Scopes are only allowed on oauth2 and openIdConnect schemes, not on \"${scheme.name}\" (${String(scheme.definition.type)})`,\n ['Remove the scopes, or use an oauth2 / openIdConnect scheme'],\n )\n }\n const unknown = scheme.scopes === undefined ? [] : scopes.filter(scope => !scheme.scopes?.has(scope))\n if (unknown.length > 0) {\n return report(\n `The scope${unknown.length > 1 ? 's' : ''} ${unknown.map(scope => `\"${scope}\"`).join(', ')} ${unknown.length > 1 ? 'are' : 'is'} not declared by the flows of \"${scheme.name}\"`,\n [`Declared scopes: ${[...(scheme.scopes ?? [])].join(', ') || 'none'}`],\n )\n }\n }\n return { scheme, scopes }\n }\n if (Array.isArray(value)) {\n const items: RequirementModel[number][] = []\n for (const item of value as readonly StaticValue[]) {\n const resolved = one(item, undefined)\n if (resolved === undefined) return undefined\n items.push(resolved)\n }\n return items\n }\n if (isRecord(value)) {\n const scopes = value['scopes']\n if (!Array.isArray(scopes) || !(scopes as readonly StaticValue[]).every(scope => typeof scope === 'string')) {\n return report('{ scheme, scopes } needs a static array of scope names')\n }\n const resolved = one(value['scheme'] as StaticValue, scopes as readonly string[])\n return resolved === undefined ? undefined : [resolved]\n }\n const resolved = one(value, undefined)\n return resolved === undefined ? undefined : [resolved]\n }\n\n /** Requirement objects of resolved requirements (`scopes` overrides every scheme's scopes). */\n objects(requirements: readonly RequirementModel[], scopes?: readonly string[]): SecurityRequirementObject[] {\n return requirements.map(requirement => {\n const object: Record<string, readonly string[]> = {}\n for (const { scheme, scopes: own } of requirement) {\n this.used.set(scheme.name, scheme)\n object[scheme.name] = [...(scopes ?? own ?? [])]\n }\n return object\n })\n }\n}\n\nclass SchemeError extends Error {}\n\nconst REQUIREMENT_HINTS = [\n 'A requirement is a scheme (ApiKey), several schemes that all apply ([Bearer, Tenant]) or { scheme: OAuth, scopes: [...] }',\n]\n\nconst ALLOWED_SCHEME_KEYS: Readonly<Record<string, ReadonlySet<string>>> = {\n apiKey: new Set(['type', 'name', 'in']),\n http: new Set(['type', 'scheme', 'bearerFormat']),\n oauth2: new Set(['type', 'flows']),\n openIdConnect: new Set(['type', 'openIdConnectUrl']),\n mutualTLS: new Set(['type']),\n}\n\nconst FLOW_URLS: Readonly<Record<string, readonly string[]>> = {\n implicit: ['authorizationUrl'],\n password: ['tokenUrl'],\n clientCredentials: ['tokenUrl'],\n authorizationCode: ['authorizationUrl', 'tokenUrl'],\n}\n\n/** Reads and checks the `@OpenApiDocument` options (and the defaults of `package.json`). */\nexport function readDocument(ctx: Context, schemes: SchemeRegistry): DocumentModel {\n const documents = ctx.stored.filter(data => data.kind === 'document')\n for (const extra of documents.slice(1)) {\n const first = documents[0]\n ctx.report({\n code: Codes.InvalidOpenApiDefinition,\n severity: 'error',\n message: `An application has one @OpenApiDocument: ${extra.displayName} and ${first?.displayName ?? '?'} both declare one`,\n location: extra.location,\n ...(first === undefined\n ? {}\n : { related: [{ message: 'the other @OpenApiDocument', location: first.location }] }),\n hints: ['Keep one class with @OpenApiDocument; filter operations with OpenApiPlugin.configure({ filter })'],\n })\n }\n const stored = documents[0]\n const cls = stored === undefined ? undefined : ctx.classInfo(stored.identity)\n const decorator = cls?.decorators.find(candidate => candidate.identity === Ids.OpenApiDocument)\n const arg = decorator?.args[0]\n const value: StaticValue = arg?.evaluated === true ? arg.value : undefined\n const location = arg?.location ?? decorator?.location\n const invalid = (message: string, hints: readonly string[] = []): void => {\n ctx.report({\n code: Codes.InvalidOpenApiDefinition,\n severity: 'error',\n message: `Invalid @OpenApiDocument options: ${message}`,\n ...(location === undefined ? {} : { location }),\n hints,\n })\n }\n const options: Readonly<Record<string, StaticValue>> = isRecord(value) ? value : {}\n if (value !== undefined && !isRecord(value)) invalid(`expected an object, received ${describe(value)}`)\n for (const key of Object.keys(options)) {\n if (!OPTION_KEYS.has(key)) invalid(`unknown option \"${key}\"`, [`Options: ${[...OPTION_KEYS].join(', ')}`])\n }\n const reserved = findReservedKey(options)\n if (reserved !== undefined) invalid(`\"$znight\" is a reserved key (${reserved})`)\n\n const bool = (key: string, fallback: boolean): boolean => {\n const option = options[key]\n if (option === undefined) return fallback\n if (typeof option !== 'boolean') {\n invalid(`\"${key}\" must be true or false`)\n return fallback\n }\n return option\n }\n const json = (key: string): JsonValue | undefined => {\n const option = options[key]\n if (option === undefined) return undefined\n const converted = toJson(option)\n if (converted === undefined) invalid(`\"${key}\" must be a static JSON value`)\n return converted\n }\n\n // info\n const doc = bool('jsdoc', true) ? cls?.doc : undefined\n const manifest = ctx.project.rootPackage?.json ?? {}\n const infoOption = json('info')\n const info: Record<string, JsonValue> = {}\n if (infoOption !== undefined && !isRecord(infoOption)) invalid('\"info\" must be an object')\n const given = isRecord(infoOption) ? (infoOption as Readonly<Record<string, JsonValue>>) : {}\n for (const key of Object.keys(given)) {\n if (!INFO_KEYS.has(key) && !key.startsWith('x-')) invalid(`unknown field \"info.${key}\"`)\n }\n const manifestString = (key: string): string | undefined => {\n const field = manifest[key]\n return typeof field === 'string' && field !== '' ? field : undefined\n }\n const title = given['title'] ?? doc?.summary ?? manifestString('name') ?? 'API'\n const version = given['version'] ?? manifestString('version') ?? '0.0.0'\n if (typeof title !== 'string' || title === '') invalid('\"info.title\" must be a non-empty string')\n if (typeof version !== 'string' || version === '') invalid('\"info.version\" must be a non-empty string')\n info['title'] = typeof title === 'string' ? title : 'API'\n info['version'] = typeof version === 'string' ? version : '0.0.0'\n for (const key of ['summary', 'termsOfService', 'contact', 'license']) {\n if (given[key] !== undefined) info[key] = given[key] as JsonValue\n }\n const description = given['description'] ?? doc?.description ?? manifestString('description')\n if (description !== undefined) info['description'] = description\n if (info['license'] === undefined) {\n const license = manifestString('license')\n if (license !== undefined && SPDX.test(license) && license !== 'UNLICENSED') {\n info['license'] = { name: license, identifier: license }\n }\n }\n for (const [key, field] of Object.entries(given)) if (key.startsWith('x-')) info[key] = field\n checkInfo(info, invalid)\n\n // servers, tags, externalDocs, extensions\n const servers = json('servers')\n if (servers !== undefined) {\n if (\n !Array.isArray(servers) ||\n servers.some(server => !isRecord(server) || !isUrlReference(String(server['url'])))\n ) {\n invalid('\"servers\" must be an array of { url, description?, variables? } with valid URLs')\n }\n }\n const tagsOption = json('tags')\n const tags: TagObject[] = []\n if (tagsOption !== undefined) {\n if (Array.isArray(tagsOption)) {\n const seen = new Set<string>()\n for (const tag of tagsOption) {\n if (!isRecord(tag) || typeof tag['name'] !== 'string' || tag['name'] === '') {\n invalid('every tag needs a non-empty \"name\"')\n continue\n }\n if (seen.has(tag['name'])) invalid(`the tag \"${tag['name']}\" is declared twice`)\n seen.add(tag['name'])\n tags.push(tag as unknown as TagObject)\n }\n } else invalid('\"tags\" must be an array of { name, description? }')\n }\n const externalDocs = json('externalDocs')\n if (externalDocs !== undefined && (!isRecord(externalDocs) || !isAbsoluteUrl(String(externalDocs['url'])))) {\n invalid('\"externalDocs\" must be { url, description? } with an absolute URL')\n }\n const extensionsOption = json('extensions')\n const extensions: Record<string, JsonValue> = {}\n if (extensionsOption !== undefined) {\n if (isRecord(extensionsOption)) {\n for (const [key, field] of Object.entries(extensionsOption as Readonly<Record<string, JsonValue>>)) {\n if (key.startsWith('x-')) extensions[key] = field\n else invalid(`the extension \"${key}\" must start with \"x-\"`)\n }\n } else invalid('\"extensions\" must be an object of x-* fields')\n }\n\n // operation ids\n const style = options['operationIds'] ?? 'controller.handler'\n if (style !== 'controller.handler' && style !== 'handler' && style !== 'Controller_handler') {\n invalid('\"operationIds\" must be \"controller.handler\", \"handler\" or \"Controller_handler\"')\n }\n\n // errors\n let errors: DocumentModel['errors'] = { contentType: 'application/json', schema: undefined }\n const errorsOption = options['errors']\n if (errorsOption === false) errors = false\n else if (isRecord(errorsOption)) {\n const schema = errorsOption['schema']\n const contentType = errorsOption['contentType'] ?? 'application/json'\n if (!isRef(schema)) invalid('\"errors.schema\" must be a Standard Schema (an exported schema)')\n if (typeof contentType !== 'string') invalid('\"errors.contentType\" must be a media type')\n errors = {\n contentType: typeof contentType === 'string' ? contentType : 'application/json',\n schema: isRef(schema) ? schema : undefined,\n }\n } else if (errorsOption !== undefined && errorsOption !== true) {\n invalid('\"errors\" must be true, false or { schema, contentType? }')\n }\n\n // security and decisions\n const where = location ?? decorator?.location\n let security: RequirementModel[] | undefined\n const securityOption = options['security']\n if (securityOption !== undefined && where !== undefined) {\n if (Array.isArray(securityOption)) {\n security = []\n for (const item of securityOption as readonly StaticValue[]) {\n const requirement = schemes.requirement(item, where)\n if (requirement !== undefined) security.push(requirement)\n }\n } else invalid('\"security\" must be an array of requirements')\n }\n const decisions = readDecisions(ctx, schemes, options['decisions'], where, invalid)\n\n return {\n identity: stored?.identity,\n location: decorator?.location,\n info: info as unknown as InfoObject,\n servers: Array.isArray(servers) ? servers : undefined,\n tags,\n externalDocs,\n security,\n decisions,\n operationIds: (typeof style === 'string' ? style : 'controller.handler') as OperationIdStyle,\n errors,\n strict: bool('strict', false),\n jsdoc: bool('jsdoc', true),\n extensions,\n }\n}\n\nfunction checkInfo(info: Readonly<Record<string, JsonValue>>, invalid: (message: string) => void): void {\n const terms = info['termsOfService']\n if (terms !== undefined && (typeof terms !== 'string' || !isAbsoluteUrl(terms))) {\n invalid('\"info.termsOfService\" must be an absolute URL')\n }\n const contact = info['contact']\n if (contact !== undefined) {\n if (isRecord(contact)) {\n if (contact['url'] !== undefined && !isAbsoluteUrl(String(contact['url']))) {\n invalid('\"info.contact.url\" must be an absolute URL')\n }\n if (contact['email'] !== undefined && !/^[^\\s@]+@[^\\s@]+$/.test(String(contact['email']))) {\n invalid('\"info.contact.email\" must be an email address')\n }\n } else invalid('\"info.contact\" must be { name?, url?, email? }')\n }\n const license = info['license']\n if (license !== undefined) {\n if (!isRecord(license) || typeof license['name'] !== 'string' || license['name'] === '') {\n invalid('\"info.license\" must be { name, identifier? } or { name, url? }')\n } else {\n if (license['identifier'] !== undefined && license['url'] !== undefined) {\n invalid('\"info.license\" takes \"identifier\" or \"url\", not both')\n }\n if (license['identifier'] !== undefined && !SPDX.test(String(license['identifier']))) {\n invalid('\"info.license.identifier\" must be an SPDX expression (MIT, Apache-2.0...)')\n }\n if (license['url'] !== undefined && !isAbsoluteUrl(String(license['url']))) {\n invalid('\"info.license.url\" must be an absolute URL')\n }\n }\n }\n}\n\nfunction readDecisions(\n ctx: Context,\n schemes: SchemeRegistry,\n value: StaticValue,\n location: Location | undefined,\n invalid: (message: string) => void,\n): DecisionModel[] {\n if (value === undefined || location === undefined) return []\n if (!Array.isArray(value)) {\n invalid('\"decisions\" must be an array of { when, security, scopes? }')\n return []\n }\n const routeDecorators = new Set(\n ctx.definitionsOf(HttpIds.createRouteDecorator).map(definition => definition.identity),\n )\n const decisions: DecisionModel[] = []\n for (const entry of value as readonly StaticValue[]) {\n if (!isRecord(entry)) {\n invalid('every decision is { when, security, scopes? }')\n continue\n }\n const when = entry['when']\n if (!isRef(when) || when.identity === undefined || !routeDecorators.has(when.identity)) {\n ctx.report({\n code: Codes.InvalidSecurityRequirement,\n severity: 'error',\n message: `decisions[].when must be a route decorator created with createRouteDecorator(), not ${describe(when)}`,\n location: isRef(when) ? when.location : location,\n hints: [\"Declare it: export const Public = createRouteDecorator('public')\"],\n })\n continue\n }\n const scopes = entry['scopes']\n if (scopes !== undefined && scopes !== 'value') {\n ctx.report({\n code: Codes.InvalidSecurityRequirement,\n severity: 'error',\n message: `decisions[].scopes must be 'value' (received ${describe(scopes)})`,\n location: when.location,\n hints: [\n \"{ when: Roles, security: [OAuth], scopes: 'value' } turns @Roles(['admin']) into the scopes ['admin']\",\n ],\n })\n continue\n }\n const security = entry['security']\n if (!Array.isArray(security)) {\n ctx.report({\n code: Codes.InvalidSecurityRequirement,\n severity: 'error',\n message: `decisions[].security of ${when.text} must be an array of requirements ([] means public)`,\n location: when.location,\n })\n continue\n }\n const requirements: RequirementModel[] = []\n let valid = true\n for (const item of security as readonly StaticValue[]) {\n const requirement = schemes.requirement(item, when.location)\n if (requirement === undefined) valid = false\n else requirements.push(requirement)\n }\n if (!valid) continue\n decisions.push({\n identity: when.identity,\n text: when.text,\n location: when.location,\n security: requirements,\n scopesFromValue: scopes === 'value',\n used: false,\n })\n }\n return decisions\n}\n\n/** The document template: `openapi`, `info`, declared `servers`, `tags`... and the default security. */\nexport function documentTemplate(\n model: DocumentModel,\n security: readonly SecurityRequirementObject[] | undefined,\n): Record<string, JsonValue> {\n const template: Record<string, JsonValue> = { openapi: OPENAPI_VERSION, info: model.info as unknown as JsonValue }\n if (model.servers !== undefined) template['servers'] = model.servers as JsonValue\n if (model.tags.length > 0) template['tags'] = model.tags as unknown as JsonValue\n if (model.externalDocs !== undefined) template['externalDocs'] = model.externalDocs\n if (security !== undefined) template['security'] = security as unknown as JsonValue\n for (const [key, value] of Object.entries(model.extensions)) template[key] = value\n return template\n}\n","/**\n * The operation model (§5.4 of RFC 0002): one operation per documented route and concrete method,\n * built from the route table of `@znight/http/compiler`, the handler signatures and their JSDoc,\n * and the `@Api*` decorators.\n */\nimport type {\n ArgInfo,\n ClassInfo,\n DecoratorInfo,\n DocComment,\n Location,\n MethodInfo,\n ParameterInfo,\n Shape,\n StaticValue,\n ValidateContext,\n} from '@znight/compiler'\nimport type {\n CoercionPlan,\n HttpControllerData,\n HttpParamData,\n HttpRouteData,\n MetaEntry,\n UploadData,\n} from '@znight/http/compiler'\nimport type { ParametersPlaceholder, SchemaTemplate } from '../metadata.ts'\nimport type { JsonSchema, JsonValue, SecurityRequirementObject } from '../types.ts'\nimport type { DecisionModel, DocumentModel, RequirementModel, SchemeRegistry } from './document.ts'\nimport type { OpenApiStored } from './model.ts'\nimport type { Schemas, SchemaUse, Slots } from './schemas.ts'\n\nimport {\n compareStrings,\n ERROR_COMPONENTS,\n ERROR_RESPONSES,\n HEADER_NAME,\n isResponseStatus,\n MEDIA_TYPE,\n METHOD_ORDER,\n OPERATION_ID,\n reasonPhrase,\n schemaRef,\n} from '../shared.ts'\nimport { Codes, EXTENSION_NAME, HttpIds, Ids } from './model.ts'\nimport { describe, findReservedKey, isRecord, isRef, toJson } from './values.ts'\n\ntype Context = ValidateContext<OpenApiStored>\ntype Json = Record<string, unknown>\n\n/** A built operation. */\nexport interface OperationModel {\n readonly controller: string\n readonly handler: string\n readonly route: string\n readonly method: string\n readonly path: string\n readonly operation: Json\n readonly operationId: string\n readonly label: string\n readonly location: Location\n}\n\n/** Inputs shared by every operation. */\nexport interface OperationsInput {\n readonly ctx: Context\n readonly document: DocumentModel\n readonly schemes: SchemeRegistry\n readonly schemas: Schemas\n readonly slots: Slots\n}\n\nconst ALL_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'] as const\nconst IGNORED_HEADERS = new Set(['accept', 'content-type', 'authorization'])\n\n/** Builds every operation of the application (sorted by path, then method) and the tag descriptions. */\nexport function buildOperations(input: OperationsInput): {\n operations: OperationModel[]\n tagDescriptions: Record<string, string>\n} {\n const { ctx } = input\n const http = ctx.graph.extensions.find(extension => extension.name === 'http')\n const controllers = [...((http?.stored ?? []) as readonly HttpControllerData[])].sort((a, b) =>\n compareStrings(a.token, b.token),\n )\n const explicit = new Set<string>()\n for (const controller of controllers) {\n for (const route of controller.routes) {\n if (route.method !== 'ALL') explicit.add(`${route.method} ${pathShape(route.fullPath)}`)\n }\n }\n const operations: OperationModel[] = []\n const tagDescriptions: Record<string, string> = {}\n for (const controller of controllers) {\n const cls = ctx.classInfo(controller.identity)\n const classDecorators = owned(cls?.decorators)\n if (excluded(ctx, classDecorators, controller.displayName)) continue\n const defaultTag = controller.displayName.replace(/Controller$/, '') || controller.displayName\n const doc = input.document.jsdoc ? cls?.doc : undefined\n const classTags = tagsOf(ctx, classDecorators)\n if (classTags.length === 0 && doc !== undefined && doc.text !== '') tagDescriptions[defaultTag] = doc.text\n for (const route of controller.routes) {\n if (!route.complete) continue\n const method = cls?.methods.find(candidate => candidate.name === route.handler && !candidate.static)\n const methodDecorators = owned(method?.decorators)\n if (excluded(ctx, methodDecorators, `${controller.displayName}.${route.handler}`)) continue\n const methods =\n route.method === 'ALL'\n ? ALL_METHODS.filter(m => !explicit.has(`${m} ${pathShape(route.fullPath)}`))\n : [route.method]\n for (const httpMethod of methods) {\n operations.push(\n new OperationBuilder(input, {\n controller,\n route,\n httpMethod,\n cls,\n method,\n classDecorators,\n methodDecorators,\n classTags,\n defaultTag,\n }).build(),\n )\n }\n }\n }\n checkDuplicateIds(ctx, operations)\n unifyPathTemplates(ctx, operations)\n for (const decision of input.document.decisions) {\n if (decision.used) continue\n ctx.report({\n code: Codes.InvalidSecurityRequirement,\n severity: 'warning',\n message: `The security decision on ${decision.text} applies to no route`,\n location: decision.location,\n hints: ['Remove the decision, or apply the decorator to the routes it describes'],\n })\n }\n operations.sort(\n (a, b) => compareStrings(a.path, b.path) || METHOD_ORDER.indexOf(a.method) - METHOD_ORDER.indexOf(b.method),\n )\n return { operations, tagDescriptions }\n}\n\n/**\n * `/books/{id}` from `/books/:id`; the trailing wildcard is `{wildcard}` (`{wildcard_1}`... when a\n * parameter of the path is named `wildcard`).\n */\nexport function pathTemplate(fullPath: string): string {\n const wildcard = wildcardName(fullPath)\n return fullPath\n .split('/')\n .map(segment => {\n if (segment.startsWith(':')) return `{${segment.slice(1)}}`\n return segment === '*' ? `{${wildcard}}` : segment\n })\n .join('/')\n}\n\n/** The name of the wildcard parameter of a path: `wildcard`, unless a `:wildcard` parameter exists. */\nfunction wildcardName(fullPath: string): string {\n const names = new Set(\n fullPath\n .split('/')\n .filter(segment => segment.startsWith(':'))\n .map(segment => segment.slice(1)),\n )\n let name = 'wildcard'\n for (let index = 1; names.has(name); index++) name = `wildcard_${index}`\n return name\n}\n\n/** Names of the parameters of a path template, in order. */\nfunction templateNames(template: string): string[] {\n return [...template.matchAll(/\\{([^}]*)\\}/g)].map(match => match[1] as string)\n}\n\n/**\n * OpenAPI forbids two templates of one path (`/books/{id}` and `/books/{bookId}`): the operations of\n * such a path are documented under one template (the first one, or the one a whole-path schema\n * names), with a ZNIGHT035 warning.\n */\nfunction unifyPathTemplates(ctx: Context, operations: OperationModel[]): void {\n const groups = new Map<string, number[]>()\n operations.forEach((operation, index) => {\n const shape = operation.path.replace(/\\{[^}]*\\}/g, '{}')\n const group = groups.get(shape)\n if (group === undefined) groups.set(shape, [index])\n else group.push(index)\n })\n for (const indexes of groups.values()) {\n const group = indexes.map(index => operations[index] as OperationModel)\n const templates = [...new Set(group.map(operation => operation.path))].sort(compareStrings)\n if (templates.length < 2) continue\n const fixed = group.filter(hasPathPlaceholder).map(operation => operation.path)\n const canonical = [...fixed].sort(compareStrings)[0] ?? (templates[0] as string)\n const target = templateNames(canonical)\n const renamed: OperationModel[] = []\n for (const index of indexes) {\n const operation = operations[index] as OperationModel\n if (operation.path === canonical || hasPathPlaceholder(operation)) continue\n const names = new Map(templateNames(operation.path).map((name, position) => [name, target[position] as string]))\n for (const parameter of (operation.operation['parameters'] ?? []) as Json[]) {\n const name = parameter['name']\n if (parameter['in'] === 'path' && typeof name === 'string' && names.has(name)) {\n parameter['name'] = names.get(name)\n }\n }\n operations[index] = { ...operation, path: canonical }\n renamed.push(operation)\n }\n const first = renamed[0] ?? (group[0] as OperationModel)\n const kept = group.filter(operation => operation.path !== canonical && hasPathPlaceholder(operation))\n ctx.report({\n code: Codes.InconsistentOperation,\n severity: 'warning',\n message: `The routes of one path name its parameters differently (${group.map(operation => operation.label).join(', ')}): OpenAPI forbids two templates of one path, ${kept.length === 0 ? `documented as ${canonical}` : `the whole-path schemas keep ${kept.map(operation => operation.path).join(', ')}`}`,\n location: first.location,\n related: group\n .filter(operation => operation !== first)\n .map(operation => ({ message: operation.label, location: operation.location })),\n hints: ['Give the parameters the same names on every route of the path'],\n })\n }\n}\n\n/** Whether the path parameters of an operation come from a whole-path schema (`@Param(Schema)`). */\nfunction hasPathPlaceholder(operation: OperationModel): boolean {\n return ((operation.operation['parameters'] ?? []) as Json[]).some(\n parameter => parameter['$znight'] === 'parameters' && parameter['in'] === 'path',\n )\n}\n\nfunction pathShape(fullPath: string): string {\n return fullPath\n .split('/')\n .map(segment => (segment.startsWith(':') ? ':' : segment))\n .join('/')\n}\n\nfunction owned(decorators: readonly DecoratorInfo[] | undefined): DecoratorInfo[] {\n return (decorators ?? []).filter(decorator => decorator.owner === EXTENSION_NAME)\n}\n\nfunction excluded(ctx: Context, decorators: readonly DecoratorInfo[], target: string): boolean {\n const exclude = decorators.find(decorator => decorator.identity === Ids.ApiExclude)\n if (exclude === undefined) return false\n const others = decorators.filter(decorator => decorator !== exclude)\n if (others.length > 0) {\n ctx.report({\n code: Codes.InconsistentOperation,\n severity: 'warning',\n message: `${target} is excluded from the OpenAPI document (@ApiExclude): ${others.map(decorator => `@${decorator.name}`).join(', ')} ${others.length > 1 ? 'have' : 'has'} no effect`,\n location: exclude.location,\n hints: ['Remove @ApiExclude to document it, or remove the other @Api* decorators'],\n })\n }\n return true\n}\n\nfunction tagsOf(ctx: Context, decorators: readonly DecoratorInfo[]): string[] {\n const tags: string[] = []\n for (const decorator of decorators.filter(candidate => candidate.identity === Ids.ApiTags)) {\n for (const arg of decorator.args) {\n if (typeof arg.value === 'string' && arg.value.trim() !== '') tags.push(arg.value)\n else invalidValue(ctx, arg, 'a tag must be a non-empty string')\n }\n }\n return [...new Set(tags)]\n}\n\nfunction invalidValue(\n ctx: Context,\n arg: ArgInfo | { readonly location: Location },\n message: string,\n hints: readonly string[] = [],\n): void {\n ctx.report({ code: Codes.InvalidOpenApiDefinition, severity: 'error', message, location: arg.location, hints })\n}\n\nfunction checkDuplicateIds(ctx: Context, operations: readonly OperationModel[]): void {\n const byId = new Map<string, OperationModel>()\n for (const operation of operations) {\n const other = byId.get(operation.operationId)\n if (other === undefined) {\n byId.set(operation.operationId, operation)\n continue\n }\n ctx.report({\n code: Codes.DuplicateOperationId,\n severity: 'error',\n message: `Duplicate operation id \"${operation.operationId}\": ${other.label} and ${operation.label}`,\n location: operation.location,\n related: [{ message: 'the other operation', location: other.location }],\n hints: [`Rename one controller, or set an id: @ApiOperation({ operationId: '...' })`],\n })\n }\n}\n\n/** Everything one operation is built from. */\ninterface OperationSource {\n readonly controller: HttpControllerData\n readonly route: HttpRouteData\n readonly httpMethod: string\n readonly cls: ClassInfo | undefined\n readonly method: MethodInfo | undefined\n readonly classDecorators: readonly DecoratorInfo[]\n readonly methodDecorators: readonly DecoratorInfo[]\n readonly classTags: readonly string[]\n readonly defaultTag: string\n}\n\n/** The success response inferred from the handler. */\ninterface SuccessModel {\n readonly status: number\n /** The status is chosen at runtime (`HttpResponse`, `@Res()`): other 2xx statuses may be declared. */\n readonly dynamic: boolean\n /** The status of an empty response also returned (`Book | undefined` → 204). */\n readonly empty: number | undefined\n readonly content: Record<string, Json> | undefined\n readonly problem: string | undefined\n readonly hints: string[]\n readonly location: Location | undefined\n}\n\n/** Inferred or declared response of a status. */\ninterface ResponseDraft {\n description: string | undefined\n headers: Record<string, Json>\n content: Record<string, Json> | undefined\n}\n\nclass OperationBuilder {\n readonly #input: OperationsInput\n readonly #ctx: Context\n readonly #source: OperationSource\n readonly #label: string\n readonly #location: Location\n readonly #doc: DocComment | undefined\n readonly #paramDocs: Map<string, string>\n readonly #strict: boolean\n\n constructor(input: OperationsInput, source: OperationSource) {\n this.#input = input\n this.#ctx = input.ctx\n this.#source = source\n this.#label = `${source.httpMethod} ${source.route.fullPath} (${source.controller.displayName}.${source.route.handler})`\n this.#location = source.method?.location ?? source.route.location\n this.#doc = input.document.jsdoc ? source.method?.doc : undefined\n this.#paramDocs = new Map()\n for (const tag of this.#doc?.tags ?? []) {\n if (tag.name !== 'param') continue\n const match = /^(?:\\{[^}]*\\}\\s*)?\\[?([\\w$]+)[^\\s]*\\s*(?:-\\s*)?([\\s\\S]*)$/.exec(tag.text)\n if (match?.[1] !== undefined && match[2] !== undefined && match[2].trim() !== '') {\n this.#paramDocs.set(match[1], match[2].trim())\n }\n }\n this.#strict = input.document.strict\n }\n\n build(): OperationModel {\n const { route, httpMethod, controller } = this.#source\n const method = httpMethod.toLowerCase()\n const options = this.#apiOperation()\n const operation: Json = {}\n const operationId = this.#operationId(options)\n operation['operationId'] = operationId\n const summary = stringOption(options, 'summary') ?? this.#doc?.summary\n const description = stringOption(options, 'description') ?? this.#doc?.description\n if (summary !== undefined) operation['summary'] = summary\n if (description !== undefined) operation['description'] = description\n const methodTags = tagsOf(this.#ctx, this.#source.methodDecorators)\n const tags = [...new Set([...this.#source.classTags, ...methodTags])]\n operation['tags'] = tags.length > 0 ? tags : [this.#source.defaultTag]\n const deprecated =\n typeof options?.['deprecated'] === 'boolean'\n ? options['deprecated']\n : this.#doc?.tags.some(tag => tag.name === 'deprecated') === true\n if (deprecated) operation['deprecated'] = true\n if (isRecord(options?.['externalDocs'])) operation['externalDocs'] = toJson(options['externalDocs'])\n const parameters = this.#parameters()\n if (parameters.length > 0) operation['parameters'] = parameters\n const body = this.#requestBody(httpMethod)\n if (body !== undefined) operation['requestBody'] = body\n operation['responses'] = this.#responses(httpMethod)\n const security = this.#security()\n if (security !== undefined) operation['security'] = security\n if (isRecord(options?.['extensions'])) {\n for (const [key, value] of Object.entries(options['extensions'])) {\n if (key.startsWith('x-')) operation[key] = toJson(value)\n }\n }\n if (route.fullPath.endsWith('/*')) operation['x-znight-wildcard'] = true\n return {\n controller: controller.token,\n handler: route.handler,\n route: route.method,\n method,\n path: pathTemplate(route.fullPath),\n operation,\n operationId,\n label: this.#label,\n location: this.#location,\n }\n }\n\n // ------------------------------------------------------------------------------------------------\n // identity and texts\n\n #apiOperation(): Readonly<Record<string, StaticValue>> | undefined {\n const decorator = this.#source.methodDecorators.find(candidate => candidate.identity === Ids.ApiOperation)\n const arg = decorator?.args[0]\n if (arg === undefined) return undefined\n if (!isRecord(arg.value)) {\n invalidValue(\n this.#ctx,\n arg,\n `@ApiOperation takes { summary?, description?, operationId?, deprecated?, externalDocs?, extensions? }, received ${describe(arg.value)}`,\n )\n return undefined\n }\n const reserved = findReservedKey(arg.value)\n if (reserved !== undefined) invalidValue(this.#ctx, arg, `\"$znight\" is a reserved key (${reserved})`)\n for (const key of Object.keys(arg.value)) {\n if (!['summary', 'description', 'operationId', 'deprecated', 'externalDocs', 'extensions'].includes(key)) {\n invalidValue(this.#ctx, arg, `@ApiOperation: unknown option \"${key}\"`)\n }\n }\n const extensions = arg.value['extensions']\n if (isRecord(extensions)) {\n for (const key of Object.keys(extensions)) {\n if (!key.startsWith('x-'))\n invalidValue(this.#ctx, arg, `@ApiOperation: the extension \"${key}\" must start with \"x-\"`)\n }\n }\n return arg.value\n }\n\n #operationId(options: Readonly<Record<string, StaticValue>> | undefined): string {\n const { controller, route, httpMethod } = this.#source\n const explicit = options?.['operationId']\n if (explicit !== undefined) {\n if (typeof explicit !== 'string' || !OPERATION_ID.test(explicit)) {\n const decorator = this.#source.methodDecorators.find(candidate => candidate.identity === Ids.ApiOperation)\n invalidValue(\n this.#ctx,\n decorator ?? { location: this.#location },\n `Invalid operation id ${describe(explicit)}: it must match ${String(OPERATION_ID)}`,\n )\n } else {\n return route.method === 'ALL' ? `${explicit}.${httpMethod.toLowerCase()}` : explicit\n }\n }\n const base = controller.displayName.replace(/Controller$/, '') || controller.displayName\n let id: string\n switch (this.#input.document.operationIds) {\n case 'handler':\n id = route.handler\n break\n case 'Controller_handler':\n id = `${controller.displayName}_${route.handler}`\n break\n default:\n id = `${base.charAt(0).toLowerCase()}${base.slice(1)}.${route.handler}`\n }\n if (route.method === 'ALL') id = `${id}.${httpMethod.toLowerCase()}`\n if (!OPERATION_ID.test(id)) id = id.replace(/[^\\w.-]/g, '_').replace(/^[^A-Za-z_]/, '_')\n return id\n }\n\n #use(part: string, io: 'input' | 'output', location?: Location): SchemaUse {\n return { io, operation: this.#label, part, location: location ?? this.#location }\n }\n\n #paramInfo(data: HttpParamData): ParameterInfo | undefined {\n return this.#source.method?.params.find(param => param.index === data.index)\n }\n\n #paramDoc(data: HttpParamData): string | undefined {\n return this.#paramDocs.get(this.#paramInfo(data)?.name ?? data.name)\n }\n\n // ------------------------------------------------------------------------------------------------\n // parameters\n\n #parameters(): unknown[] {\n const { route } = this.#source\n const parameters: unknown[] = []\n const declared = new Set<string>()\n const params = route.params\n // path parameters, in path order\n const wholePath = params.find(\n param => param.source === 'param' && param.key === undefined && param.schema !== undefined,\n )\n if (wholePath?.schema === undefined) {\n for (const segment of route.fullPath.split('/')) {\n if (!segment.startsWith(':') && segment !== '*') continue\n const key = segment === '*' ? '*' : segment.slice(1)\n const data = params.find(param => param.source === 'param' && param.key === key)\n const parameter: Json = { name: key === '*' ? wildcardName(route.fullPath) : key, in: 'path' }\n const doc = data === undefined ? undefined : this.#paramDoc(data)\n if (doc !== undefined) parameter['description'] = doc\n else if (key === '*') parameter['description'] = 'The rest of the path, `/` included'\n parameter['required'] = true\n parameter['schema'] =\n data === undefined ? { type: 'string' } : this.#paramSchema(data, `path parameter \"${key}\"`)\n if (key === '*') parameter['x-znight-wildcard'] = true\n parameters.push(parameter)\n declared.add(`path ${parameter['name']}`)\n }\n } else {\n const name = this.#input.slots.use(wholePath.schema, 'input')?.name\n if (name !== undefined) parameters.push(placeholder('path', name))\n }\n for (const data of params) {\n if (data.source === 'query') this.#signatureParameter(data, 'query', parameters, declared)\n else if (data.source === 'headers') this.#signatureParameter(data, 'header', parameters, declared)\n else if (data.source === 'cookie' || data.source === 'signedCookie') {\n this.#signatureParameter(data, 'cookie', parameters, declared)\n }\n }\n const decorated = [\n ...this.#source.classDecorators.filter(decorator => decorator.identity === Ids.ApiHeader),\n ...this.#source.methodDecorators.filter(\n decorator => decorator.identity === Ids.ApiQuery || decorator.identity === Ids.ApiHeader,\n ),\n ]\n for (const decorator of decorated) {\n const parameter = this.#decoratedParameter(decorator, declared)\n if (parameter !== undefined) parameters.push(parameter)\n }\n return parameters\n }\n\n #signatureParameter(\n data: HttpParamData,\n location: 'query' | 'header' | 'cookie',\n parameters: unknown[],\n declared: Set<string>,\n ): void {\n if (data.key === undefined) {\n if (data.schema !== undefined) {\n const name = this.#input.slots.use(data.schema, 'input')?.name\n if (name !== undefined) parameters.push(placeholder(location, name))\n return\n }\n // `@Query() q: SearchParams`: one parameter per property of the type\n const info = this.#paramInfo(data)\n if (info === undefined || location !== 'query') return\n const result = this.#input.schemas.shape({ parameter: info })\n const use = this.#use(`the ${location} parameters`, 'input', info.typeLocation)\n this.#input.schemas.register(result, use)\n const object = this.#objectProperties(result.root)\n for (const property of object ?? []) {\n const parameter: Json = { name: property.name, in: location }\n if (property.description !== undefined) parameter['description'] = property.description\n if (!property.optional) parameter['required'] = true\n parameter['schema'] = this.#input.schemas.convert(property.shape, use, property.name)\n if (property.shape.kind === 'array') {\n parameter['style'] = 'form'\n parameter['explode'] = true\n }\n parameters.push(parameter)\n declared.add(`${location} ${property.name}`)\n }\n return\n }\n if (location === 'header' && IGNORED_HEADERS.has(data.key)) {\n this.#ctx.report({\n code: Codes.InconsistentOperation,\n severity: 'warning',\n message: `The \"${data.key}\" header of ${this.#label} is not documented as a parameter: OpenAPI ignores Accept, Content-Type and Authorization parameters`,\n location: data.location,\n hints: ['Describe credentials with a security scheme (securityScheme()) and @ApiSecurity or decisions'],\n })\n return\n }\n const parameter: Json = { name: data.key, in: location }\n const doc = this.#paramDoc(data)\n if (doc !== undefined) parameter['description'] = doc\n if (!data.optional) parameter['required'] = true\n parameter['schema'] = this.#paramSchema(data, `${location} parameter \"${data.key}\"`)\n if (location === 'query' && isArrayPlan(data.coercion?.plan)) {\n parameter['style'] = 'form'\n parameter['explode'] = true\n }\n parameters.push(parameter)\n declared.add(`${location} ${data.key}`)\n }\n\n #objectProperties(\n shape: Shape,\n ): { name: string; shape: Shape; optional: boolean; description: string | undefined }[] | undefined {\n if (shape.kind === 'named') {\n const named = this.#input.schemas.named(shape.key)\n return named === undefined ? undefined : this.#objectProperties(named.shape)\n }\n if (shape.kind !== 'object') return undefined\n return shape.properties.map(property => ({\n name: property.name,\n shape: property.shape,\n optional: property.optional,\n description: property.doc?.text === '' ? undefined : property.doc?.text,\n }))\n }\n\n #paramSchema(data: HttpParamData, part: string): SchemaTemplate {\n if (data.schema !== undefined) return this.#input.slots.use(data.schema, 'input') ?? {}\n const schema: Record<string, unknown> = data.coercion === undefined ? {} : { ...planSchema(data.coercion.plan) }\n if (data.defaultValue !== undefined) {\n const value = toJson(data.defaultValue)\n if (value !== undefined) schema['default'] = value\n }\n void part\n return schema as JsonSchema\n }\n\n #decoratedParameter(decorator: DecoratorInfo, declared: Set<string>): Json | undefined {\n const location = decorator.identity === Ids.ApiQuery ? 'query' : 'header'\n const [nameArg, optionsArg] = decorator.args\n const name = nameArg?.value\n if (typeof name !== 'string' || name === '') {\n invalidValue(this.#ctx, nameArg ?? decorator, `@${decorator.name} needs a parameter name`)\n return undefined\n }\n const key = location === 'header' ? name.toLowerCase() : name\n if (location === 'header' && !HEADER_NAME.test(name)) {\n invalidValue(this.#ctx, nameArg ?? decorator, `Invalid header name ${JSON.stringify(name)}`)\n return undefined\n }\n if (location === 'header' && IGNORED_HEADERS.has(key)) {\n this.#ctx.report({\n code: Codes.InconsistentOperation,\n severity: 'error',\n message: `@ApiHeader('${name}'): OpenAPI ignores Accept, Content-Type and Authorization parameters`,\n location: decorator.location,\n hints: ['Describe credentials with a security scheme: securityScheme() and @ApiSecurity'],\n })\n return undefined\n }\n if (declared.has(`${location} ${key}`)) {\n this.#ctx.report({\n code: Codes.InconsistentOperation,\n severity: 'error',\n message: `@${decorator.name}('${name}') documents the ${location} parameter \"${key}\" of ${this.#label}, which the signature already reads`,\n location: decorator.location,\n hints: [`Remove @${decorator.name}: the parameter is documented from the signature`],\n })\n return undefined\n }\n declared.add(`${location} ${key}`)\n const options = optionsArg?.value\n if (options !== undefined && !isRecord(options)) {\n invalidValue(\n this.#ctx,\n optionsArg ?? decorator,\n `@${decorator.name} options must be { description?, required?, deprecated?, example? }`,\n )\n }\n const record = isRecord(options) ? options : {}\n for (const option of Object.keys(record)) {\n if (!['description', 'required', 'deprecated', 'example'].includes(option)) {\n invalidValue(this.#ctx, optionsArg ?? decorator, `@${decorator.name}: unknown option \"${option}\"`)\n }\n }\n const parameter: Json = { name: key, in: location }\n if (typeof record['description'] === 'string') parameter['description'] = record['description']\n if (record['required'] === true) parameter['required'] = true\n if (record['deprecated'] === true) parameter['deprecated'] = true\n if (decorator.typeArgs.length > 0) {\n const result = this.#input.schemas.shape({ decorator, typeArgument: 0 })\n parameter['schema'] = this.#input.schemas.fromResult(\n result,\n this.#use(`the ${location} parameter \"${key}\"`, 'input', decorator.location),\n )\n } else {\n parameter['schema'] = { type: 'string' }\n }\n if (record['example'] !== undefined) parameter['example'] = toJson(record['example'])\n return parameter\n }\n\n // ------------------------------------------------------------------------------------------------\n // request body\n\n #requestBody(httpMethod: string): Json | undefined {\n const { route } = this.#source\n const body = route.params.find(param => param.source === 'body')\n const uploads = route.params.filter(param => param.upload !== undefined)\n const apiBody = this.#source.methodDecorators.find(decorator => decorator.identity === Ids.ApiBody)\n if (apiBody !== undefined && (httpMethod === 'GET' || httpMethod === 'HEAD')) {\n this.#ctx.report({\n code: Codes.InconsistentOperation,\n severity: 'warning',\n message: `@ApiBody on ${this.#label}: ${httpMethod} requests have no body in OpenAPI tools`,\n location: apiBody.location,\n hints: ['Use another method, or remove @ApiBody'],\n })\n }\n if (apiBody !== undefined && (body?.schema !== undefined || route.bodySchema !== undefined)) {\n this.#ctx.report({\n code: Codes.InconsistentOperation,\n severity: 'error',\n message: `@ApiBody on ${this.#label}, whose body is already documented by its schema`,\n location: apiBody.location,\n hints: ['Remove @ApiBody: the body schema documents the request'],\n })\n return this.#bodyFromSignature(body, uploads)\n }\n if (apiBody !== undefined && uploads.length === 0) return this.#declaredBody(apiBody, body)\n return this.#bodyFromSignature(body, uploads)\n }\n\n #bodyFromSignature(body: HttpParamData | undefined, uploads: readonly HttpParamData[]): Json | undefined {\n const { route } = this.#source\n if (uploads.length > 0) return this.#multipart(body, uploads)\n if (body !== undefined) {\n const request: Json = {}\n const doc = this.#paramDoc(body)\n if (doc !== undefined) request['description'] = doc\n let content: Json\n if (body.schema === undefined) {\n const info = this.#paramInfo(body)\n const result = info === undefined ? undefined : this.#input.schemas.shape({ parameter: info })\n const root = result?.root\n if (result === undefined || root === undefined) content = { 'application/json': { schema: {} } }\n else if (root.kind === 'string') content = { 'text/plain': { schema: { type: 'string' } } }\n else if (root.kind === 'binary') content = { 'application/octet-stream': {} }\n else {\n content = {\n 'application/json': {\n schema: this.#input.schemas.fromResult(\n result,\n this.#use('the request body', 'input', info?.typeLocation),\n ),\n },\n }\n }\n } else {\n content = { 'application/json': { schema: this.#input.slots.use(body.schema, 'input') ?? {} } }\n }\n request['content'] = content\n if (!body.optional) request['required'] = true\n return request\n }\n if (route.bodySchema !== undefined) {\n return {\n content: { 'application/json': { schema: this.#input.slots.use(route.bodySchema, 'input') ?? {} } },\n required: true,\n }\n }\n return undefined\n }\n\n #multipart(form: HttpParamData | undefined, uploads: readonly HttpParamData[]): Json {\n const properties: Json = {}\n const required: string[] = []\n const encoding: Json = {}\n let additional: Json | undefined\n for (const param of uploads) {\n const upload = param.upload as UploadData\n const file: Json = { type: 'string', contentMediaType: 'application/octet-stream' }\n const doc = this.#paramDoc(param)\n const size =\n upload.maxSize === undefined || upload.maxSize === Number.POSITIVE_INFINITY ? undefined : upload.maxSize\n const descriptions = [doc, size === undefined ? undefined : `At most ${formatSize(size)}`].filter(\n text => text !== undefined,\n )\n if (descriptions.length > 0) file['description'] = descriptions.join('. ')\n if (size !== undefined) file['x-znight-max-size'] = size\n const schema: Json = upload.multiple\n ? {\n type: 'array',\n items: file,\n ...(upload.maxFiles === undefined || upload.maxFiles === Number.POSITIVE_INFINITY\n ? {}\n : { maxItems: upload.maxFiles }),\n }\n : file\n if (upload.field === undefined) {\n additional = schema\n continue\n }\n properties[upload.field] = schema\n if (upload.required) required.push(upload.field)\n if (upload.mimeTypes !== undefined && upload.mimeTypes.length > 0) {\n encoding[upload.field] = { contentType: upload.mimeTypes.join(', ') }\n }\n }\n const files: Json = { type: 'object' }\n if (Object.keys(properties).length > 0) files['properties'] = properties\n if (required.length > 0) files['required'] = required.sort(compareStrings)\n if (additional !== undefined) files['additionalProperties'] = additional\n const textFields = form?.schema === undefined ? undefined : this.#input.slots.use(form.schema, 'input')\n const media: Json = { schema: textFields === undefined ? files : { allOf: [textFields, files] } }\n if (Object.keys(encoding).length > 0) media['encoding'] = encoding\n const request: Json = { content: { 'multipart/form-data': media } }\n if (required.length > 0 || (form !== undefined && !form.optional)) request['required'] = true\n return request\n }\n\n #declaredBody(decorator: DecoratorInfo, body: HttpParamData | undefined): Json | undefined {\n void body\n const arg = decorator.args[0]\n const options = arg?.value\n if (options !== undefined && !isRecord(options)) {\n invalidValue(\n this.#ctx,\n arg ?? decorator,\n '@ApiBody options must be { description?, required?, contentType?, schema? }',\n )\n return undefined\n }\n const record = isRecord(options) ? options : {}\n for (const key of Object.keys(record)) {\n if (!['description', 'required', 'contentType', 'schema'].includes(key)) {\n invalidValue(this.#ctx, arg ?? decorator, `@ApiBody: unknown option \"${key}\"`)\n }\n }\n const contentTypes = this.#mediaTypes(record['contentType'], arg ?? decorator) ?? ['application/json']\n let schema: SchemaTemplate | undefined\n const schemaOption = record['schema']\n if (isRef(schemaOption)) schema = this.#input.slots.use(schemaOption, 'input')\n else if (schemaOption !== undefined)\n invalidValue(this.#ctx, arg ?? decorator, '@ApiBody schema must be a Standard Schema (an exported schema)')\n else if (decorator.typeArgs.length > 0) {\n const result = this.#input.schemas.shape({ decorator, typeArgument: 0 })\n schema = this.#input.schemas.fromResult(result, this.#use('the request body', 'input', decorator.location))\n }\n const content: Json = {}\n for (const type of contentTypes) {\n content[type] = schema === undefined ? defaultMedia(type) : { schema }\n }\n const request: Json = {}\n if (typeof record['description'] === 'string') request['description'] = record['description']\n request['content'] = content\n if (record['required'] !== false) request['required'] = true\n return request\n }\n\n #mediaTypes(value: StaticValue, where: ArgInfo | DecoratorInfo): string[] | undefined {\n if (value === undefined) return undefined\n let list: readonly StaticValue[] | undefined\n if (typeof value === 'string') list = [value]\n else if (Array.isArray(value)) list = value as readonly StaticValue[]\n if (\n list === undefined ||\n list.length === 0 ||\n list.some(item => typeof item !== 'string' || !MEDIA_TYPE.test(item))\n ) {\n invalidValue(this.#ctx, where, `Invalid media type ${describe(value)}: expected \"type/subtype\" or a list of them`)\n return undefined\n }\n return list as string[]\n }\n\n // ------------------------------------------------------------------------------------------------\n // responses\n\n #responses(httpMethod: string): Json {\n const { route, method } = this.#source\n const errors = this.#input.document.errors\n const declared = this.#source.methodDecorators.filter(decorator => decorator.identity === Ids.ApiResponse)\n const declaredStatuses = declared\n .map(decorator => decorator.args[0]?.value)\n .map(status => (typeof status === 'number' ? String(status) : status))\n const success = this.#success(httpMethod)\n const responses = new Map<string, ResponseDraft>()\n const covered =\n declaredStatuses.includes(String(success.status)) ||\n declaredStatuses.includes('2XX') ||\n (success.dynamic && declaredStatuses.some(status => typeof status === 'string' && /^2\\d\\d$/.test(status)))\n if (success.problem !== undefined && !covered) {\n this.#ctx.report({\n code: Codes.UndocumentedResponse,\n severity: this.#strict ? 'error' : 'warning',\n message: `The ${success.status} response of ${this.#label} cannot be documented: ${success.problem}`,\n location: success.location ?? this.#location,\n hints: success.hints,\n })\n }\n const returns = this.#doc?.tags.find(tag => tag.name === 'returns' || tag.name === 'return')?.text\n if (success.problem === undefined || !covered) {\n const headers: Record<string, Json> = {}\n for (const [name, value] of route.headers) {\n headers[name] = { schema: { type: 'string' }, example: value }\n }\n responses.set(String(success.status), {\n description: returns !== undefined && returns !== '' ? returns : undefined,\n headers,\n content: success.content,\n })\n if (success.empty !== undefined) {\n responses.set(String(success.empty), { description: undefined, headers: { ...headers }, content: undefined })\n }\n }\n for (const decorator of declared) this.#declaredResponse(decorator, responses, success)\n // standard errors\n const result: Json = {}\n const reads =\n route.params.some(param => param.source === 'body' || param.upload !== undefined) ||\n route.bodySchema !== undefined\n const validates =\n reads ||\n route.params.some(\n param => param.schema !== undefined || (param.coercion !== undefined && param.coercion.plan.kind !== 'raw'),\n )\n const uploads = route.params.some(param => param.upload !== undefined)\n if (errors !== false) {\n const standard = (status: string, name: string): void => {\n if (!responses.has(status)) result[status] = { $ref: `#/components/responses/${name}` }\n }\n if (validates) standard('400', ERROR_RESPONSES.badRequest)\n if (reads) standard('413', ERROR_RESPONSES.payloadTooLarge)\n if (uploads) standard('415', ERROR_RESPONSES.unsupportedMediaType)\n }\n for (const [status, draft] of responses) {\n const response: Json = { description: draft.description ?? reasonPhrase(status) }\n if (Object.keys(draft.headers).length > 0) response['headers'] = draft.headers\n let content = draft.content\n if (content === undefined && errors !== false && /^[45]/.test(status)) {\n const schema =\n errors.schema === undefined\n ? { $ref: schemaRef(ERROR_COMPONENTS.body) }\n : (this.#input.slots.use(errors.schema, 'output') ?? {})\n content = { [errors.contentType]: { schema } }\n }\n if (content !== undefined) response['content'] = content\n result[status] = response\n }\n void method\n const sorted: Json = {}\n for (const status of Object.keys(result).sort(compareStatuses)) sorted[status] = result[status]\n return sorted\n }\n\n #success(httpMethod: string): SuccessModel {\n const { route, method } = this.#source\n const example = exampleBodyType(this.#source.controller.displayName)\n const post = httpMethod === 'POST'\n const statusFor = (empty: boolean): number => {\n if (route.status !== undefined) return route.status\n if (post) return 201\n return empty ? 204 : 200\n }\n const undocumentable = (problem: string, hints: string[], dynamic = false): SuccessModel => ({\n status: statusFor(false),\n dynamic,\n empty: undefined,\n content: undefined,\n problem,\n hints,\n location: method?.location,\n })\n if (route.sse !== undefined) return this.#sse()\n if (route.rawResponse) {\n return undocumentable(\n 'the handler writes the response itself (@Res())',\n [`Declare it: @ApiResponse<${example}>(${statusFor(false)})`],\n true,\n )\n }\n if (method?.returnType === undefined) {\n return undocumentable('the handler has no return type annotation', [\n `Annotate the return type with the body type: ${handlerKey(route.handler)}(): ${method?.async === true ? `Promise<${example}>` : example}`,\n `Or declare it: @ApiResponse<${example}>(${statusFor(false)})`,\n ])\n }\n const result = this.#input.schemas.shape({ returnOf: method })\n const use = this.#use('the response', 'output')\n this.#input.schemas.register(result, use)\n // `HttpResponse<T>` members are documented as `T`, their status is chosen at runtime\n let dynamic = false\n let returnsUndefined = false\n const bodies: Shape[] = []\n for (const member of unionMembers(result.root)) {\n if (member.kind === 'reference' && member.identity === HttpIds.HttpResponse) {\n dynamic = true\n const body = member.typeArgs[0]\n if (member.explicitTypeArgs === 0 || body === undefined) {\n return undocumentable(\n 'HttpResponse has no body type',\n [\n `Give the body type: Promise<HttpResponse<${example}>>`,\n `Or declare it: @ApiResponse<${example}>(${statusFor(false)})`,\n ],\n true,\n )\n }\n bodies.push(...unionMembers(body))\n } else {\n if (member.kind === 'undefined') returnsUndefined = true\n bodies.push(member)\n }\n }\n const defined = distinct(bodies.filter(member => member.kind !== 'undefined' && member.kind !== 'never'))\n if (defined.some(member => member.kind === 'reference' && member.identity === 'globalThis#Response')) {\n return undocumentable(\n 'a Web Response has no body type',\n [`Declare it: @ApiResponse<${example}>(${statusFor(false)})`],\n true,\n )\n }\n if (defined.some(member => member.kind === 'unknown')) {\n return undocumentable(\n `the return type is ${method.returnType.kind === 'primitive' ? method.returnType.name : 'unknown'}`,\n ['Give a precise return type', `Or declare it: @ApiResponse<${example}>(${statusFor(false)})`],\n dynamic,\n )\n }\n if (defined.length === 0) {\n return {\n status: statusFor(true),\n dynamic,\n empty: undefined,\n content: undefined,\n problem: undefined,\n hints: [],\n location: undefined,\n }\n }\n const events = defined.filter(member => member.kind === 'reference' && member.identity === HttpIds.SseBody)\n if (events.length > 0) {\n // HttpResponse.sse(): 200 (even on POST) unless @HttpCode, text/event-stream\n if (events.length < defined.length) {\n return undocumentable(\n 'the handler returns an event stream or another body',\n [`Declare the responses: @ApiResponse(${route.status ?? 200}, { contentType: 'text/event-stream' })`],\n true,\n )\n }\n return {\n status: route.status ?? 200,\n dynamic: true,\n empty: undefined,\n content: httpMethod === 'HEAD' ? undefined : { 'text/event-stream': { schema: { type: 'string' } } },\n problem: undefined,\n hints: [],\n location: undefined,\n }\n }\n const status = statusFor(false)\n let content: Record<string, Json> | undefined = this.#successContent(defined, use)\n if (content !== undefined && isBodylessStatus(status)) {\n this.#ctx.report({\n code: Codes.InconsistentOperation,\n severity: 'error',\n message: `${this.#label} returns a body, but its status is always ${status} (@HttpCode(${status})): ${status} responses have none, the body is never sent`,\n location: method.location,\n hints: ['Return nothing (void), or use another status'],\n })\n content = undefined\n }\n return {\n status,\n dynamic,\n // a plain `undefined` is sent as an empty 204 (not on POST routes, not with @HttpCode)\n empty: returnsUndefined && route.status === undefined && !post && status !== 204 ? 204 : undefined,\n // HEAD responses never have a body\n content: httpMethod === 'HEAD' ? undefined : content,\n problem: undefined,\n hints: [],\n location: undefined,\n }\n }\n\n /** Content of the success response: media types of the serialiser (§9.1 of the architecture). */\n #successContent(members: readonly Shape[], use: SchemaUse): Record<string, Json> | undefined {\n const single = members.length === 1 ? (members[0] as Shape) : undefined\n if (single !== undefined) {\n if (single.kind === 'binary' || (single.kind === 'reference' && single.identity === HttpIds.FileBody)) {\n return { 'application/octet-stream': {} }\n }\n if (single.kind === 'reference' && single.identity === 'globalThis#AsyncIterable') {\n const event = single.typeArgs[0]\n const data = event?.kind === 'reference' && event.identity === HttpIds.SseEvent ? event.typeArgs[0] : event\n const media: Json = { schema: { type: 'string' } }\n if (data !== undefined) media['x-znight-event-schema'] = this.#input.schemas.convert(data, use, '')\n return { 'text/event-stream': media }\n }\n }\n // strings are sent as text/plain, everything else as JSON\n const text: Shape[] = []\n const json: Shape[] = []\n for (const member of members) this.#splitText(member, text, json, new Set())\n const schemaOf = (shapes: Shape[]): SchemaTemplate =>\n this.#input.schemas.convert(\n shapes.length === 1 ? (shapes[0] as Shape) : { kind: 'union', members: shapes },\n use,\n '',\n )\n const content: Record<string, Json> = {}\n if (json.length > 0) content['application/json'] = { schema: schemaOf(json) }\n if (text.length > 0) content['text/plain'] = { schema: schemaOf(text) }\n return content\n }\n\n /**\n * Sorts the members of a body by the media type the serialiser gives them: strings (string, string\n * literals, string enums) are text, the rest JSON. A named declaration stays whole when all its\n * members go to one side.\n */\n #splitText(shape: Shape, text: Shape[], json: Shape[], seen: Set<string>): void {\n const kind = this.#textKind(shape, new Set(seen))\n if (kind === 'text') text.push(shape)\n else if (kind === 'json') json.push(shape)\n else if (shape.kind === 'union') {\n for (const member of shape.members) this.#splitText(member, text, json, seen)\n } else if (shape.kind === 'named') {\n const named = this.#input.schemas.named(shape.key)\n if (named === undefined || seen.has(shape.key)) json.push(shape)\n else this.#splitText(named.shape, text, json, new Set([...seen, shape.key]))\n } else {\n json.push(shape)\n }\n }\n\n #textKind(shape: Shape, seen: Set<string>): 'text' | 'json' | 'mixed' {\n switch (shape.kind) {\n case 'string':\n return 'text'\n case 'literal':\n return typeof shape.value === 'string' ? 'text' : 'json'\n case 'union': {\n const kinds = new Set(shape.members.map(member => this.#textKind(member, seen)))\n return kinds.size === 1 ? ([...kinds][0] as 'text' | 'json' | 'mixed') : 'mixed'\n }\n case 'intersection':\n // branded strings (`string & { readonly brand: unique symbol }`)\n return shape.members.some(member => this.#textKind(member, seen) === 'text') ? 'text' : 'json'\n case 'named': {\n const named = this.#input.schemas.named(shape.key)\n if (named === undefined || seen.has(shape.key)) return 'json'\n seen.add(shape.key)\n return this.#textKind(named.shape, seen)\n }\n default:\n return 'json'\n }\n }\n\n /** `@Sse` routes: a 200 event stream; the type of the events' `data` when the return type tells it. */\n #sse(): SuccessModel {\n const { method } = this.#source\n const media: Json = { schema: { type: 'string' } }\n if (method?.returnType !== undefined) {\n const result = this.#input.schemas.shape({ returnOf: method })\n const use = this.#use('the events', 'output')\n this.#input.schemas.register(result, use)\n const data = eventData(result.root)\n if (data !== undefined) media['x-znight-event-schema'] = this.#input.schemas.convert(data, use, '')\n }\n return {\n status: 200,\n dynamic: true,\n empty: undefined,\n content: { 'text/event-stream': media },\n problem: undefined,\n hints: [],\n location: undefined,\n }\n }\n\n #declaredResponse(decorator: DecoratorInfo, responses: Map<string, ResponseDraft>, success: SuccessModel): void {\n const [statusArg, optionsArg] = decorator.args\n const raw = statusArg?.value\n const status = typeof raw === 'number' ? String(raw) : raw\n if (typeof status !== 'string' || !isResponseStatus(status)) {\n invalidValue(\n this.#ctx,\n statusArg ?? decorator,\n `Invalid response status ${describe(raw)}: expected a code (100-599), \"2XX\"-like or \"default\"`,\n )\n return\n }\n const options = optionsArg?.value\n if (options !== undefined && !isRecord(options)) {\n invalidValue(\n this.#ctx,\n optionsArg ?? decorator,\n '@ApiResponse options must be { description?, schema?, contentType?, headers?, example? }',\n )\n return\n }\n const record = isRecord(options) ? options : {}\n for (const key of Object.keys(record)) {\n if (!['description', 'schema', 'contentType', 'headers', 'example'].includes(key)) {\n invalidValue(this.#ctx, optionsArg ?? decorator, `@ApiResponse: unknown option \"${key}\"`)\n }\n }\n const reserved = findReservedKey(record)\n if (reserved !== undefined)\n invalidValue(this.#ctx, optionsArg ?? decorator, `\"$znight\" is a reserved key (${reserved})`)\n const code = Number(status)\n if (Number.isInteger(code) && code >= 200 && code < 300 && code !== success.status && code !== success.empty) {\n const fixed = this.#source.route.status !== undefined || !success.dynamic\n if (fixed) {\n this.#ctx.report({\n code: Codes.InconsistentOperation,\n severity: 'error',\n message: `@ApiResponse(${status}) on ${this.#label}, whose success status is always ${success.status}`,\n location: decorator.location,\n hints: [\n this.#source.route.status === undefined\n ? `Return an HttpResponse to choose the status, or document ${success.status}`\n : `@HttpCode(${this.#source.route.status}) sets the status: document ${this.#source.route.status}`,\n ],\n })\n return\n }\n }\n let schema: SchemaTemplate | undefined\n const schemaOption = record['schema']\n if (isRef(schemaOption)) schema = this.#input.slots.use(schemaOption, 'output')\n else if (schemaOption !== undefined)\n invalidValue(\n this.#ctx,\n optionsArg ?? decorator,\n '@ApiResponse schema must be a Standard Schema (an exported schema)',\n )\n else if (decorator.typeArgs.length > 0) {\n const result = this.#input.schemas.shape({ decorator, typeArgument: 0 })\n schema = this.#input.schemas.fromResult(result, this.#use(`the ${status} response`, 'output', decorator.location))\n }\n if (schema !== undefined && (status === '204' || status === '304')) {\n this.#ctx.report({\n code: Codes.InconsistentOperation,\n severity: 'error',\n message: `@ApiResponse(${status}) on ${this.#label} declares a body: ${status} responses have none`,\n location: decorator.location,\n hints: ['Remove the body type, or use another status'],\n })\n schema = undefined\n }\n const contentTypes = this.#mediaTypes(record['contentType'], optionsArg ?? decorator)\n const draft = responses.get(status) ?? { description: undefined, headers: {}, content: undefined }\n if (typeof record['description'] === 'string') draft.description = record['description']\n const headers = record['headers']\n if (headers !== undefined) {\n if (isRecord(headers)) {\n for (const [name, header] of Object.entries(headers)) {\n if (!HEADER_NAME.test(name)) {\n invalidValue(this.#ctx, optionsArg ?? decorator, `Invalid header name ${JSON.stringify(name)}`)\n continue\n }\n const json = toJson(header)\n const object = isRecord(json) ? (json as Json) : {}\n draft.headers[name.toLowerCase()] = {\n ...draft.headers[name.toLowerCase()],\n ...object,\n schema: object['schema'] ?? { type: 'string' },\n }\n }\n } else\n invalidValue(\n this.#ctx,\n optionsArg ?? decorator,\n '@ApiResponse headers must be { [name]: { description?, schema?, ... } }',\n )\n }\n const example = record['example'] === undefined ? undefined : toJson(record['example'])\n if (schema !== undefined || contentTypes !== undefined) {\n const previous = draft.content === undefined ? undefined : Object.values(draft.content)[0]\n const types = contentTypes ?? (schema === undefined ? [] : ['application/json'])\n const content: Record<string, Json> = {}\n for (const type of types) {\n const media: Json = {}\n const mediaSchema = schema ?? (previous?.['schema'] as SchemaTemplate | undefined)\n if (mediaSchema !== undefined) media['schema'] = mediaSchema\n if (example !== undefined) media['example'] = example\n content[type] = media\n }\n draft.content = content\n } else if (example !== undefined && draft.content !== undefined) {\n for (const media of Object.values(draft.content)) media['example'] = example\n }\n responses.set(status, draft)\n }\n\n // ------------------------------------------------------------------------------------------------\n // security\n\n #security(): SecurityRequirementObject[] | undefined {\n const { schemes } = this.#input\n for (const decorators of [this.#source.methodDecorators, this.#source.classDecorators]) {\n const decorator = decorators.find(candidate => candidate.identity === Ids.ApiSecurity)\n if (decorator === undefined) continue\n const requirements: RequirementModel[] = []\n for (const arg of decorator.args) {\n const requirement = schemes.requirement(arg.ref ?? arg.value, arg.location)\n if (requirement !== undefined) requirements.push(requirement)\n }\n return schemes.objects(requirements)\n }\n const decisions = this.#input.document.decisions\n if (decisions.length === 0) return undefined\n const { route, controller } = this.#source\n const routeGroups = new Set(route.meta.map(entry => entry.group))\n const inherited = controller.meta.filter(entry => !routeGroups.has(entry.group))\n for (const entries of [route.meta, inherited]) {\n for (const decision of decisions) {\n const entry = entries.find(candidate => candidate.identity === decision.identity)\n if (entry === undefined) continue\n decision.used = true\n return this.#decisionSecurity(decision, entry)\n }\n }\n return undefined\n }\n\n #decisionSecurity(decision: DecisionModel, entry: MetaEntry): SecurityRequirementObject[] | undefined {\n const { schemes } = this.#input\n if (!decision.scopesFromValue) return schemes.objects(decision.security)\n const value = entry.value\n if (!Array.isArray(value) || !(value as readonly StaticValue[]).every(item => typeof item === 'string')) {\n this.#ctx.report({\n code: Codes.InvalidSecurityRequirement,\n severity: 'error',\n message: `The decision on ${decision.text} takes its scopes from the decorator value, but @${entry.decorator}(...) on ${this.#label} is not a static string array`,\n location: entry.location,\n hints: [`Write the scopes literally: @${entry.decorator}(['admin'])`],\n })\n return schemes.objects(decision.security)\n }\n const scopes = value as readonly string[]\n for (const requirement of decision.security) {\n for (const { scheme } of requirement) {\n if (!scheme.scoped) {\n this.#ctx.report({\n code: Codes.InvalidSecurityRequirement,\n severity: 'error',\n message: `The decision on ${decision.text} gives scopes to \"${scheme.name}\" (${String(scheme.definition.type)}): scopes are only allowed on oauth2 and openIdConnect schemes`,\n location: decision.location,\n hints: [\"Remove scopes: 'value', or use an oauth2 scheme\"],\n })\n return schemes.objects(decision.security)\n }\n const unknown = scheme.scopes === undefined ? [] : scopes.filter(scope => !scheme.scopes?.has(scope))\n if (unknown.length > 0) {\n this.#ctx.report({\n code: Codes.InvalidSecurityRequirement,\n severity: 'error',\n message: `@${entry.decorator}(${JSON.stringify(scopes)}) on ${this.#label} uses ${unknown.length > 1 ? 'scopes' : 'a scope'} that \"${scheme.name}\" does not declare: ${unknown.join(', ')}`,\n location: entry.location,\n related: [{ message: 'the security scheme', location: scheme.location }],\n hints: [`Declare the scope in the flows of ${scheme.name}, or fix the decorator value`],\n })\n }\n }\n }\n return schemes.objects(decision.security, scopes)\n }\n}\n\n/** A media type without declared schema: text is a string, bytes have no schema, anything else is any value. */\nfunction defaultMedia(type: string): Json {\n if (type.startsWith('text/')) return { schema: { type: 'string' } }\n return type === 'application/octet-stream' ? {} : { schema: {} }\n}\n\nfunction stringOption(options: Readonly<Record<string, StaticValue>> | undefined, key: string): string | undefined {\n const value = options?.[key]\n return typeof value === 'string' ? value : undefined\n}\n\nfunction placeholder(location: ParametersPlaceholder['in'], name: string): ParametersPlaceholder {\n return { $znight: 'parameters', in: location, name, io: 'input' }\n}\n\nfunction isArrayPlan(plan: CoercionPlan | undefined): boolean {\n if (plan === undefined) return false\n if (plan.kind === 'optional') return isArrayPlan(plan.item)\n return plan.kind === 'array'\n}\n\n/** The members of a union (the shape itself otherwise). */\nfunction unionMembers(shape: Shape): readonly Shape[] {\n return shape.kind === 'union' ? shape.members : [shape]\n}\n\n/** The shapes without repetitions (`Book | HttpResponse<Book>` documents `Book` once). */\nfunction distinct(shapes: readonly Shape[]): Shape[] {\n const seen = new Set<string>()\n return shapes.filter(shape => {\n let key: string\n try {\n key = JSON.stringify(shape)\n } catch {\n return true\n }\n if (seen.has(key)) return false\n seen.add(key)\n return true\n })\n}\n\n/** Statuses whose responses have no body: the serialiser drops it (204, 304, 1xx). */\nfunction isBodylessStatus(status: number): boolean {\n return status === 204 || status === 304 || (status >= 100 && status < 200)\n}\n\n/** The `T` of `SseEvent<T>` found in a stream type (`AsyncIterable<SseEvent<T>> | HttpResponse`). */\nfunction eventData(shape: Shape): Shape | undefined {\n if (shape.kind === 'reference') {\n if (shape.identity === HttpIds.SseEvent) return shape.typeArgs[0]\n for (const arg of shape.typeArgs) {\n const found = eventData(arg)\n if (found !== undefined) return found\n }\n return undefined\n }\n if (shape.kind === 'union') {\n for (const member of shape.members) {\n const found = eventData(member)\n if (found !== undefined) return found\n }\n }\n return undefined\n}\n\n/** JSON Schema of a coercion plan (§5.4.2). */\nexport function planSchema(plan: CoercionPlan): JsonSchema {\n switch (plan.kind) {\n case 'string':\n case 'number':\n case 'integer':\n case 'boolean':\n return { type: plan.kind }\n case 'bigint':\n return { type: 'string', pattern: '^-?[0-9]+$' }\n case 'date':\n return { type: 'string', format: 'date-time' }\n case 'enum': {\n const types = [...new Set(plan.values.map(value => typeof value))]\n return types.length === 1 ? { type: types[0] as string, enum: [...plan.values] } : { enum: [...plan.values] }\n }\n case 'array':\n return { type: 'array', items: planSchema(plan.item) as JsonValue }\n case 'optional':\n return planSchema(plan.item)\n case 'raw':\n return {}\n }\n}\n\n/** `2 MiB`, `512 KiB`, `1000 bytes`. */\nexport function formatSize(bytes: number): string {\n const units = ['GiB', 'MiB', 'KiB'] as const\n const factors = [1024 ** 3, 1024 ** 2, 1024]\n for (const [index, unit] of units.entries()) {\n const factor = factors[index] as number\n if (bytes >= factor && bytes % (factor / 4) === 0) return `${bytes / factor} ${unit}`\n }\n return `${bytes} bytes`\n}\n\n/** Status keys: codes first in numeric order, then ranges, then `default`. */\nfunction compareStatuses(a: string, b: string): number {\n const rank = (status: string): number => {\n if (status === 'default') return 2\n return /X/.test(status) ? 1 : 0\n }\n return rank(a) - rank(b) || compareStrings(a, b)\n}\n\n/** A handler name as written in a class body: `get`, or `'get-item'` for a quoted key. */\nfunction handlerKey(name: string): string {\n return /^[A-Za-z_$][\\w$]*$/.test(name) ? name : `'${name.replace(/['\\\\]/g, '\\\\$&')}'`\n}\n\n/** The body type named by the hints (`ItemController` → `ItemResponse`): an example, never a literal `Body`. */\nfunction exampleBodyType(controller: string): string {\n const base = controller.replace(/Controller$/, '')\n return base === '' ? 'ResponseBody' : `${base}Response`\n}\n","/**\n * TypeScript shapes (`ctx.types.shape()`, C1 of RFC 0002) → JSON Schema 2020-12 (§6.2): named\n * declarations become components (`#/components/schemas/<name>`), JSDoc tags become keywords,\n * Standard Schema aliases (`z.output<typeof S>`) become placeholders converted at assembly.\n */\nimport type {\n DocComment,\n Location,\n NamedShape,\n Shape,\n ShapeIssue,\n ShapeOptions,\n ShapeProperty,\n ShapeResult,\n ShapeTarget,\n ValidateContext,\n ValueRef,\n} from '@znight/compiler'\nimport type { SchemaPlaceholder, SchemaTemplate } from '../metadata.ts'\nimport type { JsonSchema, JsonValue } from '../types.ts'\nimport type { OpenApiStored, SlotData } from './model.ts'\n\nimport { createHash } from 'node:crypto'\n\nimport { compareStrings, componentName, schemaRef } from '../shared.ts'\nimport { Codes, KEEP, SCHEMA_ALIASES, SCHEMA_MEMBERS } from './model.ts'\n\ntype Context = ValidateContext<OpenApiStored>\ntype Diagnostic = Parameters<Context['report']>[0]\n\n/** How a schema is used (messages and severities of ZNIGHT032). */\nexport interface SchemaUse {\n /** `'output'`: a response body (a `bigint` makes `JSON.stringify` throw: always an error). */\n readonly io: 'input' | 'output'\n /** `GET /books/stats (BookController.stats)`. */\n readonly operation: string\n /** `the response`, `the request body`, `query parameter \"q\"`. */\n readonly part: string\n /** Where the type is used (the handler, the decorator...). */\n readonly location: Location | undefined\n}\n\n/** Standard Schemas referenced by the document, by identity. */\nexport class Slots {\n readonly #slots = new Map<string, SlotData>()\n readonly #names = new Map<string, { identity: string; location: Location }>()\n readonly #report: (diagnostic: Diagnostic) => void\n readonly #reserved: () => ReadonlySet<string>\n readonly #locate: (ref: ValueRef) => Location | undefined\n\n constructor(\n report: (diagnostic: Diagnostic) => void,\n reserved: () => ReadonlySet<string>,\n locate: (ref: ValueRef) => Location | undefined = () => undefined,\n ) {\n this.#report = report\n this.#reserved = reserved\n this.#locate = locate\n }\n\n /** The placeholder of `ref` with this io (registers the slot), `undefined` after a name conflict. */\n use(ref: ValueRef, io: 'input' | 'output'): SchemaPlaceholder | undefined {\n const identity = ref.identity ?? `${ref.location.file}#${ref.text}`\n let slot = this.#slots.get(identity)\n if (slot === undefined) {\n const name = componentName(ref.name.slice(ref.name.lastIndexOf('.') + 1))\n const other = this.#names.get(name)\n if (other !== undefined && other.identity !== identity) {\n this.#report({\n code: Codes.SchemaNameConflict,\n severity: 'error',\n message: `Two schemas are named \"${name}\" in the OpenAPI document: ${ref.text} and ${other.identity}`,\n location: ref.location,\n related: [{ message: 'the other schema', location: other.location }],\n hints: ['Rename one of the exported schemas: component names come from their export names'],\n })\n return undefined\n }\n if (this.#reserved().has(name)) {\n this.#report({\n code: Codes.SchemaNameConflict,\n severity: 'error',\n message: `The schema ${ref.text} is named \"${name}\", a name reserved for the standard error components`,\n location: ref.location,\n hints: ['Rename the schema, or turn the standard errors off: @OpenApiDocument({ errors: false })'],\n })\n return undefined\n }\n this.#names.set(name, { identity, location: ref.location })\n slot = { name, ref, io: new Set(), location: this.#locate(ref) ?? ref.location }\n this.#slots.set(identity, slot)\n }\n slot.io.add(io)\n return { $znight: 'schema', name: slot.name, io }\n }\n\n /** Whether a slot uses this component name. */\n has(name: string): { identity: string; location: Location } | undefined {\n return this.#names.get(name)\n }\n\n /** Adds an io to the slot of `identity` (no effect for an unknown slot). */\n need(identity: string, io: 'input' | 'output'): void {\n this.#slots.get(identity)?.io.add(io)\n }\n\n /** Slots sorted by name. */\n list(): SlotData[] {\n return [...this.#slots.values()].sort((a, b) => compareStrings(a.name, b.name))\n }\n}\n\n/** A component computed from a TypeScript declaration. */\ninterface Component {\n readonly key: string\n readonly identity: string\n readonly location: Location\n schema: JsonSchema | undefined\n}\n\n/** Converts shapes to JSON Schema and collects the components. */\nexport class Schemas {\n readonly #ctx: Context\n readonly #options: ShapeOptions\n readonly #slots: Slots\n readonly #strict: boolean\n readonly #reserved: ReadonlySet<string>\n /** Component name by named key. */\n readonly #names = new Map<string, string>()\n /** The first named key given each component name. */\n readonly #keys = new Map<string, string>()\n /** Components by name. */\n readonly #components = new Map<string, Component>()\n /** Every named shape seen, by key. */\n readonly #named = new Map<string, NamedShape>()\n /** Issues reported so far, with the severity they were reported at. */\n readonly #reported = new WeakMap<object, 'warning' | 'error'>()\n readonly #conflicts = new Set<string>()\n\n constructor(ctx: Context, options: { jsdoc: boolean; strict: boolean; reserved: ReadonlySet<string> }, slots: Slots) {\n this.#ctx = ctx\n this.#slots = slots\n this.#strict = options.strict\n this.#reserved = options.reserved\n this.#options = {\n schemaAliases: SCHEMA_ALIASES,\n schemaMembers: SCHEMA_MEMBERS,\n keep: KEEP,\n jsdoc: options.jsdoc,\n }\n }\n\n /** The shape of a target with the options of the extension. */\n shape(target: ShapeTarget): ShapeResult {\n return this.#ctx.types.shape(target, this.#options)\n }\n\n /** Components computed so far, sorted by name. */\n components(): Record<string, JsonSchema> {\n const result: Record<string, JsonSchema> = {}\n for (const name of [...this.#components.keys()].sort(compareStrings)) {\n const schema = this.#components.get(name)?.schema\n if (schema !== undefined) result[name] = schema\n }\n return result\n }\n\n /** A named shape seen by a result (`undefined` for an unknown key). */\n named(key: string): NamedShape | undefined {\n return this.#named.get(key)\n }\n\n /**\n * Registers the named shapes of `result` and reports its issues. Call it before converting shapes\n * of the result.\n */\n register(result: ShapeResult, use: SchemaUse): void {\n for (const named of result.named.values()) this.#named.set(named.key, named)\n for (const named of result.named.values()) this.#component(named)\n for (const issue of result.issues) this.#issue(issue, use)\n }\n\n /** JSON Schema of the root of `result` (registers it first). */\n fromResult(result: ShapeResult, use: SchemaUse): SchemaTemplate {\n this.register(result, use)\n return this.convert(result.root, use, '')\n }\n\n /** JSON Schema of a shape whose result was {@link register}ed. */\n convert(shape: Shape, use: SchemaUse, path: string): SchemaTemplate {\n switch (shape.kind) {\n case 'string':\n return { type: 'string' }\n case 'number':\n return { type: 'number' }\n case 'boolean':\n return { type: 'boolean' }\n case 'null':\n return { type: 'null' }\n case 'undefined':\n case 'unknown':\n return {}\n case 'never':\n return { not: {} }\n case 'date':\n return { type: 'string', format: 'date-time' }\n case 'url':\n return { type: 'string', format: 'uri' }\n case 'bigint':\n // reported through the issues of the result\n return { type: 'string', pattern: '^-?[0-9]+$' }\n case 'binary':\n if (path !== '') {\n this.#warn(\n `${path} is binary data: inside a JSON body JSON.stringify writes it as an object of numeric keys (${use.operation})`,\n use,\n ['Send bytes as the whole body (application/octet-stream), or encode them (base64 string)'],\n )\n }\n return { type: 'string', contentMediaType: 'application/octet-stream' }\n case 'literal':\n return { type: typeof shape.value as 'string' | 'number' | 'boolean', const: shape.value }\n case 'array':\n return { type: 'array', items: this.convert(shape.items, use, `${path}[]`) as JsonValue }\n case 'tuple':\n return this.#tuple(shape, use, path)\n case 'object':\n return this.#object(shape.properties, shape.additional, use, path)\n case 'union':\n return this.#union(shape.members, use, path)\n case 'intersection':\n return this.#intersection(shape.members, use, path)\n case 'named': {\n const name = this.#nameOfKey(shape.key)\n return name === undefined ? {} : { $ref: schemaRef(name) }\n }\n case 'schema':\n return this.#slots.use(shape.ref, shape.io) ?? {}\n case 'reference':\n this.#warn(\n `${path === '' ? 'The type' : path} (${shape.name}) cannot be documented inside a JSON body (${use.operation})`,\n use,\n [],\n )\n return {}\n case 'opaque':\n // reported through the issues of the result\n return {}\n }\n }\n\n // ------------------------------------------------------------------------------------------------\n // components\n\n /**\n * Checks the components against the schema slots once every operation is built, whatever the order\n * they were met in: a declaration merged with the schema it is inferred from (`const User =\n * z.object(...)` and `interface User extends z.infer<typeof User> {}`) is documented by the schema\n * (its output variant); another declaration with the name of a schema is ZNIGHT034.\n */\n settle(): void {\n for (const [name, component] of [...this.#components]) {\n const slot = this.#slots.has(name)\n if (slot === undefined) continue\n if (slot.identity === component.identity) {\n this.#components.delete(name)\n this.#slots.need(slot.identity, 'output')\n continue\n }\n const named = this.#named.get(component.key)\n const key = `${name}\\u0000${component.key}`\n if (this.#conflicts.has(key)) continue\n this.#conflicts.add(key)\n this.#ctx.report({\n code: Codes.SchemaNameConflict,\n severity: 'error',\n message: `Two schemas are named \"${name}\" in the OpenAPI document: the ${named?.declaration ?? 'declaration'} ${named?.name ?? component.identity} and the schema ${slot.identity}`,\n location: component.location,\n related: [{ message: 'the schema', location: slot.location }],\n hints: ['Rename one of them: component names come from declaration and export names'],\n })\n }\n }\n\n #component(named: NamedShape): void {\n const name = this.#nameOf(named)\n const existing = this.#components.get(name)\n if (existing !== undefined) {\n if (existing.key !== named.key) this.#conflict(name, named, existing)\n return\n }\n if (this.#reserved.has(name)) {\n const key = `${name}\\u0000${named.key}`\n if (!this.#conflicts.has(key)) {\n this.#conflicts.add(key)\n this.#ctx.report({\n code: Codes.SchemaNameConflict,\n severity: 'error',\n message: `${named.name} is named \"${name}\", a name reserved for the standard error components of the OpenAPI document`,\n location: named.location,\n hints: ['Rename one of them: component names come from declaration and export names'],\n })\n }\n return\n }\n const component: Component = {\n key: named.key,\n identity: named.identity,\n location: named.location,\n schema: undefined,\n }\n this.#components.set(name, component)\n const use: SchemaUse = { io: 'output', operation: named.name, part: named.name, location: named.location }\n const schema = this.convert(named.shape, use, named.name)\n component.schema = withDoc(schema as JsonSchema, named.doc, issue => this.#tagIssue(issue))\n }\n\n #conflict(name: string, named: NamedShape, existing: Component): void {\n const key = [named.key, existing.key].sort(compareStrings).join('\\u0000')\n if (this.#conflicts.has(key)) return\n this.#conflicts.add(key)\n this.#ctx.report({\n code: Codes.SchemaNameConflict,\n severity: 'error',\n message: `Two declarations are named \"${name}\" in the OpenAPI document: ${named.identity} and ${existing.identity}`,\n location: named.location,\n related: [{ message: 'the other declaration', location: existing.location }],\n hints: ['Rename one of them: component names come from declaration names'],\n })\n }\n\n #nameOfKey(key: string): string | undefined {\n const named = this.#named.get(key)\n return named === undefined ? undefined : this.#nameOf(named)\n }\n\n /**\n * The component name of a declaration: its name, then the names of its type arguments\n * (`Page_Book`). An instantiation with an anonymous argument (`Page<{ id: string }>`), or whose\n * name another instantiation of the same declaration already has (`Box<Book[]>`, `Box<BookArray>`),\n * also gets a short hash of its key (`Page_object_1a2b3c4d`): two instantiations never clash.\n */\n #nameOf(named: NamedShape): string {\n let name = this.#names.get(named.key)\n if (name === undefined) {\n if (named.typeArgs.length === 0) name = componentName(named.name)\n else {\n const args = named.typeArgs.map(arg => this.#argName(arg))\n name = componentName([named.name, ...args.map(arg => arg.text)].join('_'))\n const taken = this.#keys.get(name)\n const sibling =\n taken !== undefined && taken !== named.key && this.#named.get(taken)?.identity === named.identity\n if (sibling || args.some(arg => !arg.exact)) name = `${name}_${shortHash(named.key)}`\n }\n this.#names.set(named.key, name)\n if (!this.#keys.has(name)) this.#keys.set(name, named.key)\n }\n return name\n }\n\n /** The name of a type argument; `exact: false` when it does not tell the argument apart (`object`). */\n #argName(shape: Shape): { text: string; exact: boolean } {\n switch (shape.kind) {\n case 'named':\n return { text: this.#nameOfKey(shape.key) ?? 'unknown', exact: true }\n case 'literal':\n return { text: String(shape.value), exact: true }\n case 'array': {\n const items = this.#argName(shape.items)\n return { text: `${items.text}Array`, exact: items.exact }\n }\n case 'union':\n case 'intersection': {\n const members = shape.members.map(member => this.#argName(member))\n return {\n text: members.map(member => member.text).join(shape.kind === 'union' ? '_or_' : '_and_'),\n exact: members.every(member => member.exact),\n }\n }\n case 'schema':\n return { text: componentName(shape.ref.name), exact: true }\n case 'reference':\n return { text: shape.name, exact: shape.typeArgs.length === 0 }\n case 'opaque':\n case 'object':\n case 'tuple':\n return { text: shape.kind, exact: false }\n default:\n return { text: shape.kind, exact: true }\n }\n }\n\n // ------------------------------------------------------------------------------------------------\n // structures\n\n #tuple(shape: Extract<Shape, { kind: 'tuple' }>, use: SchemaUse, path: string): JsonSchema {\n const prefixItems = shape.items.map((item, index) => this.convert(item, use, `${path}[${index}]`) as JsonValue)\n const schema: Record<string, JsonValue> = { type: 'array', prefixItems, minItems: shape.minItems }\n if (shape.rest === undefined) {\n schema['maxItems'] = shape.items.length\n schema['items'] = false\n } else {\n schema['items'] = this.convert(shape.rest, use, `${path}[]`) as JsonValue\n }\n return schema\n }\n\n #object(\n properties: readonly ShapeProperty[],\n additional: Shape | undefined,\n use: SchemaUse,\n path: string,\n ): JsonSchema {\n const schema: Record<string, JsonValue> = { type: 'object' }\n if (properties.length > 0) {\n const props: Record<string, JsonValue> = {}\n for (const property of properties) {\n const converted = this.convert(property.shape, use, path === '' ? property.name : `${path}.${property.name}`)\n props[property.name] = withDoc(converted as JsonSchema, property.doc, issue =>\n this.#tagIssue(issue),\n ) as JsonValue\n }\n schema['properties'] = props\n const required = properties\n .filter(property => !property.optional)\n .map(property => property.name)\n .sort(compareStrings)\n if (required.length > 0) schema['required'] = required\n }\n if (additional !== undefined) {\n schema['additionalProperties'] = this.convert(additional, use, `${path}[string]`) as JsonValue\n }\n return schema\n }\n\n #union(members: readonly Shape[], use: SchemaUse, path: string): SchemaTemplate {\n const defined = members.filter(member => member.kind !== 'undefined')\n const nullable = defined.some(member => member.kind === 'null')\n const rest = defined.filter(member => member.kind !== 'null')\n if (rest.length === 0) return nullable ? { type: 'null' } : {}\n if (rest.every(member => member.kind === 'literal')) {\n const values = rest.map(member => (member as Extract<Shape, { kind: 'literal' }>).value)\n const types = [...new Set(values.map(value => typeof value))]\n const schema: Record<string, JsonValue> = {}\n if (types.length === 1) schema['type'] = nullable ? [types[0] as string, 'null'] : (types[0] as string)\n schema['enum'] = nullable ? [...values, null] : values\n return schema\n }\n const converted = rest.map(member => this.convert(member, use, path))\n if (converted.length === 1) {\n const single = converted[0] as JsonSchema\n if (!nullable) return single\n if (typeof single['type'] === 'string' && !Object.keys(single).some(key => NOT_NULLABLE_KEYS.has(key))) {\n return { ...single, type: [single['type'], 'null'] }\n }\n return { anyOf: [single as JsonValue, { type: 'null' }] }\n }\n // only simple `{ type }` members: a type list\n const simple = converted as readonly JsonSchema[]\n if (simple.every(schema => Object.keys(schema).length === 1 && typeof schema['type'] === 'string')) {\n const types = simple.map(schema => schema['type'] as string)\n return { type: nullable ? [...types, 'null'] : types }\n }\n const discriminator = this.#discriminator(rest)\n const list: JsonValue[] = converted.map(schema => schema as JsonValue)\n if (nullable) list.push({ type: 'null' })\n if (discriminator === undefined) return { anyOf: list }\n const mapping: Record<string, string> = {}\n rest.forEach((member, index) => {\n const ref = (converted[index] as JsonSchema)['$ref']\n if (member.kind === 'named' && typeof ref === 'string') {\n mapping[String(discriminator.values[index])] = ref\n }\n })\n const schema: Record<string, JsonValue> = { oneOf: list }\n // without a mapping, tools read the values as component names: only when every member is a component\n if (Object.keys(mapping).length === rest.length) {\n schema['discriminator'] = { propertyName: discriminator.property, mapping }\n }\n return schema\n }\n\n /** A required literal property with distinct (string) values in every object member. */\n #discriminator(members: readonly Shape[]): { property: string; values: (string | number | boolean)[] } | undefined {\n const objects = members.map(member => this.#objectOf(member))\n if (objects.some(object => object === undefined)) return undefined\n const literals = objects.map(object => {\n const map = new Map<string, string | number | boolean>()\n for (const property of object?.properties ?? []) {\n if (!property.optional && property.shape.kind === 'literal' && typeof property.shape.value === 'string') {\n map.set(property.name, property.shape.value)\n }\n }\n return map\n })\n const first = literals[0]\n if (first === undefined) return undefined\n for (const property of [...first.keys()].sort(compareStrings)) {\n if (!literals.every(map => map.has(property))) continue\n const values = literals.map(map => map.get(property) as string | number | boolean)\n if (new Set(values).size === values.length) return { property, values }\n }\n return undefined\n }\n\n /** The object structure of a shape (named declarations resolved). */\n #objectOf(shape: Shape): Extract<Shape, { kind: 'object' }> | undefined {\n if (shape.kind === 'object') return shape\n if (shape.kind === 'named') {\n const named = this.#named.get(shape.key)\n return named === undefined ? undefined : this.#objectOf(named.shape)\n }\n if (shape.kind === 'intersection') {\n const parts = shape.members.map(member => this.#objectOf(member))\n if (parts.some(part => part === undefined)) return undefined\n const properties = new Map<string, ShapeProperty>()\n for (const part of parts) for (const property of part?.properties ?? []) properties.set(property.name, property)\n return { kind: 'object', properties: [...properties.values()] }\n }\n return undefined\n }\n\n #intersection(members: readonly Shape[], use: SchemaUse, path: string): SchemaTemplate {\n const merged = this.#objectOf({ kind: 'intersection', members })\n if (merged !== undefined) {\n const additional = members.map(member => this.#objectOf(member)?.additional).find(value => value !== undefined)\n return this.#object(merged.properties, additional, use, path)\n }\n return { allOf: members.map(member => this.convert(member, use, path) as JsonValue) }\n }\n\n // ------------------------------------------------------------------------------------------------\n // diagnostics\n\n #issue(issue: ShapeIssue, use: SchemaUse): void {\n // one report per issue, unless a later use is more severe (a bigint met in a request body, then in a response)\n const severity = (issue.reason === 'bigint' && use.io === 'output') || this.#strict ? 'error' : 'warning'\n const reported = this.#reported.get(issue)\n if (reported === 'error' || reported === severity) return\n this.#reported.set(issue, severity)\n const subject = issue.path === '' ? `The type of ${use.part}` : issue.path\n const location = issue.location ?? use.location\n const related =\n issue.location !== undefined && use.location !== undefined\n ? [{ message: `${use.part} of ${use.operation}`, location: use.location }]\n : []\n if (issue.reason === 'bigint') {\n const response = use.io === 'output'\n this.#ctx.report({\n code: Codes.UnrepresentableType,\n severity,\n message: response\n ? `${subject} is a bigint: JSON.stringify throws on bigint, so ${use.operation} would answer 500`\n : `${subject} is a bigint: JSON has no bigint (${use.operation})`,\n ...(location === undefined ? {} : { location }),\n related,\n hints: [\n response\n ? 'Return a number or a string (String(total)), or give the type a toJSON() method'\n : 'Declare a string and convert it (BigInt(value)), or validate the body with a schema',\n ],\n })\n return\n }\n this.#ctx.report({\n code: Codes.UnrepresentableType,\n severity,\n message: `${subject} (${issue.text}) ${REASONS[issue.reason] ?? 'has no JSON Schema'}: it is documented as any value (${use.operation})`,\n ...(location === undefined ? {} : { location }),\n related,\n hints: HINTS[issue.reason] ?? [],\n })\n }\n\n #warn(message: string, use: SchemaUse, hints: readonly string[]): void {\n this.#ctx.report({\n code: Codes.UnrepresentableType,\n severity: this.#strict ? 'error' : 'warning',\n message,\n ...(use.location === undefined ? {} : { location: use.location }),\n hints,\n })\n }\n\n #tagIssue(issue: TagIssue): void {\n this.#ctx.report({\n code: Codes.UnrepresentableType,\n severity: this.#strict ? 'error' : 'warning',\n message: issue.message,\n location: issue.location,\n hints: ['JSDoc tag values are JSON (`@minimum 1`, `@example {\"id\": 1}`) or text'],\n })\n }\n}\n\n/** 8 hexadecimal characters of the SHA-256 of `text` (deterministic name suffixes). */\nfunction shortHash(text: string): string {\n return createHash('sha256').update(text).digest('hex').slice(0, 8)\n}\n\n/** Keywords whose meaning changes when `null` joins the type list (`enum`, `const`...): `anyOf` instead. */\nconst NOT_NULLABLE_KEYS = new Set(['$ref', 'enum', 'const', 'anyOf', 'oneOf', 'allOf', 'not'])\n\nconst REASONS: Readonly<Record<string, string>> = {\n function: 'is a function, which JSON.stringify skips',\n symbol: 'is a symbol, which JSON.stringify skips',\n 'type-parameter': 'is an unbound type parameter',\n 'non-json': 'is not serialised as declared by JSON.stringify',\n mapped: 'is a mapped type the compiler cannot expand',\n conditional: 'is a conditional type the compiler cannot expand',\n typeof: 'is a typeof type that is not a schema',\n 'indexed-access': 'is an indexed access type the compiler cannot resolve',\n 'type-operator': 'uses a type operator the compiler cannot expand',\n this: 'is a this type',\n unresolved: 'cannot be resolved',\n 'missing-annotation': 'has no type annotation',\n 'to-json': 'has a toJSON() method without return type annotation',\n recursive: 'is a recursion the compiler cannot follow',\n unsupported: 'has no JSON Schema',\n}\n\nconst HINTS: Readonly<Record<string, readonly string[]>> = {\n 'non-json': ['Map, Set, RegExp and Error become {} in JSON: use an array or a record, or add a toJSON() method'],\n 'to-json': ['Annotate the return type of toJSON(): toJSON(): BookJson'],\n 'missing-annotation': ['Annotate the type: the compiler reads annotations only'],\n conditional: ['Declare the structure with an interface, or describe the body with @ApiResponse({ schema })'],\n mapped: ['Declare the structure with an interface, or describe the body with @ApiResponse({ schema })'],\n 'type-parameter': ['Give the type arguments explicitly'],\n function: ['Remove the member from the transported type'],\n}\n\n/** A JSDoc tag with an invalid value. */\ninterface TagIssue {\n readonly message: string\n readonly location: Location\n}\n\nconst NUMERIC_TAGS = new Set(['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum', 'multipleOf'])\nconst COUNT_TAGS = new Set(['minLength', 'maxLength', 'minItems', 'maxItems'])\n\n/** Adds the JSDoc text and tags of `doc` to a schema (§6.2 \"JSDoc tags on types and properties\"). */\nexport function withDoc(\n schema: JsonSchema,\n doc: DocComment | undefined,\n report: (issue: TagIssue) => void,\n): JsonSchema {\n if (doc === undefined) return schema\n const result: Record<string, JsonValue | undefined> = { ...schema }\n if (doc.text !== '') result['description'] = doc.text\n for (const tag of doc.tags) {\n const text = tag.text.trim()\n const invalid = (expected: string): void =>\n report({\n message: `Invalid @${tag.name} value ${JSON.stringify(text)}: expected ${expected}`,\n location: tag.location,\n })\n if (tag.name === 'deprecated') {\n result['deprecated'] = true\n } else if (tag.name === 'example') {\n const examples = Array.isArray(result['examples']) ? (result['examples'] as JsonValue[]) : []\n result['examples'] = [...examples, parseTagValue(stripFence(text))]\n } else if (tag.name === 'default') {\n result['default'] = parseTagValue(text)\n } else if (tag.name === 'format') {\n if (text === '' || /\\s/.test(text)) invalid('a format name (date, email, int32...)')\n else {\n result['format'] = text\n if ((text === 'int32' || text === 'int64') && result['type'] === 'number') result['type'] = 'integer'\n }\n } else if (NUMERIC_TAGS.has(tag.name)) {\n const value = parseTagValue(text)\n if (typeof value === 'number' && Number.isFinite(value)) result[tag.name] = value\n else invalid('a number')\n } else if (COUNT_TAGS.has(tag.name)) {\n const value = parseTagValue(text)\n if (typeof value === 'number' && Number.isInteger(value) && value >= 0) result[tag.name] = value\n else invalid('a non-negative integer')\n } else if (tag.name === 'pattern') {\n try {\n new RegExp(text, 'u')\n result['pattern'] = text\n } catch {\n invalid('a regular expression')\n }\n } else if (tag.name === 'uniqueItems') {\n const value = text === '' ? true : parseTagValue(text)\n if (typeof value === 'boolean') result['uniqueItems'] = value\n else invalid('true or false')\n }\n }\n return result as JsonSchema\n}\n\n/** A tag value: JSON when it parses, the text otherwise. */\nexport function parseTagValue(text: string): JsonValue {\n try {\n return JSON.parse(text) as JsonValue\n } catch {\n return text\n }\n}\n\nfunction stripFence(text: string): string {\n const fenced = /^```[\\w-]*\\n([\\s\\S]*?)\\n```$/.exec(text)\n return fenced?.[1]?.trim() ?? text\n}\n","/**\n * `validate`: builds the whole OpenAPI model once per compile (document options, security schemes,\n * operations, components, Standard Schema slots), reports its diagnostics and keeps it for\n * `generate` (keyed by the application graph).\n */\nimport type { ApplicationGraph, Location, ValidateContext } from '@znight/compiler'\nimport type { JsonSchema, JsonValue, SecuritySchemeObject } from '../types.ts'\nimport type { OpenApiStored, SlotData } from './model.ts'\nimport type { OperationModel } from './operations.ts'\n\nimport { compareStrings, ERROR_COMPONENTS } from '../shared.ts'\nimport { documentTemplate, readDocument, SchemeRegistry } from './document.ts'\nimport { buildOperations } from './operations.ts'\nimport { Schemas, Slots } from './schemas.ts'\n\n/** Everything `generate` emits. */\nexport interface OpenApiModel {\n readonly document: Record<string, JsonValue>\n readonly operations: readonly OperationModel[]\n readonly components: Readonly<Record<string, JsonSchema>>\n readonly securitySchemes: Readonly<Record<string, SecuritySchemeObject>>\n readonly slots: readonly SlotData[]\n readonly errors: { readonly contentType: string; readonly schema?: string } | undefined\n readonly tagDescriptions: Readonly<Record<string, string>>\n /** Root of the project (relative `source` locations). */\n readonly root: string\n}\n\n/**\n * Models by compile. The key is `graph.extensions`: the validate and generate contexts of one\n * compile get different graph objects (diagnostics, pruning) sharing this array.\n */\nconst models = new WeakMap<object, OpenApiModel>()\n\n/** `validate` of the extension. */\nexport function validateOpenApi(ctx: ValidateContext<OpenApiStored>): void {\n models.set(ctx.graph.extensions, buildModel(ctx))\n}\n\n/** The model built by `validate` for the compile of `graph`. */\nexport function modelOf(graph: ApplicationGraph): OpenApiModel | undefined {\n return models.get(graph.extensions)\n}\n\nfunction buildModel(ctx: ValidateContext<OpenApiStored>): OpenApiModel {\n const schemes = new SchemeRegistry(ctx)\n const document = readDocument(ctx, schemes)\n const reserved = new Set<string>(\n document.errors === false ? [] : [ERROR_COMPONENTS.body, ERROR_COMPONENTS.validation],\n )\n const slots = new Slots(\n diagnostic => ctx.report(diagnostic),\n () => reserved,\n ref => declarationOf(ctx, ref.identity),\n )\n const schemas = new Schemas(ctx, { jsdoc: document.jsdoc, strict: document.strict, reserved }, slots)\n const errorsSlot =\n document.errors === false || document.errors.schema === undefined\n ? undefined\n : slots.use(document.errors.schema, 'output')\n const { operations, tagDescriptions } = buildOperations({ ctx, document, schemes, schemas, slots })\n schemas.settle()\n const rootSecurity = document.security === undefined ? undefined : schemes.objects(document.security)\n const securitySchemes: Record<string, SecuritySchemeObject> = {}\n for (const name of [...schemes.used.keys()].sort(compareStrings)) {\n securitySchemes[name] = schemes.used.get(name)?.definition as SecuritySchemeObject\n }\n return {\n document: documentTemplate(document, rootSecurity),\n operations,\n components: schemas.components(),\n securitySchemes,\n slots: slots.list(),\n errors: errorsOf(document.errors, errorsSlot?.name),\n tagDescriptions,\n root: ctx.options.root,\n }\n}\n\nfunction errorsOf(\n errors: false | { readonly contentType: string },\n schema: string | undefined,\n): OpenApiModel['errors'] {\n if (errors === false) return undefined\n return schema === undefined ? { contentType: errors.contentType } : { contentType: errors.contentType, schema }\n}\n\n/** Location of the declaration of an identity (`export const CreateBook = ...`). */\nfunction declarationOf(ctx: ValidateContext<OpenApiStored>, identity: string | undefined): Location | undefined {\n if (identity === undefined) return undefined\n const symbol = ctx.project.lookupIdentity(identity)\n if (symbol.kind !== 'declaration') return undefined\n const declaration = symbol.declarations[0]\n if (declaration === undefined) return undefined\n return ctx.project.getFile(declaration.file)?.location(declaration.span)\n}\n\n/** `{ file, line, column }` of a location, the file relative to `root`. */\nexport function sourceOf(location: Location, root: string): { file: string; line: number; column: number } {\n const file = location.file.startsWith(`${root}/`) ? location.file.slice(root.length + 1) : location.file\n return { file, line: location.line, column: location.column }\n}\n","/**\n * `generate`: emits `metadata.extensions.openapi` (§7.1 of RFC 0002). Every value is a JSON literal,\n * except the Standard Schema slots, imported by the generated module (once, like `invoke` does).\n */\nimport type { GenerateContext, GenNode, LiteralValue } from '@znight/compiler'\nimport type { OpenApiStored } from './model.ts'\nimport type { OpenApiModel } from './validate.ts'\n\nimport { createHash } from 'node:crypto'\n\nimport { canonicalJson, OPENAPI_VERSION } from '../shared.ts'\nimport { modelOf, sourceOf } from './validate.ts'\n\n/** `generate` of the extension. */\nexport function generateOpenApi(ctx: GenerateContext<OpenApiStored>): GenNode | undefined {\n const model = modelOf(ctx.graph) ?? emptyModel(ctx.options.root)\n const operations = model.operations.map(operation => ({\n controller: operation.controller,\n handler: operation.handler,\n route: operation.route,\n method: operation.method,\n path: operation.path,\n operation: operation.operation,\n }))\n const slots = model.slots.map(slot => ({ name: slot.name, io: [...slot.io].sort() }))\n const fingerprint = fingerprintOf({\n version: 1,\n document: model.document,\n operations,\n components: model.components,\n securitySchemes: model.securitySchemes,\n schemas: slots,\n errors: model.errors,\n tagDescriptions: model.tagDescriptions,\n })\n const lit = (value: unknown): GenNode => ctx.lit(value as LiteralValue)\n const entries: [string, GenNode][] = [\n ['version', lit(1)],\n ['fingerprint', lit(fingerprint)],\n ['document', lit(model.document)],\n ['operations', lit(operations)],\n ['components', lit(model.components)],\n ['securitySchemes', lit(model.securitySchemes)],\n [\n 'schemas',\n ctx.arr(\n model.slots.map(slot =>\n ctx.obj([\n ['name', slot.name],\n ['schema', ctx.importValue(slot.ref)],\n ['io', lit([...slot.io].sort())],\n ['source', lit(sourceOf(slot.location, model.root))],\n ]),\n ),\n ),\n ],\n ]\n if (model.errors !== undefined) entries.push(['errors', lit(model.errors)])\n if (Object.keys(model.tagDescriptions).length > 0) entries.push(['tagDescriptions', lit(model.tagDescriptions)])\n return ctx.obj(entries)\n}\n\n/** SHA-256 (base64url) of the canonical JSON of the section (schema values replaced by their names). */\nexport function fingerprintOf(section: unknown): string {\n return createHash('sha256').update(canonicalJson(section)).digest('base64url')\n}\n\nfunction emptyModel(root: string): OpenApiModel {\n return {\n document: { openapi: OPENAPI_VERSION, info: { title: 'API', version: '0.0.0' } },\n operations: [],\n components: {},\n securitySchemes: {},\n slots: [],\n errors: { contentType: 'application/json' },\n tagDescriptions: {},\n root,\n }\n}\n","/**\n * `@znight/openapi/compiler`: the compiler extension of `@znight/openapi` (architecture §6.5),\n * loaded by `@znight/compiler` through `package.json#znight.compiler`.\n *\n * - `analyzeClass`: records the `@OpenApiDocument` class, checks where `@Api*` decorators are\n * (ZNIGHT030);\n * - `validate`: builds the operation model from the route table of `@znight/http/compiler`, the\n * handler signatures, their JSDoc and the type shapes, and reports ZNIGHT030–036;\n * - `generate`: `metadata.extensions.openapi` (README, \"Compiler contract\").\n *\n * This entry only `import type`s from `@znight/compiler` and `@znight/http/compiler` and never\n * loads the runtime of `@znight/openapi`.\n */\nimport type { CompilerExtension, DecoratorSpec } from '@znight/compiler'\nimport type { OpenApiStored } from './model.ts'\n\nimport { analyzeOpenApiClass } from './analyze.ts'\nimport { generateOpenApi } from './generate.ts'\nimport { EXTENSION_NAME, Ids } from './model.ts'\nimport { validateOpenApi } from './validate.ts'\n\nexport type { OpenApiStored } from './model.ts'\n\n/** Decorators owned by the extension, by canonical identity (static / value arguments, §4.6). */\nconst decorators: Readonly<Record<string, DecoratorSpec>> = Object.freeze({\n [Ids.OpenApiDocument]: { targets: ['class'], params: ['value'] },\n [Ids.ApiOperation]: { targets: ['method'], params: ['static'] },\n [Ids.ApiTags]: { targets: ['class', 'method'], params: [], rest: 'static' },\n [Ids.ApiResponse]: { targets: ['method'], params: ['static', 'value'] },\n [Ids.ApiBody]: { targets: ['method'], params: ['value'] },\n [Ids.ApiQuery]: { targets: ['method'], params: ['static', 'static'] },\n [Ids.ApiHeader]: { targets: ['class', 'method'], params: ['static', 'static'] },\n [Ids.ApiSecurity]: { targets: ['class', 'method'], params: [], rest: 'value' },\n [Ids.ApiExclude]: { targets: ['class', 'method'], params: [] },\n})\n\n/** The `@znight/openapi` compiler extension. */\nconst openapi: CompilerExtension<OpenApiStored> = Object.freeze({\n apiVersion: 1,\n name: EXTENSION_NAME,\n decorators,\n analyzeClass: analyzeOpenApiClass,\n validate: validateOpenApi,\n generate: generateOpenApi,\n})\n\nexport default openapi\n"],"mappings":";;;;AAOA,MAAa,iBAAiB;;AAG9B,MAAa,MAWT,OAAO,OAAO;CAChB,iBAAiB;CACjB,cAAc;CACd,SAAS;CACT,aAAa;CACb,SAAS;CACT,UAAU;CACV,WAAW;CACX,aAAa;CACb,YAAY;CACZ,gBAAgB;AAClB,CAAC;;AAGD,MAAa,UAOT,OAAO,OAAO;CAChB,YAAY;CACZ,sBAAsB;CACtB,cAAc;CACd,UAAU;CACV,UAAU;CACV,SAAS;AACX,CAAC;;AAGD,MAAa,mCAAwC,IAAI,IAAI;CAC3D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAa,QAST,OAAO,OAAO;CAChB,kBAAkB;CAClB,0BAA0B;CAC1B,sBAAsB;CACtB,qBAAqB;CACrB,sBAAsB;CACtB,oBAAoB;CACpB,uBAAuB;CACvB,4BAA4B;AAC9B,CAAC;;AAGD,MAAa,iBAA+D,OAAO,OAAO;CACxF,cAAc;CACd,aAAa;CACb,aAAa;CACb,iBAAiB;CACjB,gBAAgB;CAChB,gBAAgB;CAChB,uBAAuB;CACvB,sBAAsB;CACtB,kCAAkC;CAClC,iCAAiC;CACjC,sDAAsD;CACtD,qDAAqD;AACvD,CAAC;;AAGD,MAAa,iBAA+D,OAAO,OAAO;CACxF,OAAO;CACP,SAAS;AACX,CAAC;;AAGD,MAAa,OAA0B,OAAO,OAAO;CACnD,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR;CACA;CACA;CACA;AACF,CAAC;;;AC1GD,SAAgB,oBAAoB,KAAgB,KAA0C;CAC5F,MAAM,SAAS,eACb,WAAW,QAAO,cAAa,UAAU,UAAU,cAAc;CACnE,MAAM,WAAW,IAAI,WAAW,MAAK,cAAa,UAAU,aAAa,IAAI,eAAe;CAC5F,MAAM,aAAa,IAAI,WAAW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