import { CoreEntity, CoreLogChannel, ObjectLike } from "@grandlinex/core"; import { Server } from "net"; import "reflect-metadata"; export * from "@grandlinex/base-con"; //#region src/Swagger/Meta/SwaggerTypesStatic.d.ts type SMediaType = 'application/json' | 'application/octet-stream' | 'application/pdf' | 'application/xml' | 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/csv' | 'text/html' | 'text/plain' | 'text/plain; charset=utf-8' | 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp'; type SDataFormat = 'uuid'; type SContentEncoding = 'base64' | 'base64url' | 'quoted-printable' | 'binary'; type SDataType = 'integer' | 'number' | 'string' | 'boolean' | 'array' | 'object' | 'null'; type HttpStatusTypes = '100' | '101' | '102' | '103' | '200' | '201' | '202' | '203' | '204' | '205' | '206' | '207' | '208' | '226' | '300' | '301' | '302' | '303' | '304' | '305' | '306' | '307' | '308' | '400' | '401' | '402' | '403' | '404' | '405' | '406' | '407' | '408' | '409' | '410' | '411' | '412' | '413' | '414' | '415' | '416' | '417' | '418' | '421' | '422' | '423' | '424' | '425' | '426' | '428' | '429' | '431' | '451' | '500' | '501' | '502' | '503' | '504' | '505' | '506' | '507' | '508' | '510' | '511'; //#endregion //#region src/Swagger/Meta/SwaggerTypes.d.ts declare const OPENAPI_VERSION = "3.2.0"; type OpenApiVersion = typeof OPENAPI_VERSION; type SwaggerPathInput = { path: SwaggerRPath; prefix?: string; }; type SwaggerRRef = { $ref: string; }; declare function isSwaggerRef(o: unknown): o is SwaggerRRef; type SwaggerRPathConfResponseDef = SwaggerCompResponse | SwaggerRRef; type SwaggerRPath = SKey; type SwaggerRPathConfResponse = { [K in HttpStatusTypes]?: SwaggerRPathConfResponseDef; }; interface SwaggerRPathReqBody { content?: SwaggerContent; description?: string; } interface SwaggerRPathParameter { content?: SwaggerContent; description?: string; name: string; required: boolean; schema?: SSchemaEl; in?: 'query' | 'header' | 'path'; } interface SwaggerRPathConf { responses?: SwaggerRPathConfResponse; description?: string; summary?: string; tags?: string[]; operationId?: string; requestBody?: SwaggerRPathReqBody; parameters?: SwaggerRPathParameter[]; deprecated?: boolean; } interface SwaggerRPathTypes { get?: SwaggerRPathConf; post?: SwaggerRPathConf; patch?: SwaggerRPathConf; delete?: SwaggerRPathConf; query?: SwaggerRPathConf; } interface SwaggerRInfoLicence { name: string; url?: string; } interface SwaggerRServer { url: string; description?: string; variables?: string | string[]; } interface SwaggerRInfo { title: string; description?: string; termsOfService?: string; version: string; license?: SwaggerRInfoLicence; } type SSchemaElObj = { type: SDataType | SDataType[]; /** * @deprecated Deprecated since OpenAPI 3.1, use {@link SSchemaElObj.examples} instead. */ example?: unknown; examples?: unknown[]; format?: SDataFormat; contentMediaType?: SMediaType; contentEncoding?: SContentEncoding; description?: string; properties?: { [key: string]: SSchemaEl; }; items?: SSchemaEl; required?: string[]; enum?: string[]; deprecated?: boolean; }; type SSchemaEl = SSchemaElObj | SwaggerRRef; type SwaggerContent = { [K in SMediaType]?: { schema: SSchemaEl; }; }; type SwaggerCompResponse = { description?: string; content?: SwaggerContent; }; type SwaggerComSecuritySchemes = { in?: 'query' | 'header' | 'cookie'; scheme: string; type: 'apiKey' | 'http' | 'oauth2' | 'openIdConnect'; bearerFormat?: string | 'JWT'; description?: string; }; interface SKey { [key: string]: T; } interface SwaggerConfigComponents { securitySchemes?: SKey; responses?: SKey; schemas?: SKey; } interface SwaggerConfig { openapi: OpenApiVersion; info: SwaggerRInfo; servers?: SwaggerRServer[]; paths: SwaggerRPath; security?: [SKey]; tags?: string[]; components?: SwaggerConfigComponents; } /** * Caller facing shape of {@link SwaggerConfig}. `openapi` may be omitted because * swagger-mate always normalizes it to {@link OPENAPI_VERSION}. */ type SwaggerConfigInput = Omit & { openapi?: OpenApiVersion; }; interface MergeInputType { path: SwaggerPathInput | undefined; comp: SwaggerConfigComponents | undefined; } //#endregion //#region src/Swagger/Client/SwaggerClient.d.ts declare class SwaggerClient { static genAPICConnector(options: { conf: SwaggerConfig; name?: string; version?: string; writeMeta?: boolean; }): void; } //#endregion //#region src/Swagger/Path/ESchemaEditor.d.ts type ESchemaAddOptionEntity = { key: string; list?: boolean; entity: CoreEntity; required?: boolean; nullable?: boolean; }; type ESchemaAddOptionSchema = { key: string; list?: boolean; schema: SSchemaElObj; required?: boolean; nullable?: boolean; }; type ESchemaAddOptionRef = { key: string; list?: boolean; schema: SwaggerRRef; required?: boolean; }; type ESchemaAddOption = ESchemaAddOptionEntity | ESchemaAddOptionSchema | ESchemaAddOptionRef; declare class ESchemaEditor { private data; private name; private constructor(); /** * Removes the specified keys from the schema's properties and updates the required list. * * @param {...(keyof T)} keys - The keys of the properties to remove. * @returns {ESchemaEditor} The editor instance for method chaining. */ remove(...keys: (keyof T)[]): ESchemaEditor; /** * Adds properties to the schema based on the provided options. * * @param {...ESchemaAddOption} options The options describing the properties to add. Each option may specify a * `key`, a `schema` or an `entity`, and optionally whether the property is a `list`, `nullable`, or `required`. * @returns {ESchemaEditor} The editor instance for chaining. */ add(...options: ESchemaAddOption[]): ESchemaEditor; getSchema(): SSchemaElObj; getSKeySchema(): SKey; static fromEntity(e: J): ESchemaEditor; /** * Generates a JSON schema representation from a CoreEntity instance. * * This method inspects the entity's metadata to construct a schema object * describing the entity's shape. The resulting schema contains: * - `type`: always `"object"`. * - `description`: a string indicating the entity name. * - `required`: an array of property names that are defined on the entity. * - `properties`: an object mapping each property name to an object that * includes the resolved database type and its nullability. * * If no metadata is found for the provided entity, the method returns `undefined`. * * @param {T} entity - The entity instance for which to create a schema. * @returns {SSchemaElObj | undefined} The generated schema object, or `undefined` * if the entity's metadata could not be retrieved. */ static schemaFromEntity(entity: T): SSchemaElObj | undefined; } //#endregion //#region src/Swagger/Path/SPathUtil.d.ts declare class SPathUtil { /** * Generates a default response mapping for the specified HTTP status types. * * @param {HttpStatusTypes[]} types - The HTTP status types for which default responses should be created. * @return {SwaggerRPathConfResponse} An object mapping each provided status type to its default response definition. */ static defaultResponse(...types: HttpStatusTypes[]): SwaggerRPathConfResponse; /** * Creates a request body definition for JSON content type using the provided schema. * * @param {SSchemaEl} schema - The JSON schema used for validating the request body. * @return {SwaggerRPathReqBody} A Swagger path request body object specifying application/json content type with the provided schema. */ static jsonBody(schema: SSchemaEl): SwaggerRPathReqBody; /** * Builds a Swagger request body for `multipart/form-data` requests. * * @param {SSchemaEl} [schema] Optional schema describing the form data. * If omitted, a default schema with a single binary `file` field is provided. * @return {SwaggerRPathReqBody} Swagger request body definition with * `multipart/form-data` content and the supplied or default schema. */ static formBody(schema?: SSchemaEl): SwaggerRPathReqBody; /** * Generates a Swagger content definition for the provided entity. * * @param {T} entity - The entity instance to derive the Swagger schema from. * @param {boolean} [list] - When true, the schema will be wrapped in an array type, representing a list of entities. * * @returns {SwaggerContent|undefined} The Swagger content object for the entity, or `undefined` if the entity does not have a schema. */ static entityContent(entity: T, list?: boolean): SwaggerContent | undefined; /** * @template T extends CoreEntity * @param {T} entity - The entity instance for which to build the response configuration. * @param {boolean} [list] - Indicates whether the response should represent a list of entities. * @param {boolean} [create] - Indicates whether the response corresponds to a creation operation (status code 201); otherwise 200. * @returns {SwaggerRPathConfResponse} The Swagger response configuration object containing the appropriate status code and content. */ static entityResponse(entity: T, list?: boolean, create?: boolean): SwaggerRPathConfResponse; /** * Builds a JSON schema reference path for the given component name. * * @param {string} inp - The name of the schema component. * @return {string} The JSON reference path formatted as `#/components/schemas/`. */ static schemaPath(inp: string): string; /** * Creates a Swagger request body definition that references a schema. * * @param {string | CoreEntity} $ref * Either the string reference to a schema or a `CoreEntity` instance whose * class name will be used to build the reference path. * @param {boolean} list * If true, the referenced schema is wrapped in an array; otherwise the * schema is used directly. * @returns {SwaggerRPathReqBody} * The request body object containing the appropriate content and schema * configuration. */ static refRequest($ref: string | CoreEntity, list: boolean): SwaggerRPathReqBody; /** * Creates a Swagger response configuration for a given HTTP status code. * * @param {HttpStatusTypes} code - The primary HTTP status code for */ static refResponse(code: HttpStatusTypes, $ref: string | CoreEntity, list: boolean, ...addCodes: HttpStatusTypes[]): SwaggerRPathConfResponse; /** * Builds a Swagger response configuration object for a given HTTP status code and schema. * * @param {HttpStatusTypes} code - The primary HTTP status code for the response. * @param {SSchemaEl} schema - The JSON schema definition for the response body. * @param {boolean} list - If true, the schema is wrapped in an array for list responses. * @param {...HttpStatusTypes} addCodes - Additional HTTP status codes for default responses. * @return {SwaggerRPathConfResponse} The constructed response configuration object. */ static jsonResponse(code: HttpStatusTypes, schema: SSchemaEl, list: boolean, ...addCodes: HttpStatusTypes[]): SwaggerRPathConfResponse; /** * Generates a JSON schema representation from a CoreEntity instance. * * This method inspects the entity's metadata to construct a schema object * describing the entity's shape. The resulting schema contains: * - `type`: always `"object"`. * - `description`: a string indicating the entity name. * - `required`: an array of property names that are defined on the entity. * - `properties`: an object mapping each property name to an object that * includes the resolved database type and its nullability. * * If no metadata is found for the provided entity, the method returns `undefined`. * * @param {T} entity - The entity instance for which to create a schema. * @returns {SSchemaElObj | undefined} The generated schema object, or `undefined` * if the entity's metadata could not be retrieved. * @deprecated Use {@link ESchemaEditor.schemaFromEntity} instead. */ static schemaFromEntity(entity: T): SSchemaElObj | undefined; /** * Generates a content schema object for the given entity. The schema contains a description derived from the entity metadata and a JSON content schema based on the entity's structure. * * @param {T} entity - The entity instance for which to generate the content schema. The generic type `T` must extend {@link CoreEntity}. * @returns {{ description: string; content: { 'application/json': { schema: SSchemaEl } }; } | undefined} An object containing the content schema, or `undefined` if no metadata is available for the entity. */ static contentSchemaFromEntity(entity: T): { description: string; content: { 'application/json': { schema: SSchemaEl; }; }; } | undefined; /** * Generates a mapping from entity names to their corresponding schema objects. * * @param {CoreEntity[]} e The entities for which schema entries should be generated. * @return {SKey} An object whose keys are entity names and values are the schemas derived from those entities. */ static schemaEntryGen(...e: CoreEntity[]): SKey; /** * Builds a JSON schema representation for an entity view that includes both the * entity data and its related entity map. * * @param entity The primary entity used to construct the `dat` portion of the schema. * @param entityMap The related entity map used to construct the `join_map` portion of the schema. * @returns A {@link SSchemaEl} object schema with properties `i`, `dat`, and `join_map`. */ static schemaFromEntityView(entity: A, entityMap: B): SSchemaEl; static editor(e: J): ESchemaEditor; } //#endregion //#region src/Swagger/annotation/index.d.ts declare enum ActionMode { 'DEFAULT' = 0, 'DMZ' = 1, 'DMZ_WITH_USER' = 2 } type ActionTypes = 'POST' | 'GET' | 'USE' | 'PATCH' | 'DELETE' | 'QUERY'; /** * LIST - Response is an array of items * SINGLE - Response is a single item (default) */ type ResponseRequestTypes = 'LIST' | 'SINGLE'; type RouteMeta = { pathOverride?: string; mode?: ActionMode; requestSchema?: SSchemaEl | CoreEntity | string; responseSchema?: SSchemaEl | CoreEntity | string; requestType?: ResponseRequestTypes; responseType?: ResponseRequestTypes; responseCodes?: HttpStatusTypes[]; } & SwaggerRPathConf; type RouteData = { type: ActionTypes; path: string; meta?: RouteMeta; }; declare const Route: (type: RouteData["type"], path: RouteData["path"], meta?: RouteMeta) => ClassDecorator; declare function getRouteMeta(target: T): RouteData | undefined; //#endregion //#region src/Swagger/SwaggerUtil.d.ts declare class SwaggerUtil { static logger: CoreLogChannel | null; static getLogger(): CoreLogChannel; static writeMeta(conf: SwaggerConfig, kind: 'JSON' | 'YAML', path?: string): void; static readMeta(path: string): any; /** * Serves a meta page for Swagger UI or rapi-doc. * * @param {SwaggerConfig} conf The swagger configuration to expose via `/spec`. * @param {Object} [option] Options for serving the meta page. * @param {'swagger-ui'|'rapi-doc'} [option.type='swagger-ui'] The type of UI to serve. * @param {number} [option.port] The port to listen on. Defaults to 9000. * @param {string} [option.auth] Optional authentication key appended to the URL. * @returns {Promise} A promise that resolves with the created server instance or null. */ static serveMeta(conf: SwaggerConfig, option?: { type?: 'swagger-ui' | 'scalar'; port?: number; auth?: string; }): Promise; static metaExtractor(root: ObjectLike, npmPackageVersion: boolean, ...path: ObjectLike[]): SwaggerConfig | undefined; static routeToSwaggerPath(route: RouteData): SwaggerRPath; static merge(root: SwaggerConfig, data: MergeInputType[]): SwaggerConfig; static mergeConfig(root: SwaggerConfig, data: SwaggerConfig[]): SwaggerConfig; } //#endregion //#region src/Swagger/Meta/Swagger.d.ts declare const Swagger: (config: SwaggerConfigInput) => ClassDecorator; declare function getSwaggerMeta(target: T): SwaggerConfig | undefined; declare const SPath: (path: SwaggerRPath, prefix?: string) => ClassDecorator; declare function getSPath(target: T): SwaggerPathInput | undefined; declare const SComponent: (comp: SwaggerConfigComponents) => ClassDecorator; declare function getSComponent(target: T): SwaggerConfigComponents | undefined; //#endregion export { ActionMode, ActionTypes, ESchemaAddOption, ESchemaAddOptionEntity, ESchemaAddOptionRef, ESchemaAddOptionSchema, ESchemaEditor, HttpStatusTypes, MergeInputType, OPENAPI_VERSION, OpenApiVersion, ResponseRequestTypes, Route, RouteData, RouteMeta, SComponent, SContentEncoding, SDataFormat, SDataType, SKey, SMediaType, SPath, SPathUtil, SSchemaEl, SSchemaElObj, Swagger, SwaggerClient, SwaggerComSecuritySchemes, SwaggerCompResponse, SwaggerConfig, SwaggerConfigComponents, SwaggerConfigInput, SwaggerContent, SwaggerPathInput, SwaggerRInfo, SwaggerRInfoLicence, SwaggerRPath, SwaggerRPathConf, SwaggerRPathConfResponse, SwaggerRPathConfResponseDef, SwaggerRPathParameter, SwaggerRPathReqBody, SwaggerRPathTypes, SwaggerRRef, SwaggerRServer, SwaggerUtil, getRouteMeta, getSComponent, getSPath, getSwaggerMeta, isSwaggerRef };