@forinda/kickjs 1.7.0 → 1.7.1-alpha.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.
Files changed (104) hide show
  1. package/dist/chunk-DVVP7zzD.js +7 -0
  2. package/dist/core/adapter.d.ts +109 -0
  3. package/dist/core/adapter.d.ts.map +1 -0
  4. package/dist/core/adapter.js +0 -0
  5. package/dist/core/app-module.d.ts +28 -0
  6. package/dist/core/app-module.d.ts.map +1 -0
  7. package/dist/core/app-module.js +0 -0
  8. package/dist/core/cache.d.ts +93 -0
  9. package/dist/core/cache.d.ts.map +1 -0
  10. package/dist/core/cache.js +57 -0
  11. package/dist/core/container.d.ts +63 -0
  12. package/dist/core/container.d.ts.map +1 -0
  13. package/dist/core/container.js +117 -0
  14. package/dist/core/cron.d.ts +28 -0
  15. package/dist/core/cron.d.ts.map +1 -0
  16. package/dist/core/cron.js +22 -0
  17. package/dist/core/decorators.d.ts +152 -0
  18. package/dist/core/decorators.d.ts.map +1 -0
  19. package/dist/core/decorators.js +141 -0
  20. package/dist/core/errors.d.ts +64 -0
  21. package/dist/core/errors.d.ts.map +1 -0
  22. package/dist/core/errors.js +67 -0
  23. package/dist/core/index.d.ts +14 -0
  24. package/dist/core/index.d.ts.map +1 -0
  25. package/dist/core/interfaces.d.ts +44 -0
  26. package/dist/core/interfaces.d.ts.map +1 -0
  27. package/dist/core/interfaces.js +25 -0
  28. package/dist/core/logger.d.ts +43 -0
  29. package/dist/core/logger.d.ts.map +1 -0
  30. package/dist/core/logger.js +54 -0
  31. package/dist/core/path.d.ts +21 -0
  32. package/dist/core/path.d.ts.map +1 -0
  33. package/dist/core/path.js +12 -0
  34. package/dist/core/plugin.d.ts +90 -0
  35. package/dist/core/plugin.d.ts.map +1 -0
  36. package/dist/core/plugin.js +0 -0
  37. package/dist/core/reactivity.d.ts +83 -0
  38. package/dist/core/reactivity.d.ts.map +1 -0
  39. package/dist/core/reactivity.js +101 -0
  40. package/dist/core-B6Okew3W.js +7 -0
  41. package/dist/http/application.d.ts +103 -0
  42. package/dist/http/application.d.ts.map +1 -0
  43. package/dist/http/application.js +167 -0
  44. package/dist/http/bootstrap.d.ts +22 -0
  45. package/dist/http/bootstrap.d.ts.map +1 -0
  46. package/dist/http/bootstrap.js +40 -0
  47. package/dist/http/context.d.ts +129 -0
  48. package/dist/http/context.d.ts.map +1 -0
  49. package/dist/http/context.js +115 -0
  50. package/dist/http/index.d.ts +16 -0
  51. package/dist/http/index.d.ts.map +1 -0
  52. package/dist/http/middleware/cors.d.ts +43 -0
  53. package/dist/http/middleware/cors.d.ts.map +1 -0
  54. package/dist/http/middleware/cors.js +31 -0
  55. package/dist/http/middleware/csrf.d.ts +47 -0
  56. package/dist/http/middleware/csrf.d.ts.map +1 -0
  57. package/dist/http/middleware/csrf.js +25 -0
  58. package/dist/http/middleware/error-handler.d.ts +6 -0
  59. package/dist/http/middleware/error-handler.d.ts.map +1 -0
  60. package/dist/http/middleware/error-handler.js +37 -0
  61. package/dist/http/middleware/helmet.d.ts +36 -0
  62. package/dist/http/middleware/helmet.d.ts.map +1 -0
  63. package/dist/http/middleware/helmet.js +20 -0
  64. package/dist/http/middleware/rate-limit.d.ts +51 -0
  65. package/dist/http/middleware/rate-limit.d.ts.map +1 -0
  66. package/dist/http/middleware/rate-limit.js +46 -0
  67. package/dist/http/middleware/request-id.d.ts +5 -0
  68. package/dist/http/middleware/request-id.d.ts.map +1 -0
  69. package/dist/http/middleware/request-id.js +12 -0
  70. package/dist/http/middleware/request-logger.d.ts +27 -0
  71. package/dist/http/middleware/request-logger.d.ts.map +1 -0
  72. package/dist/http/middleware/request-logger.js +16 -0
  73. package/dist/http/middleware/session.d.ts +62 -0
  74. package/dist/http/middleware/session.d.ts.map +1 -0
  75. package/dist/http/middleware/session.js +76 -0
  76. package/dist/http/middleware/spa.d.ts +93 -0
  77. package/dist/http/middleware/spa.d.ts.map +1 -0
  78. package/dist/http/middleware/spa.js +52 -0
  79. package/dist/http/middleware/upload.d.ts +75 -0
  80. package/dist/http/middleware/upload.d.ts.map +1 -0
  81. package/dist/http/middleware/upload.js +119 -0
  82. package/dist/http/middleware/validate.d.ts +13 -0
  83. package/dist/http/middleware/validate.d.ts.map +1 -0
  84. package/dist/http/middleware/validate.js +45 -0
  85. package/dist/http/middleware/views.d.ts +56 -0
  86. package/dist/http/middleware/views.d.ts.map +1 -0
  87. package/dist/http/middleware/views.js +18 -0
  88. package/dist/http/query/index.d.ts +4 -0
  89. package/dist/http/query/index.d.ts.map +1 -0
  90. package/dist/http/query/index.js +10 -0
  91. package/dist/http/query/parse-query.d.ts +44 -0
  92. package/dist/http/query/parse-query.d.ts.map +1 -0
  93. package/dist/http/query/types.d.ts +100 -0
  94. package/dist/http/query/types.d.ts.map +1 -0
  95. package/dist/http/router-builder.d.ts +17 -0
  96. package/dist/http/router-builder.d.ts.map +1 -0
  97. package/dist/http/router-builder.js +37 -0
  98. package/dist/index.d.ts +23 -0
  99. package/dist/index.d.ts.map +1 -0
  100. package/dist/index.js +99 -0
  101. package/dist/query-Bym31XRp.js +88 -0
  102. package/package.json +90 -29
  103. package/index.d.ts +0 -3
  104. package/index.js +0 -13
@@ -0,0 +1,7 @@
1
+ var i = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (r, n) => (typeof require < "u" ? require : r)[n] }) : e)(function(e) {
2
+ if (typeof require < "u") return require.apply(this, arguments);
3
+ throw Error('Calling `require` for "' + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
4
+ });
5
+ export {
6
+ i as t
7
+ };
@@ -0,0 +1,109 @@
1
+ import type http from 'node:http';
2
+ import type { Express } from 'express';
3
+ import type { Container } from './container';
4
+ import type { MaybePromise, Constructor } from './interfaces';
5
+ /**
6
+ * Where in the middleware pipeline an adapter's middleware should be inserted.
7
+ *
8
+ * beforeGlobal → runs before any user-defined global middleware
9
+ * afterGlobal → runs after global middleware, before module routes
10
+ * beforeRoutes → just before module routes are mounted
11
+ * afterRoutes → after module routes but before error handlers
12
+ */
13
+ export type MiddlewarePhase = 'beforeGlobal' | 'afterGlobal' | 'beforeRoutes' | 'afterRoutes';
14
+ /** A middleware entry contributed by an adapter */
15
+ export interface AdapterMiddleware {
16
+ /** Express-compatible handler: (req, res, next) => void */
17
+ handler: any;
18
+ /** Which phase to insert into (default: 'afterGlobal') */
19
+ phase?: MiddlewarePhase;
20
+ /** Optional path to scope the middleware to (e.g. '/api/v1/auth') */
21
+ path?: string;
22
+ }
23
+ /**
24
+ * Context passed to adapter lifecycle hooks.
25
+ * Populated by the Application — provides access to the Express app,
26
+ * DI container, http.Server, and environment info without requiring
27
+ * external type imports. Cast `app` or `server` if you need specific types.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * beforeMount({ app, container }: AdapterContext) {
32
+ * app.use(myMiddleware())
33
+ * }
34
+ * ```
35
+ */
36
+ export interface AdapterContext {
37
+ /** Express application instance — fully typed */
38
+ app: Express;
39
+ /** DI container */
40
+ container: Container;
41
+ /** Node.js http.Server — only available in afterStart */
42
+ server?: http.Server;
43
+ /** Current NODE_ENV value (default: 'development') */
44
+ env: string;
45
+ /** true when NODE_ENV === 'production' */
46
+ isProduction: boolean;
47
+ }
48
+ /**
49
+ * Adapters plug into the Application lifecycle.
50
+ * Implement this to add WebSocket, database, rate limiting, docs, etc.
51
+ *
52
+ * All hooks receive an `AdapterContext` populated by the framework.
53
+ * No external type imports needed — the context is fully typed from KickJS internals.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * import type { AppAdapter, AdapterContext } from '@forinda/kickjs-core/adapter'
58
+ *
59
+ * class SentryAdapter implements AppAdapter {
60
+ * name = 'SentryAdapter'
61
+ *
62
+ * beforeMount({ app, container }: AdapterContext) {
63
+ * app.use(Sentry.expressRequestHandler())
64
+ * }
65
+ *
66
+ * afterStart({ server }: AdapterContext) {
67
+ * // server is the http.Server — available after listen()
68
+ * }
69
+ *
70
+ * async shutdown() {
71
+ * await Sentry.close(2000)
72
+ * }
73
+ * }
74
+ * ```
75
+ */
76
+ export interface AppAdapter {
77
+ /** Human-readable name for logging */
78
+ name?: string;
79
+ /**
80
+ * Return middleware entries to be inserted into the pipeline.
81
+ * The `phase` controls ordering relative to global middleware and routes.
82
+ */
83
+ middleware?(): AdapterMiddleware[];
84
+ /**
85
+ * Called before global middleware — register early routes (docs UI, health).
86
+ * May return a Promise — async rejections are caught and logged.
87
+ */
88
+ beforeMount?(ctx: AdapterContext): void | Promise<void>;
89
+ /**
90
+ * Called for each module route that gets mounted.
91
+ * Use this to collect route metadata (e.g. for OpenAPI spec generation).
92
+ */
93
+ onRouteMount?(controllerClass: Constructor, mountPath: string): void;
94
+ /**
95
+ * Called after modules registered, before HTTP server starts.
96
+ * May return a Promise — async rejections are caught and logged.
97
+ */
98
+ beforeStart?(ctx: AdapterContext): void | Promise<void>;
99
+ /**
100
+ * Called after the HTTP server is listening — attach to the raw http.Server.
101
+ * May return a Promise — async rejections are caught and logged.
102
+ */
103
+ afterStart?(ctx: AdapterContext): void | Promise<void>;
104
+ /** Called on shutdown — clean up connections */
105
+ shutdown?(): MaybePromise;
106
+ }
107
+ /** Constructor type for AppAdapter classes */
108
+ export type AppAdapterClass = new () => AppAdapter;
109
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/core/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE7D;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,aAAa,GAAG,cAAc,GAAG,aAA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@
1
+ import type { Container } from './container';
2
+ /**
3
+ * Route set returned by a module's routes() method.
4
+ * Combined with versioning: /{apiPrefix}/v{version}{path}
5
+ */
6
+ export interface ModuleRoutes {
7
+ /** URL prefix (e.g. '/users') */
8
+ path: string;
9
+ /** Express Router instance (from buildRoutes) */
10
+ router: any;
11
+ /** Optional API version override (defaults to Application.defaultVersion) */
12
+ version?: number;
13
+ /** Controller class for OpenAPI introspection */
14
+ controller?: any;
15
+ }
16
+ /**
17
+ * Interface that every feature module must implement.
18
+ * Modules register their DI bindings and declare their routes.
19
+ */
20
+ export interface AppModule {
21
+ /** Bind interfaces to implementations in the container */
22
+ register(container: Container): void;
23
+ /** Return route definitions for this module, or null for non-HTTP modules */
24
+ routes(): ModuleRoutes | ModuleRoutes[] | null;
25
+ }
26
+ /** Constructor type for AppModule classes */
27
+ export type AppModuleClass = new () => AppModule;
28
+ //# sourceMappingURL=app-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-module.d.ts","sourceRoot":"","sources":["../../src/core/app-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,iDAAiD;IACjD,MAAM,EAAE,GAAG,CAAA;IACX,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,iDAAiD;IACjD,UAAU,CAAC,EAAE,GAAG,CAAA;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAA;IACpC,6EAA6E;IAC7E,MAAM,IAAI,YAAY,GAAG,YAAY,EAAE,GAAG,IAAI,CAAA;CAC/C;AAED,6CAA6C;AAC7C,MAAM,MAAM,cAAc,GAAG,UAAU,SAAS,CAAA"}
File without changes
@@ -0,0 +1,93 @@
1
+ import 'reflect-metadata';
2
+ declare const CACHEABLE_META: unique symbol;
3
+ /**
4
+ * Abstract cache backend. Implement this interface to use Redis, Memcached,
5
+ * or any other cache store with @Cacheable and @CacheEvict.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * class RedisCacheProvider implements CacheProvider {
10
+ * private client: RedisClient
11
+ * constructor(client: RedisClient) { this.client = client }
12
+ * async get(key: string) {
13
+ * const val = await this.client.get(key)
14
+ * return val ? JSON.parse(val) : null
15
+ * }
16
+ * async set(key: string, value: any, ttlMs: number) {
17
+ * await this.client.set(key, JSON.stringify(value), 'PX', ttlMs)
18
+ * }
19
+ * async del(key: string) { await this.client.del(key) }
20
+ * async delByPrefix(prefix: string) {
21
+ * const keys = await this.client.keys(prefix + '*')
22
+ * if (keys.length) await this.client.del(...keys)
23
+ * }
24
+ * }
25
+ * ```
26
+ */
27
+ export interface CacheProvider {
28
+ /** Retrieve a cached value. Return null if not found or expired. */
29
+ get(key: string): Promise<any | null>;
30
+ /** Store a value with a TTL in milliseconds. */
31
+ set(key: string, value: any, ttlMs: number): Promise<void>;
32
+ /** Delete a specific cache key. */
33
+ del(key: string): Promise<void>;
34
+ /** Delete all keys matching a prefix. Used by @CacheEvict. */
35
+ delByPrefix?(prefix: string): Promise<void>;
36
+ /** Optional cleanup on shutdown. */
37
+ shutdown?(): Promise<void>;
38
+ }
39
+ /**
40
+ * Default in-memory cache provider using a Map.
41
+ * Suitable for development and single-instance deployments.
42
+ * For multi-instance or production, use a Redis-backed provider.
43
+ */
44
+ export declare class MemoryCacheProvider implements CacheProvider {
45
+ private store;
46
+ get(key: string): Promise<any | null>;
47
+ set(key: string, value: any, ttlMs: number): Promise<void>;
48
+ del(key: string): Promise<void>;
49
+ delByPrefix(prefix: string): Promise<void>;
50
+ shutdown(): Promise<void>;
51
+ }
52
+ /**
53
+ * Set the global cache provider used by @Cacheable and @CacheEvict.
54
+ * Call this before bootstrapping your app.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * import { setCacheProvider } from '@forinda/kickjs-core'
59
+ * import { RedisCacheProvider } from './redis-cache'
60
+ *
61
+ * setCacheProvider(new RedisCacheProvider(redisClient))
62
+ * ```
63
+ */
64
+ export declare function setCacheProvider(provider: CacheProvider): void;
65
+ /** Get the current cache provider */
66
+ export declare function getCacheProvider(): CacheProvider;
67
+ export interface CacheOptions {
68
+ /** Time-to-live in seconds (default: 60) */
69
+ ttl?: number;
70
+ /** Cache key prefix (default: ClassName.methodName) */
71
+ key?: string;
72
+ }
73
+ /**
74
+ * Cache the return value of a method for the specified TTL.
75
+ * Uses the globally registered CacheProvider (default: MemoryCacheProvider).
76
+ *
77
+ * Call `setCacheProvider()` to use Redis or any custom backend.
78
+ *
79
+ * @param ttl - Time-to-live in seconds (default: 60)
80
+ * @param options.key - Custom cache key prefix
81
+ */
82
+ export declare function Cacheable(ttl?: number, options?: {
83
+ key?: string;
84
+ }): MethodDecorator;
85
+ /**
86
+ * Evict cached values matching a key prefix after the method executes.
87
+ * Works with any CacheProvider that implements `delByPrefix`.
88
+ *
89
+ * @param key - Cache key prefix to evict (matches the @Cacheable key)
90
+ */
91
+ export declare function CacheEvict(key: string): MethodDecorator;
92
+ export { CACHEABLE_META };
93
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/core/cache.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;AAEzB,QAAA,MAAM,cAAc,eAA2B,CAAA;AAI/C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,CAAA;IACrC,gDAAgD;IAChD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA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D;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
@@ -0,0 +1,57 @@
1
+ import "reflect-metadata";
2
+ var g = /* @__PURE__ */ Symbol("kick:cacheable"), d = class {
3
+ store = /* @__PURE__ */ new Map();
4
+ async get(e) {
5
+ const t = this.store.get(e);
6
+ return t ? t.expiresAt <= Date.now() ? (this.store.delete(e), null) : t.data : null;
7
+ }
8
+ async set(e, t, s) {
9
+ this.store.set(e, {
10
+ data: t,
11
+ expiresAt: Date.now() + s
12
+ });
13
+ }
14
+ async del(e) {
15
+ this.store.delete(e);
16
+ }
17
+ async delByPrefix(e) {
18
+ for (const t of this.store.keys()) t.startsWith(e) && this.store.delete(t);
19
+ }
20
+ async shutdown() {
21
+ this.store.clear();
22
+ }
23
+ }, f = new d();
24
+ function p(e) {
25
+ f = e;
26
+ }
27
+ function v() {
28
+ return f;
29
+ }
30
+ function P(e, t) {
31
+ return (s, r, n) => {
32
+ const i = n.value, c = (e ?? 60) * 1e3, a = t?.key ?? String(r);
33
+ return n.value = async function(...o) {
34
+ const l = `${a}:${JSON.stringify(o)}`, u = v(), y = await u.get(l);
35
+ if (y !== null) return y;
36
+ const h = await i.apply(this, o);
37
+ return await u.set(l, h, c), h;
38
+ }, n;
39
+ };
40
+ }
41
+ function x(e) {
42
+ return (t, s, r) => {
43
+ const n = r.value;
44
+ return r.value = async function(...i) {
45
+ const c = await n.apply(this, i), a = v();
46
+ return a.delByPrefix && await a.delByPrefix(e), c;
47
+ }, r;
48
+ };
49
+ }
50
+ export {
51
+ g as CACHEABLE_META,
52
+ x as CacheEvict,
53
+ P as Cacheable,
54
+ d as MemoryCacheProvider,
55
+ v as getCacheProvider,
56
+ p as setCacheProvider
57
+ };
@@ -0,0 +1,63 @@
1
+ import 'reflect-metadata';
2
+ import { Constructor, Scope } from './interfaces';
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 registrations, and lifecycle hooks (@PostConstruct).
10
+ */
11
+ export 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
+ /** Callback invoked on reset so decorators can update their container reference */
18
+ static _onReset: ((container: Container) => void) | null;
19
+ /**
20
+ * Environment resolver for @Value decorator. Set by @forinda/kickjs-config
21
+ * to return Zod-validated, type-coerced env values instead of raw process.env strings.
22
+ */
23
+ static _envResolver: ((key: string) => any) | null;
24
+ static getInstance(): Container;
25
+ /**
26
+ * Resets the container by replacing the singleton with a fresh instance.
27
+ * Useful for testing to ensure a clean slate between test runs.
28
+ */
29
+ static reset(): void;
30
+ /**
31
+ * Create an isolated container instance (not the global singleton).
32
+ * Useful for concurrent tests that must not share DI state.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const container = Container.create()
37
+ * container.register(UserService, UserService)
38
+ * const svc = container.resolve(UserService)
39
+ * ```
40
+ */
41
+ static create(): Container;
42
+ /** Register a class constructor under the given token */
43
+ register(token: any, target: Constructor, scope?: Scope): void;
44
+ /** Register a factory function under the given token */
45
+ registerFactory(token: any, factory: () => any, scope?: Scope): void;
46
+ /** Register a pre-constructed singleton instance */
47
+ registerInstance(token: any, instance: any): void;
48
+ /** Check if a binding exists for the given token */
49
+ has(token: any): boolean;
50
+ /** Return a snapshot of all registered tokens with their scope and instantiation status */
51
+ getRegistrations(): Array<{
52
+ token: string;
53
+ scope: string;
54
+ instantiated: boolean;
55
+ }>;
56
+ /** Resolve a dependency by its token */
57
+ resolve<T = any>(token: any): T;
58
+ /** Lifecycle hook called during Application.setup() after module registration */
59
+ bootstrap(): void;
60
+ private createInstance;
61
+ private injectProperties;
62
+ }
63
+ //# sourceMappingURL=container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/core/container.ts"],"names":[],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,EAAE,OAAO,CAAA;KAAE,CAAC;IAYlF,wCAAwC;IACxC,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC;IAyC/B,iFAAiF;IACjF,SAAS,IAAI,IAAI;IAKjB,OAAO,CAAC,cAAc;IAyBtB,OAAO,CAAC,gBAAgB;CA4CzB"}
@@ -0,0 +1,117 @@
1
+ import { METADATA as a, Scope as c } from "./interfaces.js";
2
+ import "reflect-metadata";
3
+ function u(l) {
4
+ return typeof l == "symbol" ? l.toString() : l?.name || String(l);
5
+ }
6
+ var v = class r {
7
+ static instance;
8
+ registrations = /* @__PURE__ */ new Map();
9
+ resolving = /* @__PURE__ */ new Set();
10
+ static _onReady = null;
11
+ static _onReset = null;
12
+ static _envResolver = null;
13
+ static getInstance() {
14
+ return r.instance || (r.instance = new r()), r._onReady && (r._onReady(r.instance), r._onReady = null), r.instance;
15
+ }
16
+ static reset() {
17
+ r.instance = new r(), r._onReset?.(r.instance);
18
+ }
19
+ static create() {
20
+ return new r();
21
+ }
22
+ register(e, t, n = c.SINGLETON) {
23
+ this.registrations.set(e, {
24
+ target: t,
25
+ scope: n
26
+ }), typeof e == "function" && e.name && this.registrations.set(`__hmr__${e.name}`, {
27
+ target: t,
28
+ scope: n
29
+ });
30
+ }
31
+ registerFactory(e, t, n = c.SINGLETON) {
32
+ this.registrations.set(e, {
33
+ target: Object,
34
+ scope: n,
35
+ factory: t
36
+ });
37
+ }
38
+ registerInstance(e, t) {
39
+ this.registrations.set(e, {
40
+ target: t.constructor,
41
+ scope: c.SINGLETON,
42
+ instance: t
43
+ });
44
+ }
45
+ has(e) {
46
+ return this.registrations.has(e);
47
+ }
48
+ getRegistrations() {
49
+ const e = [];
50
+ for (const [t, n] of this.registrations) e.push({
51
+ token: u(t),
52
+ scope: n.scope,
53
+ instantiated: n.instance !== void 0
54
+ });
55
+ return e;
56
+ }
57
+ resolve(e) {
58
+ let t = this.registrations.get(e);
59
+ if (!t && typeof e == "function" && e.name && (t = this.registrations.get(`__hmr__${e.name}`)), !t) throw new Error(`No binding found for: ${u(e)}`);
60
+ if (t.scope === c.SINGLETON && t.instance !== void 0) return t.instance;
61
+ if (t.factory) {
62
+ const n = t.factory();
63
+ return t.scope === c.SINGLETON && (t.instance = n), n;
64
+ }
65
+ if (this.resolving.has(e)) {
66
+ const n = [...this.resolving].map(u);
67
+ throw n.push(u(e)), new Error(`Circular dependency detected: ${n.join(" -> ")}`);
68
+ }
69
+ this.resolving.add(e);
70
+ try {
71
+ const n = this.createInstance(t);
72
+ return t.scope === c.SINGLETON && (t.instance = n), n;
73
+ } finally {
74
+ this.resolving.delete(e);
75
+ }
76
+ }
77
+ bootstrap() {
78
+ }
79
+ createInstance(e) {
80
+ const t = (Reflect.getMetadata(a.PARAM_TYPES, e.target) || []).map((o, s) => {
81
+ const i = (Reflect.getMetadata(a.INJECT, e.target) || {})[s] || o;
82
+ return this.resolve(i);
83
+ }), n = new e.target(...t);
84
+ this.injectProperties(n, e.target);
85
+ const f = Reflect.getMetadata(a.POST_CONSTRUCT, e.target.prototype);
86
+ return f && typeof n[f] == "function" && n[f](), n;
87
+ }
88
+ injectProperties(e, t) {
89
+ const n = Reflect.getMetadata(a.AUTOWIRED, t.prototype) || /* @__PURE__ */ new Map();
90
+ for (const [o, s] of n) {
91
+ const i = s || Reflect.getMetadata(a.PROPERTY_TYPE, t.prototype, o);
92
+ i && Object.defineProperty(e, o, {
93
+ get: () => this.resolve(i),
94
+ enumerable: !0,
95
+ configurable: !0
96
+ });
97
+ }
98
+ const f = Reflect.getMetadata(a.VALUE, t.prototype) || /* @__PURE__ */ new Map();
99
+ for (const [o, s] of f) Object.defineProperty(e, o, {
100
+ get() {
101
+ if (r._envResolver) {
102
+ const p = r._envResolver(s.envKey);
103
+ if (p !== void 0) return p;
104
+ }
105
+ const i = process.env[s.envKey];
106
+ if (i !== void 0) return i;
107
+ if (s.defaultValue !== void 0) return s.defaultValue;
108
+ throw new Error(`@Value('${s.envKey}'): Environment variable "${s.envKey}" is not set and no default was provided.`);
109
+ },
110
+ enumerable: !0,
111
+ configurable: !0
112
+ });
113
+ }
114
+ };
115
+ export {
116
+ v as Container
117
+ };
@@ -0,0 +1,28 @@
1
+ import 'reflect-metadata';
2
+ declare const CRON_META: unique symbol;
3
+ export interface CronJobMeta {
4
+ expression: string;
5
+ handlerName: string;
6
+ description?: string;
7
+ timezone?: string;
8
+ runOnInit?: boolean;
9
+ }
10
+ /**
11
+ * Schedule a method to run on a cron expression.
12
+ * Requires a CronAdapter to be registered in bootstrap().
13
+ *
14
+ * @param expression - Standard 5-part cron: minute hour day month weekday.
15
+ * Use forward-slash for intervals (e.g. every 5 min, every 2 hours).
16
+ * @param options.description - Human-readable label for logging
17
+ * @param options.timezone - IANA timezone (e.g. 'America/New_York', 'UTC')
18
+ * @param options.runOnInit - Run immediately on startup before first scheduled tick
19
+ */
20
+ export declare function Cron(expression: string, options?: {
21
+ description?: string;
22
+ timezone?: string;
23
+ runOnInit?: boolean;
24
+ }): MethodDecorator;
25
+ /** Read cron jobs registered on a class */
26
+ export declare function getCronJobs(target: any): CronJobMeta[];
27
+ export { CRON_META };
28
+ //# sourceMappingURL=cron.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cron.d.ts","sourceRoot":"","sources":["../../src/core/cron.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;AAEzB,QAAA,MAAM,SAAS,eAAsB,CAAA;AAErC,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAUD;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAClB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GACzE,eAAe,CAYjB;AAED,2CAA2C;AAC3C,wBAAgB,WAAW,CAAC,MAAM,EAAE,GAAG,GAAG,WAAW,EAAE,CAEtD;AAED,OAAO,EAAE,SAAS,EAAE,CAAA"}
@@ -0,0 +1,22 @@
1
+ import "reflect-metadata";
2
+ var n = /* @__PURE__ */ Symbol("kick:cron");
3
+ function a(t, e) {
4
+ return (r, o) => {
5
+ const c = Reflect.getMetadata(n, r.constructor) ?? [];
6
+ c.push({
7
+ expression: t,
8
+ handlerName: o,
9
+ description: e?.description,
10
+ timezone: e?.timezone,
11
+ runOnInit: e?.runOnInit
12
+ }), Reflect.defineMetadata(n, c, r.constructor);
13
+ };
14
+ }
15
+ function u(t) {
16
+ return Reflect.getMetadata(n, t) ?? [];
17
+ }
18
+ export {
19
+ n as CRON_META,
20
+ a as Cron,
21
+ u as getCronJobs
22
+ };