@znight/http 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -2
- package/dist/{adapter-J0UXFnNM.d.mts → adapter-DmhQGqAR.d.mts} +18 -5
- package/dist/compiler.d.mts +23 -1
- package/dist/compiler.mjs +126 -9
- package/dist/compiler.mjs.map +1 -1
- package/dist/express.d.mts +1 -1
- package/dist/fastify.d.mts +1 -1
- package/dist/hono.d.mts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +26 -7
- package/dist/index.mjs.map +1 -1
- package/dist/node.d.mts +1 -1
- package/package.json +4 -4
- package/src/compiler/analyze.ts +43 -0
- package/src/compiler/generate.ts +122 -13
- package/src/compiler/model.ts +21 -0
- package/src/context.ts +7 -0
- package/src/metadata.ts +13 -4
- package/src/pipeline.ts +12 -7
- package/src/plugin.ts +33 -0
package/dist/compiler.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.mjs","names":["isPlainObject"],"sources":["../src/compiler/ast.ts","../src/compiler/coercion.ts","../src/compiler/model.ts","../src/compiler/route-decorators.ts","../src/compiler/analyze.ts","../src/compiler/generate.ts","../src/compiler/route-groups.ts","../src/compiler/validate.ts","../src/compiler/index.ts"],"sourcesContent":["/**\n * Minimal, structural access to the oxc AST nodes exposed by `ClassInfo` / `ArgInfo` (escape\n * hatches of the extension API). The extension does not depend on `oxc-parser`: nodes are read\n * through this loose shape and checked at runtime.\n */\nimport type { ClassInfo, MethodInfo, ParameterInfo } from '@znight/compiler'\n\n/** An ESTree node, read structurally. */\nexport interface AstNode {\n readonly type: string\n readonly start: number\n readonly end: number\n readonly [key: string]: unknown\n}\n\n/** `true` for an object shaped like an AST node. */\nexport function isNode(value: unknown): value is AstNode {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { type?: unknown }).type === 'string' &&\n typeof (value as { start?: unknown }).start === 'number'\n )\n}\n\n/** The child node stored under `key`, when it is a node. */\nexport function child(node: AstNode, key: string): AstNode | undefined {\n const value = node[key]\n return isNode(value) ? value : undefined\n}\n\n/** The child nodes stored under `key`, when it is an array. */\nexport function children(node: AstNode, key: string): AstNode[] {\n const value = node[key]\n return Array.isArray(value) ? value.filter(isNode) : []\n}\n\nconst WRAPPERS = new Set([\n 'ParenthesizedExpression',\n 'TSAsExpression',\n 'TSSatisfiesExpression',\n 'TSNonNullExpression',\n 'TSTypeAssertion',\n 'TSInstantiationExpression',\n])\n\n/** Removes parentheses and type-only wrappers (`x as T`, `x satisfies T`, `x!`, `<T>x`). */\nexport function unwrap(node: AstNode): AstNode {\n let current = node\n while (WRAPPERS.has(current.type)) {\n const inner = child(current, 'expression')\n if (!inner) {\n return current\n }\n current = inner\n }\n return current\n}\n\n/**\n * The default value expression of a method parameter (`page = 1` → `1`), found in the class\n * declaration by the location of the method key.\n */\nexport function defaultValueOf(cls: ClassInfo, method: MethodInfo, param: ParameterInfo): AstNode | undefined {\n const classNode = cls.declaration.node as unknown\n if (!isNode(classNode)) {\n return undefined\n }\n const body = child(classNode, 'body')\n if (!body) {\n return undefined\n }\n for (const member of children(body, 'body')) {\n const key = child(member, 'key')\n if (!key || key.start !== method.location.start) {\n continue\n }\n const fn = child(member, 'value')\n if (!fn) {\n return undefined\n }\n const params = children(fn, 'params').filter(node => !(node.type === 'Identifier' && node['name'] === 'this'))\n let pattern = params[param.index]\n if (pattern?.type === 'TSParameterProperty') {\n pattern = child(pattern, 'parameter')\n }\n return pattern?.type === 'AssignmentPattern' ? child(pattern, 'right') : undefined\n }\n return undefined\n}\n","/**\n * Type-based coercion of raw request values (route parameters, query values, headers) to the\n * declared type of a handler parameter (README, \"Compiler contract\" → `coerce.X` by declared type).\n */\nimport type { AnalyzeContext, ClassInfo, MethodInfo, ParameterInfo, TypeInfo } from '@znight/compiler'\nimport type { CoercionPlan, HttpControllerData, ParamCoercion, ScalarCoercion } from './model.ts'\n\nimport { child, defaultValueOf, isNode, unwrap } from './ast.ts'\n\ntype Context = AnalyzeContext<HttpControllerData>\ntype Project = Context['project']\ntype ExpressionInput = Parameters<Project['evaluate']>[1]\ntype ScopeInput = Parameters<Project['evaluate']>[0]\ntype EnumValue = string | number | boolean\n\nconst DATE_IDENTITY = 'globalThis#Date'\nconst STRING: TypeInfo = { kind: 'primitive', name: 'string' }\nconst NUMBER: TypeInfo = { kind: 'primitive', name: 'number' }\nconst BOOLEAN: TypeInfo = { kind: 'primitive', name: 'boolean' }\nconst BIGINT: TypeInfo = { kind: 'primitive', name: 'bigint' }\nconst DATE: TypeInfo = { kind: 'reference', identity: DATE_IDENTITY, name: 'Date', typeArgs: [] }\n\n/** The type of a handler parameter: its annotation, or the type of its default value. */\nexport interface ParameterType {\n /** `undefined` when the parameter has no annotation and its default value tells nothing. */\n readonly type: TypeInfo | undefined\n /** `?`, default value, `| undefined` or `| null`. */\n readonly optional: boolean\n}\n\n/** Result of {@link planCoercion}. */\nexport type CoercionResult =\n | { readonly ok: true; readonly coercion: ParamCoercion }\n | { readonly ok: false; readonly reason: string; readonly hints: readonly string[] }\n\n/** Annotated or inferred type of a parameter. */\nexport function parameterType(ctx: Context, cls: ClassInfo, method: MethodInfo, param: ParameterInfo): ParameterType {\n let type: TypeInfo | undefined = param.type\n if (param.type.kind === 'opaque' && param.type.reason === 'missing-annotation') {\n type = param.hasDefault ? inferFromDefault(ctx, cls, method, param) : undefined\n }\n const nullish = type !== undefined && hasNullish(type)\n return { type, optional: param.optional || param.hasDefault || nullish }\n}\n\n/**\n * Plans the coercion of a raw value to `type`. `required` is set for route parameters, which are\n * always present (no `coerce.optional`).\n */\nexport function planCoercion(\n ctx: Context,\n declared: ParameterType,\n param: ParameterInfo,\n required: boolean,\n): CoercionResult {\n const type = declared.type\n if (type === undefined) {\n return {\n ok: false,\n reason: `the type of parameter '${param.name}' is unknown`,\n hints: [`Annotate the parameter: ${param.name}: string`],\n }\n }\n const { type: base } = ctx.types.stripNullish(type)\n const raw = isRaw(base)\n if (raw) {\n return { ok: true, coercion: { plan: { kind: 'raw' }, cast: false } }\n }\n const scalar = scalarPlan(ctx, base)\n let plan: CoercionPlan\n let cast: boolean\n if ('reason' in scalar) {\n if (base.kind !== 'array') {\n return failure(ctx, type, scalar.reason)\n }\n const item = scalarPlan(ctx, base.element)\n if ('reason' in item) {\n return failure(ctx, type, item.reason)\n }\n plan = { kind: 'array', item: item.plan }\n cast = item.cast\n } else {\n plan = scalar.plan\n cast = scalar.cast\n }\n if (!required && declared.optional) {\n plan = { kind: 'optional', item: plan }\n // `coerce.optional` returns `T | undefined`: `x: T | null` (without `?` / default) needs a cast\n cast ||= !(param.optional || param.hasDefault || acceptsUndefined(type))\n }\n return { ok: true, coercion: { plan, cast } }\n}\n\n/** `unknown` and `any`: the raw value is passed as is. */\nexport function isRaw(type: TypeInfo): boolean {\n return type.kind === 'primitive' && (type.name === 'unknown' || type.name === 'any')\n}\n\ntype ScalarResult =\n | { readonly plan: CoercionPlan; readonly cast: boolean }\n | { readonly reason: string; readonly cast?: undefined }\n\nfunction scalarPlan(ctx: Context, type: TypeInfo): ScalarResult {\n switch (type.kind) {\n case 'primitive': {\n const kind = primitiveCoercion(type.name)\n return kind ? { plan: { kind }, cast: false } : { reason: `'${type.name}' values cannot be read from a request` }\n }\n case 'literal':\n return typeof type.value === 'bigint'\n ? { reason: 'bigint literal types are not supported' }\n : { plan: { kind: 'enum', values: [type.value] }, cast: false }\n case 'union': {\n const values: EnumValue[] = []\n for (const member of type.types) {\n if (member.kind === 'literal' && typeof member.value !== 'bigint') {\n values.push(member.value)\n } else if (member.kind === 'primitive' && member.name === 'boolean') {\n values.push(false, true)\n } else {\n return { reason: 'only unions of literal types can be coerced' }\n }\n }\n return { plan: { kind: 'enum', values }, cast: false }\n }\n case 'reference': {\n if (type.identity === DATE_IDENTITY) {\n return { plan: { kind: 'date' }, cast: false }\n }\n const values = enumValues(ctx, type.identity)\n if (values) {\n // enum members are nominal: the literal values are cast to the enum type\n return values.length === 0\n ? { reason: `the enum ${type.name} has no member` }\n : { plan: { kind: 'enum', values }, cast: true }\n }\n return { reason: 'objects cannot be read from a single request value' }\n }\n case 'intersection': {\n // branded primitives: `string & { readonly __brand: 'UserId' }`\n const primitives = type.types.filter(member => member.kind === 'primitive' || member.kind === 'literal')\n const [primitive] = primitives\n if (primitives.length === 1 && primitive !== undefined) {\n const inner = scalarPlan(ctx, primitive)\n return 'reason' in inner ? inner : { plan: inner.plan, cast: true }\n }\n return { reason: 'only branded primitives (`string & { ... }`) can be coerced' }\n }\n case 'array':\n return { reason: 'nested arrays cannot be coerced' }\n default:\n return { reason: 'this type cannot be read from a request value' }\n }\n}\n\nfunction primitiveCoercion(name: string): ScalarCoercion | undefined {\n switch (name) {\n case 'string':\n case 'number':\n case 'boolean':\n case 'bigint':\n return name\n default:\n return undefined\n }\n}\n\nfunction failure(ctx: Context, type: TypeInfo, reason: string): CoercionResult {\n return {\n ok: false,\n reason: `type '${ctx.types.format(type)}' cannot be coerced (${reason})`,\n hints: [\n 'Supported types: string, number, boolean, bigint, Date, literal unions, enums, branded primitives and arrays of them',\n 'Or validate the value with a Standard Schema',\n ],\n }\n}\n\n/** Member values of a TypeScript enum, `undefined` when `identity` is not an evaluable enum. */\nfunction enumValues(ctx: Context, identity: string): EnumValue[] | undefined {\n const symbol = ctx.project.lookupIdentity(identity)\n if (symbol.kind !== 'declaration' || symbol.declaration.kind !== 'enum') {\n return undefined\n }\n const declaration = symbol.declaration\n const node = declaration.node as unknown\n const id = isNode(node) ? child(node, 'id') : undefined\n const file = ctx.project.getFile(declaration.file)\n if (!id || !file) {\n return undefined\n }\n const scope = { file, namespace: declaration.namespace } as unknown as ScopeInput\n const result = ctx.project.evaluate(scope, id as unknown as ExpressionInput, { refs: 'none' })\n if (result.kind !== 'value' || typeof result.value !== 'object' || result.value === null) {\n return undefined\n }\n return Object.values(result.value).filter(\n (value): value is string | number => typeof value === 'string' || typeof value === 'number',\n )\n}\n\nfunction inferFromDefault(\n ctx: Context,\n cls: ClassInfo,\n method: MethodInfo,\n param: ParameterInfo,\n): TypeInfo | undefined {\n const node = defaultValueOf(cls, method, param)\n if (!node) {\n return undefined\n }\n const inner = unwrap(node)\n if (inner.type === 'NewExpression') {\n const callee = child(inner, 'callee')\n if (callee?.type === 'Identifier') {\n const resolved = ctx.project.resolveIdentifier(\n cls.file,\n callee as unknown as Parameters<Project['resolveIdentifier']>[1],\n 'value',\n )\n return resolved.identity?.identity === DATE_IDENTITY ? DATE : undefined\n }\n return undefined\n }\n const result = ctx.project.evaluate(cls.file, node as unknown as ExpressionInput, { refs: 'none' })\n return result.kind === 'value' ? typeOfValue(result.value) : undefined\n}\n\nfunction typeOfValue(value: unknown): TypeInfo | undefined {\n switch (typeof value) {\n case 'string':\n return STRING\n case 'number':\n return NUMBER\n case 'boolean':\n return BOOLEAN\n case 'bigint':\n return BIGINT\n default: {\n if (!Array.isArray(value) || value.length === 0) {\n return undefined\n }\n const items = value.map(typeOfValue)\n const [first] = items\n if (first === undefined || first.kind !== 'primitive' || items.some(item => item !== first)) {\n return undefined\n }\n return { kind: 'array', element: first }\n }\n }\n}\n\nfunction hasNullish(type: TypeInfo): boolean {\n return type.kind === 'union' && type.types.some(isNullish)\n}\n\n/** Whether a union accepts `undefined` (`T | undefined`, `T | void`). */\nexport function acceptsUndefined(type: TypeInfo): boolean {\n return (\n type.kind === 'union' &&\n type.types.some(member => member.kind === 'primitive' && (member.name === 'undefined' || member.name === 'void'))\n )\n}\n\nfunction isNullish(type: TypeInfo): boolean {\n return type.kind === 'primitive' && (type.name === 'undefined' || type.name === 'null' || type.name === 'void')\n}\n","/**\n * Data model of the `@znight/http` compiler extension: canonical identities of the decorators and\n * the data stored during analysis (`ctx.store()`), read back by `validate()` and `generate()`.\n *\n * This module is pure (types and constants only) so that the compiler entry stays free of runtime\n * dependencies.\n */\nimport type { ClassRef, Location, StaticValue, ValueRef } from '@znight/compiler'\nimport type { HttpMethod, HttpParamSource } from '../metadata.ts'\n\n/** Package name (prefix of every decorator identity). */\nexport const HTTP_PACKAGE = '@znight/http'\n\n/** Canonical identities of the decorators of `@znight/http`. */\nexport const Ids: {\n readonly Controller: string\n readonly Param: string\n readonly Query: string\n readonly Body: string\n readonly Headers: string\n readonly Req: string\n readonly Res: string\n readonly Ctx: string\n readonly HttpCode: string\n readonly Header: string\n readonly UseGuard: string\n readonly UseInterceptor: string\n readonly Validate: string\n readonly UploadedFile: string\n readonly UploadedFiles: string\n readonly BodyLimit: string\n readonly Cookie: string\n readonly SignedCookie: string\n readonly Sse: string\n readonly createRouteDecorator: string\n readonly RouteDecorator: string\n} = Object.freeze({\n Controller: '@znight/http#Controller',\n Param: '@znight/http#Param',\n Query: '@znight/http#Query',\n Body: '@znight/http#Body',\n Headers: '@znight/http#Headers',\n Req: '@znight/http#Req',\n Res: '@znight/http#Res',\n Ctx: '@znight/http#Ctx',\n HttpCode: '@znight/http#HttpCode',\n Header: '@znight/http#Header',\n UseGuard: '@znight/http#UseGuard',\n UseInterceptor: '@znight/http#UseInterceptor',\n Validate: '@znight/http#Validate',\n UploadedFile: '@znight/http#UploadedFile',\n UploadedFiles: '@znight/http#UploadedFiles',\n BodyLimit: '@znight/http#BodyLimit',\n Cookie: '@znight/http#Cookie',\n SignedCookie: '@znight/http#SignedCookie',\n Sse: '@znight/http#Sse',\n createRouteDecorator: '@znight/http#createRouteDecorator',\n RouteDecorator: '@znight/http#RouteDecorator',\n})\n\n/** Route method decorators → HTTP method (`@Sse` declares a `GET` route). */\nexport const ROUTE_METHODS: ReadonlyMap<string, HttpMethod> = new Map<string, HttpMethod>([\n ['@znight/http#Get', 'GET'],\n ['@znight/http#Post', 'POST'],\n ['@znight/http#Put', 'PUT'],\n ['@znight/http#Patch', 'PATCH'],\n ['@znight/http#Delete', 'DELETE'],\n ['@znight/http#Head', 'HEAD'],\n ['@znight/http#Options', 'OPTIONS'],\n ['@znight/http#All', 'ALL'],\n ['@znight/http#Sse', 'GET'],\n])\n\n/** Parameter decorators → parameter source. */\nexport const PARAM_SOURCES: ReadonlyMap<string, HttpParamSource> = new Map<string, HttpParamSource>([\n [Ids.Param, 'param'],\n [Ids.Query, 'query'],\n [Ids.Body, 'body'],\n [Ids.Headers, 'headers'],\n [Ids.Req, 'request'],\n [Ids.Res, 'response'],\n [Ids.Ctx, 'context'],\n [Ids.UploadedFile, 'file'],\n [Ids.UploadedFiles, 'files'],\n [Ids.Cookie, 'cookie'],\n [Ids.SignedCookie, 'signedCookie'],\n])\n\n/** Error codes used by the extension (see `ErrorCode` in `@znight/core`). */\nexport const Codes: {\n readonly MissingProvider: 'ZNIGHT001'\n readonly InvalidDecorator: 'ZNIGHT005'\n readonly InvalidRoute: 'ZNIGHT007'\n readonly UnvalidatedInput: 'ZNIGHT017'\n readonly MissingRouteDecision: 'ZNIGHT023'\n} = Object.freeze({\n MissingProvider: 'ZNIGHT001',\n InvalidDecorator: 'ZNIGHT005',\n InvalidRoute: 'ZNIGHT007',\n UnvalidatedInput: 'ZNIGHT017',\n MissingRouteDecision: 'ZNIGHT023',\n})\n\n/**\n * Grammar of an explicit route decorator group name (same as the runtime `createRouteDecorator`).\n * A decorator without `group` is its own group, named after its key (any non-empty key).\n */\nexport const GROUP_NAME: RegExp = /^[A-Za-z][\\w.-]*$/\n\n/** Primitive coercions (`coerce.<kind>`). */\nexport type ScalarCoercion = 'string' | 'number' | 'integer' | 'boolean' | 'bigint' | 'date'\n\n/**\n * How a raw value (route parameter, query value, header) is converted to the declared type of a\n * handler parameter.\n */\nexport type CoercionPlan =\n | { readonly kind: ScalarCoercion }\n | { readonly kind: 'enum'; readonly values: readonly (string | number | boolean)[] }\n | { readonly kind: 'array'; readonly item: CoercionPlan }\n | { readonly kind: 'optional'; readonly item: CoercionPlan }\n /** No conversion: the raw value is passed as is (`unknown` / `any` parameters). */\n | { readonly kind: 'raw' }\n\n/** The coercion of a handler parameter. */\nexport interface ParamCoercion {\n readonly plan: CoercionPlan\n /**\n * The coerced value does not have the declared type (branded primitives, enums, `null` without\n * `undefined`): the generated expression is cast with `as never`.\n */\n readonly cast: boolean\n}\n\n/** An upload parameter (`@UploadedFile` / `@UploadedFiles`). */\nexport interface UploadData {\n /** Multipart field; `undefined`: any field. */\n readonly field: string | undefined\n /** `@UploadedFiles`. */\n readonly multiple: boolean\n /** A file must be sent (`required` option, else the parameter is not optional). */\n readonly required: boolean\n /** `maxSize` in bytes (`Infinity` allowed). */\n readonly maxSize: number | undefined\n /** `maxFiles` (`@UploadedFiles` only). */\n readonly maxFiles: number | undefined\n /** `mimeTypes` patterns, as written. */\n readonly mimeTypes: readonly string[] | undefined\n /** The injected value does not have the declared type (`node:buffer` File, `File | null`): `as never`. */\n readonly cast: boolean\n}\n\n/** A handler parameter. */\nexport interface HttpParamData {\n /** Position in the handler signature. */\n readonly index: number\n /** Parameter name (messages). */\n readonly name: string\n readonly source: HttpParamSource\n /** Route parameter name, query key, lower-case header name or cookie name; `undefined` for the whole object. */\n readonly key: string | undefined\n /** Declared (or inferred) type, formatted for humans. */\n readonly type: string | undefined\n /** The parameter accepts `undefined` (`?`, `| undefined`, default value). */\n readonly optional: boolean\n /** Standard Schema validating the value (its output is injected). */\n readonly schema: ValueRef | undefined\n /** Coercion of a named value without schema. */\n readonly coercion: ParamCoercion | undefined\n /** Upload parameter (`source` `file` / `files`). */\n readonly upload?: UploadData\n /**\n * The default value of the handler parameter (`@Query('page') page = 1` → `1`), when it is\n * statically evaluable (literals, `const` references; references to exported bindings are left\n * out). Informational (documentation): the handler applies its own default.\n */\n readonly defaultValue?: StaticValue\n /** Location of the parameter decorator. */\n readonly location: Location\n}\n\n/** A `createRouteDecorator` value (`route.meta[key]`) and the definition of its decorator. */\nexport interface MetaEntry {\n readonly key: string\n /** Statically evaluated value; may be or contain references to exported bindings. */\n readonly value: StaticValue\n /** Location of the decorator usage. */\n readonly location: Location\n /** Decision group (`options.group ?? key`). */\n readonly group: string\n /** The group is required (`options.required`). */\n readonly required: boolean\n /** Display name of the decorator (`Roles`). */\n readonly decorator: string\n /** Canonical identity of the decorator `const` (`src/auth/access.ts#Roles`). */\n readonly identity: string\n /** Location of the decorator definition (`export const Roles = createRouteDecorator(...)`). */\n readonly definition: Location\n}\n\n/** Options of an `@Sse` route (`HttpRouteDefinition.sse`). */\nexport interface SseRouteData {\n /** Heartbeat in ms; `0` disables it (`heartbeat: false`). Absent: the plugin default. */\n readonly heartbeat?: number\n readonly retry?: number\n readonly maxDuration?: number\n}\n\n/** A route: one route decorator of a handler. */\nexport interface HttpRouteData {\n readonly method: HttpMethod\n /** Path of the route decorator as written (`undefined` when absent). */\n readonly rawPath: string\n /** `normalizePath(rawPath)`. */\n readonly path: string\n /** `joinPaths(controller base path, path)`. */\n readonly fullPath: string\n readonly handler: string\n readonly status: number | undefined\n /** `@Header` entries, lower-case names, in source order. */\n readonly headers: readonly (readonly [string, string])[]\n readonly meta: readonly MetaEntry[]\n readonly guards: readonly ClassRef[]\n readonly interceptors: readonly ClassRef[]\n readonly params: readonly HttpParamData[]\n /** `false` when a parameter could not be analysed (an error was reported; it is missing from `params`). */\n readonly complete: boolean\n /** `@Validate(S)` on a handler without `@Body()` parameter: the body is validated and discarded. */\n readonly bodySchema: ValueRef | undefined\n /** `@BodyLimit` of the method (or of the controller), in bytes. */\n readonly bodyLimit: number | undefined\n readonly rawResponse: boolean\n /** `@Sse` route: its options (`{}` without options). */\n readonly sse?: SseRouteData\n /** Location of the route decorator. */\n readonly location: Location\n /** Location of the path argument (the decorator when absent). */\n readonly pathLocation: Location\n}\n\n/** A controller (data stored by `analyzeClass`). */\nexport interface HttpControllerData {\n /** Provider token of the controller. */\n readonly token: string\n /** Canonical identity of the class (imported as a type by `invoke`). */\n readonly identity: string\n readonly displayName: string\n /** Base path as written. */\n readonly rawBasePath: string\n /** `normalizePath(rawBasePath)`. */\n readonly basePath: string\n readonly guards: readonly ClassRef[]\n readonly interceptors: readonly ClassRef[]\n readonly meta: readonly MetaEntry[]\n readonly routes: readonly HttpRouteData[]\n /** Location of `@Controller`. */\n readonly location: Location\n /** Location of the base path argument (the decorator when absent). */\n readonly pathLocation: Location\n}\n","/**\n * User-defined route metadata decorators (`createRouteDecorator<T>(key, { group?, required? })`).\n *\n * A decorator is a route decorator when its callee is a `const` initialised with a call to\n * `@znight/http#createRouteDecorator` whose first argument (the key) and optional second argument\n * (the options) are statically evaluable. Its argument is evaluated like a `value` decorator\n * argument (literals, `const` references, references to exported bindings); without argument the\n * value is `true`. Decorators of one group are alternatives: one per controller or route.\n *\n * Every helper takes the analysis context of **any** extension: other extensions read route\n * decorators on their own targets (gateways, resolvers) with {@link readRouteMeta}, exported by\n * `@znight/http/compiler`.\n */\nimport type {\n AnalyzeContext,\n ClassInfo,\n DecoratorInfo,\n Diagnostic,\n Location,\n MethodInfo,\n StaticValue,\n ValueRef,\n} from '@znight/compiler'\nimport type { MetaEntry } from './model.ts'\n\nimport { type AstNode, child, children, isNode, unwrap } from './ast.ts'\nimport { Codes, GROUP_NAME, Ids } from './model.ts'\n\ntype Context = AnalyzeContext<unknown>\ntype Project = Context['project']\ntype ScopeInput = Parameters<Project['evaluate']>[0]\ntype ExpressionInput = Parameters<Project['evaluate']>[1]\ntype EntityName = Parameters<Project['resolveIdentifier']>[1]\n\n/** A route decorator definition: `export const Roles = createRouteDecorator<T>(key, options)`. */\nexport interface RouteDecoratorDefinition {\n readonly kind: 'route'\n readonly key: string\n /** `options.group ?? key`. */\n readonly group: string\n readonly required: boolean\n /** Name of the `const` (`Roles`). */\n readonly name: string\n /** Location of the `const` name. */\n readonly definition: Location\n}\n\n/** What a decorator identity refers to. */\nexport type RouteDecoratorResolution =\n | RouteDecoratorDefinition\n | { readonly kind: 'other' }\n | {\n readonly kind: 'invalid'\n readonly message: string\n readonly hints: readonly string[]\n /** The definition, when the problem is there. */\n readonly definition?: Location\n }\n\nconst OTHER: RouteDecoratorResolution = Object.freeze({ kind: 'other' })\n\n/** Resolutions per analysis context (one context per compile). */\nconst caches = new WeakMap<object, Map<string, RouteDecoratorResolution>>()\n\n/** Resolves a decorator identity to a route decorator definition (memoized per compile). */\nexport function resolveRouteDecorator(ctx: Context, identity: string): RouteDecoratorResolution {\n let cache = caches.get(ctx)\n if (!cache) {\n cache = new Map()\n caches.set(ctx, cache)\n }\n let resolution = cache.get(identity)\n if (!resolution) {\n resolution = resolve(ctx, identity)\n cache.set(identity, resolution)\n }\n return resolution\n}\n\nfunction resolve(ctx: Context, identity: string): RouteDecoratorResolution {\n if (identity.startsWith('globalThis#')) {\n return OTHER\n }\n const symbol = ctx.project.lookupIdentity(identity)\n if (symbol.kind !== 'declaration') {\n return OTHER\n }\n const declaration = symbol.declarations.find(candidate => candidate.kind === 'const')\n const node = declaration?.node as unknown\n const file = declaration ? ctx.project.getFile(declaration.file) : undefined\n if (!declaration || !isNode(node) || !file) {\n return OTHER\n }\n const scope = { file, namespace: declaration.namespace } as unknown as ScopeInput\n const init = child(node, 'init')\n if (!init) {\n // `export declare const Roles: RouteDecorator<string[]>` (declaration file): the key is lost\n const annotation = child(child(node, 'id') ?? node, 'typeAnnotation')\n const type = annotation\n ? ctx.project.resolveType(scope, annotation as unknown as Parameters<Project['resolveType']>[1])\n : undefined\n if (type?.kind === 'reference' && type.identity === Ids.RouteDecorator) {\n return {\n kind: 'invalid',\n message: `the key of the route decorator ${declaration.name} cannot be read: it is declared without initializer`,\n hints: [\n 'Route decorators must be declared in analysed sources: `export const X = createRouteDecorator(key)`',\n 'For a provider library, publish its sources (\"znight\": { \"library\": \"source\" })',\n ],\n }\n }\n return OTHER\n }\n const call = unwrap(init)\n const callee = call.type === 'CallExpression' ? child(call, 'callee') : undefined\n if (!callee || !isEntityName(unwrap(callee))) {\n return OTHER\n }\n const resolved = ctx.project.resolveIdentifier(scope, unwrap(callee) as unknown as EntityName, 'value')\n if (resolved.identity?.identity !== Ids.createRouteDecorator) {\n return OTHER\n }\n const definition = file.location(declaration.span)\n const [keyNode, optionsNode, ...extra] = children(call, 'arguments')\n if (!keyNode || keyNode.type === 'SpreadElement') {\n return {\n kind: 'invalid',\n message: `createRouteDecorator() requires a key (${declaration.name})`,\n hints: [`export const ${declaration.name} = createRouteDecorator('${declaration.name.toLowerCase()}')`],\n definition,\n }\n }\n const key = ctx.project.evaluate(scope, keyNode as unknown as ExpressionInput, { refs: 'none' })\n if (key.kind !== 'value' || typeof key.value !== 'string' || key.value === '') {\n return {\n kind: 'invalid',\n message: `the key of the route decorator ${declaration.name} must be a statically evaluable non-empty string`,\n hints: [\"Use a string literal or a `const` string: createRouteDecorator('roles')\"],\n definition,\n }\n }\n const optionsHints = [\n `export const ${declaration.name} = createRouteDecorator('${key.value}', { group: 'access', required: true })`,\n ]\n if (extra.length > 0 || optionsNode?.type === 'SpreadElement') {\n return {\n kind: 'invalid',\n message: `createRouteDecorator() takes a key and an optional { group?, required? } object (${declaration.name})`,\n hints: optionsHints,\n definition,\n }\n }\n let options: StaticValue\n if (optionsNode !== undefined) {\n const evaluated = ctx.project.evaluate(scope, optionsNode as unknown as ExpressionInput, { refs: 'none' })\n if (evaluated.kind !== 'value') {\n return {\n kind: 'invalid',\n message: `the options of the route decorator ${declaration.name} must be statically evaluable (literals and \\`const\\` references)`,\n hints: optionsHints,\n definition,\n }\n }\n options = evaluated.value\n }\n const parsed = parseRouteDecoratorOptions(key.value, options)\n if ('error' in parsed) {\n return {\n kind: 'invalid',\n message: `the options of the route decorator ${declaration.name} ${parsed.error}`,\n hints: optionsHints,\n definition,\n }\n }\n return { kind: 'route', key: key.value, ...parsed, name: declaration.name, definition }\n}\n\n/**\n * The group and `required` of a route decorator from its evaluated options (`undefined`: the\n * defaults), or why the options are invalid.\n */\nexport function parseRouteDecoratorOptions(\n key: string,\n options: StaticValue,\n): { readonly group: string; readonly required: boolean } | { readonly error: string } {\n if (options === undefined) {\n return { group: key, required: false }\n }\n if (!isPlainObject(options)) {\n return { error: 'must be an object { group?, required? }' }\n }\n const unknown = Object.keys(options).find(name => name !== 'group' && name !== 'required')\n if (unknown !== undefined) {\n return { error: `have an unknown property \"${unknown}\" (expected group and required)` }\n }\n // the grammar applies to an explicit group only: without one, any key is its own group\n const group = options['group'] ?? key\n if (typeof group !== 'string' || (group !== key && !GROUP_NAME.test(group))) {\n const shown = typeof group === 'object' && group !== null ? 'a reference' : JSON.stringify(group)\n return { error: `have an invalid group ${shown}: a letter followed by letters, digits, _ . or -` }\n }\n const required = options['required'] ?? false\n if (typeof required !== 'boolean') {\n return { error: 'have a non-boolean \"required\"' }\n }\n return { group, required }\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, StaticValue> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return false\n }\n const prototype = Object.getPrototypeOf(value)\n return prototype === Object.prototype || prototype === null\n}\n\nfunction isEntityName(node: AstNode): boolean {\n if (node.type === 'Identifier') {\n return true\n }\n if (node.type === 'MemberExpression' && node['computed'] !== true) {\n const object = child(node, 'object')\n return child(node, 'property')?.type === 'Identifier' && object !== undefined && isEntityName(object)\n }\n return false\n}\n\n/**\n * Metadata entries of the route decorators applied to a class or a method (source order).\n * `target` names the class or the handler (`BookController`, `BookController.remove`). Problems are\n * reported as ZNIGHT005: two decisions of one group on the same target included.\n */\nexport function routeMeta(\n ctx: Context,\n cls: ClassInfo,\n decorators: readonly DecoratorInfo[],\n target: string,\n): MetaEntry[] {\n const entries: MetaEntry[] = []\n for (const decorator of decorators) {\n if (decorator.owner !== undefined || decorator.identity === undefined) {\n continue\n }\n const resolution = resolveRouteDecorator(ctx, decorator.identity)\n if (resolution.kind === 'other') {\n continue\n }\n if (resolution.kind === 'invalid') {\n report(\n ctx,\n decorator,\n `Invalid route decorator @${decorator.name}: ${resolution.message}`,\n resolution.hints,\n resolution.definition === undefined\n ? undefined\n : { message: 'The route decorator is defined here', location: resolution.definition },\n )\n continue\n }\n const value = metaValue(ctx, cls, decorator)\n if (value === INVALID) {\n continue\n }\n const previous = entries.find(entry => entry.group === resolution.group)\n if (previous) {\n if (previous.key === resolution.key && resolution.group === resolution.key) {\n report(\n ctx,\n decorator,\n `@${decorator.name} sets the route metadata '${resolution.key}', already set on the same target`,\n ['Apply each route decorator once per controller or route'],\n { message: 'First applied here', location: previous.location },\n )\n } else {\n const alternatives =\n previous.decorator === resolution.name\n ? `@${resolution.name} once`\n : `one of @${previous.decorator}, @${resolution.name}`\n report(\n ctx,\n decorator,\n `@${resolution.name} sets the \"${resolution.group}\" decision of ${target}, already set by @${previous.decorator} on the same target`,\n [`Keep ${alternatives}: the decorators of the \"${resolution.group}\" group are alternatives`],\n { message: 'First applied here', location: previous.location },\n )\n }\n continue\n }\n entries.push({\n key: resolution.key,\n value,\n location: decorator.location,\n group: resolution.group,\n required: resolution.required,\n decorator: resolution.name,\n identity: decorator.identity,\n definition: resolution.definition,\n })\n }\n return entries\n}\n\n/**\n * The route metadata entries of a class (`method` omitted) or of one of its methods: the route\n * decorators (`createRouteDecorator` consts) applied to that target, in source order, read exactly\n * as the http extension reads controllers and routes (keys, statically evaluated values, groups,\n * `required`). Problems are reported as ZNIGHT005 through `ctx`, once per call: read each target\n * once. Decorators that are not route decorators are ignored.\n *\n * Works with the analysis context of any extension. The entries of a target are its own: combine a\n * class and a method with {@link effectiveRouteMeta}.\n *\n * ```ts\n * analyzeClass(cls, ctx) {\n * const classMeta = readRouteMeta(ctx, cls)\n * for (const method of cls.methods) {\n * const meta = effectiveRouteMeta(classMeta, readRouteMeta(ctx, cls, method))\n * }\n * }\n * ```\n */\nexport function readRouteMeta(ctx: AnalyzeContext<unknown>, cls: ClassInfo, method?: MethodInfo): MetaEntry[] {\n return method === undefined\n ? routeMeta(ctx, cls, cls.decorators, cls.displayName)\n : routeMeta(ctx, cls, method.decorators, `${cls.displayName}.${method.name}`)\n}\n\n/**\n * The effective metadata of a method from the entries of its class and its own (RFC 0001 §5.1):\n * the class entries, except those of a group the method decides itself, then the method entries.\n * The same rule as `ctx.route.meta` at runtime.\n */\nexport function effectiveRouteMeta(classMeta: readonly MetaEntry[], methodMeta: readonly MetaEntry[]): MetaEntry[] {\n if (methodMeta.length === 0) {\n return [...classMeta]\n }\n const decided = new Set(methodMeta.map(entry => entry.group))\n return [...classMeta.filter(entry => !decided.has(entry.group)), ...methodMeta]\n}\n\n/** `true` when the decorator is a route metadata decorator. */\nexport function isRouteMetaDecorator(ctx: Context, decorator: DecoratorInfo): boolean {\n return (\n decorator.owner === undefined &&\n decorator.identity !== undefined &&\n resolveRouteDecorator(ctx, decorator.identity).kind !== 'other'\n )\n}\n\nconst INVALID: unique symbol = Symbol('invalid')\n\nfunction metaValue(ctx: Context, cls: ClassInfo, decorator: DecoratorInfo): StaticValue | typeof INVALID {\n if (!decorator.called) {\n report(ctx, decorator, `@${decorator.name} must be called: @${decorator.name}()`, [\n `Write @${decorator.name}(${decorator.args.length > 0 ? '...' : ''})`,\n ])\n return INVALID\n }\n const [arg, ...extra] = decorator.args\n if (arg === undefined) {\n return true\n }\n if (extra.length > 0) {\n report(ctx, decorator, `@${decorator.name} takes at most one argument`, [\n 'Pass a single value (an array or an object)',\n ])\n return INVALID\n }\n if (arg.text.startsWith('...')) {\n report(ctx, decorator, `@${decorator.name} does not accept spread arguments`, ['Pass the value directly'])\n return INVALID\n }\n const evaluation = ctx.project.evaluate(cls.file, arg.node as unknown as ExpressionInput, { refs: 'nested' })\n switch (evaluation.kind) {\n case 'value':\n return checkRefs(ctx, decorator, evaluation.value) ? evaluation.value : INVALID\n case 'ref':\n return checkRefs(ctx, decorator, evaluation.ref) ? evaluation.ref : INVALID\n case 'error': {\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'error',\n message: `Invalid argument of @${decorator.name}: ${evaluation.error.message}`,\n location: evaluation.error.location,\n hints: [evaluation.error.hint ?? 'Extract the value to `export const X = ...` and reference it'],\n })\n return INVALID\n }\n }\n}\n\n/** Checks that every reference of a value can be imported by the generated module. */\nfunction checkRefs(ctx: Context, decorator: DecoratorInfo, value: StaticValue): boolean {\n let ok = true\n const visit = (current: StaticValue): void => {\n if (isValueRef(current)) {\n const route = ctx.project.importRoute(current.symbol)\n if (!route.ok) {\n ok = false\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'error',\n message: `Invalid argument of @${decorator.name}: '${current.text}' cannot be imported by the generated module (${route.error.message})`,\n location: current.location,\n hints: route.error.hints.length > 0 ? [...route.error.hints] : ['Export it from its module'],\n })\n }\n return\n }\n if (Array.isArray(current)) {\n for (const item of current) {\n visit(item)\n }\n } else if (typeof current === 'object' && current !== null) {\n for (const item of Object.values(current)) {\n visit(item)\n }\n }\n }\n visit(value)\n return ok\n}\n\n/** `true` for a {@link ValueRef} (the only non-plain object a static value can hold). */\nexport function isValueRef(value: unknown): value is ValueRef {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return false\n }\n const prototype = Object.getPrototypeOf(value)\n return prototype !== Object.prototype && prototype !== null && (value as { kind?: unknown }).kind === 'ref'\n}\n\nfunction report(\n ctx: Context,\n decorator: DecoratorInfo,\n message: string,\n hints: readonly string[],\n related?: { readonly message: string; readonly location: Diagnostic['location'] },\n): void {\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'error',\n message,\n location: decorator.location,\n hints,\n ...(related?.location ? { related: [{ message: related.message, location: related.location }] } : {}),\n })\n}\n","/**\n * `analyzeClass` of the `@znight/http` compiler extension: controllers, routes, parameters,\n * guards, interceptors, statuses, headers and route metadata. Everything is checked here except\n * what needs the whole application (paths and duplicate routes, see `validate.ts`).\n */\nimport type {\n AnalyzeContext,\n ArgInfo,\n ClassInfo,\n ClassRef,\n DecoratorInfo,\n Location,\n MethodInfo,\n ParameterInfo,\n StaticValue,\n TypeInfo,\n ValueRef,\n} from '@znight/compiler'\nimport type { HttpMethod } from '../metadata.ts'\nimport type {\n HttpControllerData,\n HttpParamData,\n HttpRouteData,\n ParamCoercion,\n SseRouteData,\n UploadData,\n} from './model.ts'\n\nimport { isMediaTypePattern } from '../mime.ts'\nimport { joinPaths, normalizePath } from '../path.ts'\nimport { parseByteSize } from '../size.ts'\nimport { acceptsUndefined, isRaw, parameterType, planCoercion } from './coercion.ts'\nimport { Codes, HTTP_PACKAGE, Ids, PARAM_SOURCES, ROUTE_METHODS } from './model.ts'\nimport { isRouteMetaDecorator, isValueRef, readRouteMeta } from './route-decorators.ts'\n\n/** Name of the extension (owner of the decorators in `DecoratorInfo.owner`). */\nexport const EXTENSION_NAME = 'http'\n\ntype Context = AnalyzeContext<HttpControllerData>\ntype Scope = 'singleton' | 'request' | 'transient'\n\nconst SCOPES: readonly Scope[] = ['singleton', 'request', 'transient']\n/** RFC 9110 token (header names). */\nconst TOKEN = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/\n/** Types an upload parameter may have (`File`, `Blob`, arrays of them for `@UploadedFiles`); `true`: cast needed. */\nconst FILE_TYPES: ReadonlyMap<string, boolean> = new Map([\n ['globalThis#File', false],\n ['globalThis#Blob', false],\n ['node:buffer#File', true],\n ['node:buffer#Blob', true],\n])\n/** Methods whose requests usually have no body (upload parameters there are a warning). */\nconst BODYLESS_METHODS: ReadonlySet<HttpMethod> = new Set<HttpMethod>(['GET', 'HEAD', 'DELETE', 'OPTIONS'])\nconst UPLOAD_OPTIONS = ['required', 'maxSize', 'maxFiles', 'mimeTypes']\n/** Smallest `@Sse` heartbeat and `maxDuration` (ms). */\nconst MIN_SSE_INTERVAL_MS = 1_000\n/** Longest `@Sse` heartbeat and `maxDuration` (ms): the longest `setTimeout` delay. */\nconst MAX_SSE_TIMER_MS = 2_147_483_647\n/** Primitive return types an `@Sse` handler cannot return (`any`, `unknown`, `object`, `never` are accepted). */\nconst NOT_SSE_SOURCES: ReadonlySet<string> = new Set([\n 'string',\n 'number',\n 'boolean',\n 'bigint',\n 'symbol',\n 'undefined',\n 'null',\n 'void',\n])\n/** Values that are fine without schema (`@Body() body: string`, `@Body() bytes: Uint8Array`...). */\nconst UNVALIDATED_REFERENCES = new Set([\n 'globalThis#Uint8Array',\n 'globalThis#ArrayBuffer',\n 'globalThis#Buffer',\n 'globalThis#Blob',\n 'globalThis#FormData',\n 'node:buffer#Buffer',\n '@znight/http#QueryRecord',\n])\n\n/** Analyses a class carrying at least one `@znight/http` decorator. */\nexport function analyzeHttpClass(cls: ClassInfo, ctx: Context): void {\n const controllers = cls.decorators.filter(decorator => decorator.identity === Ids.Controller)\n const [controller] = controllers\n if (controller === undefined) {\n reportOutsideController(cls, ctx)\n return\n }\n for (const duplicate of controllers.slice(1)) {\n error(ctx, duplicate.location, `@Controller is applied several times to ${cls.displayName}`, [\n 'Keep a single @Controller()',\n ])\n }\n const options = controllerOptions(ctx, controller)\n const token = ctx.registerProvider(cls, { scope: options.scope })\n const basePath = normalizePath(options.path)\n const guards = classRefs(ctx, cls, cls.decorators, Ids.UseGuard, 'guard')\n const interceptors = classRefs(ctx, cls, cls.decorators, Ids.UseInterceptor, 'interceptor')\n const meta = readRouteMeta(ctx, cls)\n const bodyLimit = bodyLimitOf(ctx, cls.decorators)\n const routes: HttpRouteData[] = []\n for (const method of cls.methods) {\n routes.push(...analyzeMethod(ctx, cls, method, basePath, bodyLimit))\n }\n ctx.store({\n token,\n identity: cls.identity,\n displayName: cls.displayName,\n rawBasePath: options.path,\n basePath,\n guards,\n interceptors,\n meta,\n routes,\n location: controller.location,\n pathLocation: options.pathLocation,\n })\n}\n\n// -------------------------------------------------------------------------------------------------\n// Controller\n// -------------------------------------------------------------------------------------------------\n\ninterface ControllerOptions {\n readonly path: string\n readonly pathLocation: Location\n readonly scope: Scope\n}\n\nfunction controllerOptions(ctx: Context, decorator: DecoratorInfo): ControllerOptions {\n const [arg] = decorator.args\n const defaults: ControllerOptions = { path: '', pathLocation: decorator.location, scope: 'singleton' }\n if (arg === undefined || !arg.evaluated) {\n // missing, or not evaluable (already reported)\n return defaults\n }\n const value = arg.value\n if (typeof value === 'string') {\n return { ...defaults, path: value, pathLocation: arg.location }\n }\n if (!isPlainObject(value)) {\n error(ctx, arg.location, `@Controller expects a path or { path?, scope? }, got ${describe(value)}`, [\n \"@Controller('/users') or @Controller({ path: '/users', scope: 'request' })\",\n ])\n return defaults\n }\n let { path, scope } = defaults\n for (const [key, option] of Object.entries(value)) {\n if (key === 'path') {\n if (typeof option === 'string') {\n path = option\n } else if (option !== undefined) {\n error(ctx, arg.location, `@Controller: \"path\" must be a string, got ${describe(option)}`)\n }\n } else if (key === 'scope') {\n if (SCOPES.includes(option as Scope)) {\n scope = option as Scope\n } else if (option !== undefined) {\n error(ctx, arg.location, `@Controller: invalid scope ${describe(option)}`, [\n `Use one of ${SCOPES.map(candidate => `'${candidate}'`).join(', ')}`,\n ])\n }\n } else {\n error(ctx, arg.location, `@Controller: unknown option \"${key}\"`, ['Options: { path?, scope? }'])\n }\n }\n return { path, pathLocation: arg.location, scope }\n}\n\n/**\n * HTTP decorators on a class that is not a controller have no effect. On a class another extension\n * owns (a `@Consumer` of `@znight/messaging`...), adding `@Controller()` is no fix: a class is the\n * provider of a single extension.\n */\nfunction reportOutsideController(cls: ClassInfo, ctx: Context): void {\n const owner = foreignOwner(cls)\n const hint =\n owner === undefined\n ? [`Add @Controller() to ${cls.displayName} (routes are not inherited from base classes)`]\n : [\n `${cls.displayName} is a @${owner.name} class of '${owner.module}': HTTP decorators only apply to @Controller() classes`,\n ]\n const decorators: DecoratorInfo[] = [...cls.decorators]\n for (const method of cls.methods) {\n decorators.push(...method.decorators)\n const handler =\n owner === undefined ? undefined : method.decorators.find(decorator => decorator.owner === owner.decorator.owner)\n if (owner !== undefined && handler !== undefined) {\n reportHandlerParams(ctx, cls, method, owner, handler)\n continue\n }\n for (const param of method.params) {\n decorators.push(...unique(param.decorators))\n }\n }\n for (const decorator of decorators) {\n if (decorator.owner === EXTENSION_NAME && validTarget(decorator)) {\n error(ctx, decorator.location, `@${decorator.name} has no effect: ${cls.displayName} is not a controller`, hint)\n }\n }\n}\n\n/**\n * HTTP decorators on the parameters of a handler of the extension owning the class (an `@OnMessage`\n * handler...). That extension reads its handlers' parameters and reports those it cannot read\n * (`Headers` imported from `@znight/http` instead of `@znight/messaging`...): an HTTP decorator is\n * only reported here when the parameter is read through a decorator of that extension, or is\n * optional (left undefined without a word).\n */\nfunction reportHandlerParams(\n ctx: Context,\n cls: ClassInfo,\n method: MethodInfo,\n owner: QualifiedDecorator,\n handler: DecoratorInfo,\n): void {\n for (const param of method.params) {\n const read = param.decorators.some(decorator => decorator.owner === owner.decorator.owner)\n if (!read && !param.optional && !param.hasDefault && !param.rest) {\n continue\n }\n for (const decorator of unique(param.decorators)) {\n if (decorator.owner === EXTENSION_NAME && validTarget(decorator)) {\n error(\n ctx,\n decorator.location,\n `@${decorator.name} has no effect on parameter '${param.name}' of ${cls.displayName}.${method.name}: it is an @${handler.name} handler of '${owner.module}'`,\n [`Use the parameter decorators of '${owner.module}', or remove it`],\n )\n }\n }\n }\n}\n\n/** A decorator with the module and the export name of its identity (`'@znight/messaging#Consumer'`). */\ninterface QualifiedDecorator {\n readonly decorator: DecoratorInfo\n readonly module: string\n readonly name: string\n}\n\nfunction qualify(decorator: DecoratorInfo): QualifiedDecorator | undefined {\n const identity = decorator.identity\n const separator = identity?.lastIndexOf('#') ?? -1\n if (identity === undefined || separator <= 0) {\n return undefined\n }\n return { decorator, module: identity.slice(0, separator), name: identity.slice(separator + 1) }\n}\n\n/** The class decorator through which another extension owns the class (`@Consumer`...). */\nfunction foreignOwner(cls: ClassInfo): QualifiedDecorator | undefined {\n for (const decorator of cls.decorators) {\n const owner = decorator.owner\n if (owner === undefined || owner === EXTENSION_NAME || owner === 'core' || owner === 'manifest') {\n continue\n }\n const qualified = qualify(decorator)\n if (qualified !== undefined) {\n return qualified\n }\n }\n return undefined\n}\n\n/**\n * A parameter decorator named like an HTTP one but imported from another package (`Headers` and\n * `Ctx` of `@znight/messaging`, typically auto-imported).\n */\nfunction foreignParameterDecorator(param: ParameterInfo): QualifiedDecorator | undefined {\n for (const decorator of unique(param.decorators)) {\n const qualified = qualify(decorator)\n if (\n qualified !== undefined &&\n qualified.module !== HTTP_PACKAGE &&\n PARAM_SOURCES.has(`${HTTP_PACKAGE}#${qualified.name}`)\n ) {\n return qualified\n }\n }\n return undefined\n}\n\n// -------------------------------------------------------------------------------------------------\n// Routes\n// -------------------------------------------------------------------------------------------------\n\nfunction analyzeMethod(\n ctx: Context,\n cls: ClassInfo,\n method: MethodInfo,\n basePath: string,\n controllerBodyLimit: number | undefined,\n): HttpRouteData[] {\n const where = `${cls.displayName}.${method.name}`\n let routeDecorators = method.decorators.filter(decorator => ROUTE_METHODS.has(decorator.identity ?? ''))\n if (routeDecorators.length === 0) {\n reportNotARoute(ctx, method, where)\n return []\n }\n if (!checkHandler(ctx, method, where, routeDecorators[0] as DecoratorInfo)) {\n return []\n }\n const sseDecorator = routeDecorators.find(decorator => decorator.identity === Ids.Sse)\n if (sseDecorator !== undefined) {\n // one handler per event stream: the other route decorators are reported and ignored\n for (const other of routeDecorators) {\n if (other === sseDecorator) {\n continue\n }\n error(\n ctx,\n other.location,\n other.identity === Ids.Sse\n ? `@Sse is applied several times to ${where}`\n : `@${other.name} cannot be combined with @Sse on ${where}`,\n [\n 'One handler per event stream: declare other routes on other methods (HttpResponse.sse() serves an event stream from any route)',\n ],\n )\n }\n routeDecorators = [sseDecorator]\n }\n const decorators = method.decorators\n const bodyValidation = validateSchema(ctx, decorators)\n const { params, complete } = analyzeParams(ctx, cls, method, where, bodyValidation)\n let status = httpCode(ctx, decorators)\n let headers = responseHeaders(ctx, decorators)\n const guards = classRefs(ctx, cls, decorators, Ids.UseGuard, 'guard')\n const interceptors = classRefs(ctx, cls, decorators, Ids.UseInterceptor, 'interceptor')\n const meta = readRouteMeta(ctx, cls, method)\n const bodySchema =\n bodyValidation !== undefined && !params.some(param => param.source === 'body') ? bodyValidation.schema : undefined\n let rawResponse = params.some(param => param.source === 'response')\n const bodyLimit = bodyLimitOf(ctx, decorators) ?? controllerBodyLimit\n const uploads = checkUploads(ctx, params, where)\n if (sseDecorator !== undefined) {\n checkSseHandler(ctx, method, params, where, bodyValidation)\n status = undefined\n headers = headers.filter(([name]) => name !== 'content-type')\n rawResponse = false\n }\n\n const routes: HttpRouteData[] = []\n for (const decorator of routeDecorators) {\n const httpMethod = ROUTE_METHODS.get(decorator.identity ?? '') as HttpMethod\n const target = decorator === sseDecorator ? sseArgs(ctx, decorator) : routePath(ctx, decorator)\n if (target === undefined) {\n continue\n }\n const { rawPath, arg } = target\n const path = normalizePath(rawPath)\n if (uploads && BODYLESS_METHODS.has(httpMethod)) {\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'warning',\n message: `${where} reads uploaded files but is a ${httpMethod} route: ${httpMethod} requests usually have no body`,\n location: decorator.location,\n hints: ['Upload files with @Post(), @Put() or @Patch()'],\n })\n }\n routes.push({\n method: httpMethod,\n rawPath,\n path,\n fullPath: joinPaths(basePath, path),\n handler: method.name,\n status,\n headers,\n meta,\n guards,\n interceptors,\n params,\n complete,\n bodySchema,\n bodyLimit,\n rawResponse,\n ...(target.sse === undefined ? {} : { sse: target.sse }),\n location: decorator.location,\n pathLocation: arg?.location ?? decorator.location,\n })\n }\n return routes\n}\n\n/** The path of a route decorator, its argument and, for `@Sse`, its options. */\ninterface RouteTarget {\n readonly rawPath: string\n readonly arg: ArgInfo | undefined\n readonly sse?: SseRouteData\n}\n\n/** The path argument of a route decorator (`undefined` after an error). */\nfunction routePath(ctx: Context, decorator: DecoratorInfo): RouteTarget | undefined {\n const [arg] = decorator.args\n if (arg === undefined) {\n return { rawPath: '', arg }\n }\n if (!arg.evaluated) {\n return undefined // not evaluable: already reported\n }\n if (typeof arg.value !== 'string') {\n error(ctx, arg.location, `@${decorator.name} expects a path (string), got ${describe(arg.value)}`, [\n `@${decorator.name}('/:id')`,\n ])\n return undefined\n }\n return { rawPath: arg.value, arg }\n}\n\n/** `@Sse(path?, options?)` / `@Sse(options)`: the path and the options (`undefined` after an error). */\nfunction sseArgs(ctx: Context, decorator: DecoratorInfo): RouteTarget | undefined {\n const [first, second] = decorator.args\n let pathArg: ArgInfo | undefined\n let options: ArgInfo | undefined\n if (first !== undefined) {\n if (!first.evaluated) {\n return undefined // already reported\n }\n if (typeof first.value === 'string') {\n pathArg = first\n options = second\n } else if (first.value === undefined) {\n options = second\n } else if (isPlainObject(first.value)) {\n if (second !== undefined) {\n error(ctx, second.location, '@Sse(options) takes a single argument', [\n \"Put the path first: @Sse('/events', { retry: 5000 })\",\n ])\n return undefined\n }\n options = first\n } else {\n error(ctx, first.location, `@Sse expects a path (string) or options, got ${describe(first.value)}`, [\n \"@Sse('/events'), @Sse('/events', { heartbeat: 15_000 }) or @Sse({ retry: 5000 })\",\n ])\n return undefined\n }\n }\n const sse = sseOptions(ctx, options)\n if (sse === undefined) {\n return undefined\n }\n return { rawPath: typeof pathArg?.value === 'string' ? pathArg.value : '', arg: pathArg, sse }\n}\n\n/** The static `{ heartbeat?, retry?, maxDuration? }` of `@Sse` (`undefined` after an error). */\nfunction sseOptions(ctx: Context, arg: ArgInfo | undefined): SseRouteData | undefined {\n if (arg === undefined) {\n return {}\n }\n if (!arg.evaluated) {\n return undefined\n }\n const shape = '{ heartbeat?: number | false, retry?: number, maxDuration?: number }'\n if (arg.value === undefined) {\n return {}\n }\n if (!isPlainObject(arg.value)) {\n error(ctx, arg.location, `@Sse options must be an object ${shape}, got ${describe(arg.value)}`)\n return undefined\n }\n const result: { heartbeat?: number; retry?: number; maxDuration?: number } = {}\n let ok = true\n const invalid = (message: string, hints: readonly string[] = []): void => {\n ok = false\n error(ctx, arg.location, `@Sse: ${message}`, hints)\n }\n const integer = (value: StaticValue, min: number, max = Number.MAX_SAFE_INTEGER): value is number =>\n typeof value === 'number' && Number.isSafeInteger(value) && value >= min && value <= max\n for (const [key, value] of Object.entries(arg.value)) {\n if (value === undefined) {\n continue\n }\n switch (key) {\n case 'heartbeat':\n if (value === false) {\n result.heartbeat = 0\n } else if (integer(value, MIN_SSE_INTERVAL_MS, MAX_SSE_TIMER_MS)) {\n result.heartbeat = value\n } else {\n invalid(\n `\"heartbeat\" must be an integer number of ms from ${MIN_SSE_INTERVAL_MS} to ${MAX_SSE_TIMER_MS}, or false, got ${describe(value)}`,\n ['Keep it below the idle timeouts of the proxies and of Bun.serve() (10 s): the default is 8 000'],\n )\n }\n break\n case 'retry':\n if (integer(value, 0)) {\n result.retry = value\n } else {\n invalid(`\"retry\" must be an integer number of ms ≥ 0, got ${describe(value)}`)\n }\n break\n case 'maxDuration':\n if (integer(value, MIN_SSE_INTERVAL_MS, MAX_SSE_TIMER_MS)) {\n result.maxDuration = value\n } else {\n invalid(\n `\"maxDuration\" must be an integer number of ms from ${MIN_SSE_INTERVAL_MS} to ${MAX_SSE_TIMER_MS} (about 24.8 days), got ${describe(value)}`,\n )\n }\n break\n default:\n invalid(`unknown option \"${key}\"`, [`Options: ${shape}`])\n }\n }\n return ok ? result : undefined\n}\n\n/**\n * `@Sse` handlers: the plugin writes the stream with status 200 and its own content type, so\n * `@HttpCode`, `@Header('content-type')` and `@Res()` are errors; a body is a warning (EventSource\n * sends `GET` without body); a primitive return type is an error.\n */\nfunction checkSseHandler(\n ctx: Context,\n method: MethodInfo,\n params: readonly HttpParamData[],\n where: string,\n bodyValidation: BodyValidation | undefined,\n): void {\n for (const decorator of method.decorators) {\n if (decorator.identity === Ids.HttpCode) {\n error(ctx, decorator.location, `@HttpCode has no effect on @Sse route ${where}: an event stream answers 200`, [\n 'Throw an HttpException or return an HttpResponse from the handler for other statuses',\n ])\n } else if (decorator.identity === Ids.Header) {\n const [name] = decorator.args\n if (name?.evaluated === true && typeof name.value === 'string' && name.value.toLowerCase() === 'content-type') {\n error(ctx, decorator.location, `@Header('content-type') has no effect on @Sse route ${where}`, [\n 'An event stream is always sent as text/event-stream; charset=utf-8',\n ])\n }\n }\n }\n for (const param of params) {\n if (param.source === 'response') {\n error(ctx, param.location, `@Res() cannot be used on @Sse route ${where}: the plugin writes the event stream`, [\n 'Return an AsyncIterable of SseEvent, or use a plain route to write the response yourself',\n ])\n }\n }\n const body = params.find(param => param.source === 'body' || param.upload !== undefined)\n const bodyLocation = body?.location ?? bodyValidation?.decorator.location\n if (bodyLocation !== undefined) {\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'warning',\n message: `@Sse route ${where} reads a request body: EventSource sends GET requests without body`,\n location: bodyLocation,\n hints: ['For fetch() clients streaming a POST, use @Post() and return HttpResponse.sse(source)'],\n })\n }\n const returned = method.returnType === undefined ? undefined : ctx.types.awaited(method.returnType)\n if (returned !== undefined && !method.generator) {\n const members = returned.kind === 'union' ? returned.types : [returned]\n const invalid = members.some(\n member => member.kind === 'literal' || (member.kind === 'primitive' && NOT_SSE_SOURCES.has(member.name)),\n )\n if (invalid) {\n error(\n ctx,\n method.location,\n `@Sse handler ${where} returns ${ctx.types.format(returned)}: return an AsyncIterable, an Iterable or a ReadableStream of SseEvent (or an HttpResponse)`,\n ['async events(): Promise<AsyncIterable<SseEvent<T>>> { ...; return channel }'],\n )\n }\n }\n}\n\n/** `@BodyLimit(size)` of a class or method, in bytes. */\nfunction bodyLimitOf(ctx: Context, decorators: readonly DecoratorInfo[]): number | undefined {\n const [decorator, ...duplicates] = decorators.filter(candidate => candidate.identity === Ids.BodyLimit)\n for (const duplicate of duplicates) {\n error(ctx, duplicate.location, '@BodyLimit is applied several times', ['Keep a single @BodyLimit(size)'])\n }\n if (decorator === undefined) {\n return undefined\n }\n const [arg] = decorator.args\n if (arg === undefined) {\n error(ctx, decorator.location, '@BodyLimit requires a size', [\"@BodyLimit('10mb') or @BodyLimit(10_485_760)\"])\n return undefined\n }\n if (!arg.evaluated) {\n return undefined\n }\n const size = parseByteSize(arg.value)\n if (size === undefined) {\n error(ctx, arg.location, `@BodyLimit expects a size in bytes, got ${describe(arg.value)}`, [\n \"A non-negative integer (10_485_760), a size with a unit ('10mb', '512kb'; kb = 1024 bytes) or Infinity\",\n ])\n }\n return size\n}\n\n/**\n * Checks the upload parameters of a handler together (one parameter per field; a parameter without\n * field takes every file and stands alone). Returns whether the handler reads uploaded files.\n */\nfunction checkUploads(ctx: Context, params: readonly HttpParamData[], where: string): boolean {\n const uploads = params.filter(param => param.upload !== undefined)\n uploads.forEach((param, index) => {\n const field = param.upload?.field\n const previous = uploads\n .slice(0, index)\n .find(other => field === undefined || other.upload?.field === undefined || other.upload.field === field)\n if (previous === undefined) {\n return\n }\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'error',\n message:\n field !== undefined && previous.upload?.field === field\n ? `The field \"${field}\" of ${where} is read by several upload parameters`\n : `${where}: an upload parameter without field receives every file of the body and cannot be combined with other upload parameters`,\n location: param.location,\n hints: ['Give each @UploadedFile / @UploadedFiles parameter its own field'],\n related: [{ message: 'Other upload parameter', location: previous.location }],\n })\n })\n return uploads.length > 0\n}\n\n/** HTTP method decorators (and parameter decorators) on a method without route decorator. */\nfunction reportNotARoute(ctx: Context, method: MethodInfo, where: string): void {\n const hint = [`Add a route decorator to ${where}: @Get(), @Post(), @Put(), @Patch(), @Delete()...`]\n for (const decorator of method.decorators) {\n if (decorator.owner === EXTENSION_NAME && validTarget(decorator)) {\n error(ctx, decorator.location, `@${decorator.name} has no effect: ${where} is not a route`, hint)\n } else if (isRouteMetaDecorator(ctx, decorator)) {\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'warning',\n message: `@${decorator.name} has no effect: ${where} is not a route`,\n location: decorator.location,\n hints: hint,\n })\n }\n }\n for (const param of method.params) {\n for (const decorator of unique(param.decorators)) {\n if (decorator.owner === EXTENSION_NAME && validTarget(decorator)) {\n error(ctx, decorator.location, `@${decorator.name} has no effect: ${where} is not a route`, hint)\n }\n }\n }\n}\n\n/** A route handler must be a public, non-static method with a plain name. */\nfunction checkHandler(ctx: Context, method: MethodInfo, where: string, decorator: DecoratorInfo): boolean {\n let problem: string | undefined\n let hint = 'Route handlers are public instance methods'\n if (method.static) {\n problem = `Static method ${where} cannot be a route handler`\n } else if (method.privateName) {\n problem = `#private method ${where} cannot be a route handler`\n hint = 'Use a public method (the generated code calls it from outside the class)'\n } else if (method.visibility !== 'public') {\n problem = `${method.visibility === 'protected' ? 'Protected' : 'Private'} method ${where} cannot be a route handler`\n hint = 'Make the method public (the generated code calls it from outside the class)'\n } else if (method.kind !== 'method') {\n problem = `Accessor ${where} cannot be a route handler`\n } else if (method.computed) {\n problem = `${where} cannot be a route handler: handlers need a plain name (no computed key)`\n }\n if (problem !== undefined) {\n error(ctx, decorator.location, problem, [hint])\n return false\n }\n return true\n}\n\nfunction httpCode(ctx: Context, decorators: readonly DecoratorInfo[]): number | undefined {\n const [decorator, ...duplicates] = decorators.filter(candidate => candidate.identity === Ids.HttpCode)\n for (const duplicate of duplicates) {\n error(ctx, duplicate.location, '@HttpCode is applied several times', ['Keep a single @HttpCode(status)'])\n }\n if (decorator === undefined) {\n return undefined\n }\n const [arg] = decorator.args\n if (arg === undefined) {\n error(ctx, decorator.location, '@HttpCode requires a status', ['@HttpCode(202)'])\n return undefined\n }\n if (!arg.evaluated) {\n return undefined\n }\n const status = arg.value\n if (typeof status !== 'number' || !Number.isInteger(status) || status < 100 || status > 599) {\n error(ctx, arg.location, `@HttpCode expects an integer status between 100 and 599, got ${describe(status)}`)\n return undefined\n }\n return status\n}\n\nfunction responseHeaders(ctx: Context, decorators: readonly DecoratorInfo[]): (readonly [string, string])[] {\n const headers: (readonly [string, string])[] = []\n const seen = new Map<string, Location>()\n for (const decorator of decorators) {\n if (decorator.identity !== Ids.Header) {\n continue\n }\n const [name, value] = decorator.args\n if (name === undefined || value === undefined) {\n error(ctx, decorator.location, '@Header requires a name and a value', [\"@Header('cache-control', 'no-store')\"])\n continue\n }\n if (!name.evaluated || !value.evaluated) {\n continue\n }\n if (typeof name.value !== 'string' || !TOKEN.test(name.value)) {\n error(ctx, name.location, `@Header: invalid header name ${describe(name.value)}`, [\n \"Header names are tokens: letters, digits and ! # $ % & ' * + - . ^ _ ` | ~\",\n ])\n continue\n }\n if (typeof value.value !== 'string' || /[\\r\\n\\0]/.test(value.value)) {\n error(ctx, value.location, `@Header: the value of \"${name.value}\" must be a string without line breaks`)\n continue\n }\n const lower = name.value.toLowerCase()\n const previous = seen.get(lower)\n if (previous) {\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'error',\n message: `@Header: \"${lower}\" is set several times`,\n location: decorator.location,\n hints: ['Set each response header once (or use ctx.appendHeader() in the handler)'],\n related: [{ message: 'First set here', location: previous }],\n })\n continue\n }\n seen.set(lower, decorator.location)\n headers.push([lower, value.value])\n }\n return headers\n}\n\ninterface BodyValidation {\n readonly schema: ValueRef\n readonly decorator: DecoratorInfo\n}\n\n/** `@Validate(schema)` of a handler. */\nfunction validateSchema(ctx: Context, decorators: readonly DecoratorInfo[]): BodyValidation | undefined {\n const [decorator, ...duplicates] = decorators.filter(candidate => candidate.identity === Ids.Validate)\n for (const duplicate of duplicates) {\n error(ctx, duplicate.location, '@Validate is applied several times', [\n 'Keep a single @Validate(schema): compose the validation in the schema',\n ])\n }\n if (decorator === undefined) {\n return undefined\n }\n const [arg] = decorator.args\n if (arg === undefined) {\n error(ctx, decorator.location, '@Validate requires a schema', ['@Validate(CreateUser)'])\n return undefined\n }\n const schema = schemaRef(ctx, arg, '@Validate')\n return schema ? { schema, decorator } : undefined\n}\n\n/** Guard / interceptor references of a class or method, bound to provider tokens (in order). */\nfunction classRefs(\n ctx: Context,\n cls: ClassInfo,\n decorators: readonly DecoratorInfo[],\n identity: string,\n role: string,\n): ClassRef[] {\n const refs: ClassRef[] = []\n for (const decorator of decorators) {\n if (decorator.identity !== identity) {\n continue\n }\n if (decorator.called && decorator.args.length === 0) {\n error(ctx, decorator.location, `@${decorator.name} requires at least one ${role}`, [\n `@${decorator.name}(My${role === 'guard' ? 'Guard' : 'Interceptor'})`,\n ])\n }\n for (const arg of decorator.args) {\n // binds the class (auto-registered as a singleton when it is not a provider) and declares the\n // controller → guard edge (ZNIGHT003, ZNIGHT019)\n const ref = ctx.resolveClassRef(arg, { from: cls, role })\n if (ref) {\n refs.push(ref)\n }\n }\n }\n return refs\n}\n\n// -------------------------------------------------------------------------------------------------\n// Parameters\n// -------------------------------------------------------------------------------------------------\n\nfunction analyzeParams(\n ctx: Context,\n cls: ClassInfo,\n method: MethodInfo,\n where: string,\n bodyValidation: BodyValidation | undefined,\n): { readonly params: HttpParamData[]; readonly complete: boolean } {\n const params: HttpParamData[] = []\n let complete = true\n for (const param of method.params) {\n const decorators = unique(param.decorators).filter(\n decorator => decorator.owner === EXTENSION_NAME && PARAM_SOURCES.has(decorator.identity ?? ''),\n )\n const [decorator, ...extra] = decorators\n const foreign = decorator === undefined ? foreignParameterDecorator(param) : undefined\n if (foreign !== undefined) {\n error(\n ctx,\n foreign.decorator.location,\n `@${foreign.decorator.name} on parameter '${param.name}' of ${where} is imported from '${foreign.module}': route parameters use ${foreign.name} from '${HTTP_PACKAGE}'`,\n [`Import it from '${HTTP_PACKAGE}': import { ${foreign.name} } from '${HTTP_PACKAGE}'`],\n )\n complete = false\n continue\n }\n if (decorator === undefined) {\n error(ctx, param.location, `Parameter '${param.name}' of ${where} has no HTTP decorator`, [\n 'Decorate it with @Param(), @Query(), @Body(), @Headers(), @Cookie(), @SignedCookie(), @UploadedFile(), @UploadedFiles(), @Ctx(), @Req() or @Res()',\n ])\n complete = false\n continue\n }\n for (const other of extra) {\n error(ctx, other.location, `Parameter '${param.name}' of ${where} has several HTTP decorators`, [\n 'Keep a single parameter decorator',\n ])\n }\n if (param.rest) {\n error(ctx, decorator.location, `Rest parameter '${param.name}' of ${where} cannot be injected`)\n complete = false\n continue\n }\n const data = analyzeParam(ctx, cls, method, param, decorator, where, bodyValidation)\n if (data) {\n params.push(data)\n } else {\n complete = false\n }\n }\n return { params, complete }\n}\n\nfunction analyzeParam(\n ctx: Context,\n cls: ClassInfo,\n method: MethodInfo,\n param: ParameterInfo,\n decorator: DecoratorInfo,\n where: string,\n bodyValidation: BodyValidation | undefined,\n): HttpParamData | undefined {\n const source = PARAM_SOURCES.get(decorator.identity ?? '')\n if (source === undefined) {\n return undefined\n }\n const declared = parameterType(ctx, cls, method, param)\n const defaultValue = staticDefault(param)\n const base: Omit<HttpParamData, 'key' | 'schema' | 'coercion' | 'optional'> = {\n index: param.index,\n name: param.name,\n source,\n type: undefined,\n ...(defaultValue === undefined ? {} : { defaultValue: defaultValue.value }),\n location: decorator.location,\n }\n // the declared type is recorded for coerced values (informational, `params[i].type`)\n const type = declared.type === undefined ? undefined : ctx.types.format(declared.type)\n const plain = (): HttpParamData => ({\n ...base,\n key: undefined,\n optional: false,\n schema: undefined,\n coercion: undefined,\n })\n\n switch (source) {\n case 'request':\n case 'context':\n return plain()\n case 'response':\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'warning',\n message: `@Res() makes ${where} adapter-specific: the handler writes the native response itself`,\n location: decorator.location,\n hints: ['Prefer returning a value, an HttpResponse or a Web Response (portable across adapters)'],\n })\n return plain()\n case 'body': {\n const [arg] = decorator.args\n let schema: ValueRef | undefined\n if (arg !== undefined) {\n schema = schemaRef(ctx, arg, '@Body')\n if (schema === undefined) {\n return undefined\n }\n }\n if (bodyValidation !== undefined) {\n if (schema !== undefined) {\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'error',\n message: `The body of ${where} is validated twice: @Validate(${bodyValidation.schema.text}) and @Body(${schema.text})`,\n location: bodyValidation.decorator.location,\n hints: ['Keep one of them: @Validate(S) on the method is the same as @Body(S) on the parameter'],\n related: [{ message: '@Body schema', location: decorator.location }],\n })\n return undefined\n }\n schema = bodyValidation.schema\n }\n if (schema === undefined) {\n checkUnvalidated(ctx, declared.type, decorator, param, where, 'body')\n }\n return { ...base, key: undefined, optional: declared.optional, schema, coercion: undefined }\n }\n case 'file':\n case 'files': {\n const upload = uploadOf(ctx, decorator, param, declared, where, source === 'files')\n return upload === undefined\n ? undefined\n : {\n ...base,\n key: upload.field,\n optional: !upload.required,\n schema: undefined,\n coercion: undefined,\n upload,\n }\n }\n case 'headers': {\n const [arg] = decorator.args\n if (arg === undefined) {\n return plain()\n }\n if (!arg.evaluated) {\n return undefined\n }\n if (typeof arg.value !== 'string' || !TOKEN.test(arg.value)) {\n error(ctx, arg.location, `@Headers: invalid header name ${describe(arg.value)}`, [\n \"@Headers('x-api-key'), or @Headers() for every header\",\n ])\n return undefined\n }\n const key = arg.value.toLowerCase()\n const coercion = coercionOf(ctx, declared, param, decorator, where, 'headers', key)\n return coercion ? { ...base, key, type, optional: declared.optional, schema: undefined, coercion } : undefined\n }\n case 'param':\n case 'query': {\n const parsed = nameAndSchema(ctx, decorator)\n if (!parsed.ok) {\n return undefined\n }\n const { key, schema } = parsed\n const optional = source === 'query' && declared.optional\n if (schema !== undefined) {\n return { ...base, key, optional, schema, coercion: undefined }\n }\n if (key === undefined) {\n if (source === 'query') {\n checkUnvalidated(ctx, declared.type, decorator, param, where, 'query')\n }\n return { ...base, key, optional: false, schema: undefined, coercion: undefined }\n }\n const coercion = coercionOf(ctx, declared, param, decorator, where, source, key)\n return coercion ? { ...base, key, type, optional, schema: undefined, coercion } : undefined\n }\n case 'cookie':\n case 'signedCookie':\n return cookieParam(ctx, param, decorator, declared, where, base, type)\n }\n}\n\n/** `@Cookie(name?, schema?)` / `@SignedCookie(name, schema?)`. */\nfunction cookieParam(\n ctx: Context,\n param: ParameterInfo,\n decorator: DecoratorInfo,\n declared: ReturnType<typeof parameterType>,\n where: string,\n base: Omit<HttpParamData, 'key' | 'schema' | 'coercion' | 'optional'>,\n type: string | undefined,\n): HttpParamData | undefined {\n const parsed = nameAndSchema(ctx, decorator)\n if (!parsed.ok) {\n return undefined\n }\n const { key, schema } = parsed\n const name = `@${decorator.name}`\n if (key !== undefined && !TOKEN.test(key)) {\n error(ctx, decorator.args[0]?.location ?? decorator.location, `${name}: invalid cookie name ${describe(key)}`, [\n `Cookie names are tokens (letters, digits and ! # $ % & ' * + - . ^ _ \\` | ~): ${name}('session_id')`,\n ])\n return undefined\n }\n if (decorator.identity === Ids.SignedCookie && key === undefined) {\n error(ctx, decorator.location, '@SignedCookie requires a cookie name', [\"@SignedCookie('session_id')\"])\n return undefined\n }\n const optional = declared.optional\n if (schema !== undefined) {\n return { ...base, key, optional, schema, coercion: undefined }\n }\n if (key === undefined) {\n checkUnvalidated(ctx, declared.type, decorator, param, where, 'cookies')\n return { ...base, key, optional: false, schema: undefined, coercion: undefined }\n }\n const coercion = coercionOf(ctx, declared, param, decorator, where, 'cookie', key)\n return coercion ? { ...base, key, type, optional, schema: undefined, coercion } : undefined\n}\n\n/**\n * The statically evaluable default value of a parameter (`page = 1`), without references to\n * exported bindings. `ParameterInfo.initializer` is read defensively (compilers before RFC 0002 C4\n * do not provide it).\n */\nfunction staticDefault(param: ParameterInfo): { readonly value: StaticValue } | undefined {\n const initializer = (param as { readonly initializer?: ArgInfo | undefined }).initializer\n if (initializer === undefined || !initializer.evaluated || initializer.ref !== undefined) {\n return undefined\n }\n const value = initializer.value\n if (value === undefined || hasRef(value)) {\n return undefined\n }\n return { value }\n}\n\nfunction hasRef(value: StaticValue): boolean {\n if (isValueRef(value)) {\n return true\n }\n if (Array.isArray(value)) {\n return value.some(hasRef)\n }\n if (typeof value === 'object' && value !== null) {\n return Object.values(value).some(hasRef)\n }\n return false\n}\n\n/** `@UploadedFile(field?, options?)` / `@UploadedFiles(field?, options?)`: field, options and type. */\nfunction uploadOf(\n ctx: Context,\n decorator: DecoratorInfo,\n param: ParameterInfo,\n declared: ReturnType<typeof parameterType>,\n where: string,\n multiple: boolean,\n): UploadData | undefined {\n const name = `@${decorator.name}`\n const [first, second] = decorator.args\n let field: string | undefined\n let options: ArgInfo | undefined\n if (first !== undefined) {\n if (!first.evaluated) {\n return undefined // already reported\n }\n if (typeof first.value === 'string') {\n if (first.value === '') {\n error(ctx, first.location, `${name} expects a non-empty field name`, [`${name}('avatar')`])\n return undefined\n }\n field = first.value\n options = second\n } else if (first.value === undefined) {\n options = second\n } else if (isPlainObject(first.value)) {\n if (second !== undefined) {\n error(ctx, second.location, `${name}(options) takes a single argument`, [\n `Put the field first: ${name}('field', { ... })`,\n ])\n return undefined\n }\n options = first\n } else {\n error(ctx, first.location, `${name} expects a field name (string) or options, got ${describe(first.value)}`, [\n `${name}('avatar'), ${name}('avatar', { maxSize: '5mb' }) or ${name}({ maxSize: '5mb' })`,\n ])\n return undefined\n }\n }\n const parsed = uploadOptions(ctx, name, options, multiple)\n if (parsed === undefined) {\n return undefined\n }\n const type = uploadType(ctx, declared.type, multiple)\n if (!type.ok) {\n error(\n ctx,\n param.typeLocation,\n `${name} parameter '${param.name}' of ${where} must be typed ${multiple ? 'File[]' : 'File'}, got ${type.got}`,\n [multiple ? `${param.name}: File[]` : `${param.name}: File (or ${param.name}?: File when optional)`],\n )\n return undefined\n }\n const required = parsed.required ?? !declared.optional\n let cast = type.cast\n if (!multiple && !required) {\n const acceptsMissing =\n declared.type === undefined ||\n param.optional ||\n param.hasDefault ||\n acceptsUndefined(declared.type) ||\n isRaw(ctx.types.stripNullish(declared.type).type)\n if (!acceptsMissing && !declared.optional) {\n error(\n ctx,\n options?.location ?? decorator.location,\n `${name}: '${param.name}' of ${where} is optional ({ required: false }) but typed ${ctx.types.format(declared.type as TypeInfo)}`,\n [`Type it ${param.name}?: File (undefined when no file is sent)`],\n )\n return undefined\n }\n // `File | null` receives undefined\n cast ||= !acceptsMissing\n }\n return {\n field,\n multiple,\n required,\n maxSize: parsed.maxSize,\n maxFiles: parsed.maxFiles,\n mimeTypes: parsed.mimeTypes,\n cast,\n }\n}\n\ninterface ParsedUploadOptions {\n readonly required: boolean | undefined\n readonly maxSize: number | undefined\n readonly maxFiles: number | undefined\n readonly mimeTypes: readonly string[] | undefined\n}\n\n/** The options object of an upload decorator (`undefined` after an error). */\nfunction uploadOptions(\n ctx: Context,\n name: string,\n arg: ArgInfo | undefined,\n multiple: boolean,\n): ParsedUploadOptions | undefined {\n const result: { -readonly [K in keyof ParsedUploadOptions]: ParsedUploadOptions[K] } = {\n required: undefined,\n maxSize: undefined,\n maxFiles: undefined,\n mimeTypes: undefined,\n }\n if (arg === undefined) {\n return result\n }\n if (!arg.evaluated) {\n return undefined\n }\n if (arg.value === undefined) {\n return result\n }\n const allowed = multiple ? UPLOAD_OPTIONS : UPLOAD_OPTIONS.filter(option => option !== 'maxFiles')\n const shape = `{ ${allowed.map(option => `${option}?`).join(', ')} }`\n if (!isPlainObject(arg.value)) {\n error(ctx, arg.location, `${name} options must be an object ${shape}, got ${describe(arg.value)}`)\n return undefined\n }\n let ok = true\n const invalid = (message: string, hints: readonly string[] = []): void => {\n ok = false\n error(ctx, arg.location, `${name}: ${message}`, hints)\n }\n for (const [key, value] of Object.entries(arg.value)) {\n if (value === undefined) {\n continue\n }\n switch (key) {\n case 'required':\n if (typeof value === 'boolean') {\n result.required = value\n } else {\n invalid(`\"required\" must be a boolean, got ${describe(value)}`)\n }\n break\n case 'maxSize': {\n const size = parseByteSize(value)\n if (size === undefined) {\n invalid(`\"maxSize\" must be a size in bytes, got ${describe(value)}`, [\n \"A non-negative integer (5_242_880), a size with a unit ('5mb', '512kb'; kb = 1024 bytes) or Infinity\",\n ])\n } else {\n result.maxSize = size\n }\n break\n }\n case 'maxFiles':\n if (!multiple) {\n invalid('\"maxFiles\" only applies to @UploadedFiles (a single file is expected here)', [\n 'Use @UploadedFiles() to receive several files',\n ])\n } else if (value === Number.POSITIVE_INFINITY || (Number.isSafeInteger(value) && (value as number) >= 1)) {\n result.maxFiles = value as number\n } else {\n invalid(`\"maxFiles\" must be a positive integer, got ${describe(value)}`)\n }\n break\n case 'mimeTypes': {\n const patterns = Array.isArray(value) ? value : undefined\n const wrong = patterns?.filter(pattern => typeof pattern !== 'string' || !isMediaTypePattern(pattern)) ?? []\n if (patterns === undefined || patterns.length === 0) {\n invalid(`\"mimeTypes\" must be a non-empty array of media types, got ${describe(value)}`, [\n \"mimeTypes: ['image/png', 'image/*']\",\n ])\n } else if (wrong.length > 0) {\n invalid(`invalid media type ${wrong.map(describe).join(', ')} in \"mimeTypes\"`, [\n \"Use type/subtype, type/* or */* without parameters: 'image/png', 'image/*'\",\n ])\n } else {\n result.mimeTypes = patterns as string[]\n }\n break\n }\n default:\n invalid(`unknown option \"${key}\"`, [`Options: ${shape}`])\n }\n }\n return ok ? result : undefined\n}\n\n/** Whether a parameter type can receive uploaded files (and whether the value must be cast). */\nfunction uploadType(\n ctx: Context,\n type: TypeInfo | undefined,\n multiple: boolean,\n): { readonly ok: true; readonly cast: boolean } | { readonly ok: false; readonly got: string } {\n if (type === undefined) {\n return { ok: true, cast: false }\n }\n const { type: base } = ctx.types.stripNullish(type)\n if (isRaw(base)) {\n return { ok: true, cast: false }\n }\n let target: TypeInfo | undefined = base\n if (multiple) {\n target = base.kind === 'array' ? base.element : undefined\n }\n if (target !== undefined && isRaw(target)) {\n return { ok: true, cast: false }\n }\n const cast = target?.kind === 'reference' ? FILE_TYPES.get(target.identity) : undefined\n return cast === undefined ? { ok: false, got: ctx.types.format(type) } : { ok: true, cast }\n}\n\n/** Name and/or schema of `@Param(name?, schema?)` / `@Query(name?, schema?)`. */\nfunction nameAndSchema(\n ctx: Context,\n decorator: DecoratorInfo,\n):\n | { readonly ok: true; readonly key: string | undefined; readonly schema: ValueRef | undefined }\n | { readonly ok: false } {\n const [first, second] = decorator.args\n if (first === undefined) {\n return { ok: true, key: undefined, schema: undefined }\n }\n if (first.error !== undefined) {\n return { ok: false }\n }\n if (first.ref !== undefined) {\n if (second !== undefined) {\n error(ctx, second.location, `@${decorator.name}(schema) takes a single argument`, [\n `Put the name first: @${decorator.name}('name', Schema)`,\n ])\n return { ok: false }\n }\n return { ok: true, key: undefined, schema: first.ref }\n }\n if (typeof first.value !== 'string' || first.value === '') {\n error(\n ctx,\n first.location,\n `@${decorator.name} expects a name (non-empty string) or a schema, got ${describe(first.value)}`,\n [`@${decorator.name}('id'), @${decorator.name}('id', Schema) or @${decorator.name}(Schema)`],\n )\n return { ok: false }\n }\n if (second === undefined) {\n return { ok: true, key: first.value, schema: undefined }\n }\n const schema = schemaRef(ctx, second, `@${decorator.name}`)\n return schema ? { ok: true, key: first.value, schema } : { ok: false }\n}\n\n/** A schema argument: a reference to an exported binding. */\nfunction schemaRef(ctx: Context, arg: ArgInfo, what: string): ValueRef | undefined {\n if (arg.error !== undefined) {\n return undefined // already reported\n }\n if (arg.ref === undefined) {\n error(ctx, arg.location, `${what} expects a Standard Schema, got ${describe(arg.value)}`, [\n 'Pass a schema declared with `export const Schema = z.object({ ... })` (Zod, Valibot, ArkType...)',\n ])\n return undefined\n }\n const symbol = arg.ref.symbol\n if (symbol.kind === 'declaration' && symbol.declaration.kind === 'class' && !hasStandardSchema(ctx, arg.ref)) {\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'warning',\n message: `${what}(${arg.ref.text}): ${arg.ref.name} is a class, not a Standard Schema; the validation fails at runtime`,\n location: arg.location,\n hints: ['Pass a Standard Schema object (Zod, Valibot, ArkType...): classes are not validators'],\n })\n }\n return arg.ref\n}\n\nfunction hasStandardSchema(ctx: Context, ref: ValueRef): boolean {\n const info = ref.identity === undefined ? undefined : ctx.classInfo(ref.identity)\n return (\n info === undefined ||\n info.superClass !== undefined ||\n info.properties.some(property => property.static && property.name === '~standard') ||\n info.methods.some(member => member.static && member.name === '~standard')\n )\n}\n\n/** Coercion of a named parameter / query value / header without schema. */\nfunction coercionOf(\n ctx: Context,\n declared: ReturnType<typeof parameterType>,\n param: ParameterInfo,\n decorator: DecoratorInfo,\n where: string,\n source: 'param' | 'query' | 'headers' | 'cookie',\n key: string,\n): ParamCoercion | undefined {\n const result = planCoercion(ctx, declared, param, source === 'param')\n const label = `${source === 'headers' ? 'header' : source} \"${key}\"`\n if (result.ok) {\n if (source === 'query' && declared.type !== undefined && isAny(declared.type)) {\n unvalidated(ctx, decorator, `${label} of ${where} is typed any`)\n }\n return result.coercion\n }\n if (source === 'query') {\n // unvalidated input: the raw value is passed as is\n unvalidated(ctx, decorator, `${label} of ${where}: ${result.reason}`, result.hints)\n return { plan: { kind: 'raw' }, cast: false }\n }\n ctx.report({\n code: Codes.InvalidRoute,\n severity: 'error',\n message: `Invalid ${label} of ${where}: ${result.reason}`,\n location: param.typeLocation,\n hints: [...result.hints],\n })\n return undefined\n}\n\n/** ZNIGHT017 for a non-primitive `@Body()` / `@Query()` without schema. */\nfunction checkUnvalidated(\n ctx: Context,\n type: TypeInfo | undefined,\n decorator: DecoratorInfo,\n param: ParameterInfo,\n where: string,\n what: 'body' | 'query' | 'cookies',\n): void {\n if (type !== undefined && acceptedWithoutSchema(ctx, type)) {\n return\n }\n const described = type === undefined ? 'untyped' : `typed ${ctx.types.format(type)}`\n unvalidated(ctx, decorator, `the ${what} of ${where} ('${param.name}', ${described}) has no schema`)\n}\n\nfunction unvalidated(ctx: Context, decorator: DecoratorInfo, detail: string, extraHints: readonly string[] = []): void {\n ctx.report({\n code: Codes.UnvalidatedInput,\n severity: ctx.options.strictValidation ? 'error' : 'warning',\n message: `Unvalidated input: ${detail}`,\n location: decorator.location,\n hints: [\n ...extraHints.filter(hint => !hint.startsWith('Or validate')),\n `Validate it with a Standard Schema: ${schemaHint(decorator.name)}`,\n 'Or type the parameter as unknown and check it yourself',\n ],\n })\n}\n\nfunction schemaHint(decorator: string): string {\n if (decorator === 'Body') {\n return '@Body(Schema) or @Validate(Schema)'\n }\n if (decorator === 'Cookie') {\n return \"@Cookie(Schema) for every cookie, or @Cookie('name', Schema)\"\n }\n return `@${decorator}('name', Schema)`\n}\n\nfunction acceptedWithoutSchema(ctx: Context, type: TypeInfo): boolean {\n const { type: base } = ctx.types.stripNullish(type)\n switch (base.kind) {\n case 'primitive':\n return base.name !== 'any' && base.name !== 'object' && base.name !== 'never' && base.name !== 'symbol'\n case 'literal':\n return true\n case 'reference':\n if (UNVALIDATED_REFERENCES.has(base.identity)) {\n return true\n }\n // Record<string, string | string[]> (the shape of ctx.query and of form bodies)\n return (\n base.identity === 'globalThis#Record' &&\n base.typeArgs.length === 2 &&\n isStringLike(base.typeArgs[1] as TypeInfo)\n )\n default:\n return false\n }\n}\n\nfunction isStringLike(type: TypeInfo): boolean {\n switch (type.kind) {\n case 'primitive':\n return type.name === 'string' || type.name === 'undefined' || type.name === 'unknown'\n case 'array':\n return type.element.kind === 'primitive' && type.element.name === 'string'\n case 'union':\n return type.types.every(isStringLike)\n default:\n return false\n }\n}\n\nfunction isAny(type: TypeInfo): boolean {\n return isRaw(type) && type.kind === 'primitive' && type.name === 'any'\n}\n\n// -------------------------------------------------------------------------------------------------\n// Helpers\n// -------------------------------------------------------------------------------------------------\n\n/**\n * Decorators of a parameter without duplicates (a parameter with a default value may list its\n * decorators twice).\n */\nfunction unique(decorators: readonly DecoratorInfo[]): DecoratorInfo[] {\n const seen = new Set<number>()\n return decorators.filter(decorator => {\n if (seen.has(decorator.location.start)) {\n return false\n }\n seen.add(decorator.location.start)\n return true\n })\n}\n\n/** `false` when the decorator is applied to a target it does not support (reported by the core). */\nfunction validTarget(decorator: DecoratorInfo): boolean {\n const identity = decorator.identity ?? ''\n if (ROUTE_METHODS.has(identity)) {\n return decorator.target === 'method'\n }\n if (PARAM_SOURCES.has(identity)) {\n return decorator.target === 'parameter'\n }\n switch (identity) {\n case Ids.Controller:\n return decorator.target === 'class'\n case Ids.UseGuard:\n case Ids.UseInterceptor:\n case Ids.BodyLimit:\n return decorator.target === 'class' || decorator.target === 'method'\n default:\n return decorator.target === 'method'\n }\n}\n\nfunction isPlainObject(value: StaticValue): value is { readonly [key: string]: StaticValue } {\n return typeof value === 'object' && value !== null && !Array.isArray(value) && !isValueRef(value)\n}\n\nfunction describe(value: StaticValue): string {\n if (value === null) {\n return 'null'\n }\n if (Array.isArray(value)) {\n return 'an array'\n }\n if (isValueRef(value)) {\n return `a reference to '${value.text}'`\n }\n if (typeof value === 'object') {\n return 'an object'\n }\n if (typeof value === 'string') {\n return JSON.stringify(value)\n }\n return typeof value === 'bigint' ? `${value}n` : String(value)\n}\n\nfunction error(ctx: Context, location: Location, message: string, hints?: readonly string[]): void {\n ctx.report({ code: Codes.InvalidDecorator, severity: 'error', message, location, ...(hints ? { hints } : {}) })\n}\n","/**\n * `generate` of the `@znight/http` compiler extension: the `metadata.extensions.http` section\n * (README, \"Compiler contract\"). Controllers are sorted by token, routes keep their source order and\n * every route gets an `invoke(c, ctx)` arrow extracting, coercing and validating its arguments.\n */\nimport type { ClassRef, GenerateContext, GenInput, GenNode, ValueRef } from '@znight/compiler'\nimport type {\n CoercionPlan,\n HttpControllerData,\n HttpParamData,\n HttpRouteData,\n MetaEntry,\n ParamCoercion,\n SseRouteData,\n UploadData,\n} from './model.ts'\n\nimport { compareStrings } from '../path.ts'\nimport { HTTP_PACKAGE } from './model.ts'\n\ntype Context = GenerateContext<HttpControllerData>\n\n/** `uploads` helper by kind and presence (`@UploadedFile` / `@UploadedFiles`, required or not). */\nconst UPLOAD_HELPERS = {\n file: { required: 'file', optional: 'optionalFile' },\n files: { required: 'files', optional: 'optionalFiles' },\n} as const\n\n/** Imports of `@znight/http` helpers, created on first use (the generated module has no unused import). */\ninterface Helpers {\n coerce(): GenNode\n validate(): GenNode\n isThenable(): GenNode\n uploads(): GenNode\n context(): GenNode\n}\n\n/** Generates `metadata.extensions.http` (`undefined` when the application has no controller). */\nexport function generateHttp(ctx: Context): GenNode | undefined {\n if (ctx.stored.length === 0) {\n return undefined\n }\n const controllers = [...ctx.stored].sort((a, b) => compareStrings(a.token, b.token))\n const helpers = createHelpers(ctx)\n const entries: [string, GenInput][] = [\n ['controllers', ctx.arr(controllers.map(controller => controllerNode(ctx, helpers, controller)))],\n ]\n const groups = groupsNode(ctx, controllers)\n if (groups !== undefined) {\n entries.push(['groups', groups])\n }\n return ctx.obj(entries)\n}\n\n/**\n * `groups`: the route decorator groups the runtime needs (required, holding several keys, or named\n * differently from their key), sorted, with sorted keys; `undefined` when there is none, so that\n * applications without groups keep a byte-identical output.\n */\nfunction groupsNode(ctx: Context, controllers: readonly HttpControllerData[]): GenNode | undefined {\n const groups = new Map<string, { readonly keys: Set<string>; required: boolean }>()\n const visit = (entries: readonly MetaEntry[]): void => {\n for (const entry of entries) {\n const group = groups.get(entry.group)\n if (group === undefined) {\n groups.set(entry.group, { keys: new Set([entry.key]), required: entry.required })\n } else {\n group.keys.add(entry.key)\n group.required ||= entry.required\n }\n }\n }\n for (const controller of controllers) {\n visit(controller.meta)\n for (const route of controller.routes) {\n visit(route.meta)\n }\n }\n const needed = [...groups]\n .filter(([name, group]) => group.required || group.keys.size > 1 || !group.keys.has(name))\n .sort(([a], [b]) => compareStrings(a, b))\n if (needed.length === 0) {\n return undefined\n }\n return ctx.obj(\n needed.map(\n ([name, group]) =>\n [\n name,\n ctx.obj([\n ['keys', ctx.lit([...group.keys].sort(compareStrings))],\n ['required', group.required],\n ]),\n ] as const,\n ),\n )\n}\n\nfunction createHelpers(ctx: Context): Helpers {\n let coerce: GenNode | undefined\n let validate: GenNode | undefined\n let isThenable: GenNode | undefined\n let uploads: GenNode | undefined\n let context: GenNode | undefined\n return {\n coerce: () => {\n coerce ??= ctx.importFrom(HTTP_PACKAGE, 'coerce')\n return coerce\n },\n validate: () => {\n validate ??= ctx.importFrom(HTTP_PACKAGE, 'validate')\n return validate\n },\n isThenable: () => {\n isThenable ??= ctx.importFrom(HTTP_PACKAGE, 'isThenable')\n return isThenable\n },\n uploads: () => {\n uploads ??= ctx.importFrom(HTTP_PACKAGE, 'uploads')\n return uploads\n },\n context: () => {\n context ??= ctx.importFrom(HTTP_PACKAGE, 'HttpContext', { type: true })\n return context\n },\n }\n}\n\nfunction controllerNode(ctx: Context, helpers: Helpers, controller: HttpControllerData): GenNode {\n return ctx.obj([\n ['token', controller.token],\n ['basePath', controller.basePath],\n ['guards', tokens(ctx, controller.guards)],\n ['interceptors', tokens(ctx, controller.interceptors)],\n ['meta', metaNode(ctx, controller.meta)],\n ['routes', ctx.arr(controller.routes.map(route => routeNode(ctx, helpers, controller, route)))],\n ])\n}\n\nfunction routeNode(ctx: Context, helpers: Helpers, controller: HttpControllerData, route: HttpRouteData): GenNode {\n const entries: [string, GenInput][] = [\n ['method', route.method],\n ['path', route.path],\n ['fullPath', route.fullPath],\n ['handler', route.handler],\n ]\n if (route.status !== undefined) {\n entries.push(['status', route.status])\n }\n if (route.headers.length > 0) {\n entries.push(['headers', ctx.obj(route.headers.map(([name, value]) => [name, value] as const))])\n }\n entries.push(\n ['meta', metaNode(ctx, route.meta)],\n ['guards', tokens(ctx, route.guards)],\n ['interceptors', tokens(ctx, route.interceptors)],\n ['params', ctx.arr(route.params.map(param => paramNode(ctx, param)))],\n )\n if (route.bodyLimit !== undefined) {\n entries.push(['bodyLimit', route.bodyLimit])\n }\n const uploads = route.params.flatMap(param => (param.upload === undefined ? [] : [param.upload]))\n if (uploads.length > 0) {\n entries.push(['uploads', ctx.arr(uploads.map(upload => uploadNode(ctx, upload)))])\n }\n if (route.rawResponse) {\n entries.push(['rawResponse', true])\n }\n if (route.sse !== undefined) {\n entries.push(['sse', sseNode(ctx, route.sse)])\n }\n entries.push(['invoke', invokeNode(ctx, helpers, controller, route)])\n return ctx.obj(entries)\n}\n\n/** `{ heartbeat?, retry?, maxDuration? }` (`{}` without options). */\nfunction sseNode(ctx: Context, sse: SseRouteData): GenNode {\n const entries: [string, GenInput][] = []\n if (sse.heartbeat !== undefined) {\n entries.push(['heartbeat', sse.heartbeat])\n }\n if (sse.retry !== undefined) {\n entries.push(['retry', sse.retry])\n }\n if (sse.maxDuration !== undefined) {\n entries.push(['maxDuration', sse.maxDuration])\n }\n return ctx.obj(entries)\n}\n\nfunction paramNode(ctx: Context, param: HttpParamData): GenNode {\n const entries: [string, GenInput][] = [\n ['index', param.index],\n ['source', param.source],\n ]\n if (param.key !== undefined) {\n entries.push(['name', param.key])\n }\n if (param.type !== undefined) {\n entries.push(['type', param.type])\n }\n if (param.optional) {\n entries.push(['optional', true])\n }\n if (param.schema !== undefined) {\n entries.push(['schema', true])\n }\n return ctx.obj(entries)\n}\n\n/** `{ field?, multiple?, required?, maxSize?, maxFiles?, mimeTypes? }` (absent values omitted). */\nfunction uploadNode(ctx: Context, upload: UploadData): GenNode {\n const entries: [string, GenInput][] = []\n if (upload.field !== undefined) {\n entries.push(['field', upload.field])\n }\n if (upload.multiple) {\n entries.push(['multiple', true])\n }\n if (upload.required) {\n entries.push(['required', true])\n }\n if (upload.maxSize !== undefined) {\n entries.push(['maxSize', upload.maxSize])\n }\n if (upload.maxFiles !== undefined) {\n entries.push(['maxFiles', upload.maxFiles])\n }\n if (upload.mimeTypes !== undefined) {\n entries.push(['mimeTypes', ctx.lit(upload.mimeTypes)])\n }\n return ctx.obj(entries)\n}\n\nfunction metaNode(ctx: Context, meta: readonly MetaEntry[]): GenNode {\n return ctx.obj(meta.map(entry => [entry.key, ctx.lit(entry.value)] as const))\n}\n\nfunction tokens(ctx: Context, refs: readonly ClassRef[]): GenNode {\n return ctx.arr(refs.map(ref => ctx.tokenOf(ref) ?? ref.token))\n}\n\n// -------------------------------------------------------------------------------------------------\n// invoke\n// -------------------------------------------------------------------------------------------------\n\n/**\n * `(c: Controller, ctx: HttpContext) => c.handler(...args)`, synchronous when no argument is\n * validated with a schema. A route validating arguments gets a block that stays synchronous as long\n * as every `validate()` returns a value (see {@link validatingBlock}). `@Validate(S)` without\n * `@Body()` parameter reads the body in `invoke`: that arrow is `async` and `await`s every\n * `validate()`.\n */\nfunction invokeNode(ctx: Context, helpers: Helpers, controller: HttpControllerData, route: HttpRouteData): GenNode {\n const params: [string, GenNode][] = [['c', ctx.importType(controller.identity)]]\n // `ctx` is declared only when used (generated code type-checks with `noUnusedParameters`)\n if (route.params.length > 0 || route.bodySchema !== undefined) {\n params.push(['ctx', helpers.context()])\n }\n // arguments in evaluation order (handler parameter order); a hole is passed as `undefined`\n const slots: (HttpParamData | undefined)[] = []\n for (const param of route.params) {\n slots[param.index] = param\n }\n const bodySchema = route.bodySchema\n if (bodySchema !== undefined) {\n return ctx.arrow(\n params,\n (c, http) => {\n const call = handlerCall(\n ctx,\n c,\n route,\n Array.from(slots, param => awaitedArgument(ctx, helpers, http as GenNode, param)),\n )\n // @Validate(S) without @Body() parameter: the body is validated (and discarded)\n const body = ctx.code`await ${ctx.call(ctx.member(http as GenNode, 'parseBody'))}`\n const check = ctx.code`await ${validation(ctx, helpers, bodySchema, body, 'body')}`\n return ctx.code`{ ${check}; return ${call} }`\n },\n { async: true },\n )\n }\n const last = slots.findLastIndex(param => param?.schema !== undefined)\n return ctx.arrow(params, (c, http) =>\n last === -1\n ? handlerCall(\n ctx,\n c,\n route,\n Array.from(slots, param => plainArgument(ctx, helpers, http as GenNode, param)),\n )\n : validatingBlock(ctx, helpers, route, slots, last, c, http as GenNode),\n )\n}\n\n/** `c.handler(args)`. */\nfunction handlerCall(ctx: Context, c: GenNode, route: HttpRouteData, args: readonly GenNode[]): GenNode {\n return ctx.call(ctx.member(c, route.handler), args)\n}\n\n/**\n * The body of the `invoke` of a route validating arguments with schemas: the arguments up to the\n * last validated one are evaluated in order into `const`s (`a<index>`), the handler is called with\n * them. `validate()` returns the value when the schema validates synchronously (Zod, Valibot and\n * ArkType without async refinements), so the request needs no promise; when one returns a\n * thenable, the rest runs in an `async` arrow that awaits it, then evaluates the remaining arguments\n * (`await`ing their validations) and calls the handler: the order of evaluation, the error reported\n * when several arguments are invalid and the value received by the handler are those of an `async`\n * `invoke` awaiting every `validate()`.\n *\n * ```ts\n * (c: UserController, ctx: HttpContext) => {\n * const a0 = coerce.number(ctx.params['id'], 'param \"id\"')\n * const a1 = validate(UpdateUser, ctx.body, 'body')\n * if (isThenable(a1)) return (async () => c.update(a0, await a1, ctx))()\n * return c.update(a0, a1, ctx)\n * }\n * ```\n */\nfunction validatingBlock(\n ctx: Context,\n helpers: Helpers,\n route: HttpRouteData,\n slots: readonly (HttpParamData | undefined)[],\n last: number,\n c: GenNode,\n http: GenNode,\n): GenNode {\n // `@Ctx()` and holes are inlined: nothing to evaluate\n const bound: number[] = []\n for (let index = 0; index <= last; index++) {\n const param = slots[index]\n if (param !== undefined && param.source !== 'context') {\n bound.push(index)\n }\n }\n return ctx.block(\n bound.map(index => `a${index}`),\n (...locals) => {\n const local = new Map(bound.map((index, position) => [index, locals[position] as GenNode]))\n // the value of an argument evaluated before the current statement\n const evaluated = (index: number): GenNode => local.get(index) ?? plainArgument(ctx, helpers, http, slots[index])\n const statements: GenNode[] = []\n for (const index of bound) {\n const param = slots[index] as HttpParamData\n const name = local.get(index) as GenNode\n statements.push(ctx.code`const ${name} = ${plainArgument(ctx, helpers, http, param)}`)\n if (param.schema !== undefined) {\n const rest = Array.from(slots, (other, position) => {\n if (position < index) {\n return evaluated(position)\n }\n return position === index ? ctx.code`await ${name}` : awaitedArgument(ctx, helpers, http, other)\n })\n const resume = ctx.arrow([], () => handlerCall(ctx, c, route, rest), { async: true })\n statements.push(ctx.code`if (${ctx.call(helpers.isThenable(), [name])}) return (${resume})()`)\n }\n }\n const args = Array.from(slots, (param, position) =>\n position <= last ? evaluated(position) : plainArgument(ctx, helpers, http, param),\n )\n statements.push(ctx.code`return ${handlerCall(ctx, c, route, args)}`)\n return statements\n },\n )\n}\n\n/** An argument evaluated in an `async` arrow: its validation, if any, is `await`ed. */\nfunction awaitedArgument(ctx: Context, helpers: Helpers, http: GenNode, param: HttpParamData | undefined): GenNode {\n const node = plainArgument(ctx, helpers, http, param)\n return param?.schema === undefined ? node : ctx.code`await ${node}`\n}\n\n/** An argument as an expression (`validate()` not awaited); `undefined` for a hole. */\nfunction plainArgument(ctx: Context, helpers: Helpers, http: GenNode, param: HttpParamData | undefined): GenNode {\n return param === undefined ? ctx.lit(undefined) : argumentNode(ctx, helpers, http, param)\n}\n\n/** The expression passed to the handler for one parameter. */\nfunction argumentNode(ctx: Context, helpers: Helpers, http: GenNode, param: HttpParamData): GenNode {\n switch (param.source) {\n case 'context':\n return http\n case 'request':\n return ctx.code`${ctx.member(http, 'request')} as never`\n case 'response':\n return ctx.code`${ctx.member(http, 'response')} as never`\n case 'body': {\n const body = ctx.member(http, 'body')\n return param.schema === undefined\n ? ctx.code`${body} as never`\n : validation(ctx, helpers, param.schema, body, 'body')\n }\n case 'file':\n case 'files': {\n const upload = param.upload as UploadData\n const helper = UPLOAD_HELPERS[upload.multiple ? 'files' : 'file'][upload.required ? 'required' : 'optional']\n const call = ctx.call(ctx.member(helpers.uploads(), helper), [http, ctx.lit(upload.field)])\n return upload.cast ? ctx.code`${call} as never` : call\n }\n case 'headers':\n case 'param':\n case 'query': {\n const record = ctx.member(http, param.source === 'param' ? 'params' : param.source)\n if (param.key === undefined) {\n const location = param.source === 'param' ? 'params' : param.source\n return param.schema === undefined\n ? ctx.code`${record} as never`\n : validation(ctx, helpers, param.schema, record, location)\n }\n const value = ctx.code`${record}[${param.key}]`\n const label = `${param.source === 'headers' ? 'header' : param.source} \"${param.key}\"`\n if (param.schema !== undefined) {\n return validation(ctx, helpers, param.schema, value, label)\n }\n return coercion(ctx, helpers, param.coercion ?? { plan: { kind: 'raw' }, cast: false }, value, label)\n }\n case 'cookie':\n case 'signedCookie': {\n if (param.key === undefined) {\n // @Cookie() / @Cookie(S): every cookie\n const cookies = ctx.member(http, 'cookies')\n return param.schema === undefined\n ? ctx.code`${cookies} as never`\n : validation(ctx, helpers, param.schema, cookies, 'cookies')\n }\n const value =\n param.source === 'cookie'\n ? ctx.code`${ctx.member(http, 'cookies')}[${param.key}]`\n : ctx.call(ctx.member(http, 'signedCookie'), [param.key])\n const label = `cookie \"${param.key}\"`\n if (param.schema !== undefined) {\n return validation(ctx, helpers, param.schema, value, label)\n }\n return coercion(ctx, helpers, param.coercion ?? { plan: { kind: 'raw' }, cast: false }, value, label)\n }\n }\n}\n\n/** `validate(schema, value, location)` (the value, or a promise when the schema validates asynchronously). */\nfunction validation(ctx: Context, helpers: Helpers, schema: ValueRef, value: GenNode, location: string): GenNode {\n return ctx.call(helpers.validate(), [ctx.ref(schema), value, location])\n}\n\n/** `coerce.X(value, label, ...)`, cast with `as never` when the result does not have the declared type. */\nfunction coercion(ctx: Context, helpers: Helpers, coercion: ParamCoercion, value: GenNode, label: string): GenNode {\n const node = coerceCall(ctx, helpers, coercion.plan, value, label)\n return coercion.cast ? ctx.code`${node} as never` : node\n}\n\nfunction coerceCall(ctx: Context, helpers: Helpers, plan: CoercionPlan, value: GenNode, label: GenInput): GenNode {\n const helper = (name: string): GenNode => ctx.member(helpers.coerce(), name)\n switch (plan.kind) {\n case 'raw':\n return ctx.code`${value} as never`\n case 'enum':\n return ctx.call(helper('enum'), [value, label, ctx.lit(plan.values)])\n case 'array':\n case 'optional':\n return ctx.call(helper(plan.kind), [value, label, itemCoercer(ctx, helpers, plan.item)])\n default:\n return ctx.call(helper(plan.kind), [value, label])\n }\n}\n\n/** A `Coercer` value: `coerce.number`, or `(v, l) => coerce.enum(v, l, [...])`. */\nfunction itemCoercer(ctx: Context, helpers: Helpers, plan: CoercionPlan): GenNode {\n switch (plan.kind) {\n case 'enum':\n case 'array':\n case 'optional':\n return ctx.arrow(['v', 'l'], (v, l) => coerceCall(ctx, helpers, plan, v, l))\n case 'raw':\n return ctx.arrow(['v'], v => v)\n default:\n return ctx.member(helpers.coerce(), plan.kind)\n }\n}\n","/**\n * Route decorator groups of the application (RFC 0001 §5.1): every `createRouteDecorator`\n * definition, applied or not, the consistency of their options and the **required** groups.\n *\n * The http extension reports the inconsistencies (ZNIGHT005) and checks every route against the\n * required groups (ZNIGHT023). Other extensions whose targets carry route decorators (WebSocket\n * gateways, GraphQL root fields) call {@link requiredRouteGroups} to check their own targets with\n * exactly the same groups, without reporting the inconsistencies a second time.\n */\nimport type { Diagnostic, Location, ValidateContext } from '@znight/compiler'\nimport type { MetaEntry } from './model.ts'\n\nimport { compareStrings } from '../path.ts'\nimport { Codes, Ids } from './model.ts'\nimport { parseRouteDecoratorOptions } from './route-decorators.ts'\n\n/** A route decorator definition of the application (`export const Roles = createRouteDecorator(...)`). */\nexport interface RouteGroupMember {\n /** Canonical identity of the decorator `const` (`src/auth/access.ts#Roles`). */\n readonly identity: string\n /** Name of the `const` (`Roles`). */\n readonly name: string\n readonly key: string\n /** Decision group (`options.group ?? key`). */\n readonly group: string\n readonly required: boolean\n /** Location of the definition. */\n readonly definition: Location\n /**\n * A flag (`@Public()`): created without type argument, and applied without argument wherever it\n * was seen. Decides how the decorator is suggested: `@Public()` or `@Roles(...)`.\n */\n readonly flag: boolean\n}\n\n/** A required route decorator group: every route-like target must carry a decision of it. */\nexport interface RequiredRouteGroup {\n /** Group name (`access`). */\n readonly group: string\n /** The decorators of the group, in source order (file, then position). Never empty. */\n readonly decorators: readonly RouteGroupMember[]\n /** The decorators as a hint: `@Public(), @Authenticated() or @Roles(...)`. */\n readonly suggestion: string\n}\n\n/** Result of {@link analyzeRouteGroups}. */\nexport interface RouteGroupsAnalysis {\n /** Inconsistent definitions (ZNIGHT005), at the second definition; not reported. */\n readonly conflicts: readonly Diagnostic[]\n /** The required groups, in the order of their first definition by identity. */\n readonly required: readonly RequiredRouteGroup[]\n}\n\n/** A definition while flags are computed. */\ntype MutableMember = { -readonly [K in keyof RouteGroupMember]: RouteGroupMember[K] }\n\n/**\n * Every route decorator definition, sorted by identity: the applied ones (`applied`, first usage\n * wins) and, when the compiler provides `definitionsOf`, the ones applied nowhere (invalid ones are\n * left to the usages, which report them).\n */\nfunction routeDecoratorDefinitions(\n ctx: Pick<ValidateContext<unknown>, 'definitionsOf'>,\n applied: Iterable<MetaEntry>,\n): MutableMember[] {\n const definitions = new Map<string, MutableMember>()\n for (const entry of applied) {\n const known = definitions.get(entry.identity)\n if (known === undefined) {\n definitions.set(entry.identity, {\n identity: entry.identity,\n name: entry.decorator,\n key: entry.key,\n group: entry.group,\n required: entry.required,\n definition: entry.definition,\n flag: entry.value === true,\n })\n } else if (entry.value !== true) {\n known.flag = false\n }\n }\n // compilers before RFC 0001 have no definitionsOf: only applied decorators are known then\n const all = typeof ctx.definitionsOf === 'function' ? ctx.definitionsOf(Ids.createRouteDecorator) : []\n for (const found of all) {\n const [keyArg, optionsArg, ...extra] = found.args\n const key = keyArg?.evaluated === true ? keyArg.value : undefined\n if (\n typeof key !== 'string' ||\n key === '' ||\n extra.length > 0 ||\n (optionsArg !== undefined && !optionsArg.evaluated)\n ) {\n continue\n }\n const parsed = parseRouteDecoratorOptions(key, optionsArg?.value)\n if ('error' in parsed) {\n continue\n }\n const flag = found.typeArgs.length === 0\n const known = definitions.get(found.identity)\n if (known !== undefined) {\n known.flag &&= flag\n continue\n }\n definitions.set(found.identity, {\n identity: found.identity,\n name: found.name,\n key,\n ...parsed,\n definition: found.location,\n flag,\n })\n }\n return [...definitions.values()].sort((a, b) => compareStrings(a.identity, b.identity))\n}\n\n/**\n * The route decorator groups of the application (RFC 0001 §5.1): every definition of a key must use\n * the same options and the decorators of a group must agree on `required` (a conflict is returned\n * at the second definition, which is then ignored); the required groups with their decorators.\n * `applied` are the entries of the targets the caller analysed (their first usage of a decorator\n * wins over its `definitionsOf` entry).\n */\nexport function analyzeRouteGroups(\n ctx: Pick<ValidateContext<unknown>, 'definitionsOf'>,\n applied: Iterable<MetaEntry>,\n): RouteGroupsAnalysis {\n const definitions = routeDecoratorDefinitions(ctx, applied)\n if (definitions.length === 0) {\n return { conflicts: [], required: [] }\n }\n const conflicts: Diagnostic[] = []\n const byKey = new Map<string, RouteGroupMember>()\n const byGroup = new Map<string, RouteGroupMember>()\n const members = new Map<string, RouteGroupMember[]>()\n for (const definition of definitions) {\n const sameKey = byKey.get(definition.key)\n if (sameKey !== undefined && (sameKey.group !== definition.group || sameKey.required !== definition.required)) {\n conflicts.push({\n code: Codes.InvalidDecorator,\n severity: 'error',\n message: `The route decorator ${definition.name} defines the key \"${definition.key}\" with ${describeOptions(definition)}, but ${sameKey.name} defines it with ${describeOptions(sameKey)}`,\n location: definition.definition,\n hints: ['Every definition of a key must use the same options: share one definition'],\n related: [{ message: `${sameKey.name} is defined here`, location: sameKey.definition }],\n })\n continue\n }\n const sameGroup = byGroup.get(definition.group)\n if (sameGroup !== undefined && sameGroup.required !== definition.required) {\n conflicts.push({\n code: Codes.InvalidDecorator,\n severity: 'error',\n message: `The \"${definition.group}\" group is ${definition.required ? '' : 'not '}required for ${definition.name} but ${sameGroup.required ? '' : 'not '}required for ${sameGroup.name}`,\n location: definition.definition,\n hints: [`All the decorators of the \"${definition.group}\" group must agree on required`],\n related: [{ message: `${sameGroup.name} is defined here`, location: sameGroup.definition }],\n })\n continue\n }\n byKey.set(definition.key, sameKey ?? definition)\n byGroup.set(definition.group, sameGroup ?? definition)\n const list = members.get(definition.group) ?? []\n list.push(definition)\n members.set(definition.group, list)\n }\n const required: RequiredRouteGroup[] = []\n for (const first of byGroup.values()) {\n if (!first.required) {\n continue\n }\n // the decorators of the group in source order: `@Public(), @Authenticated() or @Roles(...)`\n const decorators = [...(members.get(first.group) ?? [first])]\n .sort((a, b) => compareStrings(a.definition.file, b.definition.file) || a.definition.start - b.definition.start)\n .map(member => Object.freeze({ ...member }))\n const usages = decorators.map(member => `@${member.name}(${member.flag ? '' : '...'})`)\n const suggestion =\n usages.length === 1 ? (usages[0] as string) : `${usages.slice(0, -1).join(', ')} or ${usages.at(-1) as string}`\n required.push(Object.freeze({ group: first.group, decorators: Object.freeze(decorators), suggestion }))\n }\n return { conflicts, required }\n}\n\n/**\n * The required route decorator groups of the application (RFC 0001): what every route-like target\n * of another extension (a gateway, a GraphQL root field) must decide, exactly as HTTP routes must.\n * A target without a decision of a returned group is **ZNIGHT023**, reported by the caller.\n *\n * `applied` are the route metadata entries the caller read on its own targets\n * ({@link readRouteMeta}): they make decorators known even when the compiler has no\n * `definitionsOf`, and refine how flags are suggested. Inconsistent definitions are left out and\n * not reported here: the http extension reports them (ZNIGHT005) once.\n *\n * ```ts\n * validate(ctx) {\n * const required = requiredRouteGroups(ctx, ctx.stored.flatMap(gateway => gateway.meta))\n * for (const gateway of ctx.stored)\n * for (const group of required)\n * if (!gateway.meta.some(entry => entry.group === group.group))\n * ctx.report({ code: 'ZNIGHT023', severity: 'error', message: `${gateway.name} has no \"${group.group}\" decision`,\n * location: gateway.location, hints: [`Add ${group.suggestion} to ${gateway.name}`] })\n * }\n * ```\n */\nexport function requiredRouteGroups(\n ctx: ValidateContext<unknown>,\n applied: Iterable<MetaEntry> = [],\n): readonly RequiredRouteGroup[] {\n return analyzeRouteGroups(ctx, applied).required\n}\n\nfunction describeOptions(entry: RouteGroupMember): string {\n const group = entry.group === entry.key ? 'no group' : `group \"${entry.group}\"`\n return entry.required ? `${group}, required` : group\n}\n","/**\n * `validate` of the `@znight/http` compiler extension: route paths (grammar of `@znight/http/path`),\n * `:param` ↔ `@Param` consistency and duplicate routes across every controller (ZNIGHT007); route\n * decorator groups: consistent definitions (ZNIGHT005) and a decision of every required group on\n * every route (ZNIGHT023).\n */\nimport type { Location, ValidateContext } from '@znight/compiler'\nimport type { RoutePath } from '../path.ts'\nimport type { HttpControllerData, HttpRouteData, MetaEntry } from './model.ts'\nimport type { RequiredRouteGroup, RouteGroupMember } from './route-groups.ts'\n\nimport { checkRoutePath, compareStrings, parseRoutePath, WILDCARD_PARAM } from '../path.ts'\nimport { Codes } from './model.ts'\nimport { analyzeRouteGroups } from './route-groups.ts'\n\ntype Context = ValidateContext<HttpControllerData>\n\ninterface RegisteredRoute {\n readonly where: string\n readonly route: HttpRouteData\n}\n\n/** Validates the routes of every controller. */\nexport function validateHttp(ctx: Context): void {\n const controllers = [...ctx.stored].sort((a, b) => compareStrings(a.token, b.token))\n const registered = new Map<string, RegisteredRoute>()\n for (const controller of controllers) {\n const baseIssue = checkRoutePath(controller.rawBasePath)\n if (baseIssue !== undefined) {\n invalidRoute(\n ctx,\n controller.pathLocation,\n `Invalid base path ${JSON.stringify(controller.rawBasePath)} of ${controller.displayName}: ${baseIssue.message}`,\n GRAMMAR_HINTS,\n )\n continue\n }\n for (const route of controller.routes) {\n const where = `${controller.displayName}.${route.handler}`\n const ownIssue = checkRoutePath(route.rawPath)\n const issue = ownIssue ?? checkRoutePath(route.fullPath)\n if (issue !== undefined) {\n const path = ownIssue === undefined ? route.fullPath : route.rawPath\n invalidRoute(\n ctx,\n route.pathLocation,\n `Invalid route path ${JSON.stringify(path)} of ${where}: ${issue.message}`,\n GRAMMAR_HINTS,\n )\n continue\n }\n const parsed = parseRoutePath(route.fullPath)\n checkParams(ctx, route, parsed, where)\n const key = `${route.method} ${parsed.shape}`\n const previous = registered.get(key)\n if (previous === undefined) {\n registered.set(key, { where, route })\n continue\n }\n ctx.report({\n code: Codes.InvalidRoute,\n severity: 'error',\n message: `Duplicate route ${route.method} ${route.fullPath}: ${where} conflicts with ${previous.where} (${previous.route.method} ${previous.route.fullPath})`,\n location: route.location,\n hints: ['Two routes with the same method and the same path shape (parameter names aside) cannot coexist'],\n related: [{ message: `${previous.where} is declared here`, location: previous.route.location }],\n })\n }\n }\n validateDecisions(ctx, controllers)\n}\n\n/** Every route metadata entry of the controllers: controller entries, then route entries. */\nfunction* appliedEntries(controllers: readonly HttpControllerData[]): Generator<MetaEntry> {\n for (const controller of controllers) {\n yield* controller.meta\n for (const route of controller.routes) yield* route.meta\n }\n}\n\n/**\n * Route decorator groups (RFC 0001 §5.1): every definition of a key uses the same options and the\n * decorators of a group agree on `required` (ZNIGHT005, at the second definition); every route has\n * a decision of every required group, its own or its controller's (ZNIGHT023).\n */\nfunction validateDecisions(ctx: Context, controllers: readonly HttpControllerData[]): void {\n const { conflicts, required } = analyzeRouteGroups(ctx, appliedEntries(controllers))\n for (const conflict of conflicts) {\n ctx.report(conflict)\n }\n if (required.length === 0) {\n return\n }\n for (const controller of controllers) {\n const controllerGroups = new Set(controller.meta.map(entry => entry.group))\n for (const route of controller.routes) {\n const decided = new Set([...controllerGroups, ...route.meta.map(entry => entry.group)])\n for (const group of required) {\n if (decided.has(group.group)) {\n continue\n }\n ctx.report({\n code: Codes.MissingRouteDecision,\n severity: 'error',\n message: `Route ${route.method} ${route.fullPath} (${controller.displayName}.${route.handler}) has no \"${group.group}\" decision`,\n location: route.location,\n hints: [`Add ${group.suggestion} to the route or to ${controller.displayName}`],\n related: [\n { message: `The \"${group.group}\" group is required`, location: firstDefinition(group) },\n { message: `${controller.displayName} is declared here`, location: controller.location },\n ],\n })\n }\n }\n }\n}\n\n/** Where the first decorator of a group (source order) is defined. */\nfunction firstDefinition(group: RequiredRouteGroup): Location {\n return (group.decorators[0] as RouteGroupMember).definition\n}\n\nconst GRAMMAR_HINTS: readonly string[] = [\n \"Paths are made of static segments (letters, digits and - . _ ~ ! $ & ' + , ; = @), :name parameters and a trailing * wildcard\",\n]\n\n/** `:param` of the path ↔ `@Param('name')` parameters of the handler. */\nfunction checkParams(ctx: Context, route: HttpRouteData, path: RoutePath, where: string): void {\n const declared = new Set(path.params)\n const consumed = new Set<string>()\n let everything = false\n for (const param of route.params) {\n if (param.source === 'context' || param.source === 'request') {\n everything = true // ctx.params / the native request give access to every parameter\n continue\n }\n if (param.source !== 'param') {\n continue\n }\n if (param.key === undefined) {\n everything = true\n continue\n }\n if (declared.has(param.key)) {\n consumed.add(param.key)\n continue\n }\n const available = path.params.filter(name => name !== WILDCARD_PARAM).map(name => `:${name}`)\n invalidRoute(\n ctx,\n param.location,\n `@Param('${param.key}') of ${where}: the route ${route.method} ${route.fullPath} has no ${param.key === WILDCARD_PARAM ? 'wildcard' : `\":${param.key}\" parameter`}`,\n [\n available.length > 0\n ? `Parameters of the route: ${available.join(', ')}`\n : `Add \":${param.key}\" to the route path`,\n ],\n )\n }\n if (everything || !route.complete) {\n return // a parameter could not be analysed (already reported): do not guess what it consumes\n }\n for (const name of path.params) {\n if (name !== WILDCARD_PARAM && !consumed.has(name)) {\n invalidRoute(\n ctx,\n route.pathLocation,\n `Route ${route.method} ${route.fullPath} declares \":${name}\" but ${where} has no @Param('${name}') parameter`,\n [`Add a parameter: @Param('${name}') ${name}: string`],\n )\n }\n }\n}\n\nfunction invalidRoute(ctx: Context, location: Location, message: string, hints: readonly string[]): void {\n ctx.report({ code: Codes.InvalidRoute, severity: 'error', message, location, hints })\n}\n","/**\n * `@znight/http/compiler`: the compiler extension of `@znight/http` (architecture §6.5), loaded by\n * `@znight/compiler` through `package.json#znight.compiler`.\n *\n * - `analyzeClass`: `@Controller` classes become providers; their decorated methods become routes\n * (paths, parameters with type-based coercion or Standard Schema validation, cookies, uploaded\n * files, guards, interceptors, status, headers, body limits, `@Sse` event streams,\n * `createRouteDecorator` metadata);\n * - `validate`: route paths, `:param` ↔ `@Param`, duplicate routes (ZNIGHT007);\n * - `generate`: `metadata.extensions.http` with one `invoke` function per route (README,\n * \"Compiler contract\").\n *\n * It also exports the route decorator readers of other extensions: `readRouteMeta`,\n * `effectiveRouteMeta` and `requiredRouteGroups`.\n *\n * This entry only `import type`s from `@znight/compiler` and never loads the HTTP runtime.\n */\nimport type { CompilerExtension, DecoratorSpec } from '@znight/compiler'\nimport type { HttpControllerData } from './model.ts'\n\nimport { analyzeHttpClass, EXTENSION_NAME } from './analyze.ts'\nimport { generateHttp } from './generate.ts'\nimport { Ids, ROUTE_METHODS } from './model.ts'\nimport { validateHttp } from './validate.ts'\n\nexport type {\n CoercionPlan,\n HttpControllerData,\n HttpParamData,\n HttpRouteData,\n MetaEntry,\n ParamCoercion,\n ScalarCoercion,\n SseRouteData,\n UploadData,\n} from './model.ts'\nexport type { RequiredRouteGroup, RouteGroupMember } from './route-groups.ts'\n\n/**\n * Route decorators for other extensions (RFC 0003 §6.4, RFC 0005 H3): read `createRouteDecorator`\n * metadata on any class or method, and the required groups of the application, with the exact\n * rules of controllers and routes. Stable API, see the README (\"Route metadata in other\n * extensions\").\n */\nexport { effectiveRouteMeta, readRouteMeta } from './route-decorators.ts'\nexport { requiredRouteGroups } from './route-groups.ts'\n\nconst ROUTE: DecoratorSpec = { targets: ['method'], params: ['static'] }\nconst NAME_OR_SCHEMA: DecoratorSpec = { targets: ['parameter'], params: ['value', 'value'] }\nconst NO_ARGUMENT: DecoratorSpec = { targets: ['parameter'], params: [] }\nconst CLASS_REFS: DecoratorSpec = { targets: ['class', 'method'], params: [], rest: 'value' }\nconst UPLOAD: DecoratorSpec = { targets: ['parameter'], params: ['static', 'static'] }\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.Controller]: { targets: ['class'], params: ['static'] },\n ...Object.fromEntries([...ROUTE_METHODS.keys()].map(identity => [identity, ROUTE])),\n [Ids.Param]: NAME_OR_SCHEMA,\n [Ids.Query]: NAME_OR_SCHEMA,\n [Ids.Body]: { targets: ['parameter'], params: ['value'] },\n [Ids.Headers]: { targets: ['parameter'], params: ['static'] },\n [Ids.Req]: NO_ARGUMENT,\n [Ids.Res]: NO_ARGUMENT,\n [Ids.Ctx]: NO_ARGUMENT,\n [Ids.HttpCode]: { targets: ['method'], params: ['static'] },\n [Ids.Header]: { targets: ['method'], params: ['static', 'static'] },\n [Ids.UseGuard]: CLASS_REFS,\n [Ids.UseInterceptor]: CLASS_REFS,\n [Ids.Validate]: { targets: ['method'], params: ['value'] },\n [Ids.UploadedFile]: UPLOAD,\n [Ids.UploadedFiles]: UPLOAD,\n [Ids.BodyLimit]: { targets: ['class', 'method'], params: ['static'] },\n [Ids.Cookie]: NAME_OR_SCHEMA,\n [Ids.SignedCookie]: NAME_OR_SCHEMA,\n // after the ROUTE spread: `@Sse(path?, options?)` takes two static arguments\n [Ids.Sse]: { targets: ['method'], params: ['static', 'static'] },\n})\n\n/** The `@znight/http` compiler extension. */\nconst http: CompilerExtension<HttpControllerData> = Object.freeze({\n apiVersion: 1,\n name: EXTENSION_NAME,\n decorators,\n analyzeClass: analyzeHttpClass,\n validate: validateHttp,\n generate: generateHttp,\n})\n\nexport default http\n"],"mappings":";;;;AAgBA,SAAgB,OAAO,OAAkC;CACvD,OACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAA6B,SAAS,YAC9C,OAAQ,MAA8B,UAAU;AAEpD;;AAGA,SAAgB,MAAM,MAAe,KAAkC;CACrE,MAAM,QAAQ,KAAK;CACnB,OAAO,OAAO,KAAK,IAAI,QAAQ,KAAA;AACjC;;AAGA,SAAgB,SAAS,MAAe,KAAwB;CAC9D,MAAM,QAAQ,KAAK;CACnB,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,OAAO,MAAM,IAAI,CAAC;AACxD;AAEA,MAAM,2BAAW,IAAI,IAAI;CACvB;CACA;CACA;C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EACzD,IAAI,SAAS;EAAE,SAAS,CAAC,QAAQ;EAAG,QAAQ,CAAC,UAAU,QAAQ;CAAE;EACjE,IAAI,WAAW;EACf,IAAI,iBAAiB;EACrB,IAAI,WAAW;EAAE,SAAS,CAAC,QAAQ;EAAG,QAAQ,CAAC,OAAO;CAAE;EACxD,IAAI,eAAe;EACnB,IAAI,gBAAgB;EACpB,IAAI,YAAY;EAAE,SAAS,CAAC,SAAS,QAAQ;EAAG,QAAQ,CAAC,QAAQ;CAAE;EACnE,IAAI,SAAS;EACb,IAAI,eAAe;EAEnB,IAAI,MAAM;EAAE,SAAS,CAAC,QAAQ;EAAG,QAAQ,CAAC,UAAU,QAAQ;CAAE;AACjE,CAAC;;AAGD,MAAM,OAA8C,OAAO,OAAO;CAChE,YAAY;CACZ,MAAM;CACN;CACA,cAAc;CACd,UAAU;CACV,UAAU;AACZ,CAAC"}
|
|
1
|
+
{"version":3,"file":"compiler.mjs","names":["isPlainObject"],"sources":["../src/compiler/ast.ts","../src/compiler/coercion.ts","../src/compiler/model.ts","../src/compiler/route-decorators.ts","../src/compiler/analyze.ts","../src/compiler/generate.ts","../src/compiler/route-groups.ts","../src/compiler/validate.ts","../src/compiler/index.ts"],"sourcesContent":["/**\n * Minimal, structural access to the oxc AST nodes exposed by `ClassInfo` / `ArgInfo` (escape\n * hatches of the extension API). The extension does not depend on `oxc-parser`: nodes are read\n * through this loose shape and checked at runtime.\n */\nimport type { ClassInfo, MethodInfo, ParameterInfo } from '@znight/compiler'\n\n/** An ESTree node, read structurally. */\nexport interface AstNode {\n readonly type: string\n readonly start: number\n readonly end: number\n readonly [key: string]: unknown\n}\n\n/** `true` for an object shaped like an AST node. */\nexport function isNode(value: unknown): value is AstNode {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { type?: unknown }).type === 'string' &&\n typeof (value as { start?: unknown }).start === 'number'\n )\n}\n\n/** The child node stored under `key`, when it is a node. */\nexport function child(node: AstNode, key: string): AstNode | undefined {\n const value = node[key]\n return isNode(value) ? value : undefined\n}\n\n/** The child nodes stored under `key`, when it is an array. */\nexport function children(node: AstNode, key: string): AstNode[] {\n const value = node[key]\n return Array.isArray(value) ? value.filter(isNode) : []\n}\n\nconst WRAPPERS = new Set([\n 'ParenthesizedExpression',\n 'TSAsExpression',\n 'TSSatisfiesExpression',\n 'TSNonNullExpression',\n 'TSTypeAssertion',\n 'TSInstantiationExpression',\n])\n\n/** Removes parentheses and type-only wrappers (`x as T`, `x satisfies T`, `x!`, `<T>x`). */\nexport function unwrap(node: AstNode): AstNode {\n let current = node\n while (WRAPPERS.has(current.type)) {\n const inner = child(current, 'expression')\n if (!inner) {\n return current\n }\n current = inner\n }\n return current\n}\n\n/**\n * The default value expression of a method parameter (`page = 1` → `1`), found in the class\n * declaration by the location of the method key.\n */\nexport function defaultValueOf(cls: ClassInfo, method: MethodInfo, param: ParameterInfo): AstNode | undefined {\n const classNode = cls.declaration.node as unknown\n if (!isNode(classNode)) {\n return undefined\n }\n const body = child(classNode, 'body')\n if (!body) {\n return undefined\n }\n for (const member of children(body, 'body')) {\n const key = child(member, 'key')\n if (!key || key.start !== method.location.start) {\n continue\n }\n const fn = child(member, 'value')\n if (!fn) {\n return undefined\n }\n const params = children(fn, 'params').filter(node => !(node.type === 'Identifier' && node['name'] === 'this'))\n let pattern = params[param.index]\n if (pattern?.type === 'TSParameterProperty') {\n pattern = child(pattern, 'parameter')\n }\n return pattern?.type === 'AssignmentPattern' ? child(pattern, 'right') : undefined\n }\n return undefined\n}\n","/**\n * Type-based coercion of raw request values (route parameters, query values, headers) to the\n * declared type of a handler parameter (README, \"Compiler contract\" → `coerce.X` by declared type).\n */\nimport type { AnalyzeContext, ClassInfo, MethodInfo, ParameterInfo, TypeInfo } from '@znight/compiler'\nimport type { CoercionPlan, HttpControllerData, ParamCoercion, ScalarCoercion } from './model.ts'\n\nimport { child, defaultValueOf, isNode, unwrap } from './ast.ts'\n\ntype Context = AnalyzeContext<HttpControllerData>\ntype Project = Context['project']\ntype ExpressionInput = Parameters<Project['evaluate']>[1]\ntype ScopeInput = Parameters<Project['evaluate']>[0]\ntype EnumValue = string | number | boolean\n\nconst DATE_IDENTITY = 'globalThis#Date'\nconst STRING: TypeInfo = { kind: 'primitive', name: 'string' }\nconst NUMBER: TypeInfo = { kind: 'primitive', name: 'number' }\nconst BOOLEAN: TypeInfo = { kind: 'primitive', name: 'boolean' }\nconst BIGINT: TypeInfo = { kind: 'primitive', name: 'bigint' }\nconst DATE: TypeInfo = { kind: 'reference', identity: DATE_IDENTITY, name: 'Date', typeArgs: [] }\n\n/** The type of a handler parameter: its annotation, or the type of its default value. */\nexport interface ParameterType {\n /** `undefined` when the parameter has no annotation and its default value tells nothing. */\n readonly type: TypeInfo | undefined\n /** `?`, default value, `| undefined` or `| null`. */\n readonly optional: boolean\n}\n\n/** Result of {@link planCoercion}. */\nexport type CoercionResult =\n | { readonly ok: true; readonly coercion: ParamCoercion }\n | { readonly ok: false; readonly reason: string; readonly hints: readonly string[] }\n\n/** Annotated or inferred type of a parameter. */\nexport function parameterType(ctx: Context, cls: ClassInfo, method: MethodInfo, param: ParameterInfo): ParameterType {\n let type: TypeInfo | undefined = param.type\n if (param.type.kind === 'opaque' && param.type.reason === 'missing-annotation') {\n type = param.hasDefault ? inferFromDefault(ctx, cls, method, param) : undefined\n }\n const nullish = type !== undefined && hasNullish(type)\n return { type, optional: param.optional || param.hasDefault || nullish }\n}\n\n/**\n * Plans the coercion of a raw value to `type`. `required` is set for route parameters, which are\n * always present (no `coerce.optional`).\n */\nexport function planCoercion(\n ctx: Context,\n declared: ParameterType,\n param: ParameterInfo,\n required: boolean,\n): CoercionResult {\n const type = declared.type\n if (type === undefined) {\n return {\n ok: false,\n reason: `the type of parameter '${param.name}' is unknown`,\n hints: [`Annotate the parameter: ${param.name}: string`],\n }\n }\n const { type: base } = ctx.types.stripNullish(type)\n const raw = isRaw(base)\n if (raw) {\n return { ok: true, coercion: { plan: { kind: 'raw' }, cast: false } }\n }\n const scalar = scalarPlan(ctx, base)\n let plan: CoercionPlan\n let cast: boolean\n if ('reason' in scalar) {\n if (base.kind !== 'array') {\n return failure(ctx, type, scalar.reason)\n }\n const item = scalarPlan(ctx, base.element)\n if ('reason' in item) {\n return failure(ctx, type, item.reason)\n }\n plan = { kind: 'array', item: item.plan }\n cast = item.cast\n } else {\n plan = scalar.plan\n cast = scalar.cast\n }\n if (!required && declared.optional) {\n plan = { kind: 'optional', item: plan }\n // `coerce.optional` returns `T | undefined`: `x: T | null` (without `?` / default) needs a cast\n cast ||= !(param.optional || param.hasDefault || acceptsUndefined(type))\n }\n return { ok: true, coercion: { plan, cast } }\n}\n\n/** `unknown` and `any`: the raw value is passed as is. */\nexport function isRaw(type: TypeInfo): boolean {\n return type.kind === 'primitive' && (type.name === 'unknown' || type.name === 'any')\n}\n\ntype ScalarResult =\n | { readonly plan: CoercionPlan; readonly cast: boolean }\n | { readonly reason: string; readonly cast?: undefined }\n\nfunction scalarPlan(ctx: Context, type: TypeInfo): ScalarResult {\n switch (type.kind) {\n case 'primitive': {\n const kind = primitiveCoercion(type.name)\n return kind ? { plan: { kind }, cast: false } : { reason: `'${type.name}' values cannot be read from a request` }\n }\n case 'literal':\n return typeof type.value === 'bigint'\n ? { reason: 'bigint literal types are not supported' }\n : { plan: { kind: 'enum', values: [type.value] }, cast: false }\n case 'union': {\n const values: EnumValue[] = []\n for (const member of type.types) {\n if (member.kind === 'literal' && typeof member.value !== 'bigint') {\n values.push(member.value)\n } else if (member.kind === 'primitive' && member.name === 'boolean') {\n values.push(false, true)\n } else {\n return { reason: 'only unions of literal types can be coerced' }\n }\n }\n return { plan: { kind: 'enum', values }, cast: false }\n }\n case 'reference': {\n if (type.identity === DATE_IDENTITY) {\n return { plan: { kind: 'date' }, cast: false }\n }\n const values = enumValues(ctx, type.identity)\n if (values) {\n // enum members are nominal: the literal values are cast to the enum type\n return values.length === 0\n ? { reason: `the enum ${type.name} has no member` }\n : { plan: { kind: 'enum', values }, cast: true }\n }\n return { reason: 'objects cannot be read from a single request value' }\n }\n case 'intersection': {\n // branded primitives: `string & { readonly __brand: 'UserId' }`\n const primitives = type.types.filter(member => member.kind === 'primitive' || member.kind === 'literal')\n const [primitive] = primitives\n if (primitives.length === 1 && primitive !== undefined) {\n const inner = scalarPlan(ctx, primitive)\n return 'reason' in inner ? inner : { plan: inner.plan, cast: true }\n }\n return { reason: 'only branded primitives (`string & { ... }`) can be coerced' }\n }\n case 'array':\n return { reason: 'nested arrays cannot be coerced' }\n default:\n return { reason: 'this type cannot be read from a request value' }\n }\n}\n\nfunction primitiveCoercion(name: string): ScalarCoercion | undefined {\n switch (name) {\n case 'string':\n case 'number':\n case 'boolean':\n case 'bigint':\n return name\n default:\n return undefined\n }\n}\n\nfunction failure(ctx: Context, type: TypeInfo, reason: string): CoercionResult {\n return {\n ok: false,\n reason: `type '${ctx.types.format(type)}' cannot be coerced (${reason})`,\n hints: [\n 'Supported types: string, number, boolean, bigint, Date, literal unions, enums, branded primitives and arrays of them',\n 'Or validate the value with a Standard Schema',\n ],\n }\n}\n\n/** Member values of a TypeScript enum, `undefined` when `identity` is not an evaluable enum. */\nfunction enumValues(ctx: Context, identity: string): EnumValue[] | undefined {\n const symbol = ctx.project.lookupIdentity(identity)\n if (symbol.kind !== 'declaration' || symbol.declaration.kind !== 'enum') {\n return undefined\n }\n const declaration = symbol.declaration\n const node = declaration.node as unknown\n const id = isNode(node) ? child(node, 'id') : undefined\n const file = ctx.project.getFile(declaration.file)\n if (!id || !file) {\n return undefined\n }\n const scope = { file, namespace: declaration.namespace } as unknown as ScopeInput\n const result = ctx.project.evaluate(scope, id as unknown as ExpressionInput, { refs: 'none' })\n if (result.kind !== 'value' || typeof result.value !== 'object' || result.value === null) {\n return undefined\n }\n return Object.values(result.value).filter(\n (value): value is string | number => typeof value === 'string' || typeof value === 'number',\n )\n}\n\nfunction inferFromDefault(\n ctx: Context,\n cls: ClassInfo,\n method: MethodInfo,\n param: ParameterInfo,\n): TypeInfo | undefined {\n const node = defaultValueOf(cls, method, param)\n if (!node) {\n return undefined\n }\n const inner = unwrap(node)\n if (inner.type === 'NewExpression') {\n const callee = child(inner, 'callee')\n if (callee?.type === 'Identifier') {\n const resolved = ctx.project.resolveIdentifier(\n cls.file,\n callee as unknown as Parameters<Project['resolveIdentifier']>[1],\n 'value',\n )\n return resolved.identity?.identity === DATE_IDENTITY ? DATE : undefined\n }\n return undefined\n }\n const result = ctx.project.evaluate(cls.file, node as unknown as ExpressionInput, { refs: 'none' })\n return result.kind === 'value' ? typeOfValue(result.value) : undefined\n}\n\nfunction typeOfValue(value: unknown): TypeInfo | undefined {\n switch (typeof value) {\n case 'string':\n return STRING\n case 'number':\n return NUMBER\n case 'boolean':\n return BOOLEAN\n case 'bigint':\n return BIGINT\n default: {\n if (!Array.isArray(value) || value.length === 0) {\n return undefined\n }\n const items = value.map(typeOfValue)\n const [first] = items\n if (first === undefined || first.kind !== 'primitive' || items.some(item => item !== first)) {\n return undefined\n }\n return { kind: 'array', element: first }\n }\n }\n}\n\nfunction hasNullish(type: TypeInfo): boolean {\n return type.kind === 'union' && type.types.some(isNullish)\n}\n\n/** Whether a union accepts `undefined` (`T | undefined`, `T | void`). */\nexport function acceptsUndefined(type: TypeInfo): boolean {\n return (\n type.kind === 'union' &&\n type.types.some(member => member.kind === 'primitive' && (member.name === 'undefined' || member.name === 'void'))\n )\n}\n\nfunction isNullish(type: TypeInfo): boolean {\n return type.kind === 'primitive' && (type.name === 'undefined' || type.name === 'null' || type.name === 'void')\n}\n","/**\n * Data model of the `@znight/http` compiler extension: canonical identities of the decorators and\n * the data stored during analysis (`ctx.store()`), read back by `validate()` and `generate()`.\n *\n * This module is pure (types and constants only) so that the compiler entry stays free of runtime\n * dependencies.\n */\nimport type { ClassRef, Location, StaticValue, ValueRef } from '@znight/compiler'\nimport type { HttpMethod, HttpParamSource } from '../metadata.ts'\n\n/** Package name (prefix of every decorator identity). */\nexport const HTTP_PACKAGE = '@znight/http'\n\n/** Canonical identities of the decorators of `@znight/http`. */\nexport const Ids: {\n readonly Controller: string\n readonly Param: string\n readonly Query: string\n readonly Body: string\n readonly Headers: string\n readonly Req: string\n readonly Res: string\n readonly Ctx: string\n readonly HttpCode: string\n readonly Header: string\n readonly UseGuard: string\n readonly UseInterceptor: string\n readonly Validate: string\n readonly UploadedFile: string\n readonly UploadedFiles: string\n readonly BodyLimit: string\n readonly Cookie: string\n readonly SignedCookie: string\n readonly Sse: string\n readonly createRouteDecorator: string\n readonly RouteDecorator: string\n} = Object.freeze({\n Controller: '@znight/http#Controller',\n Param: '@znight/http#Param',\n Query: '@znight/http#Query',\n Body: '@znight/http#Body',\n Headers: '@znight/http#Headers',\n Req: '@znight/http#Req',\n Res: '@znight/http#Res',\n Ctx: '@znight/http#Ctx',\n HttpCode: '@znight/http#HttpCode',\n Header: '@znight/http#Header',\n UseGuard: '@znight/http#UseGuard',\n UseInterceptor: '@znight/http#UseInterceptor',\n Validate: '@znight/http#Validate',\n UploadedFile: '@znight/http#UploadedFile',\n UploadedFiles: '@znight/http#UploadedFiles',\n BodyLimit: '@znight/http#BodyLimit',\n Cookie: '@znight/http#Cookie',\n SignedCookie: '@znight/http#SignedCookie',\n Sse: '@znight/http#Sse',\n createRouteDecorator: '@znight/http#createRouteDecorator',\n RouteDecorator: '@znight/http#RouteDecorator',\n})\n\n/** Route method decorators → HTTP method (`@Sse` declares a `GET` route). */\nexport const ROUTE_METHODS: ReadonlyMap<string, HttpMethod> = new Map<string, HttpMethod>([\n ['@znight/http#Get', 'GET'],\n ['@znight/http#Post', 'POST'],\n ['@znight/http#Put', 'PUT'],\n ['@znight/http#Patch', 'PATCH'],\n ['@znight/http#Delete', 'DELETE'],\n ['@znight/http#Head', 'HEAD'],\n ['@znight/http#Options', 'OPTIONS'],\n ['@znight/http#All', 'ALL'],\n ['@znight/http#Sse', 'GET'],\n])\n\n/** Parameter decorators → parameter source. */\nexport const PARAM_SOURCES: ReadonlyMap<string, HttpParamSource> = new Map<string, HttpParamSource>([\n [Ids.Param, 'param'],\n [Ids.Query, 'query'],\n [Ids.Body, 'body'],\n [Ids.Headers, 'headers'],\n [Ids.Req, 'request'],\n [Ids.Res, 'response'],\n [Ids.Ctx, 'context'],\n [Ids.UploadedFile, 'file'],\n [Ids.UploadedFiles, 'files'],\n [Ids.Cookie, 'cookie'],\n [Ids.SignedCookie, 'signedCookie'],\n])\n\n/** Error codes used by the extension (see `ErrorCode` in `@znight/core`). */\nexport const Codes: {\n readonly MissingProvider: 'ZNIGHT001'\n readonly InvalidDecorator: 'ZNIGHT005'\n readonly InvalidRoute: 'ZNIGHT007'\n readonly UnvalidatedInput: 'ZNIGHT017'\n readonly MissingRouteDecision: 'ZNIGHT023'\n} = Object.freeze({\n MissingProvider: 'ZNIGHT001',\n InvalidDecorator: 'ZNIGHT005',\n InvalidRoute: 'ZNIGHT007',\n UnvalidatedInput: 'ZNIGHT017',\n MissingRouteDecision: 'ZNIGHT023',\n})\n\n/**\n * Grammar of an explicit route decorator group name (same as the runtime `createRouteDecorator`).\n * A decorator without `group` is its own group, named after its key (any non-empty key).\n */\nexport const GROUP_NAME: RegExp = /^[A-Za-z][\\w.-]*$/\n\n/** Primitive coercions (`coerce.<kind>`). */\nexport type ScalarCoercion = 'string' | 'number' | 'integer' | 'boolean' | 'bigint' | 'date'\n\n/**\n * How a raw value (route parameter, query value, header) is converted to the declared type of a\n * handler parameter.\n */\nexport type CoercionPlan =\n | { readonly kind: ScalarCoercion }\n | { readonly kind: 'enum'; readonly values: readonly (string | number | boolean)[] }\n | { readonly kind: 'array'; readonly item: CoercionPlan }\n | { readonly kind: 'optional'; readonly item: CoercionPlan }\n /** No conversion: the raw value is passed as is (`unknown` / `any` parameters). */\n | { readonly kind: 'raw' }\n\n/** The coercion of a handler parameter. */\nexport interface ParamCoercion {\n readonly plan: CoercionPlan\n /**\n * The coerced value does not have the declared type (branded primitives, enums, `null` without\n * `undefined`): the generated expression is cast with `as never`.\n */\n readonly cast: boolean\n}\n\n/** An upload parameter (`@UploadedFile` / `@UploadedFiles`). */\nexport interface UploadData {\n /** Multipart field; `undefined`: any field. */\n readonly field: string | undefined\n /** `@UploadedFiles`. */\n readonly multiple: boolean\n /** A file must be sent (`required` option, else the parameter is not optional). */\n readonly required: boolean\n /** `maxSize` in bytes (`Infinity` allowed). */\n readonly maxSize: number | undefined\n /** `maxFiles` (`@UploadedFiles` only). */\n readonly maxFiles: number | undefined\n /** `mimeTypes` patterns, as written. */\n readonly mimeTypes: readonly string[] | undefined\n /** The injected value does not have the declared type (`node:buffer` File, `File | null`): `as never`. */\n readonly cast: boolean\n}\n\n/** A custom parameter (`createParamDecorator`, RFC 0010). */\nexport interface CustomParamData {\n /** Canonical identity of the decorator `const` (imported by the generated module). */\n readonly identity: string\n /** Name of the decorator (`CurrentUser`). */\n readonly name: string\n /** The data argument: evaluated value (it may contain references) or a reference; `undefined` without argument. */\n readonly data: { readonly value: StaticValue } | undefined\n /** The class resolver (`x[i].resolve(ctx, data)`); `undefined` for a function resolver. */\n readonly resolver: ClassRef | undefined\n /**\n * Parameters of the class resolver's `resolve` (own, inherited or an arrow function property);\n * `undefined` for a function resolver, or when the compiler cannot read it (the call is cast).\n */\n readonly arity?: number\n /** The value type could not be checked against the parameter: `as never`. */\n readonly cast: boolean\n}\n\n/** A handler parameter. */\nexport interface HttpParamData {\n /** Position in the handler signature. */\n readonly index: number\n /** Parameter name (messages). */\n readonly name: string\n readonly source: HttpParamSource\n /** Route parameter name, query key, lower-case header name or cookie name; `undefined` for the whole object. */\n readonly key: string | undefined\n /** Declared (or inferred) type, formatted for humans. */\n readonly type: string | undefined\n /** The parameter accepts `undefined` (`?`, `| undefined`, default value). */\n readonly optional: boolean\n /** Standard Schema validating the value (its output is injected). */\n readonly schema: ValueRef | undefined\n /** Coercion of a named value without schema. */\n readonly coercion: ParamCoercion | undefined\n /** Upload parameter (`source` `file` / `files`). */\n readonly upload?: UploadData\n /** Custom parameter (`source` `custom`). */\n readonly custom?: CustomParamData\n /**\n * The default value of the handler parameter (`@Query('page') page = 1` → `1`), when it is\n * statically evaluable (literals, `const` references; references to exported bindings are left\n * out). Informational (documentation): the handler applies its own default.\n */\n readonly defaultValue?: StaticValue\n /** Location of the parameter decorator. */\n readonly location: Location\n}\n\n/** A `createRouteDecorator` value (`route.meta[key]`) and the definition of its decorator. */\nexport interface MetaEntry {\n readonly key: string\n /** Statically evaluated value; may be or contain references to exported bindings. */\n readonly value: StaticValue\n /** Location of the decorator usage. */\n readonly location: Location\n /** Decision group (`options.group ?? key`). */\n readonly group: string\n /** The group is required (`options.required`). */\n readonly required: boolean\n /** Display name of the decorator (`Roles`). */\n readonly decorator: string\n /** Canonical identity of the decorator `const` (`src/auth/access.ts#Roles`). */\n readonly identity: string\n /** Location of the decorator definition (`export const Roles = createRouteDecorator(...)`). */\n readonly definition: Location\n}\n\n/** Options of an `@Sse` route (`HttpRouteDefinition.sse`). */\nexport interface SseRouteData {\n /** Heartbeat in ms; `0` disables it (`heartbeat: false`). Absent: the plugin default. */\n readonly heartbeat?: number\n readonly retry?: number\n readonly maxDuration?: number\n}\n\n/** A route: one route decorator of a handler. */\nexport interface HttpRouteData {\n readonly method: HttpMethod\n /** Path of the route decorator as written (`undefined` when absent). */\n readonly rawPath: string\n /** `normalizePath(rawPath)`. */\n readonly path: string\n /** `joinPaths(controller base path, path)`. */\n readonly fullPath: string\n readonly handler: string\n readonly status: number | undefined\n /** `@Header` entries, lower-case names, in source order. */\n readonly headers: readonly (readonly [string, string])[]\n readonly meta: readonly MetaEntry[]\n readonly guards: readonly ClassRef[]\n readonly interceptors: readonly ClassRef[]\n readonly params: readonly HttpParamData[]\n /** `false` when a parameter could not be analysed (an error was reported; it is missing from `params`). */\n readonly complete: boolean\n /** `@Validate(S)` on a handler without `@Body()` parameter: the body is validated and discarded. */\n readonly bodySchema: ValueRef | undefined\n /** `@BodyLimit` of the method (or of the controller), in bytes. */\n readonly bodyLimit: number | undefined\n readonly rawResponse: boolean\n /** `@Sse` route: its options (`{}` without options). */\n readonly sse?: SseRouteData\n /** Location of the route decorator. */\n readonly location: Location\n /** Location of the path argument (the decorator when absent). */\n readonly pathLocation: Location\n}\n\n/** A controller (data stored by `analyzeClass`). */\nexport interface HttpControllerData {\n /** Provider token of the controller. */\n readonly token: string\n /** Canonical identity of the class (imported as a type by `invoke`). */\n readonly identity: string\n readonly displayName: string\n /** Base path as written. */\n readonly rawBasePath: string\n /** `normalizePath(rawBasePath)`. */\n readonly basePath: string\n readonly guards: readonly ClassRef[]\n readonly interceptors: readonly ClassRef[]\n readonly meta: readonly MetaEntry[]\n readonly routes: readonly HttpRouteData[]\n /** Location of `@Controller`. */\n readonly location: Location\n /** Location of the base path argument (the decorator when absent). */\n readonly pathLocation: Location\n}\n","/**\n * User-defined route metadata decorators (`createRouteDecorator<T>(key, { group?, required? })`).\n *\n * A decorator is a route decorator when its callee is a `const` initialised with a call to\n * `@znight/http#createRouteDecorator` whose first argument (the key) and optional second argument\n * (the options) are statically evaluable. Its argument is evaluated like a `value` decorator\n * argument (literals, `const` references, references to exported bindings); without argument the\n * value is `true`. Decorators of one group are alternatives: one per controller or route.\n *\n * Every helper takes the analysis context of **any** extension: other extensions read route\n * decorators on their own targets (gateways, resolvers) with {@link readRouteMeta}, exported by\n * `@znight/http/compiler`.\n */\nimport type {\n AnalyzeContext,\n ClassInfo,\n DecoratorInfo,\n Diagnostic,\n Location,\n MethodInfo,\n StaticValue,\n ValueRef,\n} from '@znight/compiler'\nimport type { MetaEntry } from './model.ts'\n\nimport { type AstNode, child, children, isNode, unwrap } from './ast.ts'\nimport { Codes, GROUP_NAME, Ids } from './model.ts'\n\ntype Context = AnalyzeContext<unknown>\ntype Project = Context['project']\ntype ScopeInput = Parameters<Project['evaluate']>[0]\ntype ExpressionInput = Parameters<Project['evaluate']>[1]\ntype EntityName = Parameters<Project['resolveIdentifier']>[1]\n\n/** A route decorator definition: `export const Roles = createRouteDecorator<T>(key, options)`. */\nexport interface RouteDecoratorDefinition {\n readonly kind: 'route'\n readonly key: string\n /** `options.group ?? key`. */\n readonly group: string\n readonly required: boolean\n /** Name of the `const` (`Roles`). */\n readonly name: string\n /** Location of the `const` name. */\n readonly definition: Location\n}\n\n/** What a decorator identity refers to. */\nexport type RouteDecoratorResolution =\n | RouteDecoratorDefinition\n | { readonly kind: 'other' }\n | {\n readonly kind: 'invalid'\n readonly message: string\n readonly hints: readonly string[]\n /** The definition, when the problem is there. */\n readonly definition?: Location\n }\n\nconst OTHER: RouteDecoratorResolution = Object.freeze({ kind: 'other' })\n\n/** Resolutions per analysis context (one context per compile). */\nconst caches = new WeakMap<object, Map<string, RouteDecoratorResolution>>()\n\n/** Resolves a decorator identity to a route decorator definition (memoized per compile). */\nexport function resolveRouteDecorator(ctx: Context, identity: string): RouteDecoratorResolution {\n let cache = caches.get(ctx)\n if (!cache) {\n cache = new Map()\n caches.set(ctx, cache)\n }\n let resolution = cache.get(identity)\n if (!resolution) {\n resolution = resolve(ctx, identity)\n cache.set(identity, resolution)\n }\n return resolution\n}\n\nfunction resolve(ctx: Context, identity: string): RouteDecoratorResolution {\n if (identity.startsWith('globalThis#')) {\n return OTHER\n }\n const symbol = ctx.project.lookupIdentity(identity)\n if (symbol.kind !== 'declaration') {\n return OTHER\n }\n const declaration = symbol.declarations.find(candidate => candidate.kind === 'const')\n const node = declaration?.node as unknown\n const file = declaration ? ctx.project.getFile(declaration.file) : undefined\n if (!declaration || !isNode(node) || !file) {\n return OTHER\n }\n const scope = { file, namespace: declaration.namespace } as unknown as ScopeInput\n const init = child(node, 'init')\n if (!init) {\n // `export declare const Roles: RouteDecorator<string[]>` (declaration file): the key is lost\n const annotation = child(child(node, 'id') ?? node, 'typeAnnotation')\n const type = annotation\n ? ctx.project.resolveType(scope, annotation as unknown as Parameters<Project['resolveType']>[1])\n : undefined\n if (type?.kind === 'reference' && type.identity === Ids.RouteDecorator) {\n return {\n kind: 'invalid',\n message: `the key of the route decorator ${declaration.name} cannot be read: it is declared without initializer`,\n hints: [\n 'Route decorators must be declared in analysed sources: `export const X = createRouteDecorator(key)`',\n 'For a provider library, publish its sources (\"znight\": { \"library\": \"source\" })',\n ],\n }\n }\n return OTHER\n }\n const call = unwrap(init)\n const callee = call.type === 'CallExpression' ? child(call, 'callee') : undefined\n if (!callee || !isEntityName(unwrap(callee))) {\n return OTHER\n }\n const resolved = ctx.project.resolveIdentifier(scope, unwrap(callee) as unknown as EntityName, 'value')\n if (resolved.identity?.identity !== Ids.createRouteDecorator) {\n return OTHER\n }\n const definition = file.location(declaration.span)\n const [keyNode, optionsNode, ...extra] = children(call, 'arguments')\n if (!keyNode || keyNode.type === 'SpreadElement') {\n return {\n kind: 'invalid',\n message: `createRouteDecorator() requires a key (${declaration.name})`,\n hints: [`export const ${declaration.name} = createRouteDecorator('${declaration.name.toLowerCase()}')`],\n definition,\n }\n }\n const key = ctx.project.evaluate(scope, keyNode as unknown as ExpressionInput, { refs: 'none' })\n if (key.kind !== 'value' || typeof key.value !== 'string' || key.value === '') {\n return {\n kind: 'invalid',\n message: `the key of the route decorator ${declaration.name} must be a statically evaluable non-empty string`,\n hints: [\"Use a string literal or a `const` string: createRouteDecorator('roles')\"],\n definition,\n }\n }\n const optionsHints = [\n `export const ${declaration.name} = createRouteDecorator('${key.value}', { group: 'access', required: true })`,\n ]\n if (extra.length > 0 || optionsNode?.type === 'SpreadElement') {\n return {\n kind: 'invalid',\n message: `createRouteDecorator() takes a key and an optional { group?, required? } object (${declaration.name})`,\n hints: optionsHints,\n definition,\n }\n }\n let options: StaticValue\n if (optionsNode !== undefined) {\n const evaluated = ctx.project.evaluate(scope, optionsNode as unknown as ExpressionInput, { refs: 'none' })\n if (evaluated.kind !== 'value') {\n return {\n kind: 'invalid',\n message: `the options of the route decorator ${declaration.name} must be statically evaluable (literals and \\`const\\` references)`,\n hints: optionsHints,\n definition,\n }\n }\n options = evaluated.value\n }\n const parsed = parseRouteDecoratorOptions(key.value, options)\n if ('error' in parsed) {\n return {\n kind: 'invalid',\n message: `the options of the route decorator ${declaration.name} ${parsed.error}`,\n hints: optionsHints,\n definition,\n }\n }\n return { kind: 'route', key: key.value, ...parsed, name: declaration.name, definition }\n}\n\n/**\n * The group and `required` of a route decorator from its evaluated options (`undefined`: the\n * defaults), or why the options are invalid.\n */\nexport function parseRouteDecoratorOptions(\n key: string,\n options: StaticValue,\n): { readonly group: string; readonly required: boolean } | { readonly error: string } {\n if (options === undefined) {\n return { group: key, required: false }\n }\n if (!isPlainObject(options)) {\n return { error: 'must be an object { group?, required? }' }\n }\n const unknown = Object.keys(options).find(name => name !== 'group' && name !== 'required')\n if (unknown !== undefined) {\n return { error: `have an unknown property \"${unknown}\" (expected group and required)` }\n }\n // the grammar applies to an explicit group only: without one, any key is its own group\n const group = options['group'] ?? key\n if (typeof group !== 'string' || (group !== key && !GROUP_NAME.test(group))) {\n const shown = typeof group === 'object' && group !== null ? 'a reference' : JSON.stringify(group)\n return { error: `have an invalid group ${shown}: a letter followed by letters, digits, _ . or -` }\n }\n const required = options['required'] ?? false\n if (typeof required !== 'boolean') {\n return { error: 'have a non-boolean \"required\"' }\n }\n return { group, required }\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, StaticValue> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return false\n }\n const prototype = Object.getPrototypeOf(value)\n return prototype === Object.prototype || prototype === null\n}\n\nfunction isEntityName(node: AstNode): boolean {\n if (node.type === 'Identifier') {\n return true\n }\n if (node.type === 'MemberExpression' && node['computed'] !== true) {\n const object = child(node, 'object')\n return child(node, 'property')?.type === 'Identifier' && object !== undefined && isEntityName(object)\n }\n return false\n}\n\n/**\n * Metadata entries of the route decorators applied to a class or a method (source order).\n * `target` names the class or the handler (`BookController`, `BookController.remove`). Problems are\n * reported as ZNIGHT005: two decisions of one group on the same target included.\n */\nexport function routeMeta(\n ctx: Context,\n cls: ClassInfo,\n decorators: readonly DecoratorInfo[],\n target: string,\n): MetaEntry[] {\n const entries: MetaEntry[] = []\n for (const decorator of decorators) {\n if (decorator.owner !== undefined || decorator.identity === undefined) {\n continue\n }\n const resolution = resolveRouteDecorator(ctx, decorator.identity)\n if (resolution.kind === 'other') {\n continue\n }\n if (resolution.kind === 'invalid') {\n report(\n ctx,\n decorator,\n `Invalid route decorator @${decorator.name}: ${resolution.message}`,\n resolution.hints,\n resolution.definition === undefined\n ? undefined\n : { message: 'The route decorator is defined here', location: resolution.definition },\n )\n continue\n }\n const value = metaValue(ctx, cls, decorator)\n if (value === INVALID) {\n continue\n }\n const previous = entries.find(entry => entry.group === resolution.group)\n if (previous) {\n if (previous.key === resolution.key && resolution.group === resolution.key) {\n report(\n ctx,\n decorator,\n `@${decorator.name} sets the route metadata '${resolution.key}', already set on the same target`,\n ['Apply each route decorator once per controller or route'],\n { message: 'First applied here', location: previous.location },\n )\n } else {\n const alternatives =\n previous.decorator === resolution.name\n ? `@${resolution.name} once`\n : `one of @${previous.decorator}, @${resolution.name}`\n report(\n ctx,\n decorator,\n `@${resolution.name} sets the \"${resolution.group}\" decision of ${target}, already set by @${previous.decorator} on the same target`,\n [`Keep ${alternatives}: the decorators of the \"${resolution.group}\" group are alternatives`],\n { message: 'First applied here', location: previous.location },\n )\n }\n continue\n }\n entries.push({\n key: resolution.key,\n value,\n location: decorator.location,\n group: resolution.group,\n required: resolution.required,\n decorator: resolution.name,\n identity: decorator.identity,\n definition: resolution.definition,\n })\n }\n return entries\n}\n\n/**\n * The route metadata entries of a class (`method` omitted) or of one of its methods: the route\n * decorators (`createRouteDecorator` consts) applied to that target, in source order, read exactly\n * as the http extension reads controllers and routes (keys, statically evaluated values, groups,\n * `required`). Problems are reported as ZNIGHT005 through `ctx`, once per call: read each target\n * once. Decorators that are not route decorators are ignored.\n *\n * Works with the analysis context of any extension. The entries of a target are its own: combine a\n * class and a method with {@link effectiveRouteMeta}.\n *\n * ```ts\n * analyzeClass(cls, ctx) {\n * const classMeta = readRouteMeta(ctx, cls)\n * for (const method of cls.methods) {\n * const meta = effectiveRouteMeta(classMeta, readRouteMeta(ctx, cls, method))\n * }\n * }\n * ```\n */\nexport function readRouteMeta(ctx: AnalyzeContext<unknown>, cls: ClassInfo, method?: MethodInfo): MetaEntry[] {\n return method === undefined\n ? routeMeta(ctx, cls, cls.decorators, cls.displayName)\n : routeMeta(ctx, cls, method.decorators, `${cls.displayName}.${method.name}`)\n}\n\n/**\n * The effective metadata of a method from the entries of its class and its own (RFC 0001 §5.1):\n * the class entries, except those of a group the method decides itself, then the method entries.\n * The same rule as `ctx.route.meta` at runtime.\n */\nexport function effectiveRouteMeta(classMeta: readonly MetaEntry[], methodMeta: readonly MetaEntry[]): MetaEntry[] {\n if (methodMeta.length === 0) {\n return [...classMeta]\n }\n const decided = new Set(methodMeta.map(entry => entry.group))\n return [...classMeta.filter(entry => !decided.has(entry.group)), ...methodMeta]\n}\n\n/** `true` when the decorator is a route metadata decorator. */\nexport function isRouteMetaDecorator(ctx: Context, decorator: DecoratorInfo): boolean {\n return (\n decorator.owner === undefined &&\n decorator.identity !== undefined &&\n resolveRouteDecorator(ctx, decorator.identity).kind !== 'other'\n )\n}\n\nconst INVALID: unique symbol = Symbol('invalid')\n\nfunction metaValue(ctx: Context, cls: ClassInfo, decorator: DecoratorInfo): StaticValue | typeof INVALID {\n if (!decorator.called) {\n report(ctx, decorator, `@${decorator.name} must be called: @${decorator.name}()`, [\n `Write @${decorator.name}(${decorator.args.length > 0 ? '...' : ''})`,\n ])\n return INVALID\n }\n const [arg, ...extra] = decorator.args\n if (arg === undefined) {\n return true\n }\n if (extra.length > 0) {\n report(ctx, decorator, `@${decorator.name} takes at most one argument`, [\n 'Pass a single value (an array or an object)',\n ])\n return INVALID\n }\n if (arg.text.startsWith('...')) {\n report(ctx, decorator, `@${decorator.name} does not accept spread arguments`, ['Pass the value directly'])\n return INVALID\n }\n const evaluation = ctx.project.evaluate(cls.file, arg.node as unknown as ExpressionInput, { refs: 'nested' })\n switch (evaluation.kind) {\n case 'value':\n return checkRefs(ctx, decorator, evaluation.value) ? evaluation.value : INVALID\n case 'ref':\n return checkRefs(ctx, decorator, evaluation.ref) ? evaluation.ref : INVALID\n case 'error': {\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'error',\n message: `Invalid argument of @${decorator.name}: ${evaluation.error.message}`,\n location: evaluation.error.location,\n hints: [evaluation.error.hint ?? 'Extract the value to `export const X = ...` and reference it'],\n })\n return INVALID\n }\n }\n}\n\n/** Checks that every reference of a value can be imported by the generated module. */\nfunction checkRefs(ctx: Context, decorator: DecoratorInfo, value: StaticValue): boolean {\n let ok = true\n const visit = (current: StaticValue): void => {\n if (isValueRef(current)) {\n const route = ctx.project.importRoute(current.symbol)\n if (!route.ok) {\n ok = false\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'error',\n message: `Invalid argument of @${decorator.name}: '${current.text}' cannot be imported by the generated module (${route.error.message})`,\n location: current.location,\n hints: route.error.hints.length > 0 ? [...route.error.hints] : ['Export it from its module'],\n })\n }\n return\n }\n if (Array.isArray(current)) {\n for (const item of current) {\n visit(item)\n }\n } else if (typeof current === 'object' && current !== null) {\n for (const item of Object.values(current)) {\n visit(item)\n }\n }\n }\n visit(value)\n return ok\n}\n\n/** `true` for a {@link ValueRef} (the only non-plain object a static value can hold). */\nexport function isValueRef(value: unknown): value is ValueRef {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return false\n }\n const prototype = Object.getPrototypeOf(value)\n return prototype !== Object.prototype && prototype !== null && (value as { kind?: unknown }).kind === 'ref'\n}\n\nfunction report(\n ctx: Context,\n decorator: DecoratorInfo,\n message: string,\n hints: readonly string[],\n related?: { readonly message: string; readonly location: Diagnostic['location'] },\n): void {\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'error',\n message,\n location: decorator.location,\n hints,\n ...(related?.location ? { related: [{ message: related.message, location: related.location }] } : {}),\n })\n}\n","/**\n * `analyzeClass` of the `@znight/http` compiler extension: controllers, routes, parameters,\n * guards, interceptors, statuses, headers and route metadata. Everything is checked here except\n * what needs the whole application (paths and duplicate routes, see `validate.ts`).\n */\nimport type {\n AnalyzeContext,\n ArgInfo,\n ClassInfo,\n ClassRef,\n DecoratorInfo,\n Location,\n MethodInfo,\n ParamDecoratorUse,\n ParameterInfo,\n StaticValue,\n TypeInfo,\n ValueRef,\n} from '@znight/compiler'\nimport type { HttpMethod } from '../metadata.ts'\nimport type {\n HttpControllerData,\n HttpParamData,\n HttpRouteData,\n ParamCoercion,\n SseRouteData,\n UploadData,\n} from './model.ts'\n\nimport { isMediaTypePattern } from '../mime.ts'\nimport { joinPaths, normalizePath } from '../path.ts'\nimport { parseByteSize } from '../size.ts'\nimport { acceptsUndefined, isRaw, parameterType, planCoercion } from './coercion.ts'\nimport { Codes, HTTP_PACKAGE, Ids, PARAM_SOURCES, ROUTE_METHODS } from './model.ts'\nimport { isRouteMetaDecorator, isValueRef, readRouteMeta } from './route-decorators.ts'\n\n/** Name of the extension (owner of the decorators in `DecoratorInfo.owner`). */\nexport const EXTENSION_NAME = 'http'\n\ntype Context = AnalyzeContext<HttpControllerData>\ntype Scope = 'singleton' | 'request' | 'transient'\n\nconst SCOPES: readonly Scope[] = ['singleton', 'request', 'transient']\n/** RFC 9110 token (header names). */\nconst TOKEN = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/\n/** Types an upload parameter may have (`File`, `Blob`, arrays of them for `@UploadedFiles`); `true`: cast needed. */\nconst FILE_TYPES: ReadonlyMap<string, boolean> = new Map([\n ['globalThis#File', false],\n ['globalThis#Blob', false],\n ['node:buffer#File', true],\n ['node:buffer#Blob', true],\n])\n/** Methods whose requests usually have no body (upload parameters there are a warning). */\nconst BODYLESS_METHODS: ReadonlySet<HttpMethod> = new Set<HttpMethod>(['GET', 'HEAD', 'DELETE', 'OPTIONS'])\nconst UPLOAD_OPTIONS = ['required', 'maxSize', 'maxFiles', 'mimeTypes']\n/** Smallest `@Sse` heartbeat and `maxDuration` (ms). */\nconst MIN_SSE_INTERVAL_MS = 1_000\n/** Longest `@Sse` heartbeat and `maxDuration` (ms): the longest `setTimeout` delay. */\nconst MAX_SSE_TIMER_MS = 2_147_483_647\n/** Primitive return types an `@Sse` handler cannot return (`any`, `unknown`, `object`, `never` are accepted). */\nconst NOT_SSE_SOURCES: ReadonlySet<string> = new Set([\n 'string',\n 'number',\n 'boolean',\n 'bigint',\n 'symbol',\n 'undefined',\n 'null',\n 'void',\n])\n/** Values that are fine without schema (`@Body() body: string`, `@Body() bytes: Uint8Array`...). */\nconst UNVALIDATED_REFERENCES = new Set([\n 'globalThis#Uint8Array',\n 'globalThis#ArrayBuffer',\n 'globalThis#Buffer',\n 'globalThis#Blob',\n 'globalThis#FormData',\n 'node:buffer#Buffer',\n '@znight/http#QueryRecord',\n])\n\n/** Analyses a class carrying at least one `@znight/http` decorator. */\nexport function analyzeHttpClass(cls: ClassInfo, ctx: Context): void {\n const controllers = cls.decorators.filter(decorator => decorator.identity === Ids.Controller)\n const [controller] = controllers\n if (controller === undefined) {\n reportOutsideController(cls, ctx)\n return\n }\n for (const duplicate of controllers.slice(1)) {\n error(ctx, duplicate.location, `@Controller is applied several times to ${cls.displayName}`, [\n 'Keep a single @Controller()',\n ])\n }\n const options = controllerOptions(ctx, controller)\n const token = ctx.registerProvider(cls, { scope: options.scope })\n const basePath = normalizePath(options.path)\n const guards = classRefs(ctx, cls, cls.decorators, Ids.UseGuard, 'guard')\n const interceptors = classRefs(ctx, cls, cls.decorators, Ids.UseInterceptor, 'interceptor')\n const meta = readRouteMeta(ctx, cls)\n const bodyLimit = bodyLimitOf(ctx, cls.decorators)\n const routes: HttpRouteData[] = []\n for (const method of cls.methods) {\n routes.push(...analyzeMethod(ctx, cls, method, basePath, bodyLimit))\n }\n ctx.store({\n token,\n identity: cls.identity,\n displayName: cls.displayName,\n rawBasePath: options.path,\n basePath,\n guards,\n interceptors,\n meta,\n routes,\n location: controller.location,\n pathLocation: options.pathLocation,\n })\n}\n\n// -------------------------------------------------------------------------------------------------\n// Controller\n// -------------------------------------------------------------------------------------------------\n\ninterface ControllerOptions {\n readonly path: string\n readonly pathLocation: Location\n readonly scope: Scope\n}\n\nfunction controllerOptions(ctx: Context, decorator: DecoratorInfo): ControllerOptions {\n const [arg] = decorator.args\n const defaults: ControllerOptions = { path: '', pathLocation: decorator.location, scope: 'singleton' }\n if (arg === undefined || !arg.evaluated) {\n // missing, or not evaluable (already reported)\n return defaults\n }\n const value = arg.value\n if (typeof value === 'string') {\n return { ...defaults, path: value, pathLocation: arg.location }\n }\n if (!isPlainObject(value)) {\n error(ctx, arg.location, `@Controller expects a path or { path?, scope? }, got ${describe(value)}`, [\n \"@Controller('/users') or @Controller({ path: '/users', scope: 'request' })\",\n ])\n return defaults\n }\n let { path, scope } = defaults\n for (const [key, option] of Object.entries(value)) {\n if (key === 'path') {\n if (typeof option === 'string') {\n path = option\n } else if (option !== undefined) {\n error(ctx, arg.location, `@Controller: \"path\" must be a string, got ${describe(option)}`)\n }\n } else if (key === 'scope') {\n if (SCOPES.includes(option as Scope)) {\n scope = option as Scope\n } else if (option !== undefined) {\n error(ctx, arg.location, `@Controller: invalid scope ${describe(option)}`, [\n `Use one of ${SCOPES.map(candidate => `'${candidate}'`).join(', ')}`,\n ])\n }\n } else {\n error(ctx, arg.location, `@Controller: unknown option \"${key}\"`, ['Options: { path?, scope? }'])\n }\n }\n return { path, pathLocation: arg.location, scope }\n}\n\n/**\n * HTTP decorators on a class that is not a controller have no effect. On a class another extension\n * owns (a `@Consumer` of `@znight/messaging`...), adding `@Controller()` is no fix: a class is the\n * provider of a single extension.\n */\nfunction reportOutsideController(cls: ClassInfo, ctx: Context): void {\n const owner = foreignOwner(cls)\n const hint =\n owner === undefined\n ? [`Add @Controller() to ${cls.displayName} (routes are not inherited from base classes)`]\n : [\n `${cls.displayName} is a @${owner.name} class of '${owner.module}': HTTP decorators only apply to @Controller() classes`,\n ]\n const decorators: DecoratorInfo[] = [...cls.decorators]\n for (const method of cls.methods) {\n decorators.push(...method.decorators)\n const handler =\n owner === undefined ? undefined : method.decorators.find(decorator => decorator.owner === owner.decorator.owner)\n if (owner !== undefined && handler !== undefined) {\n reportHandlerParams(ctx, cls, method, owner, handler)\n continue\n }\n for (const param of method.params) {\n decorators.push(...unique(param.decorators))\n }\n }\n for (const decorator of decorators) {\n if (decorator.owner === EXTENSION_NAME && validTarget(decorator)) {\n error(ctx, decorator.location, `@${decorator.name} has no effect: ${cls.displayName} is not a controller`, hint)\n }\n }\n}\n\n/**\n * HTTP decorators on the parameters of a handler of the extension owning the class (an `@OnMessage`\n * handler...). That extension reads its handlers' parameters and reports those it cannot read\n * (`Headers` imported from `@znight/http` instead of `@znight/messaging`...): an HTTP decorator is\n * only reported here when the parameter is read through a decorator of that extension, or is\n * optional (left undefined without a word).\n */\nfunction reportHandlerParams(\n ctx: Context,\n cls: ClassInfo,\n method: MethodInfo,\n owner: QualifiedDecorator,\n handler: DecoratorInfo,\n): void {\n for (const param of method.params) {\n const read = param.decorators.some(decorator => decorator.owner === owner.decorator.owner)\n if (!read && !param.optional && !param.hasDefault && !param.rest) {\n continue\n }\n for (const decorator of unique(param.decorators)) {\n if (decorator.owner === EXTENSION_NAME && validTarget(decorator)) {\n error(\n ctx,\n decorator.location,\n `@${decorator.name} has no effect on parameter '${param.name}' of ${cls.displayName}.${method.name}: it is an @${handler.name} handler of '${owner.module}'`,\n [`Use the parameter decorators of '${owner.module}', or remove it`],\n )\n }\n }\n }\n}\n\n/** A decorator with the module and the export name of its identity (`'@znight/messaging#Consumer'`). */\ninterface QualifiedDecorator {\n readonly decorator: DecoratorInfo\n readonly module: string\n readonly name: string\n}\n\nfunction qualify(decorator: DecoratorInfo): QualifiedDecorator | undefined {\n const identity = decorator.identity\n const separator = identity?.lastIndexOf('#') ?? -1\n if (identity === undefined || separator <= 0) {\n return undefined\n }\n return { decorator, module: identity.slice(0, separator), name: identity.slice(separator + 1) }\n}\n\n/** The class decorator through which another extension owns the class (`@Consumer`...). */\nfunction foreignOwner(cls: ClassInfo): QualifiedDecorator | undefined {\n for (const decorator of cls.decorators) {\n const owner = decorator.owner\n if (owner === undefined || owner === EXTENSION_NAME || owner === 'core' || owner === 'manifest') {\n continue\n }\n const qualified = qualify(decorator)\n if (qualified !== undefined) {\n return qualified\n }\n }\n return undefined\n}\n\n/**\n * A parameter decorator named like an HTTP one but imported from another package (`Headers` and\n * `Ctx` of `@znight/messaging`, typically auto-imported).\n */\nfunction foreignParameterDecorator(param: ParameterInfo): QualifiedDecorator | undefined {\n for (const decorator of unique(param.decorators)) {\n const qualified = qualify(decorator)\n if (\n qualified !== undefined &&\n qualified.module !== HTTP_PACKAGE &&\n PARAM_SOURCES.has(`${HTTP_PACKAGE}#${qualified.name}`)\n ) {\n return qualified\n }\n }\n return undefined\n}\n\n// -------------------------------------------------------------------------------------------------\n// Routes\n// -------------------------------------------------------------------------------------------------\n\nfunction analyzeMethod(\n ctx: Context,\n cls: ClassInfo,\n method: MethodInfo,\n basePath: string,\n controllerBodyLimit: number | undefined,\n): HttpRouteData[] {\n const where = `${cls.displayName}.${method.name}`\n let routeDecorators = method.decorators.filter(decorator => ROUTE_METHODS.has(decorator.identity ?? ''))\n if (routeDecorators.length === 0) {\n reportNotARoute(ctx, method, where)\n return []\n }\n if (!checkHandler(ctx, method, where, routeDecorators[0] as DecoratorInfo)) {\n return []\n }\n const sseDecorator = routeDecorators.find(decorator => decorator.identity === Ids.Sse)\n if (sseDecorator !== undefined) {\n // one handler per event stream: the other route decorators are reported and ignored\n for (const other of routeDecorators) {\n if (other === sseDecorator) {\n continue\n }\n error(\n ctx,\n other.location,\n other.identity === Ids.Sse\n ? `@Sse is applied several times to ${where}`\n : `@${other.name} cannot be combined with @Sse on ${where}`,\n [\n 'One handler per event stream: declare other routes on other methods (HttpResponse.sse() serves an event stream from any route)',\n ],\n )\n }\n routeDecorators = [sseDecorator]\n }\n const decorators = method.decorators\n const bodyValidation = validateSchema(ctx, decorators)\n const { params, complete } = analyzeParams(ctx, cls, method, where, bodyValidation)\n let status = httpCode(ctx, decorators)\n let headers = responseHeaders(ctx, decorators)\n const guards = classRefs(ctx, cls, decorators, Ids.UseGuard, 'guard')\n const interceptors = classRefs(ctx, cls, decorators, Ids.UseInterceptor, 'interceptor')\n const meta = readRouteMeta(ctx, cls, method)\n const bodySchema =\n bodyValidation !== undefined && !params.some(param => param.source === 'body') ? bodyValidation.schema : undefined\n let rawResponse = params.some(param => param.source === 'response')\n const bodyLimit = bodyLimitOf(ctx, decorators) ?? controllerBodyLimit\n const uploads = checkUploads(ctx, params, where)\n if (sseDecorator !== undefined) {\n checkSseHandler(ctx, method, params, where, bodyValidation)\n status = undefined\n headers = headers.filter(([name]) => name !== 'content-type')\n rawResponse = false\n }\n\n const routes: HttpRouteData[] = []\n for (const decorator of routeDecorators) {\n const httpMethod = ROUTE_METHODS.get(decorator.identity ?? '') as HttpMethod\n const target = decorator === sseDecorator ? sseArgs(ctx, decorator) : routePath(ctx, decorator)\n if (target === undefined) {\n continue\n }\n const { rawPath, arg } = target\n const path = normalizePath(rawPath)\n if (uploads && BODYLESS_METHODS.has(httpMethod)) {\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'warning',\n message: `${where} reads uploaded files but is a ${httpMethod} route: ${httpMethod} requests usually have no body`,\n location: decorator.location,\n hints: ['Upload files with @Post(), @Put() or @Patch()'],\n })\n }\n routes.push({\n method: httpMethod,\n rawPath,\n path,\n fullPath: joinPaths(basePath, path),\n handler: method.name,\n status,\n headers,\n meta,\n guards,\n interceptors,\n params,\n complete,\n bodySchema,\n bodyLimit,\n rawResponse,\n ...(target.sse === undefined ? {} : { sse: target.sse }),\n location: decorator.location,\n pathLocation: arg?.location ?? decorator.location,\n })\n }\n return routes\n}\n\n/** The path of a route decorator, its argument and, for `@Sse`, its options. */\ninterface RouteTarget {\n readonly rawPath: string\n readonly arg: ArgInfo | undefined\n readonly sse?: SseRouteData\n}\n\n/** The path argument of a route decorator (`undefined` after an error). */\nfunction routePath(ctx: Context, decorator: DecoratorInfo): RouteTarget | undefined {\n const [arg] = decorator.args\n if (arg === undefined) {\n return { rawPath: '', arg }\n }\n if (!arg.evaluated) {\n return undefined // not evaluable: already reported\n }\n if (typeof arg.value !== 'string') {\n error(ctx, arg.location, `@${decorator.name} expects a path (string), got ${describe(arg.value)}`, [\n `@${decorator.name}('/:id')`,\n ])\n return undefined\n }\n return { rawPath: arg.value, arg }\n}\n\n/** `@Sse(path?, options?)` / `@Sse(options)`: the path and the options (`undefined` after an error). */\nfunction sseArgs(ctx: Context, decorator: DecoratorInfo): RouteTarget | undefined {\n const [first, second] = decorator.args\n let pathArg: ArgInfo | undefined\n let options: ArgInfo | undefined\n if (first !== undefined) {\n if (!first.evaluated) {\n return undefined // already reported\n }\n if (typeof first.value === 'string') {\n pathArg = first\n options = second\n } else if (first.value === undefined) {\n options = second\n } else if (isPlainObject(first.value)) {\n if (second !== undefined) {\n error(ctx, second.location, '@Sse(options) takes a single argument', [\n \"Put the path first: @Sse('/events', { retry: 5000 })\",\n ])\n return undefined\n }\n options = first\n } else {\n error(ctx, first.location, `@Sse expects a path (string) or options, got ${describe(first.value)}`, [\n \"@Sse('/events'), @Sse('/events', { heartbeat: 15_000 }) or @Sse({ retry: 5000 })\",\n ])\n return undefined\n }\n }\n const sse = sseOptions(ctx, options)\n if (sse === undefined) {\n return undefined\n }\n return { rawPath: typeof pathArg?.value === 'string' ? pathArg.value : '', arg: pathArg, sse }\n}\n\n/** The static `{ heartbeat?, retry?, maxDuration? }` of `@Sse` (`undefined` after an error). */\nfunction sseOptions(ctx: Context, arg: ArgInfo | undefined): SseRouteData | undefined {\n if (arg === undefined) {\n return {}\n }\n if (!arg.evaluated) {\n return undefined\n }\n const shape = '{ heartbeat?: number | false, retry?: number, maxDuration?: number }'\n if (arg.value === undefined) {\n return {}\n }\n if (!isPlainObject(arg.value)) {\n error(ctx, arg.location, `@Sse options must be an object ${shape}, got ${describe(arg.value)}`)\n return undefined\n }\n const result: { heartbeat?: number; retry?: number; maxDuration?: number } = {}\n let ok = true\n const invalid = (message: string, hints: readonly string[] = []): void => {\n ok = false\n error(ctx, arg.location, `@Sse: ${message}`, hints)\n }\n const integer = (value: StaticValue, min: number, max = Number.MAX_SAFE_INTEGER): value is number =>\n typeof value === 'number' && Number.isSafeInteger(value) && value >= min && value <= max\n for (const [key, value] of Object.entries(arg.value)) {\n if (value === undefined) {\n continue\n }\n switch (key) {\n case 'heartbeat':\n if (value === false) {\n result.heartbeat = 0\n } else if (integer(value, MIN_SSE_INTERVAL_MS, MAX_SSE_TIMER_MS)) {\n result.heartbeat = value\n } else {\n invalid(\n `\"heartbeat\" must be an integer number of ms from ${MIN_SSE_INTERVAL_MS} to ${MAX_SSE_TIMER_MS}, or false, got ${describe(value)}`,\n ['Keep it below the idle timeouts of the proxies and of Bun.serve() (10 s): the default is 8 000'],\n )\n }\n break\n case 'retry':\n if (integer(value, 0)) {\n result.retry = value\n } else {\n invalid(`\"retry\" must be an integer number of ms ≥ 0, got ${describe(value)}`)\n }\n break\n case 'maxDuration':\n if (integer(value, MIN_SSE_INTERVAL_MS, MAX_SSE_TIMER_MS)) {\n result.maxDuration = value\n } else {\n invalid(\n `\"maxDuration\" must be an integer number of ms from ${MIN_SSE_INTERVAL_MS} to ${MAX_SSE_TIMER_MS} (about 24.8 days), got ${describe(value)}`,\n )\n }\n break\n default:\n invalid(`unknown option \"${key}\"`, [`Options: ${shape}`])\n }\n }\n return ok ? result : undefined\n}\n\n/**\n * `@Sse` handlers: the plugin writes the stream with status 200 and its own content type, so\n * `@HttpCode`, `@Header('content-type')` and `@Res()` are errors; a body is a warning (EventSource\n * sends `GET` without body); a primitive return type is an error.\n */\nfunction checkSseHandler(\n ctx: Context,\n method: MethodInfo,\n params: readonly HttpParamData[],\n where: string,\n bodyValidation: BodyValidation | undefined,\n): void {\n for (const decorator of method.decorators) {\n if (decorator.identity === Ids.HttpCode) {\n error(ctx, decorator.location, `@HttpCode has no effect on @Sse route ${where}: an event stream answers 200`, [\n 'Throw an HttpException or return an HttpResponse from the handler for other statuses',\n ])\n } else if (decorator.identity === Ids.Header) {\n const [name] = decorator.args\n if (name?.evaluated === true && typeof name.value === 'string' && name.value.toLowerCase() === 'content-type') {\n error(ctx, decorator.location, `@Header('content-type') has no effect on @Sse route ${where}`, [\n 'An event stream is always sent as text/event-stream; charset=utf-8',\n ])\n }\n }\n }\n for (const param of params) {\n if (param.source === 'response') {\n error(ctx, param.location, `@Res() cannot be used on @Sse route ${where}: the plugin writes the event stream`, [\n 'Return an AsyncIterable of SseEvent, or use a plain route to write the response yourself',\n ])\n }\n }\n const body = params.find(param => param.source === 'body' || param.upload !== undefined)\n const bodyLocation = body?.location ?? bodyValidation?.decorator.location\n if (bodyLocation !== undefined) {\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'warning',\n message: `@Sse route ${where} reads a request body: EventSource sends GET requests without body`,\n location: bodyLocation,\n hints: ['For fetch() clients streaming a POST, use @Post() and return HttpResponse.sse(source)'],\n })\n }\n const returned = method.returnType === undefined ? undefined : ctx.types.awaited(method.returnType)\n if (returned !== undefined && !method.generator) {\n const members = returned.kind === 'union' ? returned.types : [returned]\n const invalid = members.some(\n member => member.kind === 'literal' || (member.kind === 'primitive' && NOT_SSE_SOURCES.has(member.name)),\n )\n if (invalid) {\n error(\n ctx,\n method.location,\n `@Sse handler ${where} returns ${ctx.types.format(returned)}: return an AsyncIterable, an Iterable or a ReadableStream of SseEvent (or an HttpResponse)`,\n ['async events(): Promise<AsyncIterable<SseEvent<T>>> { ...; return channel }'],\n )\n }\n }\n}\n\n/** `@BodyLimit(size)` of a class or method, in bytes. */\nfunction bodyLimitOf(ctx: Context, decorators: readonly DecoratorInfo[]): number | undefined {\n const [decorator, ...duplicates] = decorators.filter(candidate => candidate.identity === Ids.BodyLimit)\n for (const duplicate of duplicates) {\n error(ctx, duplicate.location, '@BodyLimit is applied several times', ['Keep a single @BodyLimit(size)'])\n }\n if (decorator === undefined) {\n return undefined\n }\n const [arg] = decorator.args\n if (arg === undefined) {\n error(ctx, decorator.location, '@BodyLimit requires a size', [\"@BodyLimit('10mb') or @BodyLimit(10_485_760)\"])\n return undefined\n }\n if (!arg.evaluated) {\n return undefined\n }\n const size = parseByteSize(arg.value)\n if (size === undefined) {\n error(ctx, arg.location, `@BodyLimit expects a size in bytes, got ${describe(arg.value)}`, [\n \"A non-negative integer (10_485_760), a size with a unit ('10mb', '512kb'; kb = 1024 bytes) or Infinity\",\n ])\n }\n return size\n}\n\n/**\n * Checks the upload parameters of a handler together (one parameter per field; a parameter without\n * field takes every file and stands alone). Returns whether the handler reads uploaded files.\n */\nfunction checkUploads(ctx: Context, params: readonly HttpParamData[], where: string): boolean {\n const uploads = params.filter(param => param.upload !== undefined)\n uploads.forEach((param, index) => {\n const field = param.upload?.field\n const previous = uploads\n .slice(0, index)\n .find(other => field === undefined || other.upload?.field === undefined || other.upload.field === field)\n if (previous === undefined) {\n return\n }\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'error',\n message:\n field !== undefined && previous.upload?.field === field\n ? `The field \"${field}\" of ${where} is read by several upload parameters`\n : `${where}: an upload parameter without field receives every file of the body and cannot be combined with other upload parameters`,\n location: param.location,\n hints: ['Give each @UploadedFile / @UploadedFiles parameter its own field'],\n related: [{ message: 'Other upload parameter', location: previous.location }],\n })\n })\n return uploads.length > 0\n}\n\n/** HTTP method decorators (and parameter decorators) on a method without route decorator. */\nfunction reportNotARoute(ctx: Context, method: MethodInfo, where: string): void {\n const hint = [`Add a route decorator to ${where}: @Get(), @Post(), @Put(), @Patch(), @Delete()...`]\n for (const decorator of method.decorators) {\n if (decorator.owner === EXTENSION_NAME && validTarget(decorator)) {\n error(ctx, decorator.location, `@${decorator.name} has no effect: ${where} is not a route`, hint)\n } else if (isRouteMetaDecorator(ctx, decorator)) {\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'warning',\n message: `@${decorator.name} has no effect: ${where} is not a route`,\n location: decorator.location,\n hints: hint,\n })\n }\n }\n for (const param of method.params) {\n for (const decorator of unique(param.decorators)) {\n if (decorator.owner === EXTENSION_NAME && validTarget(decorator)) {\n error(ctx, decorator.location, `@${decorator.name} has no effect: ${where} is not a route`, hint)\n }\n }\n }\n}\n\n/** A route handler must be a public, non-static method with a plain name. */\nfunction checkHandler(ctx: Context, method: MethodInfo, where: string, decorator: DecoratorInfo): boolean {\n let problem: string | undefined\n let hint = 'Route handlers are public instance methods'\n if (method.static) {\n problem = `Static method ${where} cannot be a route handler`\n } else if (method.privateName) {\n problem = `#private method ${where} cannot be a route handler`\n hint = 'Use a public method (the generated code calls it from outside the class)'\n } else if (method.visibility !== 'public') {\n problem = `${method.visibility === 'protected' ? 'Protected' : 'Private'} method ${where} cannot be a route handler`\n hint = 'Make the method public (the generated code calls it from outside the class)'\n } else if (method.kind !== 'method') {\n problem = `Accessor ${where} cannot be a route handler`\n } else if (method.computed) {\n problem = `${where} cannot be a route handler: handlers need a plain name (no computed key)`\n }\n if (problem !== undefined) {\n error(ctx, decorator.location, problem, [hint])\n return false\n }\n return true\n}\n\nfunction httpCode(ctx: Context, decorators: readonly DecoratorInfo[]): number | undefined {\n const [decorator, ...duplicates] = decorators.filter(candidate => candidate.identity === Ids.HttpCode)\n for (const duplicate of duplicates) {\n error(ctx, duplicate.location, '@HttpCode is applied several times', ['Keep a single @HttpCode(status)'])\n }\n if (decorator === undefined) {\n return undefined\n }\n const [arg] = decorator.args\n if (arg === undefined) {\n error(ctx, decorator.location, '@HttpCode requires a status', ['@HttpCode(202)'])\n return undefined\n }\n if (!arg.evaluated) {\n return undefined\n }\n const status = arg.value\n if (typeof status !== 'number' || !Number.isInteger(status) || status < 100 || status > 599) {\n error(ctx, arg.location, `@HttpCode expects an integer status between 100 and 599, got ${describe(status)}`)\n return undefined\n }\n return status\n}\n\nfunction responseHeaders(ctx: Context, decorators: readonly DecoratorInfo[]): (readonly [string, string])[] {\n const headers: (readonly [string, string])[] = []\n const seen = new Map<string, Location>()\n for (const decorator of decorators) {\n if (decorator.identity !== Ids.Header) {\n continue\n }\n const [name, value] = decorator.args\n if (name === undefined || value === undefined) {\n error(ctx, decorator.location, '@Header requires a name and a value', [\"@Header('cache-control', 'no-store')\"])\n continue\n }\n if (!name.evaluated || !value.evaluated) {\n continue\n }\n if (typeof name.value !== 'string' || !TOKEN.test(name.value)) {\n error(ctx, name.location, `@Header: invalid header name ${describe(name.value)}`, [\n \"Header names are tokens: letters, digits and ! # $ % & ' * + - . ^ _ ` | ~\",\n ])\n continue\n }\n if (typeof value.value !== 'string' || /[\\r\\n\\0]/.test(value.value)) {\n error(ctx, value.location, `@Header: the value of \"${name.value}\" must be a string without line breaks`)\n continue\n }\n const lower = name.value.toLowerCase()\n const previous = seen.get(lower)\n if (previous) {\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'error',\n message: `@Header: \"${lower}\" is set several times`,\n location: decorator.location,\n hints: ['Set each response header once (or use ctx.appendHeader() in the handler)'],\n related: [{ message: 'First set here', location: previous }],\n })\n continue\n }\n seen.set(lower, decorator.location)\n headers.push([lower, value.value])\n }\n return headers\n}\n\ninterface BodyValidation {\n readonly schema: ValueRef\n readonly decorator: DecoratorInfo\n}\n\n/** `@Validate(schema)` of a handler. */\nfunction validateSchema(ctx: Context, decorators: readonly DecoratorInfo[]): BodyValidation | undefined {\n const [decorator, ...duplicates] = decorators.filter(candidate => candidate.identity === Ids.Validate)\n for (const duplicate of duplicates) {\n error(ctx, duplicate.location, '@Validate is applied several times', [\n 'Keep a single @Validate(schema): compose the validation in the schema',\n ])\n }\n if (decorator === undefined) {\n return undefined\n }\n const [arg] = decorator.args\n if (arg === undefined) {\n error(ctx, decorator.location, '@Validate requires a schema', ['@Validate(CreateUser)'])\n return undefined\n }\n const schema = schemaRef(ctx, arg, '@Validate')\n return schema ? { schema, decorator } : undefined\n}\n\n/** Guard / interceptor references of a class or method, bound to provider tokens (in order). */\nfunction classRefs(\n ctx: Context,\n cls: ClassInfo,\n decorators: readonly DecoratorInfo[],\n identity: string,\n role: string,\n): ClassRef[] {\n const refs: ClassRef[] = []\n for (const decorator of decorators) {\n if (decorator.identity !== identity) {\n continue\n }\n if (decorator.called && decorator.args.length === 0) {\n error(ctx, decorator.location, `@${decorator.name} requires at least one ${role}`, [\n `@${decorator.name}(My${role === 'guard' ? 'Guard' : 'Interceptor'})`,\n ])\n }\n for (const arg of decorator.args) {\n // binds the class (auto-registered as a singleton when it is not a provider) and declares the\n // controller → guard edge (ZNIGHT003, ZNIGHT019)\n const ref = ctx.resolveClassRef(arg, { from: cls, role })\n if (ref) {\n refs.push(ref)\n }\n }\n }\n return refs\n}\n\n// -------------------------------------------------------------------------------------------------\n// Parameters\n// -------------------------------------------------------------------------------------------------\n\nfunction analyzeParams(\n ctx: Context,\n cls: ClassInfo,\n method: MethodInfo,\n where: string,\n bodyValidation: BodyValidation | undefined,\n): { readonly params: HttpParamData[]; readonly complete: boolean } {\n const params: HttpParamData[] = []\n let complete = true\n for (const param of method.params) {\n const decorators = unique(param.decorators).filter(\n decorator => decorator.owner === EXTENSION_NAME && PARAM_SOURCES.has(decorator.identity ?? ''),\n )\n // custom parameter decorators (RFC 0010); compilers before it have no paramDecorator\n const custom = typeof ctx.paramDecorator === 'function' ? ctx.paramDecorator(param, 'http', cls) : undefined\n if (custom !== undefined) {\n for (const other of decorators) {\n error(\n ctx,\n other.location,\n `Parameter '${param.name}' of ${where} has several parameter decorators (@${custom.decorator.name} and @${other.name})`,\n ['Keep a single parameter decorator'],\n )\n }\n if (custom.ok && decorators.length === 0) {\n params.push(customParam(param, custom))\n } else {\n complete = false\n }\n continue\n }\n const [decorator, ...extra] = decorators\n const foreign = decorator === undefined ? foreignParameterDecorator(param) : undefined\n if (foreign !== undefined) {\n error(\n ctx,\n foreign.decorator.location,\n `@${foreign.decorator.name} on parameter '${param.name}' of ${where} is imported from '${foreign.module}': route parameters use ${foreign.name} from '${HTTP_PACKAGE}'`,\n [`Import it from '${HTTP_PACKAGE}': import { ${foreign.name} } from '${HTTP_PACKAGE}'`],\n )\n complete = false\n continue\n }\n if (decorator === undefined) {\n error(ctx, param.location, `Parameter '${param.name}' of ${where} has no HTTP decorator`, [\n 'Decorate it with @Param(), @Query(), @Body(), @Headers(), @Cookie(), @SignedCookie(), @UploadedFile(), @UploadedFiles(), @Ctx(), @Req() or @Res()',\n ])\n complete = false\n continue\n }\n for (const other of extra) {\n error(ctx, other.location, `Parameter '${param.name}' of ${where} has several HTTP decorators`, [\n 'Keep a single parameter decorator',\n ])\n }\n if (param.rest) {\n error(ctx, decorator.location, `Rest parameter '${param.name}' of ${where} cannot be injected`)\n complete = false\n continue\n }\n const data = analyzeParam(ctx, cls, method, param, decorator, where, bodyValidation)\n if (data) {\n params.push(data)\n } else {\n complete = false\n }\n }\n return { params, complete }\n}\n\n/** A custom parameter (`source: 'custom'`, the decorator name as `name`). */\nfunction customParam(param: ParameterInfo, use: Extract<ParamDecoratorUse, { readonly ok: true }>): HttpParamData {\n const data = use.data\n return {\n index: param.index,\n name: param.name,\n source: 'custom',\n key: use.name,\n type: undefined,\n optional: param.optional || param.hasDefault,\n schema: undefined,\n coercion: undefined,\n custom: {\n identity: use.identity,\n name: use.name,\n data: data === undefined ? undefined : { value: data.ref ?? (data.value as StaticValue) },\n resolver: use.resolver.kind === 'class' ? use.resolver.ref : undefined,\n ...(use.resolver.kind === 'class' && use.resolver.arity !== undefined ? { arity: use.resolver.arity } : {}),\n cast: use.cast,\n },\n location: use.location,\n }\n}\n\nfunction analyzeParam(\n ctx: Context,\n cls: ClassInfo,\n method: MethodInfo,\n param: ParameterInfo,\n decorator: DecoratorInfo,\n where: string,\n bodyValidation: BodyValidation | undefined,\n): HttpParamData | undefined {\n const source = PARAM_SOURCES.get(decorator.identity ?? '')\n if (source === undefined) {\n return undefined\n }\n const declared = parameterType(ctx, cls, method, param)\n const defaultValue = staticDefault(param)\n const base: Omit<HttpParamData, 'key' | 'schema' | 'coercion' | 'optional'> = {\n index: param.index,\n name: param.name,\n source,\n type: undefined,\n ...(defaultValue === undefined ? {} : { defaultValue: defaultValue.value }),\n location: decorator.location,\n }\n // the declared type is recorded for coerced values (informational, `params[i].type`)\n const type = declared.type === undefined ? undefined : ctx.types.format(declared.type)\n const plain = (): HttpParamData => ({\n ...base,\n key: undefined,\n optional: false,\n schema: undefined,\n coercion: undefined,\n })\n\n switch (source) {\n case 'request':\n case 'context':\n return plain()\n case 'response':\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'warning',\n message: `@Res() makes ${where} adapter-specific: the handler writes the native response itself`,\n location: decorator.location,\n hints: ['Prefer returning a value, an HttpResponse or a Web Response (portable across adapters)'],\n })\n return plain()\n case 'body': {\n const [arg] = decorator.args\n let schema: ValueRef | undefined\n if (arg !== undefined) {\n schema = schemaRef(ctx, arg, '@Body')\n if (schema === undefined) {\n return undefined\n }\n }\n if (bodyValidation !== undefined) {\n if (schema !== undefined) {\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'error',\n message: `The body of ${where} is validated twice: @Validate(${bodyValidation.schema.text}) and @Body(${schema.text})`,\n location: bodyValidation.decorator.location,\n hints: ['Keep one of them: @Validate(S) on the method is the same as @Body(S) on the parameter'],\n related: [{ message: '@Body schema', location: decorator.location }],\n })\n return undefined\n }\n schema = bodyValidation.schema\n }\n if (schema === undefined) {\n checkUnvalidated(ctx, declared.type, decorator, param, where, 'body')\n }\n return { ...base, key: undefined, optional: declared.optional, schema, coercion: undefined }\n }\n case 'file':\n case 'files': {\n const upload = uploadOf(ctx, decorator, param, declared, where, source === 'files')\n return upload === undefined\n ? undefined\n : {\n ...base,\n key: upload.field,\n optional: !upload.required,\n schema: undefined,\n coercion: undefined,\n upload,\n }\n }\n case 'headers': {\n const [arg] = decorator.args\n if (arg === undefined) {\n return plain()\n }\n if (!arg.evaluated) {\n return undefined\n }\n if (typeof arg.value !== 'string' || !TOKEN.test(arg.value)) {\n error(ctx, arg.location, `@Headers: invalid header name ${describe(arg.value)}`, [\n \"@Headers('x-api-key'), or @Headers() for every header\",\n ])\n return undefined\n }\n const key = arg.value.toLowerCase()\n const coercion = coercionOf(ctx, declared, param, decorator, where, 'headers', key)\n return coercion ? { ...base, key, type, optional: declared.optional, schema: undefined, coercion } : undefined\n }\n case 'param':\n case 'query': {\n const parsed = nameAndSchema(ctx, decorator)\n if (!parsed.ok) {\n return undefined\n }\n const { key, schema } = parsed\n const optional = source === 'query' && declared.optional\n if (schema !== undefined) {\n return { ...base, key, optional, schema, coercion: undefined }\n }\n if (key === undefined) {\n if (source === 'query') {\n checkUnvalidated(ctx, declared.type, decorator, param, where, 'query')\n }\n return { ...base, key, optional: false, schema: undefined, coercion: undefined }\n }\n const coercion = coercionOf(ctx, declared, param, decorator, where, source, key)\n return coercion ? { ...base, key, type, optional, schema: undefined, coercion } : undefined\n }\n case 'cookie':\n case 'signedCookie':\n return cookieParam(ctx, param, decorator, declared, where, base, type)\n }\n}\n\n/** `@Cookie(name?, schema?)` / `@SignedCookie(name, schema?)`. */\nfunction cookieParam(\n ctx: Context,\n param: ParameterInfo,\n decorator: DecoratorInfo,\n declared: ReturnType<typeof parameterType>,\n where: string,\n base: Omit<HttpParamData, 'key' | 'schema' | 'coercion' | 'optional'>,\n type: string | undefined,\n): HttpParamData | undefined {\n const parsed = nameAndSchema(ctx, decorator)\n if (!parsed.ok) {\n return undefined\n }\n const { key, schema } = parsed\n const name = `@${decorator.name}`\n if (key !== undefined && !TOKEN.test(key)) {\n error(ctx, decorator.args[0]?.location ?? decorator.location, `${name}: invalid cookie name ${describe(key)}`, [\n `Cookie names are tokens (letters, digits and ! # $ % & ' * + - . ^ _ \\` | ~): ${name}('session_id')`,\n ])\n return undefined\n }\n if (decorator.identity === Ids.SignedCookie && key === undefined) {\n error(ctx, decorator.location, '@SignedCookie requires a cookie name', [\"@SignedCookie('session_id')\"])\n return undefined\n }\n const optional = declared.optional\n if (schema !== undefined) {\n return { ...base, key, optional, schema, coercion: undefined }\n }\n if (key === undefined) {\n checkUnvalidated(ctx, declared.type, decorator, param, where, 'cookies')\n return { ...base, key, optional: false, schema: undefined, coercion: undefined }\n }\n const coercion = coercionOf(ctx, declared, param, decorator, where, 'cookie', key)\n return coercion ? { ...base, key, type, optional, schema: undefined, coercion } : undefined\n}\n\n/**\n * The statically evaluable default value of a parameter (`page = 1`), without references to\n * exported bindings. `ParameterInfo.initializer` is read defensively (compilers before RFC 0002 C4\n * do not provide it).\n */\nfunction staticDefault(param: ParameterInfo): { readonly value: StaticValue } | undefined {\n const initializer = (param as { readonly initializer?: ArgInfo | undefined }).initializer\n if (initializer === undefined || !initializer.evaluated || initializer.ref !== undefined) {\n return undefined\n }\n const value = initializer.value\n if (value === undefined || hasRef(value)) {\n return undefined\n }\n return { value }\n}\n\nfunction hasRef(value: StaticValue): boolean {\n if (isValueRef(value)) {\n return true\n }\n if (Array.isArray(value)) {\n return value.some(hasRef)\n }\n if (typeof value === 'object' && value !== null) {\n return Object.values(value).some(hasRef)\n }\n return false\n}\n\n/** `@UploadedFile(field?, options?)` / `@UploadedFiles(field?, options?)`: field, options and type. */\nfunction uploadOf(\n ctx: Context,\n decorator: DecoratorInfo,\n param: ParameterInfo,\n declared: ReturnType<typeof parameterType>,\n where: string,\n multiple: boolean,\n): UploadData | undefined {\n const name = `@${decorator.name}`\n const [first, second] = decorator.args\n let field: string | undefined\n let options: ArgInfo | undefined\n if (first !== undefined) {\n if (!first.evaluated) {\n return undefined // already reported\n }\n if (typeof first.value === 'string') {\n if (first.value === '') {\n error(ctx, first.location, `${name} expects a non-empty field name`, [`${name}('avatar')`])\n return undefined\n }\n field = first.value\n options = second\n } else if (first.value === undefined) {\n options = second\n } else if (isPlainObject(first.value)) {\n if (second !== undefined) {\n error(ctx, second.location, `${name}(options) takes a single argument`, [\n `Put the field first: ${name}('field', { ... })`,\n ])\n return undefined\n }\n options = first\n } else {\n error(ctx, first.location, `${name} expects a field name (string) or options, got ${describe(first.value)}`, [\n `${name}('avatar'), ${name}('avatar', { maxSize: '5mb' }) or ${name}({ maxSize: '5mb' })`,\n ])\n return undefined\n }\n }\n const parsed = uploadOptions(ctx, name, options, multiple)\n if (parsed === undefined) {\n return undefined\n }\n const type = uploadType(ctx, declared.type, multiple)\n if (!type.ok) {\n error(\n ctx,\n param.typeLocation,\n `${name} parameter '${param.name}' of ${where} must be typed ${multiple ? 'File[]' : 'File'}, got ${type.got}`,\n [multiple ? `${param.name}: File[]` : `${param.name}: File (or ${param.name}?: File when optional)`],\n )\n return undefined\n }\n const required = parsed.required ?? !declared.optional\n let cast = type.cast\n if (!multiple && !required) {\n const acceptsMissing =\n declared.type === undefined ||\n param.optional ||\n param.hasDefault ||\n acceptsUndefined(declared.type) ||\n isRaw(ctx.types.stripNullish(declared.type).type)\n if (!acceptsMissing && !declared.optional) {\n error(\n ctx,\n options?.location ?? decorator.location,\n `${name}: '${param.name}' of ${where} is optional ({ required: false }) but typed ${ctx.types.format(declared.type as TypeInfo)}`,\n [`Type it ${param.name}?: File (undefined when no file is sent)`],\n )\n return undefined\n }\n // `File | null` receives undefined\n cast ||= !acceptsMissing\n }\n return {\n field,\n multiple,\n required,\n maxSize: parsed.maxSize,\n maxFiles: parsed.maxFiles,\n mimeTypes: parsed.mimeTypes,\n cast,\n }\n}\n\ninterface ParsedUploadOptions {\n readonly required: boolean | undefined\n readonly maxSize: number | undefined\n readonly maxFiles: number | undefined\n readonly mimeTypes: readonly string[] | undefined\n}\n\n/** The options object of an upload decorator (`undefined` after an error). */\nfunction uploadOptions(\n ctx: Context,\n name: string,\n arg: ArgInfo | undefined,\n multiple: boolean,\n): ParsedUploadOptions | undefined {\n const result: { -readonly [K in keyof ParsedUploadOptions]: ParsedUploadOptions[K] } = {\n required: undefined,\n maxSize: undefined,\n maxFiles: undefined,\n mimeTypes: undefined,\n }\n if (arg === undefined) {\n return result\n }\n if (!arg.evaluated) {\n return undefined\n }\n if (arg.value === undefined) {\n return result\n }\n const allowed = multiple ? UPLOAD_OPTIONS : UPLOAD_OPTIONS.filter(option => option !== 'maxFiles')\n const shape = `{ ${allowed.map(option => `${option}?`).join(', ')} }`\n if (!isPlainObject(arg.value)) {\n error(ctx, arg.location, `${name} options must be an object ${shape}, got ${describe(arg.value)}`)\n return undefined\n }\n let ok = true\n const invalid = (message: string, hints: readonly string[] = []): void => {\n ok = false\n error(ctx, arg.location, `${name}: ${message}`, hints)\n }\n for (const [key, value] of Object.entries(arg.value)) {\n if (value === undefined) {\n continue\n }\n switch (key) {\n case 'required':\n if (typeof value === 'boolean') {\n result.required = value\n } else {\n invalid(`\"required\" must be a boolean, got ${describe(value)}`)\n }\n break\n case 'maxSize': {\n const size = parseByteSize(value)\n if (size === undefined) {\n invalid(`\"maxSize\" must be a size in bytes, got ${describe(value)}`, [\n \"A non-negative integer (5_242_880), a size with a unit ('5mb', '512kb'; kb = 1024 bytes) or Infinity\",\n ])\n } else {\n result.maxSize = size\n }\n break\n }\n case 'maxFiles':\n if (!multiple) {\n invalid('\"maxFiles\" only applies to @UploadedFiles (a single file is expected here)', [\n 'Use @UploadedFiles() to receive several files',\n ])\n } else if (value === Number.POSITIVE_INFINITY || (Number.isSafeInteger(value) && (value as number) >= 1)) {\n result.maxFiles = value as number\n } else {\n invalid(`\"maxFiles\" must be a positive integer, got ${describe(value)}`)\n }\n break\n case 'mimeTypes': {\n const patterns = Array.isArray(value) ? value : undefined\n const wrong = patterns?.filter(pattern => typeof pattern !== 'string' || !isMediaTypePattern(pattern)) ?? []\n if (patterns === undefined || patterns.length === 0) {\n invalid(`\"mimeTypes\" must be a non-empty array of media types, got ${describe(value)}`, [\n \"mimeTypes: ['image/png', 'image/*']\",\n ])\n } else if (wrong.length > 0) {\n invalid(`invalid media type ${wrong.map(describe).join(', ')} in \"mimeTypes\"`, [\n \"Use type/subtype, type/* or */* without parameters: 'image/png', 'image/*'\",\n ])\n } else {\n result.mimeTypes = patterns as string[]\n }\n break\n }\n default:\n invalid(`unknown option \"${key}\"`, [`Options: ${shape}`])\n }\n }\n return ok ? result : undefined\n}\n\n/** Whether a parameter type can receive uploaded files (and whether the value must be cast). */\nfunction uploadType(\n ctx: Context,\n type: TypeInfo | undefined,\n multiple: boolean,\n): { readonly ok: true; readonly cast: boolean } | { readonly ok: false; readonly got: string } {\n if (type === undefined) {\n return { ok: true, cast: false }\n }\n const { type: base } = ctx.types.stripNullish(type)\n if (isRaw(base)) {\n return { ok: true, cast: false }\n }\n let target: TypeInfo | undefined = base\n if (multiple) {\n target = base.kind === 'array' ? base.element : undefined\n }\n if (target !== undefined && isRaw(target)) {\n return { ok: true, cast: false }\n }\n const cast = target?.kind === 'reference' ? FILE_TYPES.get(target.identity) : undefined\n return cast === undefined ? { ok: false, got: ctx.types.format(type) } : { ok: true, cast }\n}\n\n/** Name and/or schema of `@Param(name?, schema?)` / `@Query(name?, schema?)`. */\nfunction nameAndSchema(\n ctx: Context,\n decorator: DecoratorInfo,\n):\n | { readonly ok: true; readonly key: string | undefined; readonly schema: ValueRef | undefined }\n | { readonly ok: false } {\n const [first, second] = decorator.args\n if (first === undefined) {\n return { ok: true, key: undefined, schema: undefined }\n }\n if (first.error !== undefined) {\n return { ok: false }\n }\n if (first.ref !== undefined) {\n if (second !== undefined) {\n error(ctx, second.location, `@${decorator.name}(schema) takes a single argument`, [\n `Put the name first: @${decorator.name}('name', Schema)`,\n ])\n return { ok: false }\n }\n return { ok: true, key: undefined, schema: first.ref }\n }\n if (typeof first.value !== 'string' || first.value === '') {\n error(\n ctx,\n first.location,\n `@${decorator.name} expects a name (non-empty string) or a schema, got ${describe(first.value)}`,\n [`@${decorator.name}('id'), @${decorator.name}('id', Schema) or @${decorator.name}(Schema)`],\n )\n return { ok: false }\n }\n if (second === undefined) {\n return { ok: true, key: first.value, schema: undefined }\n }\n const schema = schemaRef(ctx, second, `@${decorator.name}`)\n return schema ? { ok: true, key: first.value, schema } : { ok: false }\n}\n\n/** A schema argument: a reference to an exported binding. */\nfunction schemaRef(ctx: Context, arg: ArgInfo, what: string): ValueRef | undefined {\n if (arg.error !== undefined) {\n return undefined // already reported\n }\n if (arg.ref === undefined) {\n error(ctx, arg.location, `${what} expects a Standard Schema, got ${describe(arg.value)}`, [\n 'Pass a schema declared with `export const Schema = z.object({ ... })` (Zod, Valibot, ArkType...)',\n ])\n return undefined\n }\n const symbol = arg.ref.symbol\n if (symbol.kind === 'declaration' && symbol.declaration.kind === 'class' && !hasStandardSchema(ctx, arg.ref)) {\n ctx.report({\n code: Codes.InvalidDecorator,\n severity: 'warning',\n message: `${what}(${arg.ref.text}): ${arg.ref.name} is a class, not a Standard Schema; the validation fails at runtime`,\n location: arg.location,\n hints: ['Pass a Standard Schema object (Zod, Valibot, ArkType...): classes are not validators'],\n })\n }\n return arg.ref\n}\n\nfunction hasStandardSchema(ctx: Context, ref: ValueRef): boolean {\n const info = ref.identity === undefined ? undefined : ctx.classInfo(ref.identity)\n return (\n info === undefined ||\n info.superClass !== undefined ||\n info.properties.some(property => property.static && property.name === '~standard') ||\n info.methods.some(member => member.static && member.name === '~standard')\n )\n}\n\n/** Coercion of a named parameter / query value / header without schema. */\nfunction coercionOf(\n ctx: Context,\n declared: ReturnType<typeof parameterType>,\n param: ParameterInfo,\n decorator: DecoratorInfo,\n where: string,\n source: 'param' | 'query' | 'headers' | 'cookie',\n key: string,\n): ParamCoercion | undefined {\n const result = planCoercion(ctx, declared, param, source === 'param')\n const label = `${source === 'headers' ? 'header' : source} \"${key}\"`\n if (result.ok) {\n if (source === 'query' && declared.type !== undefined && isAny(declared.type)) {\n unvalidated(ctx, decorator, `${label} of ${where} is typed any`)\n }\n return result.coercion\n }\n if (source === 'query') {\n // unvalidated input: the raw value is passed as is\n unvalidated(ctx, decorator, `${label} of ${where}: ${result.reason}`, result.hints)\n return { plan: { kind: 'raw' }, cast: false }\n }\n ctx.report({\n code: Codes.InvalidRoute,\n severity: 'error',\n message: `Invalid ${label} of ${where}: ${result.reason}`,\n location: param.typeLocation,\n hints: [...result.hints],\n })\n return undefined\n}\n\n/** ZNIGHT017 for a non-primitive `@Body()` / `@Query()` without schema. */\nfunction checkUnvalidated(\n ctx: Context,\n type: TypeInfo | undefined,\n decorator: DecoratorInfo,\n param: ParameterInfo,\n where: string,\n what: 'body' | 'query' | 'cookies',\n): void {\n if (type !== undefined && acceptedWithoutSchema(ctx, type)) {\n return\n }\n const described = type === undefined ? 'untyped' : `typed ${ctx.types.format(type)}`\n unvalidated(ctx, decorator, `the ${what} of ${where} ('${param.name}', ${described}) has no schema`)\n}\n\nfunction unvalidated(ctx: Context, decorator: DecoratorInfo, detail: string, extraHints: readonly string[] = []): void {\n ctx.report({\n code: Codes.UnvalidatedInput,\n severity: ctx.options.strictValidation ? 'error' : 'warning',\n message: `Unvalidated input: ${detail}`,\n location: decorator.location,\n hints: [\n ...extraHints.filter(hint => !hint.startsWith('Or validate')),\n `Validate it with a Standard Schema: ${schemaHint(decorator.name)}`,\n 'Or type the parameter as unknown and check it yourself',\n ],\n })\n}\n\nfunction schemaHint(decorator: string): string {\n if (decorator === 'Body') {\n return '@Body(Schema) or @Validate(Schema)'\n }\n if (decorator === 'Cookie') {\n return \"@Cookie(Schema) for every cookie, or @Cookie('name', Schema)\"\n }\n return `@${decorator}('name', Schema)`\n}\n\nfunction acceptedWithoutSchema(ctx: Context, type: TypeInfo): boolean {\n const { type: base } = ctx.types.stripNullish(type)\n switch (base.kind) {\n case 'primitive':\n return base.name !== 'any' && base.name !== 'object' && base.name !== 'never' && base.name !== 'symbol'\n case 'literal':\n return true\n case 'reference':\n if (UNVALIDATED_REFERENCES.has(base.identity)) {\n return true\n }\n // Record<string, string | string[]> (the shape of ctx.query and of form bodies)\n return (\n base.identity === 'globalThis#Record' &&\n base.typeArgs.length === 2 &&\n isStringLike(base.typeArgs[1] as TypeInfo)\n )\n default:\n return false\n }\n}\n\nfunction isStringLike(type: TypeInfo): boolean {\n switch (type.kind) {\n case 'primitive':\n return type.name === 'string' || type.name === 'undefined' || type.name === 'unknown'\n case 'array':\n return type.element.kind === 'primitive' && type.element.name === 'string'\n case 'union':\n return type.types.every(isStringLike)\n default:\n return false\n }\n}\n\nfunction isAny(type: TypeInfo): boolean {\n return isRaw(type) && type.kind === 'primitive' && type.name === 'any'\n}\n\n// -------------------------------------------------------------------------------------------------\n// Helpers\n// -------------------------------------------------------------------------------------------------\n\n/**\n * Decorators of a parameter without duplicates (a parameter with a default value may list its\n * decorators twice).\n */\nfunction unique(decorators: readonly DecoratorInfo[]): DecoratorInfo[] {\n const seen = new Set<number>()\n return decorators.filter(decorator => {\n if (seen.has(decorator.location.start)) {\n return false\n }\n seen.add(decorator.location.start)\n return true\n })\n}\n\n/** `false` when the decorator is applied to a target it does not support (reported by the core). */\nfunction validTarget(decorator: DecoratorInfo): boolean {\n const identity = decorator.identity ?? ''\n if (ROUTE_METHODS.has(identity)) {\n return decorator.target === 'method'\n }\n if (PARAM_SOURCES.has(identity)) {\n return decorator.target === 'parameter'\n }\n switch (identity) {\n case Ids.Controller:\n return decorator.target === 'class'\n case Ids.UseGuard:\n case Ids.UseInterceptor:\n case Ids.BodyLimit:\n return decorator.target === 'class' || decorator.target === 'method'\n default:\n return decorator.target === 'method'\n }\n}\n\nfunction isPlainObject(value: StaticValue): value is { readonly [key: string]: StaticValue } {\n return typeof value === 'object' && value !== null && !Array.isArray(value) && !isValueRef(value)\n}\n\nfunction describe(value: StaticValue): string {\n if (value === null) {\n return 'null'\n }\n if (Array.isArray(value)) {\n return 'an array'\n }\n if (isValueRef(value)) {\n return `a reference to '${value.text}'`\n }\n if (typeof value === 'object') {\n return 'an object'\n }\n if (typeof value === 'string') {\n return JSON.stringify(value)\n }\n return typeof value === 'bigint' ? `${value}n` : String(value)\n}\n\nfunction error(ctx: Context, location: Location, message: string, hints?: readonly string[]): void {\n ctx.report({ code: Codes.InvalidDecorator, severity: 'error', message, location, ...(hints ? { hints } : {}) })\n}\n","/**\n * `generate` of the `@znight/http` compiler extension: the `metadata.extensions.http` section\n * (README, \"Compiler contract\"). Controllers are sorted by token, routes keep their source order and\n * every route gets an `invoke(c, ctx)` arrow extracting, coercing and validating its arguments.\n */\nimport type { ClassRef, GenerateContext, GenInput, GenNode, StaticValue, ValueRef } from '@znight/compiler'\nimport type {\n CoercionPlan,\n CustomParamData,\n HttpControllerData,\n HttpParamData,\n HttpRouteData,\n MetaEntry,\n ParamCoercion,\n SseRouteData,\n UploadData,\n} from './model.ts'\n\nimport { compareStrings } from '../path.ts'\nimport { HTTP_PACKAGE } from './model.ts'\nimport { isValueRef } from './route-decorators.ts'\n\ntype Context = GenerateContext<HttpControllerData>\n\n/** `uploads` helper by kind and presence (`@UploadedFile` / `@UploadedFiles`, required or not). */\nconst UPLOAD_HELPERS = {\n file: { required: 'file', optional: 'optionalFile' },\n files: { required: 'files', optional: 'optionalFiles' },\n} as const\n\n/** Imports of `@znight/http` helpers, created on first use (the generated module has no unused import). */\ninterface Helpers {\n coerce(): GenNode\n validate(): GenNode\n isThenable(): GenNode\n uploads(): GenNode\n context(): GenNode\n paramFunctionOf(): GenNode\n /** The resolver instances of the route being generated (`x`), with the index of each token. */\n readonly resolvers?: { readonly x: GenNode; readonly index: ReadonlyMap<string, number> }\n}\n\n/** Generates `metadata.extensions.http` (`undefined` when the application has no controller). */\nexport function generateHttp(ctx: Context): GenNode | undefined {\n if (ctx.stored.length === 0) {\n return undefined\n }\n const controllers = [...ctx.stored].sort((a, b) => compareStrings(a.token, b.token))\n const helpers = createHelpers(ctx)\n const entries: [string, GenInput][] = [\n ['controllers', ctx.arr(controllers.map(controller => controllerNode(ctx, helpers, controller)))],\n ]\n const groups = groupsNode(ctx, controllers)\n if (groups !== undefined) {\n entries.push(['groups', groups])\n }\n return ctx.obj(entries)\n}\n\n/**\n * `groups`: the route decorator groups the runtime needs (required, holding several keys, or named\n * differently from their key), sorted, with sorted keys; `undefined` when there is none, so that\n * applications without groups keep a byte-identical output.\n */\nfunction groupsNode(ctx: Context, controllers: readonly HttpControllerData[]): GenNode | undefined {\n const groups = new Map<string, { readonly keys: Set<string>; required: boolean }>()\n const visit = (entries: readonly MetaEntry[]): void => {\n for (const entry of entries) {\n const group = groups.get(entry.group)\n if (group === undefined) {\n groups.set(entry.group, { keys: new Set([entry.key]), required: entry.required })\n } else {\n group.keys.add(entry.key)\n group.required ||= entry.required\n }\n }\n }\n for (const controller of controllers) {\n visit(controller.meta)\n for (const route of controller.routes) {\n visit(route.meta)\n }\n }\n const needed = [...groups]\n .filter(([name, group]) => group.required || group.keys.size > 1 || !group.keys.has(name))\n .sort(([a], [b]) => compareStrings(a, b))\n if (needed.length === 0) {\n return undefined\n }\n return ctx.obj(\n needed.map(\n ([name, group]) =>\n [\n name,\n ctx.obj([\n ['keys', ctx.lit([...group.keys].sort(compareStrings))],\n ['required', group.required],\n ]),\n ] as const,\n ),\n )\n}\n\nfunction createHelpers(ctx: Context): Helpers {\n let coerce: GenNode | undefined\n let validate: GenNode | undefined\n let isThenable: GenNode | undefined\n let uploads: GenNode | undefined\n let context: GenNode | undefined\n let paramFunctionOf: GenNode | undefined\n return {\n coerce: () => {\n coerce ??= ctx.importFrom(HTTP_PACKAGE, 'coerce')\n return coerce\n },\n validate: () => {\n validate ??= ctx.importFrom(HTTP_PACKAGE, 'validate')\n return validate\n },\n isThenable: () => {\n isThenable ??= ctx.importFrom(HTTP_PACKAGE, 'isThenable')\n return isThenable\n },\n uploads: () => {\n uploads ??= ctx.importFrom(HTTP_PACKAGE, 'uploads')\n return uploads\n },\n context: () => {\n context ??= ctx.importFrom(HTTP_PACKAGE, 'HttpContext', { type: true })\n return context\n },\n paramFunctionOf: () => {\n paramFunctionOf ??= ctx.importFrom('@znight/core', 'ParamFunctionOf', { type: true })\n return paramFunctionOf\n },\n }\n}\n\nfunction controllerNode(ctx: Context, helpers: Helpers, controller: HttpControllerData): GenNode {\n return ctx.obj([\n ['token', controller.token],\n ['basePath', controller.basePath],\n ['guards', tokens(ctx, controller.guards)],\n ['interceptors', tokens(ctx, controller.interceptors)],\n ['meta', metaNode(ctx, controller.meta)],\n ['routes', ctx.arr(controller.routes.map(route => routeNode(ctx, helpers, controller, route)))],\n ])\n}\n\nfunction routeNode(ctx: Context, helpers: Helpers, controller: HttpControllerData, route: HttpRouteData): GenNode {\n const entries: [string, GenInput][] = [\n ['method', route.method],\n ['path', route.path],\n ['fullPath', route.fullPath],\n ['handler', route.handler],\n ]\n if (route.status !== undefined) {\n entries.push(['status', route.status])\n }\n if (route.headers.length > 0) {\n entries.push(['headers', ctx.obj(route.headers.map(([name, value]) => [name, value] as const))])\n }\n entries.push(\n ['meta', metaNode(ctx, route.meta)],\n ['guards', tokens(ctx, route.guards)],\n ['interceptors', tokens(ctx, route.interceptors)],\n ['params', ctx.arr(route.params.map(param => paramNode(ctx, param)))],\n )\n if (route.bodyLimit !== undefined) {\n entries.push(['bodyLimit', route.bodyLimit])\n }\n const uploads = route.params.flatMap(param => (param.upload === undefined ? [] : [param.upload]))\n if (uploads.length > 0) {\n entries.push(['uploads', ctx.arr(uploads.map(upload => uploadNode(ctx, upload)))])\n }\n if (route.rawResponse) {\n entries.push(['rawResponse', true])\n }\n if (route.sse !== undefined) {\n entries.push(['sse', sseNode(ctx, route.sse)])\n }\n const resolvers = paramResolvers(route)\n if (resolvers.length > 0) {\n entries.push(['paramResolvers', tokens(ctx, resolvers)])\n }\n entries.push(['invoke', invokeNode(ctx, helpers, controller, route, resolvers)])\n return ctx.obj(entries)\n}\n\n/** `{ heartbeat?, retry?, maxDuration? }` (`{}` without options). */\nfunction sseNode(ctx: Context, sse: SseRouteData): GenNode {\n const entries: [string, GenInput][] = []\n if (sse.heartbeat !== undefined) {\n entries.push(['heartbeat', sse.heartbeat])\n }\n if (sse.retry !== undefined) {\n entries.push(['retry', sse.retry])\n }\n if (sse.maxDuration !== undefined) {\n entries.push(['maxDuration', sse.maxDuration])\n }\n return ctx.obj(entries)\n}\n\nfunction paramNode(ctx: Context, param: HttpParamData): GenNode {\n const entries: [string, GenInput][] = [\n ['index', param.index],\n ['source', param.source],\n ]\n if (param.key !== undefined) {\n entries.push(['name', param.key])\n }\n if (param.type !== undefined) {\n entries.push(['type', param.type])\n }\n if (param.optional) {\n entries.push(['optional', true])\n }\n if (param.schema !== undefined) {\n entries.push(['schema', true])\n }\n return ctx.obj(entries)\n}\n\n/** `{ field?, multiple?, required?, maxSize?, maxFiles?, mimeTypes? }` (absent values omitted). */\nfunction uploadNode(ctx: Context, upload: UploadData): GenNode {\n const entries: [string, GenInput][] = []\n if (upload.field !== undefined) {\n entries.push(['field', upload.field])\n }\n if (upload.multiple) {\n entries.push(['multiple', true])\n }\n if (upload.required) {\n entries.push(['required', true])\n }\n if (upload.maxSize !== undefined) {\n entries.push(['maxSize', upload.maxSize])\n }\n if (upload.maxFiles !== undefined) {\n entries.push(['maxFiles', upload.maxFiles])\n }\n if (upload.mimeTypes !== undefined) {\n entries.push(['mimeTypes', ctx.lit(upload.mimeTypes)])\n }\n return ctx.obj(entries)\n}\n\nfunction metaNode(ctx: Context, meta: readonly MetaEntry[]): GenNode {\n return ctx.obj(meta.map(entry => [entry.key, ctx.lit(entry.value)] as const))\n}\n\nfunction tokens(ctx: Context, refs: readonly ClassRef[]): GenNode {\n return ctx.arr(refs.map(ref => ctx.tokenOf(ref) ?? ref.token))\n}\n\n// -------------------------------------------------------------------------------------------------\n// invoke\n// -------------------------------------------------------------------------------------------------\n\n/**\n * `(c: Controller, ctx: HttpContext) => c.handler(...args)`, synchronous when no argument is\n * validated with a schema. A route validating arguments gets a block that stays synchronous as long\n * as every `validate()` returns a value (see {@link validatingBlock}). `@Validate(S)` without\n * `@Body()` parameter reads the body in `invoke`: that arrow is `async` and `await`s every\n * `validate()`.\n */\nfunction invokeNode(\n ctx: Context,\n helpers: Helpers,\n controller: HttpControllerData,\n route: HttpRouteData,\n resolvers: readonly ClassRef[],\n): GenNode {\n const params: [string, GenNode][] = [['c', ctx.importType(controller.identity)]]\n // `ctx` is declared only when used (generated code type-checks with `noUnusedParameters`), and as\n // `_ctx` before `x` when only class resolvers whose `resolve()` takes no parameter need arguments\n if (route.params.length > 0 || route.bodySchema !== undefined) {\n params.push([readsContext(route) ? 'ctx' : '_ctx', helpers.context()])\n }\n // `x`: the instances of the parameter resolvers (RFC 0010), only for routes that have some\n if (resolvers.length > 0) {\n const tuple = resolvers.map(ref => ctx.importType(ref))\n params.push(['x', ctx.code`readonly [${joinNodes(ctx, tuple)}]`])\n const index = new Map(resolvers.map((ref, position) => [ref.token, position]))\n const withResolvers = (x: GenNode | undefined): Helpers =>\n x === undefined ? helpers : { ...helpers, resolvers: { x, index } }\n return invokeArrow(ctx, params, route, (c, http, x) => [c, http, withResolvers(x)])\n }\n return invokeArrow(ctx, params, route, (c, http) => [c, http, helpers])\n}\n\n/** `true` when an argument (or the body validation) reads the context: all but a `resolve()` without parameter. */\nfunction readsContext(route: HttpRouteData): boolean {\n return (\n route.bodySchema !== undefined ||\n route.params.some(param => param.custom?.resolver === undefined || param.custom.arity !== 0)\n )\n}\n\n/** The provider classes resolving custom parameters, in order of first use (`x[i]`). */\nfunction paramResolvers(route: HttpRouteData): ClassRef[] {\n const found = new Map<string, ClassRef>()\n for (const param of route.params) {\n const resolver = param.custom?.resolver\n if (resolver !== undefined && !found.has(resolver.token)) {\n found.set(resolver.token, resolver)\n }\n }\n return [...found.values()]\n}\n\n/** `a, b, c`. */\nfunction joinNodes(ctx: Context, nodes: readonly GenNode[]): GenNode {\n return nodes.slice(1).reduce((joined, node) => ctx.code`${joined}, ${node}`, nodes[0] as GenNode)\n}\n\n/** The arrow of {@link invokeNode}; `bind` maps the arrow parameters to the controller, the context and the helpers. */\nfunction invokeArrow(\n ctx: Context,\n params: readonly [string, GenNode][],\n route: HttpRouteData,\n bind: (...params: GenNode[]) => readonly [GenNode, GenNode | undefined, Helpers],\n): GenNode {\n // arguments in evaluation order (handler parameter order); a hole is passed as `undefined`\n const slots: (HttpParamData | undefined)[] = []\n for (const param of route.params) {\n slots[param.index] = param\n }\n const bodySchema = route.bodySchema\n if (bodySchema !== undefined) {\n return ctx.arrow(\n params,\n (...bound) => {\n const [c, http, helpers] = bind(...bound)\n const call = handlerCall(\n ctx,\n c,\n route,\n Array.from(slots, param => awaitedArgument(ctx, helpers, http as GenNode, param)),\n )\n // @Validate(S) without @Body() parameter: the body is validated (and discarded)\n const body = ctx.code`await ${ctx.call(ctx.member(http as GenNode, 'parseBody'))}`\n const check = ctx.code`await ${validation(ctx, helpers, bodySchema, body, 'body')}`\n return ctx.code`{ ${check}; return ${call} }`\n },\n { async: true },\n )\n }\n const last = slots.findLastIndex(param => param !== undefined && isDeferred(param))\n return ctx.arrow(params, (...bound) => {\n const [c, http, helpers] = bind(...bound)\n return last === -1\n ? handlerCall(\n ctx,\n c,\n route,\n Array.from(slots, param => plainArgument(ctx, helpers, http as GenNode, param)),\n )\n : validatingBlock(ctx, helpers, route, slots, last, c, http as GenNode)\n })\n}\n\n/**\n * `true` for an argument whose expression may return a thenable: a validation with a schema, or a\n * custom parameter (its resolver may return a promise).\n */\nfunction isDeferred(param: HttpParamData): boolean {\n return param.schema !== undefined || param.custom !== undefined\n}\n\n/** `c.handler(args)`. */\nfunction handlerCall(ctx: Context, c: GenNode, route: HttpRouteData, args: readonly GenNode[]): GenNode {\n return ctx.call(ctx.member(c, route.handler), args)\n}\n\n/**\n * The body of the `invoke` of a route validating arguments with schemas: the arguments up to the\n * last validated one are evaluated in order into `const`s (`a<index>`), the handler is called with\n * them. `validate()` returns the value when the schema validates synchronously (Zod, Valibot and\n * ArkType without async refinements), so the request needs no promise; when one returns a\n * thenable, the rest runs in an `async` arrow that awaits it, then evaluates the remaining arguments\n * (`await`ing their validations) and calls the handler: the order of evaluation, the error reported\n * when several arguments are invalid and the value received by the handler are those of an `async`\n * `invoke` awaiting every `validate()`.\n *\n * ```ts\n * (c: UserController, ctx: HttpContext) => {\n * const a0 = coerce.number(ctx.params['id'], 'param \"id\"')\n * const a1 = validate(UpdateUser, ctx.body, 'body')\n * if (isThenable(a1)) return (async () => c.update(a0, await a1, ctx))()\n * return c.update(a0, a1, ctx)\n * }\n * ```\n */\nfunction validatingBlock(\n ctx: Context,\n helpers: Helpers,\n route: HttpRouteData,\n slots: readonly (HttpParamData | undefined)[],\n last: number,\n c: GenNode,\n http: GenNode,\n): GenNode {\n // `@Ctx()` and holes are inlined: nothing to evaluate\n const bound: number[] = []\n for (let index = 0; index <= last; index++) {\n const param = slots[index]\n if (param !== undefined && param.source !== 'context') {\n bound.push(index)\n }\n }\n return ctx.block(\n bound.map(index => `a${index}`),\n (...locals) => {\n const local = new Map(bound.map((index, position) => [index, locals[position] as GenNode]))\n // the value of an argument evaluated before the current statement\n const evaluated = (index: number): GenNode => local.get(index) ?? plainArgument(ctx, helpers, http, slots[index])\n const statements: GenNode[] = []\n for (const index of bound) {\n const param = slots[index] as HttpParamData\n const name = local.get(index) as GenNode\n statements.push(ctx.code`const ${name} = ${plainArgument(ctx, helpers, http, param)}`)\n if (isDeferred(param)) {\n const rest = Array.from(slots, (other, position) => {\n if (position < index) {\n return evaluated(position)\n }\n return position === index ? ctx.code`await ${name}` : awaitedArgument(ctx, helpers, http, other)\n })\n const resume = ctx.arrow([], () => handlerCall(ctx, c, route, rest), { async: true })\n statements.push(ctx.code`if (${ctx.call(helpers.isThenable(), [name])}) return (${resume})()`)\n }\n }\n const args = Array.from(slots, (param, position) =>\n position <= last ? evaluated(position) : plainArgument(ctx, helpers, http, param),\n )\n statements.push(ctx.code`return ${handlerCall(ctx, c, route, args)}`)\n return statements\n },\n )\n}\n\n/** An argument evaluated in an `async` arrow: its validation, if any, is `await`ed. */\nfunction awaitedArgument(ctx: Context, helpers: Helpers, http: GenNode, param: HttpParamData | undefined): GenNode {\n const node = plainArgument(ctx, helpers, http, param)\n return param === undefined || !isDeferred(param) ? node : ctx.code`await ${node}`\n}\n\n/** An argument as an expression (`validate()` not awaited); `undefined` for a hole. */\nfunction plainArgument(ctx: Context, helpers: Helpers, http: GenNode, param: HttpParamData | undefined): GenNode {\n return param === undefined ? ctx.lit(undefined) : argumentNode(ctx, helpers, http, param)\n}\n\n/** The expression passed to the handler for one parameter. */\nfunction argumentNode(ctx: Context, helpers: Helpers, http: GenNode, param: HttpParamData): GenNode {\n switch (param.source) {\n case 'context':\n return http\n case 'request':\n return ctx.code`${ctx.member(http, 'request')} as never`\n case 'response':\n return ctx.code`${ctx.member(http, 'response')} as never`\n case 'body': {\n const body = ctx.member(http, 'body')\n return param.schema === undefined\n ? ctx.code`${body} as never`\n : validation(ctx, helpers, param.schema, body, 'body')\n }\n case 'file':\n case 'files': {\n const upload = param.upload as UploadData\n const helper = UPLOAD_HELPERS[upload.multiple ? 'files' : 'file'][upload.required ? 'required' : 'optional']\n const call = ctx.call(ctx.member(helpers.uploads(), helper), [http, ctx.lit(upload.field)])\n return upload.cast ? ctx.code`${call} as never` : call\n }\n case 'headers':\n case 'param':\n case 'query': {\n const record = ctx.member(http, param.source === 'param' ? 'params' : param.source)\n if (param.key === undefined) {\n const location = param.source === 'param' ? 'params' : param.source\n return param.schema === undefined\n ? ctx.code`${record} as never`\n : validation(ctx, helpers, param.schema, record, location)\n }\n const value = ctx.code`${record}[${param.key}]`\n const label = `${param.source === 'headers' ? 'header' : param.source} \"${param.key}\"`\n if (param.schema !== undefined) {\n return validation(ctx, helpers, param.schema, value, label)\n }\n return coercion(ctx, helpers, param.coercion ?? { plan: { kind: 'raw' }, cast: false }, value, label)\n }\n case 'cookie':\n case 'signedCookie': {\n if (param.key === undefined) {\n // @Cookie() / @Cookie(S): every cookie\n const cookies = ctx.member(http, 'cookies')\n return param.schema === undefined\n ? ctx.code`${cookies} as never`\n : validation(ctx, helpers, param.schema, cookies, 'cookies')\n }\n const value =\n param.source === 'cookie'\n ? ctx.code`${ctx.member(http, 'cookies')}[${param.key}]`\n : ctx.call(ctx.member(http, 'signedCookie'), [param.key])\n const label = `cookie \"${param.key}\"`\n if (param.schema !== undefined) {\n return validation(ctx, helpers, param.schema, value, label)\n }\n return coercion(ctx, helpers, param.coercion ?? { plan: { kind: 'raw' }, cast: false }, value, label)\n }\n case 'custom':\n return customArgument(ctx, helpers, http, param.custom as CustomParamData)\n }\n}\n\n/**\n * A custom parameter (RFC 0010): `(D.resolvers.http as ParamFunctionOf<typeof D, 'http'>)(ctx, data)`\n * for a function resolver, `x[i].resolve(ctx, data)` for a class resolver; cast with `as never` when\n * the value type could not be checked against the parameter.\n */\nfunction customArgument(ctx: Context, helpers: Helpers, http: GenNode, custom: CustomParamData): GenNode {\n const data = custom.data === undefined ? ctx.lit(undefined) : dataNode(ctx, custom.data.value)\n let call: GenNode\n if (custom.resolver === undefined) {\n const decorator = ctx.importValue(custom.identity)\n const callee = ctx.code`${ctx.member(decorator, 'resolvers', 'http')} as ${helpers.paramFunctionOf()}<typeof ${decorator}, 'http'>`\n call = ctx.call(callee, [http, data])\n } else {\n const resolvers = helpers.resolvers as NonNullable<Helpers['resolvers']>\n const index = resolvers.index.get(custom.resolver.token) as number\n if (custom.arity === undefined) {\n // a `resolve` the compiler cannot read (inherited from a mixin...): the instance is cast to a\n // method taking both arguments (method parameters are bivariant), the value with `as never`\n return ctx.code`(${resolvers.x}[${index}] as { resolve(ctx: unknown, data: unknown): unknown }).resolve(${http}, ${data}) as never`\n }\n // a `resolve(ctx)` that ignores the data gets no data argument (TypeScript checks the arity)\n const args = [http, data].slice(0, custom.arity)\n call = ctx.code`${resolvers.x}[${index}].resolve(${args.length === 0 ? ctx.code`` : joinNodes(ctx, args)})`\n }\n return custom.cast ? ctx.code`${call} as never` : call\n}\n\n/** The data argument of a custom parameter: a literal (references imported) or a reference. */\nfunction dataNode(ctx: Context, value: StaticValue): GenNode {\n return isValueRef(value) ? ctx.ref(value) : ctx.lit(value as Parameters<Context['lit']>[0])\n}\n\n/** `validate(schema, value, location)` (the value, or a promise when the schema validates asynchronously). */\nfunction validation(ctx: Context, helpers: Helpers, schema: ValueRef, value: GenNode, location: string): GenNode {\n return ctx.call(helpers.validate(), [ctx.ref(schema), value, location])\n}\n\n/** `coerce.X(value, label, ...)`, cast with `as never` when the result does not have the declared type. */\nfunction coercion(ctx: Context, helpers: Helpers, coercion: ParamCoercion, value: GenNode, label: string): GenNode {\n const node = coerceCall(ctx, helpers, coercion.plan, value, label)\n return coercion.cast ? ctx.code`${node} as never` : node\n}\n\nfunction coerceCall(ctx: Context, helpers: Helpers, plan: CoercionPlan, value: GenNode, label: GenInput): GenNode {\n const helper = (name: string): GenNode => ctx.member(helpers.coerce(), name)\n switch (plan.kind) {\n case 'raw':\n return ctx.code`${value} as never`\n case 'enum':\n return ctx.call(helper('enum'), [value, label, ctx.lit(plan.values)])\n case 'array':\n case 'optional':\n return ctx.call(helper(plan.kind), [value, label, itemCoercer(ctx, helpers, plan.item)])\n default:\n return ctx.call(helper(plan.kind), [value, label])\n }\n}\n\n/** A `Coercer` value: `coerce.number`, or `(v, l) => coerce.enum(v, l, [...])`. */\nfunction itemCoercer(ctx: Context, helpers: Helpers, plan: CoercionPlan): GenNode {\n switch (plan.kind) {\n case 'enum':\n case 'array':\n case 'optional':\n return ctx.arrow(['v', 'l'], (v, l) => coerceCall(ctx, helpers, plan, v, l))\n case 'raw':\n return ctx.arrow(['v'], v => v)\n default:\n return ctx.member(helpers.coerce(), plan.kind)\n }\n}\n","/**\n * Route decorator groups of the application (RFC 0001 §5.1): every `createRouteDecorator`\n * definition, applied or not, the consistency of their options and the **required** groups.\n *\n * The http extension reports the inconsistencies (ZNIGHT005) and checks every route against the\n * required groups (ZNIGHT023). Other extensions whose targets carry route decorators (WebSocket\n * gateways, GraphQL root fields) call {@link requiredRouteGroups} to check their own targets with\n * exactly the same groups, without reporting the inconsistencies a second time.\n */\nimport type { Diagnostic, Location, ValidateContext } from '@znight/compiler'\nimport type { MetaEntry } from './model.ts'\n\nimport { compareStrings } from '../path.ts'\nimport { Codes, Ids } from './model.ts'\nimport { parseRouteDecoratorOptions } from './route-decorators.ts'\n\n/** A route decorator definition of the application (`export const Roles = createRouteDecorator(...)`). */\nexport interface RouteGroupMember {\n /** Canonical identity of the decorator `const` (`src/auth/access.ts#Roles`). */\n readonly identity: string\n /** Name of the `const` (`Roles`). */\n readonly name: string\n readonly key: string\n /** Decision group (`options.group ?? key`). */\n readonly group: string\n readonly required: boolean\n /** Location of the definition. */\n readonly definition: Location\n /**\n * A flag (`@Public()`): created without type argument, and applied without argument wherever it\n * was seen. Decides how the decorator is suggested: `@Public()` or `@Roles(...)`.\n */\n readonly flag: boolean\n}\n\n/** A required route decorator group: every route-like target must carry a decision of it. */\nexport interface RequiredRouteGroup {\n /** Group name (`access`). */\n readonly group: string\n /** The decorators of the group, in source order (file, then position). Never empty. */\n readonly decorators: readonly RouteGroupMember[]\n /** The decorators as a hint: `@Public(), @Authenticated() or @Roles(...)`. */\n readonly suggestion: string\n}\n\n/** Result of {@link analyzeRouteGroups}. */\nexport interface RouteGroupsAnalysis {\n /** Inconsistent definitions (ZNIGHT005), at the second definition; not reported. */\n readonly conflicts: readonly Diagnostic[]\n /** The required groups, in the order of their first definition by identity. */\n readonly required: readonly RequiredRouteGroup[]\n}\n\n/** A definition while flags are computed. */\ntype MutableMember = { -readonly [K in keyof RouteGroupMember]: RouteGroupMember[K] }\n\n/**\n * Every route decorator definition, sorted by identity: the applied ones (`applied`, first usage\n * wins) and, when the compiler provides `definitionsOf`, the ones applied nowhere (invalid ones are\n * left to the usages, which report them).\n */\nfunction routeDecoratorDefinitions(\n ctx: Pick<ValidateContext<unknown>, 'definitionsOf'>,\n applied: Iterable<MetaEntry>,\n): MutableMember[] {\n const definitions = new Map<string, MutableMember>()\n for (const entry of applied) {\n const known = definitions.get(entry.identity)\n if (known === undefined) {\n definitions.set(entry.identity, {\n identity: entry.identity,\n name: entry.decorator,\n key: entry.key,\n group: entry.group,\n required: entry.required,\n definition: entry.definition,\n flag: entry.value === true,\n })\n } else if (entry.value !== true) {\n known.flag = false\n }\n }\n // compilers before RFC 0001 have no definitionsOf: only applied decorators are known then\n const all = typeof ctx.definitionsOf === 'function' ? ctx.definitionsOf(Ids.createRouteDecorator) : []\n for (const found of all) {\n const [keyArg, optionsArg, ...extra] = found.args\n const key = keyArg?.evaluated === true ? keyArg.value : undefined\n if (\n typeof key !== 'string' ||\n key === '' ||\n extra.length > 0 ||\n (optionsArg !== undefined && !optionsArg.evaluated)\n ) {\n continue\n }\n const parsed = parseRouteDecoratorOptions(key, optionsArg?.value)\n if ('error' in parsed) {\n continue\n }\n const flag = found.typeArgs.length === 0\n const known = definitions.get(found.identity)\n if (known !== undefined) {\n known.flag &&= flag\n continue\n }\n definitions.set(found.identity, {\n identity: found.identity,\n name: found.name,\n key,\n ...parsed,\n definition: found.location,\n flag,\n })\n }\n return [...definitions.values()].sort((a, b) => compareStrings(a.identity, b.identity))\n}\n\n/**\n * The route decorator groups of the application (RFC 0001 §5.1): every definition of a key must use\n * the same options and the decorators of a group must agree on `required` (a conflict is returned\n * at the second definition, which is then ignored); the required groups with their decorators.\n * `applied` are the entries of the targets the caller analysed (their first usage of a decorator\n * wins over its `definitionsOf` entry).\n */\nexport function analyzeRouteGroups(\n ctx: Pick<ValidateContext<unknown>, 'definitionsOf'>,\n applied: Iterable<MetaEntry>,\n): RouteGroupsAnalysis {\n const definitions = routeDecoratorDefinitions(ctx, applied)\n if (definitions.length === 0) {\n return { conflicts: [], required: [] }\n }\n const conflicts: Diagnostic[] = []\n const byKey = new Map<string, RouteGroupMember>()\n const byGroup = new Map<string, RouteGroupMember>()\n const members = new Map<string, RouteGroupMember[]>()\n for (const definition of definitions) {\n const sameKey = byKey.get(definition.key)\n if (sameKey !== undefined && (sameKey.group !== definition.group || sameKey.required !== definition.required)) {\n conflicts.push({\n code: Codes.InvalidDecorator,\n severity: 'error',\n message: `The route decorator ${definition.name} defines the key \"${definition.key}\" with ${describeOptions(definition)}, but ${sameKey.name} defines it with ${describeOptions(sameKey)}`,\n location: definition.definition,\n hints: ['Every definition of a key must use the same options: share one definition'],\n related: [{ message: `${sameKey.name} is defined here`, location: sameKey.definition }],\n })\n continue\n }\n const sameGroup = byGroup.get(definition.group)\n if (sameGroup !== undefined && sameGroup.required !== definition.required) {\n conflicts.push({\n code: Codes.InvalidDecorator,\n severity: 'error',\n message: `The \"${definition.group}\" group is ${definition.required ? '' : 'not '}required for ${definition.name} but ${sameGroup.required ? '' : 'not '}required for ${sameGroup.name}`,\n location: definition.definition,\n hints: [`All the decorators of the \"${definition.group}\" group must agree on required`],\n related: [{ message: `${sameGroup.name} is defined here`, location: sameGroup.definition }],\n })\n continue\n }\n byKey.set(definition.key, sameKey ?? definition)\n byGroup.set(definition.group, sameGroup ?? definition)\n const list = members.get(definition.group) ?? []\n list.push(definition)\n members.set(definition.group, list)\n }\n const required: RequiredRouteGroup[] = []\n for (const first of byGroup.values()) {\n if (!first.required) {\n continue\n }\n // the decorators of the group in source order: `@Public(), @Authenticated() or @Roles(...)`\n const decorators = [...(members.get(first.group) ?? [first])]\n .sort((a, b) => compareStrings(a.definition.file, b.definition.file) || a.definition.start - b.definition.start)\n .map(member => Object.freeze({ ...member }))\n const usages = decorators.map(member => `@${member.name}(${member.flag ? '' : '...'})`)\n const suggestion =\n usages.length === 1 ? (usages[0] as string) : `${usages.slice(0, -1).join(', ')} or ${usages.at(-1) as string}`\n required.push(Object.freeze({ group: first.group, decorators: Object.freeze(decorators), suggestion }))\n }\n return { conflicts, required }\n}\n\n/**\n * The required route decorator groups of the application (RFC 0001): what every route-like target\n * of another extension (a gateway, a GraphQL root field) must decide, exactly as HTTP routes must.\n * A target without a decision of a returned group is **ZNIGHT023**, reported by the caller.\n *\n * `applied` are the route metadata entries the caller read on its own targets\n * ({@link readRouteMeta}): they make decorators known even when the compiler has no\n * `definitionsOf`, and refine how flags are suggested. Inconsistent definitions are left out and\n * not reported here: the http extension reports them (ZNIGHT005) once.\n *\n * ```ts\n * validate(ctx) {\n * const required = requiredRouteGroups(ctx, ctx.stored.flatMap(gateway => gateway.meta))\n * for (const gateway of ctx.stored)\n * for (const group of required)\n * if (!gateway.meta.some(entry => entry.group === group.group))\n * ctx.report({ code: 'ZNIGHT023', severity: 'error', message: `${gateway.name} has no \"${group.group}\" decision`,\n * location: gateway.location, hints: [`Add ${group.suggestion} to ${gateway.name}`] })\n * }\n * ```\n */\nexport function requiredRouteGroups(\n ctx: ValidateContext<unknown>,\n applied: Iterable<MetaEntry> = [],\n): readonly RequiredRouteGroup[] {\n return analyzeRouteGroups(ctx, applied).required\n}\n\nfunction describeOptions(entry: RouteGroupMember): string {\n const group = entry.group === entry.key ? 'no group' : `group \"${entry.group}\"`\n return entry.required ? `${group}, required` : group\n}\n","/**\n * `validate` of the `@znight/http` compiler extension: route paths (grammar of `@znight/http/path`),\n * `:param` ↔ `@Param` consistency and duplicate routes across every controller (ZNIGHT007); route\n * decorator groups: consistent definitions (ZNIGHT005) and a decision of every required group on\n * every route (ZNIGHT023).\n */\nimport type { Location, ValidateContext } from '@znight/compiler'\nimport type { RoutePath } from '../path.ts'\nimport type { HttpControllerData, HttpRouteData, MetaEntry } from './model.ts'\nimport type { RequiredRouteGroup, RouteGroupMember } from './route-groups.ts'\n\nimport { checkRoutePath, compareStrings, parseRoutePath, WILDCARD_PARAM } from '../path.ts'\nimport { Codes } from './model.ts'\nimport { analyzeRouteGroups } from './route-groups.ts'\n\ntype Context = ValidateContext<HttpControllerData>\n\ninterface RegisteredRoute {\n readonly where: string\n readonly route: HttpRouteData\n}\n\n/** Validates the routes of every controller. */\nexport function validateHttp(ctx: Context): void {\n const controllers = [...ctx.stored].sort((a, b) => compareStrings(a.token, b.token))\n const registered = new Map<string, RegisteredRoute>()\n for (const controller of controllers) {\n const baseIssue = checkRoutePath(controller.rawBasePath)\n if (baseIssue !== undefined) {\n invalidRoute(\n ctx,\n controller.pathLocation,\n `Invalid base path ${JSON.stringify(controller.rawBasePath)} of ${controller.displayName}: ${baseIssue.message}`,\n GRAMMAR_HINTS,\n )\n continue\n }\n for (const route of controller.routes) {\n const where = `${controller.displayName}.${route.handler}`\n const ownIssue = checkRoutePath(route.rawPath)\n const issue = ownIssue ?? checkRoutePath(route.fullPath)\n if (issue !== undefined) {\n const path = ownIssue === undefined ? route.fullPath : route.rawPath\n invalidRoute(\n ctx,\n route.pathLocation,\n `Invalid route path ${JSON.stringify(path)} of ${where}: ${issue.message}`,\n GRAMMAR_HINTS,\n )\n continue\n }\n const parsed = parseRoutePath(route.fullPath)\n checkParams(ctx, route, parsed, where)\n const key = `${route.method} ${parsed.shape}`\n const previous = registered.get(key)\n if (previous === undefined) {\n registered.set(key, { where, route })\n continue\n }\n ctx.report({\n code: Codes.InvalidRoute,\n severity: 'error',\n message: `Duplicate route ${route.method} ${route.fullPath}: ${where} conflicts with ${previous.where} (${previous.route.method} ${previous.route.fullPath})`,\n location: route.location,\n hints: ['Two routes with the same method and the same path shape (parameter names aside) cannot coexist'],\n related: [{ message: `${previous.where} is declared here`, location: previous.route.location }],\n })\n }\n }\n validateDecisions(ctx, controllers)\n}\n\n/** Every route metadata entry of the controllers: controller entries, then route entries. */\nfunction* appliedEntries(controllers: readonly HttpControllerData[]): Generator<MetaEntry> {\n for (const controller of controllers) {\n yield* controller.meta\n for (const route of controller.routes) yield* route.meta\n }\n}\n\n/**\n * Route decorator groups (RFC 0001 §5.1): every definition of a key uses the same options and the\n * decorators of a group agree on `required` (ZNIGHT005, at the second definition); every route has\n * a decision of every required group, its own or its controller's (ZNIGHT023).\n */\nfunction validateDecisions(ctx: Context, controllers: readonly HttpControllerData[]): void {\n const { conflicts, required } = analyzeRouteGroups(ctx, appliedEntries(controllers))\n for (const conflict of conflicts) {\n ctx.report(conflict)\n }\n if (required.length === 0) {\n return\n }\n for (const controller of controllers) {\n const controllerGroups = new Set(controller.meta.map(entry => entry.group))\n for (const route of controller.routes) {\n const decided = new Set([...controllerGroups, ...route.meta.map(entry => entry.group)])\n for (const group of required) {\n if (decided.has(group.group)) {\n continue\n }\n ctx.report({\n code: Codes.MissingRouteDecision,\n severity: 'error',\n message: `Route ${route.method} ${route.fullPath} (${controller.displayName}.${route.handler}) has no \"${group.group}\" decision`,\n location: route.location,\n hints: [`Add ${group.suggestion} to the route or to ${controller.displayName}`],\n related: [\n { message: `The \"${group.group}\" group is required`, location: firstDefinition(group) },\n { message: `${controller.displayName} is declared here`, location: controller.location },\n ],\n })\n }\n }\n }\n}\n\n/** Where the first decorator of a group (source order) is defined. */\nfunction firstDefinition(group: RequiredRouteGroup): Location {\n return (group.decorators[0] as RouteGroupMember).definition\n}\n\nconst GRAMMAR_HINTS: readonly string[] = [\n \"Paths are made of static segments (letters, digits and - . _ ~ ! $ & ' + , ; = @), :name parameters and a trailing * wildcard\",\n]\n\n/** `:param` of the path ↔ `@Param('name')` parameters of the handler. */\nfunction checkParams(ctx: Context, route: HttpRouteData, path: RoutePath, where: string): void {\n const declared = new Set(path.params)\n const consumed = new Set<string>()\n let everything = false\n for (const param of route.params) {\n if (param.source === 'context' || param.source === 'request') {\n everything = true // ctx.params / the native request give access to every parameter\n continue\n }\n if (param.source !== 'param') {\n continue\n }\n if (param.key === undefined) {\n everything = true\n continue\n }\n if (declared.has(param.key)) {\n consumed.add(param.key)\n continue\n }\n const available = path.params.filter(name => name !== WILDCARD_PARAM).map(name => `:${name}`)\n invalidRoute(\n ctx,\n param.location,\n `@Param('${param.key}') of ${where}: the route ${route.method} ${route.fullPath} has no ${param.key === WILDCARD_PARAM ? 'wildcard' : `\":${param.key}\" parameter`}`,\n [\n available.length > 0\n ? `Parameters of the route: ${available.join(', ')}`\n : `Add \":${param.key}\" to the route path`,\n ],\n )\n }\n if (everything || !route.complete) {\n return // a parameter could not be analysed (already reported): do not guess what it consumes\n }\n for (const name of path.params) {\n if (name !== WILDCARD_PARAM && !consumed.has(name)) {\n invalidRoute(\n ctx,\n route.pathLocation,\n `Route ${route.method} ${route.fullPath} declares \":${name}\" but ${where} has no @Param('${name}') parameter`,\n [`Add a parameter: @Param('${name}') ${name}: string`],\n )\n }\n }\n}\n\nfunction invalidRoute(ctx: Context, location: Location, message: string, hints: readonly string[]): void {\n ctx.report({ code: Codes.InvalidRoute, severity: 'error', message, location, hints })\n}\n","/**\n * `@znight/http/compiler`: the compiler extension of `@znight/http` (architecture §6.5), loaded by\n * `@znight/compiler` through `package.json#znight.compiler`.\n *\n * - `analyzeClass`: `@Controller` classes become providers; their decorated methods become routes\n * (paths, parameters with type-based coercion or Standard Schema validation, cookies, uploaded\n * files, guards, interceptors, status, headers, body limits, `@Sse` event streams,\n * `createRouteDecorator` metadata);\n * - `validate`: route paths, `:param` ↔ `@Param`, duplicate routes (ZNIGHT007);\n * - `generate`: `metadata.extensions.http` with one `invoke` function per route (README,\n * \"Compiler contract\").\n *\n * It also exports the route decorator readers of other extensions: `readRouteMeta`,\n * `effectiveRouteMeta` and `requiredRouteGroups`.\n *\n * This entry only `import type`s from `@znight/compiler` and never loads the HTTP runtime.\n */\nimport type { CompilerExtension, DecoratorSpec } from '@znight/compiler'\nimport type { HttpControllerData } from './model.ts'\n\nimport { analyzeHttpClass, EXTENSION_NAME } from './analyze.ts'\nimport { generateHttp } from './generate.ts'\nimport { Ids, ROUTE_METHODS } from './model.ts'\nimport { validateHttp } from './validate.ts'\n\nexport type {\n CoercionPlan,\n HttpControllerData,\n HttpParamData,\n HttpRouteData,\n MetaEntry,\n ParamCoercion,\n ScalarCoercion,\n SseRouteData,\n UploadData,\n} from './model.ts'\nexport type { RequiredRouteGroup, RouteGroupMember } from './route-groups.ts'\n\n/**\n * Route decorators for other extensions (RFC 0003 §6.4, RFC 0005 H3): read `createRouteDecorator`\n * metadata on any class or method, and the required groups of the application, with the exact\n * rules of controllers and routes. Stable API, see the README (\"Route metadata in other\n * extensions\").\n */\nexport { effectiveRouteMeta, readRouteMeta } from './route-decorators.ts'\nexport { requiredRouteGroups } from './route-groups.ts'\n\nconst ROUTE: DecoratorSpec = { targets: ['method'], params: ['static'] }\nconst NAME_OR_SCHEMA: DecoratorSpec = { targets: ['parameter'], params: ['value', 'value'] }\nconst NO_ARGUMENT: DecoratorSpec = { targets: ['parameter'], params: [] }\nconst CLASS_REFS: DecoratorSpec = { targets: ['class', 'method'], params: [], rest: 'value' }\nconst UPLOAD: DecoratorSpec = { targets: ['parameter'], params: ['static', 'static'] }\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.Controller]: { targets: ['class'], params: ['static'] },\n ...Object.fromEntries([...ROUTE_METHODS.keys()].map(identity => [identity, ROUTE])),\n [Ids.Param]: NAME_OR_SCHEMA,\n [Ids.Query]: NAME_OR_SCHEMA,\n [Ids.Body]: { targets: ['parameter'], params: ['value'] },\n [Ids.Headers]: { targets: ['parameter'], params: ['static'] },\n [Ids.Req]: NO_ARGUMENT,\n [Ids.Res]: NO_ARGUMENT,\n [Ids.Ctx]: NO_ARGUMENT,\n [Ids.HttpCode]: { targets: ['method'], params: ['static'] },\n [Ids.Header]: { targets: ['method'], params: ['static', 'static'] },\n [Ids.UseGuard]: CLASS_REFS,\n [Ids.UseInterceptor]: CLASS_REFS,\n [Ids.Validate]: { targets: ['method'], params: ['value'] },\n [Ids.UploadedFile]: UPLOAD,\n [Ids.UploadedFiles]: UPLOAD,\n [Ids.BodyLimit]: { targets: ['class', 'method'], params: ['static'] },\n [Ids.Cookie]: NAME_OR_SCHEMA,\n [Ids.SignedCookie]: NAME_OR_SCHEMA,\n // after the ROUTE spread: `@Sse(path?, options?)` takes two static arguments\n [Ids.Sse]: { targets: ['method'], params: ['static', 'static'] },\n})\n\n/** The `@znight/http` compiler extension. */\nconst http: CompilerExtension<HttpControllerData> = Object.freeze({\n apiVersion: 1,\n name: EXTENSION_NAME,\n decorators,\n analyzeClass: analyzeHttpClass,\n validate: validateHttp,\n generate: generateHttp,\n})\n\nexport default http\n"],"mappings":";;;;AAgBA,SAAgB,OAAO,OAAkC;CACvD,OACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAA6B,SAAS,YAC9C,OAAQ,MAA8B,UAAU;AAEpD;;AAGA,SAAgB,MAAM,MAAe,KAAkC;CACrE,MAAM,QAAQ,KAAK;CACnB,OAAO,OAAO,KAAK,IAAI,QAAQ,KAAA;AACjC;;AAGA,SAAgB,SAAS,MAAe,KAAwB;CAC9D,MAAM,QAAQ,KAAK;CACnB,OAAO,MAAM,QA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