@forinda/kickjs-core 0.3.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.
@@ -0,0 +1,75 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-7QVYU63E.js";
4
+
5
+ // src/logger.ts
6
+ import pino from "pino";
7
+ var isDev = process.env.NODE_ENV !== "production";
8
+ var rootLogger = pino({
9
+ level: process.env.LOG_LEVEL || "info",
10
+ ...isDev ? {
11
+ transport: {
12
+ target: "pino-pretty",
13
+ options: {
14
+ colorize: true,
15
+ translateTime: "SYS:HH:MM:ss.l"
16
+ }
17
+ }
18
+ } : {}
19
+ });
20
+ var loggerCache = /* @__PURE__ */ new Map();
21
+ var Logger = class _Logger {
22
+ static {
23
+ __name(this, "Logger");
24
+ }
25
+ log;
26
+ constructor(name) {
27
+ this.log = name ? rootLogger.child({
28
+ component: name
29
+ }) : rootLogger;
30
+ }
31
+ /** Create or retrieve a cached named logger */
32
+ static for(name) {
33
+ let cached = loggerCache.get(name);
34
+ if (!cached) {
35
+ cached = new _Logger(name);
36
+ loggerCache.set(name, cached);
37
+ }
38
+ return cached;
39
+ }
40
+ /** Create a child logger with a sub-component name */
41
+ child(name) {
42
+ return new _Logger(name);
43
+ }
44
+ info(msg, ...args) {
45
+ this.log.info(msg, ...args);
46
+ }
47
+ warn(msg, ...args) {
48
+ this.log.warn(msg, ...args);
49
+ }
50
+ error(msgOrObj, msg, ...args) {
51
+ this.log.error(msgOrObj, msg, ...args);
52
+ }
53
+ debug(msg, ...args) {
54
+ this.log.debug(msg, ...args);
55
+ }
56
+ trace(msg, ...args) {
57
+ this.log.trace(msg, ...args);
58
+ }
59
+ fatal(msg, ...args) {
60
+ this.log.fatal(msg, ...args);
61
+ }
62
+ };
63
+ function createLogger(name) {
64
+ return Logger.for(name);
65
+ }
66
+ __name(createLogger, "createLogger");
67
+ var logger = rootLogger;
68
+
69
+ export {
70
+ rootLogger,
71
+ Logger,
72
+ createLogger,
73
+ logger
74
+ };
75
+ //# sourceMappingURL=chunk-IHZOCBCK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/logger.ts"],"sourcesContent":["import pino from 'pino'\n\nconst isDev = process.env.NODE_ENV !== 'production'\n\n/** Root pino logger instance */\nexport const rootLogger = pino({\n level: process.env.LOG_LEVEL || 'info',\n ...(isDev\n ? {\n transport: {\n target: 'pino-pretty',\n options: { colorize: true, translateTime: 'SYS:HH:MM:ss.l' },\n },\n }\n : {}),\n})\n\n/** Cache of named loggers to avoid creating duplicates */\nconst loggerCache = new Map<string, Logger>()\n\n/**\n * Named logger with component context.\n *\n * @example\n * ```ts\n * // Static factory — preferred\n * const log = Logger.for('UserService')\n * log.info('User created')\n * // Output: [UserService] User created\n *\n * // Shorthand function\n * const log = createLogger('OrderService')\n *\n * // Injectable — auto-named from class\n * class MyService {\n * @Autowired() private logger!: Logger\n * // or inject a named one:\n * private log = Logger.for('MyService')\n * }\n * ```\n */\nexport class Logger {\n private log: pino.Logger\n\n constructor(name?: string) {\n this.log = name ? rootLogger.child({ component: name }) : rootLogger\n }\n\n /** Create or retrieve a cached named logger */\n static for(name: string): Logger {\n let cached = loggerCache.get(name)\n if (!cached) {\n cached = new Logger(name)\n loggerCache.set(name, cached)\n }\n return cached\n }\n\n /** Create a child logger with a sub-component name */\n child(name: string): Logger {\n return new Logger(name)\n }\n\n info(msg: string, ...args: any[]) {\n this.log.info(msg, ...args)\n }\n\n warn(msg: string, ...args: any[]) {\n this.log.warn(msg, ...args)\n }\n\n error(msgOrObj: any, msg?: string, ...args: any[]) {\n this.log.error(msgOrObj, msg, ...args)\n }\n\n debug(msg: string, ...args: any[]) {\n this.log.debug(msg, ...args)\n }\n\n trace(msg: string, ...args: any[]) {\n this.log.trace(msg, ...args)\n }\n\n fatal(msg: string, ...args: any[]) {\n this.log.fatal(msg, ...args)\n }\n}\n\n/** Shorthand for Logger.for(name) */\nexport function createLogger(name: string): Logger {\n return Logger.for(name)\n}\n\n/** @deprecated Use rootLogger instead */\nexport const logger = rootLogger\n"],"mappings":";;;;;AAAA,OAAOA,UAAU;AAEjB,IAAMC,QAAQC,QAAQC,IAAIC,aAAa;AAGhC,IAAMC,aAAaC,KAAK;EAC7BC,OAAOL,QAAQC,IAAIK,aAAa;EAChC,GAAIP,QACA;IACEQ,WAAW;MACTC,QAAQ;MACRC,SAAS;QAAEC,UAAU;QAAMC,eAAe;MAAiB;IAC7D;EACF,IACA,CAAC;AACP,CAAA;AAGA,IAAMC,cAAc,oBAAIC,IAAAA;AAuBjB,IAAMC,SAAN,MAAMA,QAAAA;EAzCb,OAyCaA;;;EACHC;EAER,YAAYC,MAAe;AACzB,SAAKD,MAAMC,OAAOb,WAAWc,MAAM;MAAEC,WAAWF;IAAK,CAAA,IAAKb;EAC5D;;EAGA,OAAOgB,IAAIH,MAAsB;AAC/B,QAAII,SAASR,YAAYS,IAAIL,IAAAA;AAC7B,QAAI,CAACI,QAAQ;AACXA,eAAS,IAAIN,QAAOE,IAAAA;AACpBJ,kBAAYU,IAAIN,MAAMI,MAAAA;IACxB;AACA,WAAOA;EACT;;EAGAH,MAAMD,MAAsB;AAC1B,WAAO,IAAIF,QAAOE,IAAAA;EACpB;EAEAO,KAAKC,QAAgBC,MAAa;AAChC,SAAKV,IAAIQ,KAAKC,KAAAA,GAAQC,IAAAA;EACxB;EAEAC,KAAKF,QAAgBC,MAAa;AAChC,SAAKV,IAAIW,KAAKF,KAAAA,GAAQC,IAAAA;EACxB;EAEAE,MAAMC,UAAeJ,QAAiBC,MAAa;AACjD,SAAKV,IAAIY,MAAMC,UAAUJ,KAAAA,GAAQC,IAAAA;EACnC;EAEAI,MAAML,QAAgBC,MAAa;AACjC,SAAKV,IAAIc,MAAML,KAAAA,GAAQC,IAAAA;EACzB;EAEAK,MAAMN,QAAgBC,MAAa;AACjC,SAAKV,IAAIe,MAAMN,KAAAA,GAAQC,IAAAA;EACzB;EAEAM,MAAMP,QAAgBC,MAAa;AACjC,SAAKV,IAAIgB,MAAMP,KAAAA,GAAQC,IAAAA;EACzB;AACF;AAGO,SAASO,aAAahB,MAAY;AACvC,SAAOF,OAAOK,IAAIH,IAAAA;AACpB;AAFgBgB;AAKT,IAAMC,SAAS9B;","names":["pino","isDev","process","env","NODE_ENV","rootLogger","pino","level","LOG_LEVEL","transport","target","options","colorize","translateTime","loggerCache","Map","Logger","log","name","child","component","for","cached","get","set","info","msg","args","warn","error","msgOrObj","debug","trace","fatal","createLogger","logger"]}
@@ -0,0 +1,56 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-7QVYU63E.js";
4
+
5
+ // src/errors.ts
6
+ var HttpException = class _HttpException extends Error {
7
+ static {
8
+ __name(this, "HttpException");
9
+ }
10
+ status;
11
+ details;
12
+ constructor(status, message, details) {
13
+ super(message), this.status = status, this.details = details;
14
+ this.name = "HttpException";
15
+ }
16
+ /** Create from a Zod error */
17
+ static fromZodError(error, message) {
18
+ const firstIssue = error.issues?.[0];
19
+ return new _HttpException(422, message || firstIssue?.message || "Validation failed", [
20
+ ...(error.issues || []).map((issue) => ({
21
+ field: issue.path?.join(".") || "",
22
+ message: issue.message,
23
+ code: issue.code
24
+ }))
25
+ ]);
26
+ }
27
+ static badRequest(message = "Bad Request") {
28
+ return new _HttpException(400, message);
29
+ }
30
+ static unauthorized(message = "Unauthorized") {
31
+ return new _HttpException(401, message);
32
+ }
33
+ static forbidden(message = "Forbidden") {
34
+ return new _HttpException(403, message);
35
+ }
36
+ static notFound(message = "Not Found") {
37
+ return new _HttpException(404, message);
38
+ }
39
+ static conflict(message = "Conflict") {
40
+ return new _HttpException(409, message);
41
+ }
42
+ static unprocessable(message = "Unprocessable Entity", details) {
43
+ return new _HttpException(422, message, details);
44
+ }
45
+ static tooManyRequests(message = "Too Many Requests") {
46
+ return new _HttpException(429, message);
47
+ }
48
+ static internal(message = "Internal Server Error") {
49
+ return new _HttpException(500, message);
50
+ }
51
+ };
52
+
53
+ export {
54
+ HttpException
55
+ };
56
+ //# sourceMappingURL=chunk-PKJSIVAI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"sourcesContent":["/** Validation error detail */\nexport interface ValidationError {\n field: string\n message: string\n code?: string\n}\n\n/**\n * Typed HTTP exception with status code and optional validation details.\n * Provides static factory methods for common HTTP errors.\n */\nexport class HttpException extends Error {\n constructor(\n public readonly status: number,\n message: string,\n public readonly details?: ValidationError[],\n ) {\n super(message)\n this.name = 'HttpException'\n }\n\n /** Create from a Zod error */\n static fromZodError(error: any, message?: string): HttpException {\n const firstIssue = error.issues?.[0]\n return new HttpException(422, message || firstIssue?.message || 'Validation failed', [\n ...(error.issues || []).map((issue: any) => ({\n field: issue.path?.join('.') || '',\n message: issue.message,\n code: issue.code,\n })),\n ])\n }\n\n static badRequest(message = 'Bad Request') {\n return new HttpException(400, message)\n }\n static unauthorized(message = 'Unauthorized') {\n return new HttpException(401, message)\n }\n static forbidden(message = 'Forbidden') {\n return new HttpException(403, message)\n }\n static notFound(message = 'Not Found') {\n return new HttpException(404, message)\n }\n static conflict(message = 'Conflict') {\n return new HttpException(409, message)\n }\n static unprocessable(message = 'Unprocessable Entity', details?: ValidationError[]) {\n return new HttpException(422, message, details)\n }\n static tooManyRequests(message = 'Too Many Requests') {\n return new HttpException(429, message)\n }\n static internal(message = 'Internal Server Error') {\n return new HttpException(500, message)\n }\n}\n"],"mappings":";;;;;AAWO,IAAMA,gBAAN,MAAMA,uBAAsBC,MAAAA;EAXnC,OAWmCA;;;;;EACjC,YACkBC,QAChBC,SACgBC,SAChB;AACA,UAAMD,OAAAA,GAAAA,KAJUD,SAAAA,QAAAA,KAEAE,UAAAA;AAGhB,SAAKC,OAAO;EACd;;EAGA,OAAOC,aAAaC,OAAYJ,SAAiC;AAC/D,UAAMK,aAAaD,MAAME,SAAS,CAAA;AAClC,WAAO,IAAIT,eAAc,KAAKG,WAAWK,YAAYL,WAAW,qBAAqB;UAC/EI,MAAME,UAAU,CAAA,GAAIC,IAAI,CAACC,WAAgB;QAC3CC,OAAOD,MAAME,MAAMC,KAAK,GAAA,KAAQ;QAChCX,SAASQ,MAAMR;QACfY,MAAMJ,MAAMI;MACd,EAAA;KACD;EACH;EAEA,OAAOC,WAAWb,UAAU,eAAe;AACzC,WAAO,IAAIH,eAAc,KAAKG,OAAAA;EAChC;EACA,OAAOc,aAAad,UAAU,gBAAgB;AAC5C,WAAO,IAAIH,eAAc,KAAKG,OAAAA;EAChC;EACA,OAAOe,UAAUf,UAAU,aAAa;AACtC,WAAO,IAAIH,eAAc,KAAKG,OAAAA;EAChC;EACA,OAAOgB,SAAShB,UAAU,aAAa;AACrC,WAAO,IAAIH,eAAc,KAAKG,OAAAA;EAChC;EACA,OAAOiB,SAASjB,UAAU,YAAY;AACpC,WAAO,IAAIH,eAAc,KAAKG,OAAAA;EAChC;EACA,OAAOkB,cAAclB,UAAU,wBAAwBC,SAA6B;AAClF,WAAO,IAAIJ,eAAc,KAAKG,SAASC,OAAAA;EACzC;EACA,OAAOkB,gBAAgBnB,UAAU,qBAAqB;AACpD,WAAO,IAAIH,eAAc,KAAKG,OAAAA;EAChC;EACA,OAAOoB,SAASpB,UAAU,yBAAyB;AACjD,WAAO,IAAIH,eAAc,KAAKG,OAAAA;EAChC;AACF;","names":["HttpException","Error","status","message","details","name","fromZodError","error","firstIssue","issues","map","issue","field","path","join","code","badRequest","unauthorized","forbidden","notFound","conflict","unprocessable","tooManyRequests","internal"]}
@@ -0,0 +1,37 @@
1
+ // src/interfaces.ts
2
+ import "reflect-metadata";
3
+ var Scope = /* @__PURE__ */ (function(Scope2) {
4
+ Scope2["SINGLETON"] = "singleton";
5
+ Scope2["TRANSIENT"] = "transient";
6
+ return Scope2;
7
+ })({});
8
+ var METADATA = {
9
+ INJECTABLE: /* @__PURE__ */ Symbol("kick:injectable"),
10
+ SCOPE: /* @__PURE__ */ Symbol("kick:scope"),
11
+ AUTOWIRED: /* @__PURE__ */ Symbol("kick:autowired"),
12
+ INJECT: /* @__PURE__ */ Symbol("kick:inject"),
13
+ CONFIGURATION: /* @__PURE__ */ Symbol("kick:configuration"),
14
+ BEAN: /* @__PURE__ */ Symbol("kick:bean"),
15
+ BEAN_OPTIONS: /* @__PURE__ */ Symbol("kick:bean:options"),
16
+ POST_CONSTRUCT: /* @__PURE__ */ Symbol("kick:post_construct"),
17
+ TRANSACTIONAL: /* @__PURE__ */ Symbol("kick:transactional"),
18
+ BUILDER: /* @__PURE__ */ Symbol("kick:builder"),
19
+ CONTROLLER_PATH: /* @__PURE__ */ Symbol("kick:controller:path"),
20
+ ROUTES: /* @__PURE__ */ Symbol("kick:routes"),
21
+ CLASS_MIDDLEWARES: /* @__PURE__ */ Symbol("kick:class:middlewares"),
22
+ METHOD_MIDDLEWARES: /* @__PURE__ */ Symbol("kick:method:middlewares"),
23
+ FILE_UPLOAD: /* @__PURE__ */ Symbol("kick:file:upload"),
24
+ VALUE: /* @__PURE__ */ Symbol("kick:value"),
25
+ // TypeScript emit metadata keys
26
+ PARAM_TYPES: "design:paramtypes",
27
+ PROPERTY_TYPE: "design:type",
28
+ RETURN_TYPE: "design:returntype"
29
+ };
30
+ var TRANSACTION_MANAGER = /* @__PURE__ */ Symbol("TransactionManager");
31
+
32
+ export {
33
+ Scope,
34
+ METADATA,
35
+ TRANSACTION_MANAGER
36
+ };
37
+ //# sourceMappingURL=chunk-RYMYKGZK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/interfaces.ts"],"sourcesContent":["import 'reflect-metadata'\n\n/** Lifecycle scope for DI registrations */\nexport enum Scope {\n SINGLETON = 'singleton',\n TRANSIENT = 'transient',\n}\n\n/** Generic constructor type */\nexport type Constructor<T = any> = new (...args: any[]) => T\n\n/** Options for @Service, @Repository, @Component decorators */\nexport interface ServiceOptions {\n scope?: Scope\n}\n\n/** Options for @Bean decorator */\nexport interface BeanOptions {\n scope?: Scope\n}\n\n/** Transaction manager interface for @Transactional support */\nexport interface TransactionManager<TTx = unknown> {\n begin(): Promise<TTx>\n commit(tx: TTx): Promise<void>\n rollback(tx: TTx): Promise<void>\n}\n\n/** Fluent builder type */\nexport type BuilderOf<T> = {\n [K in keyof T as T[K] extends Function ? never : K]-?: (value: T[K]) => BuilderOf<T>\n} & { build(): T }\n\n/** Class with static builder() method */\nexport interface Buildable<T> {\n builder(): BuilderOf<T>\n}\n\n/** Symbol-based metadata keys for the DI system */\nexport const METADATA = {\n INJECTABLE: Symbol('kick:injectable'),\n SCOPE: Symbol('kick:scope'),\n AUTOWIRED: Symbol('kick:autowired'),\n INJECT: Symbol('kick:inject'),\n CONFIGURATION: Symbol('kick:configuration'),\n BEAN: Symbol('kick:bean'),\n BEAN_OPTIONS: Symbol('kick:bean:options'),\n POST_CONSTRUCT: Symbol('kick:post_construct'),\n TRANSACTIONAL: Symbol('kick:transactional'),\n BUILDER: Symbol('kick:builder'),\n CONTROLLER_PATH: Symbol('kick:controller:path'),\n ROUTES: Symbol('kick:routes'),\n CLASS_MIDDLEWARES: Symbol('kick:class:middlewares'),\n METHOD_MIDDLEWARES: Symbol('kick:method:middlewares'),\n FILE_UPLOAD: Symbol('kick:file:upload'),\n VALUE: Symbol('kick:value'),\n // TypeScript emit metadata keys\n PARAM_TYPES: 'design:paramtypes',\n PROPERTY_TYPE: 'design:type',\n RETURN_TYPE: 'design:returntype',\n} as const\n\n/** DI token for transaction manager */\nexport const TRANSACTION_MANAGER = Symbol('TransactionManager')\n"],"mappings":";AAAA,OAAO;AAGA,IAAKA,QAAAA,0BAAAA,QAAAA;;;SAAAA;;AAoCL,IAAMC,WAAW;EACtBC,YAAYC,uBAAO,iBAAA;EACnBC,OAAOD,uBAAO,YAAA;EACdE,WAAWF,uBAAO,gBAAA;EAClBG,QAAQH,uBAAO,aAAA;EACfI,eAAeJ,uBAAO,oBAAA;EACtBK,MAAML,uBAAO,WAAA;EACbM,cAAcN,uBAAO,mBAAA;EACrBO,gBAAgBP,uBAAO,qBAAA;EACvBQ,eAAeR,uBAAO,oBAAA;EACtBS,SAAST,uBAAO,cAAA;EAChBU,iBAAiBV,uBAAO,sBAAA;EACxBW,QAAQX,uBAAO,aAAA;EACfY,mBAAmBZ,uBAAO,wBAAA;EAC1Ba,oBAAoBb,uBAAO,yBAAA;EAC3Bc,aAAad,uBAAO,kBAAA;EACpBe,OAAOf,uBAAO,YAAA;;EAEdgB,aAAa;EACbC,eAAe;EACfC,aAAa;AACf;AAGO,IAAMC,sBAAsBnB,uBAAO,oBAAA;","names":["Scope","METADATA","INJECTABLE","Symbol","SCOPE","AUTOWIRED","INJECT","CONFIGURATION","BEAN","BEAN_OPTIONS","POST_CONSTRUCT","TRANSACTIONAL","BUILDER","CONTROLLER_PATH","ROUTES","CLASS_MIDDLEWARES","METHOD_MIDDLEWARES","FILE_UPLOAD","VALUE","PARAM_TYPES","PROPERTY_TYPE","RETURN_TYPE","TRANSACTION_MANAGER"]}
@@ -0,0 +1,40 @@
1
+ import { Constructor, Scope } from './interfaces.js';
2
+
3
+ /**
4
+ * Inversion-of-Control (IoC) container that manages dependency registration,
5
+ * resolution, and lifecycle. Implements the Singleton pattern so all parts of
6
+ * the application share a single container instance.
7
+ *
8
+ * Supports constructor injection, property injection (@Autowired),
9
+ * factory-based beans (@Bean), and lifecycle hooks (@PostConstruct).
10
+ */
11
+ declare class Container {
12
+ private static instance;
13
+ private registrations;
14
+ private resolving;
15
+ /** Callback set by the decorators module to flush pending registrations */
16
+ static _onReady: ((container: Container) => void) | null;
17
+ static getInstance(): Container;
18
+ /**
19
+ * Resets the container by replacing the singleton with a fresh instance.
20
+ * Useful for testing to ensure a clean slate between test runs.
21
+ */
22
+ static reset(): void;
23
+ /** Register a class constructor under the given token */
24
+ register(token: any, target: Constructor, scope?: Scope): void;
25
+ /** Register a factory function under the given token */
26
+ registerFactory(token: any, factory: () => any, scope?: Scope): void;
27
+ /** Register a pre-constructed singleton instance */
28
+ registerInstance(token: any, instance: any): void;
29
+ /** Check if a binding exists for the given token */
30
+ has(token: any): boolean;
31
+ /** Resolve a dependency by its token */
32
+ resolve<T = any>(token: any): T;
33
+ /** Process all @Configuration classes and invoke their @Bean methods */
34
+ bootstrap(): void;
35
+ private createInstance;
36
+ private injectProperties;
37
+ private processConfiguration;
38
+ }
39
+
40
+ export { Container };
@@ -0,0 +1,9 @@
1
+ import {
2
+ Container
3
+ } from "./chunk-AZH3H6VS.js";
4
+ import "./chunk-RYMYKGZK.js";
5
+ import "./chunk-7QVYU63E.js";
6
+ export {
7
+ Container
8
+ };
9
+ //# sourceMappingURL=container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,65 @@
1
+ import { BeanOptions, ServiceOptions } from './interfaces.js';
2
+
3
+ /** Mark a class as injectable with lifecycle scope */
4
+ declare function Injectable(options?: ServiceOptions): ClassDecorator;
5
+ /** Mark a class as a service (semantic alias for Injectable) */
6
+ declare function Service(options?: ServiceOptions): ClassDecorator;
7
+ /** Mark a class as a generic managed component */
8
+ declare function Component(options?: ServiceOptions): ClassDecorator;
9
+ /** Mark a class as a repository */
10
+ declare function Repository(options?: ServiceOptions): ClassDecorator;
11
+ /** Mark a class as a configuration provider for @Bean methods */
12
+ declare function Configuration(): ClassDecorator;
13
+ /** Mark a class as an HTTP controller with an optional route prefix */
14
+ declare function Controller(path?: string): ClassDecorator;
15
+ /** Mark a method inside @Configuration as a bean factory */
16
+ declare function Bean(options?: BeanOptions): MethodDecorator;
17
+ /** Mark a method as a lifecycle hook called after instantiation */
18
+ declare function PostConstruct(): MethodDecorator;
19
+ /** Wrap a method in a database transaction with auto commit/rollback */
20
+ declare function Transactional(): MethodDecorator;
21
+ /** Property injection — resolved lazily from the container */
22
+ declare function Autowired(token?: any): PropertyDecorator;
23
+ /** Constructor parameter injection with explicit token */
24
+ declare function Inject(token: any): ParameterDecorator;
25
+ /**
26
+ * Inject an environment variable value. Evaluated lazily so the env
27
+ * is available at access time, not at decoration time.
28
+ *
29
+ * If no default is provided and the env var is missing, throws at access time
30
+ * to catch misconfiguration early instead of returning undefined.
31
+ *
32
+ * Uses metadata + instance getter to work correctly with `useDefineForClassFields`.
33
+ */
34
+ declare function Value(envKey: string, defaultValue?: any): PropertyDecorator;
35
+ interface RouteDefinition {
36
+ method: string;
37
+ path: string;
38
+ handlerName: string;
39
+ validation?: {
40
+ body?: any;
41
+ query?: any;
42
+ params?: any;
43
+ };
44
+ }
45
+ declare const Get: (path?: string, validation?: RouteDefinition["validation"]) => MethodDecorator;
46
+ declare const Post: (path?: string, validation?: RouteDefinition["validation"]) => MethodDecorator;
47
+ declare const Put: (path?: string, validation?: RouteDefinition["validation"]) => MethodDecorator;
48
+ declare const Delete: (path?: string, validation?: RouteDefinition["validation"]) => MethodDecorator;
49
+ declare const Patch: (path?: string, validation?: RouteDefinition["validation"]) => MethodDecorator;
50
+ type MiddlewareHandler = (ctx: any, next: () => void) => void | Promise<void>;
51
+ /** Attach middleware handlers to a class or method */
52
+ declare function Middleware(...handlers: MiddlewareHandler[]): ClassDecorator & MethodDecorator;
53
+ interface FileUploadConfig {
54
+ mode: 'single' | 'array' | 'none';
55
+ fieldName?: string;
56
+ maxCount?: number;
57
+ maxSize?: number;
58
+ allowedMimeTypes?: string[];
59
+ }
60
+ /** Configure file upload handling for a controller method */
61
+ declare function FileUpload(config: FileUploadConfig): MethodDecorator;
62
+ /** Add a static builder() method for fluent construction */
63
+ declare function Builder(target: any): void;
64
+
65
+ export { Autowired, Bean, Builder, Component, Configuration, Controller, Delete, FileUpload, type FileUploadConfig, Get, Inject, Injectable, Middleware, type MiddlewareHandler, Patch, Post, PostConstruct, Put, Repository, type RouteDefinition, Service, Transactional, Value };
@@ -0,0 +1,48 @@
1
+ import {
2
+ Autowired,
3
+ Bean,
4
+ Builder,
5
+ Component,
6
+ Configuration,
7
+ Controller,
8
+ Delete,
9
+ FileUpload,
10
+ Get,
11
+ Inject,
12
+ Injectable,
13
+ Middleware,
14
+ Patch,
15
+ Post,
16
+ PostConstruct,
17
+ Put,
18
+ Repository,
19
+ Service,
20
+ Transactional,
21
+ Value
22
+ } from "./chunk-GAO2TPCH.js";
23
+ import "./chunk-AZH3H6VS.js";
24
+ import "./chunk-RYMYKGZK.js";
25
+ import "./chunk-7QVYU63E.js";
26
+ export {
27
+ Autowired,
28
+ Bean,
29
+ Builder,
30
+ Component,
31
+ Configuration,
32
+ Controller,
33
+ Delete,
34
+ FileUpload,
35
+ Get,
36
+ Inject,
37
+ Injectable,
38
+ Middleware,
39
+ Patch,
40
+ Post,
41
+ PostConstruct,
42
+ Put,
43
+ Repository,
44
+ Service,
45
+ Transactional,
46
+ Value
47
+ };
48
+ //# sourceMappingURL=decorators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,27 @@
1
+ /** Validation error detail */
2
+ interface ValidationError {
3
+ field: string;
4
+ message: string;
5
+ code?: string;
6
+ }
7
+ /**
8
+ * Typed HTTP exception with status code and optional validation details.
9
+ * Provides static factory methods for common HTTP errors.
10
+ */
11
+ declare class HttpException extends Error {
12
+ readonly status: number;
13
+ readonly details?: ValidationError[] | undefined;
14
+ constructor(status: number, message: string, details?: ValidationError[] | undefined);
15
+ /** Create from a Zod error */
16
+ static fromZodError(error: any, message?: string): HttpException;
17
+ static badRequest(message?: string): HttpException;
18
+ static unauthorized(message?: string): HttpException;
19
+ static forbidden(message?: string): HttpException;
20
+ static notFound(message?: string): HttpException;
21
+ static conflict(message?: string): HttpException;
22
+ static unprocessable(message?: string, details?: ValidationError[]): HttpException;
23
+ static tooManyRequests(message?: string): HttpException;
24
+ static internal(message?: string): HttpException;
25
+ }
26
+
27
+ export { HttpException, type ValidationError };
package/dist/errors.js ADDED
@@ -0,0 +1,8 @@
1
+ import {
2
+ HttpException
3
+ } from "./chunk-PKJSIVAI.js";
4
+ import "./chunk-7QVYU63E.js";
5
+ export {
6
+ HttpException
7
+ };
8
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,8 @@
1
+ export { Container } from './container.js';
2
+ export { BeanOptions, Buildable, BuilderOf, Constructor, METADATA, Scope, ServiceOptions, TRANSACTION_MANAGER, TransactionManager } from './interfaces.js';
3
+ export { Autowired, Bean, Builder, Component, Configuration, Controller, Delete, FileUpload, FileUploadConfig, Get, Inject, Injectable, Middleware, MiddlewareHandler, Patch, Post, PostConstruct, Put, Repository, RouteDefinition, Service, Transactional, Value } from './decorators.js';
4
+ export { AppModule, AppModuleClass, ModuleRoutes } from './app-module.js';
5
+ export { AdapterMiddleware, AppAdapter, AppAdapterClass, MiddlewarePhase } from './adapter.js';
6
+ export { Logger, createLogger, logger, rootLogger } from './logger.js';
7
+ export { HttpException, ValidationError } from './errors.js';
8
+ import 'pino';
package/dist/index.js ADDED
@@ -0,0 +1,75 @@
1
+ import {
2
+ Autowired,
3
+ Bean,
4
+ Builder,
5
+ Component,
6
+ Configuration,
7
+ Controller,
8
+ Delete,
9
+ FileUpload,
10
+ Get,
11
+ Inject,
12
+ Injectable,
13
+ Middleware,
14
+ Patch,
15
+ Post,
16
+ PostConstruct,
17
+ Put,
18
+ Repository,
19
+ Service,
20
+ Transactional,
21
+ Value
22
+ } from "./chunk-GAO2TPCH.js";
23
+ import {
24
+ Container
25
+ } from "./chunk-AZH3H6VS.js";
26
+ import {
27
+ HttpException
28
+ } from "./chunk-PKJSIVAI.js";
29
+ import {
30
+ METADATA,
31
+ Scope,
32
+ TRANSACTION_MANAGER
33
+ } from "./chunk-RYMYKGZK.js";
34
+ import {
35
+ Logger,
36
+ createLogger,
37
+ logger,
38
+ rootLogger
39
+ } from "./chunk-IHZOCBCK.js";
40
+ import "./chunk-7QVYU63E.js";
41
+
42
+ // src/index.ts
43
+ import "reflect-metadata";
44
+ export {
45
+ Autowired,
46
+ Bean,
47
+ Builder,
48
+ Component,
49
+ Configuration,
50
+ Container,
51
+ Controller,
52
+ Delete,
53
+ FileUpload,
54
+ Get,
55
+ HttpException,
56
+ Inject,
57
+ Injectable,
58
+ Logger,
59
+ METADATA,
60
+ Middleware,
61
+ Patch,
62
+ Post,
63
+ PostConstruct,
64
+ Put,
65
+ Repository,
66
+ Scope,
67
+ Service,
68
+ TRANSACTION_MANAGER,
69
+ Transactional,
70
+ Value,
71
+ createLogger,
72
+ logger,
73
+ rootLogger
74
+ };
75
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import 'reflect-metadata'\n\n// DI Container\nexport { Container } from './container'\n\n// Interfaces & Constants\nexport {\n Scope,\n METADATA,\n TRANSACTION_MANAGER,\n type Constructor,\n type ServiceOptions,\n type BeanOptions,\n type TransactionManager,\n type BuilderOf,\n type Buildable,\n} from './interfaces'\n\n// Decorators\nexport {\n Injectable,\n Service,\n Component,\n Repository,\n Configuration,\n Controller,\n Bean,\n PostConstruct,\n Transactional,\n Autowired,\n Inject,\n Value,\n Get,\n Post,\n Put,\n Delete,\n Patch,\n Middleware,\n FileUpload,\n Builder,\n type RouteDefinition,\n type MiddlewareHandler,\n type FileUploadConfig,\n} from './decorators'\n\n// Module System\nexport { type AppModule, type AppModuleClass, type ModuleRoutes } from './app-module'\n\n// Adapter System\nexport {\n type AppAdapter,\n type AppAdapterClass,\n type AdapterMiddleware,\n type MiddlewarePhase,\n} from './adapter'\n\n// Logger\nexport { Logger, createLogger, rootLogger, logger } from './logger'\n\n// Errors\nexport { HttpException, type ValidationError } from './errors'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO;","names":[]}
@@ -0,0 +1,57 @@
1
+ /** Lifecycle scope for DI registrations */
2
+ declare enum Scope {
3
+ SINGLETON = "singleton",
4
+ TRANSIENT = "transient"
5
+ }
6
+ /** Generic constructor type */
7
+ type Constructor<T = any> = new (...args: any[]) => T;
8
+ /** Options for @Service, @Repository, @Component decorators */
9
+ interface ServiceOptions {
10
+ scope?: Scope;
11
+ }
12
+ /** Options for @Bean decorator */
13
+ interface BeanOptions {
14
+ scope?: Scope;
15
+ }
16
+ /** Transaction manager interface for @Transactional support */
17
+ interface TransactionManager<TTx = unknown> {
18
+ begin(): Promise<TTx>;
19
+ commit(tx: TTx): Promise<void>;
20
+ rollback(tx: TTx): Promise<void>;
21
+ }
22
+ /** Fluent builder type */
23
+ type BuilderOf<T> = {
24
+ [K in keyof T as T[K] extends Function ? never : K]-?: (value: T[K]) => BuilderOf<T>;
25
+ } & {
26
+ build(): T;
27
+ };
28
+ /** Class with static builder() method */
29
+ interface Buildable<T> {
30
+ builder(): BuilderOf<T>;
31
+ }
32
+ /** Symbol-based metadata keys for the DI system */
33
+ declare const METADATA: {
34
+ readonly INJECTABLE: symbol;
35
+ readonly SCOPE: symbol;
36
+ readonly AUTOWIRED: symbol;
37
+ readonly INJECT: symbol;
38
+ readonly CONFIGURATION: symbol;
39
+ readonly BEAN: symbol;
40
+ readonly BEAN_OPTIONS: symbol;
41
+ readonly POST_CONSTRUCT: symbol;
42
+ readonly TRANSACTIONAL: symbol;
43
+ readonly BUILDER: symbol;
44
+ readonly CONTROLLER_PATH: symbol;
45
+ readonly ROUTES: symbol;
46
+ readonly CLASS_MIDDLEWARES: symbol;
47
+ readonly METHOD_MIDDLEWARES: symbol;
48
+ readonly FILE_UPLOAD: symbol;
49
+ readonly VALUE: symbol;
50
+ readonly PARAM_TYPES: "design:paramtypes";
51
+ readonly PROPERTY_TYPE: "design:type";
52
+ readonly RETURN_TYPE: "design:returntype";
53
+ };
54
+ /** DI token for transaction manager */
55
+ declare const TRANSACTION_MANAGER: unique symbol;
56
+
57
+ export { type BeanOptions, type Buildable, type BuilderOf, type Constructor, METADATA, Scope, type ServiceOptions, TRANSACTION_MANAGER, type TransactionManager };
@@ -0,0 +1,12 @@
1
+ import {
2
+ METADATA,
3
+ Scope,
4
+ TRANSACTION_MANAGER
5
+ } from "./chunk-RYMYKGZK.js";
6
+ import "./chunk-7QVYU63E.js";
7
+ export {
8
+ METADATA,
9
+ Scope,
10
+ TRANSACTION_MANAGER
11
+ };
12
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,45 @@
1
+ import pino from 'pino';
2
+
3
+ /** Root pino logger instance */
4
+ declare const rootLogger: pino.Logger<never, boolean>;
5
+ /**
6
+ * Named logger with component context.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * // Static factory — preferred
11
+ * const log = Logger.for('UserService')
12
+ * log.info('User created')
13
+ * // Output: [UserService] User created
14
+ *
15
+ * // Shorthand function
16
+ * const log = createLogger('OrderService')
17
+ *
18
+ * // Injectable — auto-named from class
19
+ * class MyService {
20
+ * @Autowired() private logger!: Logger
21
+ * // or inject a named one:
22
+ * private log = Logger.for('MyService')
23
+ * }
24
+ * ```
25
+ */
26
+ declare class Logger {
27
+ private log;
28
+ constructor(name?: string);
29
+ /** Create or retrieve a cached named logger */
30
+ static for(name: string): Logger;
31
+ /** Create a child logger with a sub-component name */
32
+ child(name: string): Logger;
33
+ info(msg: string, ...args: any[]): void;
34
+ warn(msg: string, ...args: any[]): void;
35
+ error(msgOrObj: any, msg?: string, ...args: any[]): void;
36
+ debug(msg: string, ...args: any[]): void;
37
+ trace(msg: string, ...args: any[]): void;
38
+ fatal(msg: string, ...args: any[]): void;
39
+ }
40
+ /** Shorthand for Logger.for(name) */
41
+ declare function createLogger(name: string): Logger;
42
+ /** @deprecated Use rootLogger instead */
43
+ declare const logger: pino.Logger<never, boolean>;
44
+
45
+ export { Logger, createLogger, logger, rootLogger };
package/dist/logger.js ADDED
@@ -0,0 +1,14 @@
1
+ import {
2
+ Logger,
3
+ createLogger,
4
+ logger,
5
+ rootLogger
6
+ } from "./chunk-IHZOCBCK.js";
7
+ import "./chunk-7QVYU63E.js";
8
+ export {
9
+ Logger,
10
+ createLogger,
11
+ logger,
12
+ rootLogger
13
+ };
14
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}