@forinda/kickjs 2.0.1 → 2.2.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 +63 -20
- package/dist/adapter-wuoBNkNs.d.mts +122 -0
- package/dist/adapter-wuoBNkNs.d.mts.map +1 -0
- package/dist/app-module-DOBmxARW.d.mts +40 -0
- package/dist/app-module-DOBmxARW.d.mts.map +1 -0
- package/dist/application-C5Q720a2.mjs +449 -0
- package/dist/application-C5Q720a2.mjs.map +1 -0
- package/dist/bootstrap-dEN6SjBl.mjs +205 -0
- package/dist/bootstrap-dEN6SjBl.mjs.map +1 -0
- package/dist/{core/cache.d.ts → cache-PufEhr0n.d.mts} +33 -31
- package/dist/cache-PufEhr0n.d.mts.map +1 -0
- package/dist/chunk-C9tIbwLT.mjs +15 -0
- package/dist/container-B7jFEbPE.mjs +496 -0
- package/dist/container-B7jFEbPE.mjs.map +1 -0
- package/dist/container-CcgV8eHL.d.mts +253 -0
- package/dist/container-CcgV8eHL.d.mts.map +1 -0
- package/dist/core/adapter.d.mts +3 -0
- package/dist/core/adapter.mjs +11 -0
- package/dist/core/app-module.d.mts +3 -0
- package/dist/core/app-module.mjs +11 -0
- package/dist/core/cache.d.mts +3 -0
- package/dist/core/cache.mjs +113 -0
- package/dist/core/cache.mjs.map +1 -0
- package/dist/core/container.d.mts +3 -0
- package/dist/core/container.mjs +12 -0
- package/dist/core/cron.d.mts +3 -0
- package/dist/core/cron.mjs +42 -0
- package/dist/core/cron.mjs.map +1 -0
- package/dist/core/decorators.d.mts +3 -0
- package/dist/core/decorators.mjs +219 -0
- package/dist/core/decorators.mjs.map +1 -0
- package/dist/core/errors.d.mts +3 -0
- package/dist/core/errors.mjs +97 -0
- package/dist/core/errors.mjs.map +1 -0
- package/dist/core/interfaces.d.mts +3 -0
- package/dist/core/interfaces.mjs +44 -0
- package/dist/core/interfaces.mjs.map +1 -0
- package/dist/core/logger.d.mts +3 -0
- package/dist/core/logger.mjs +217 -0
- package/dist/core/logger.mjs.map +1 -0
- package/dist/core/path.d.mts +3 -0
- package/dist/core/path.mjs +45 -0
- package/dist/core/path.mjs.map +1 -0
- package/dist/core/plugin.d.mts +3 -0
- package/dist/core/plugin.mjs +11 -0
- package/dist/core/reactivity.d.mts +3 -0
- package/dist/core/reactivity.mjs +189 -0
- package/dist/core/reactivity.mjs.map +1 -0
- package/dist/core-CMgIoRvg.mjs +121 -0
- package/dist/core-CMgIoRvg.mjs.map +1 -0
- package/dist/{core/cron.d.ts → cron-C29iHvHT.d.mts} +16 -14
- package/dist/cron-C29iHvHT.d.mts.map +1 -0
- package/dist/decorators-D3lBlmud.d.mts +204 -0
- package/dist/decorators-D3lBlmud.d.mts.map +1 -0
- package/dist/errors-BZUdxtjC.d.mts +68 -0
- package/dist/errors-BZUdxtjC.d.mts.map +1 -0
- package/dist/http/application.d.mts +220 -0
- package/dist/http/application.d.mts.map +1 -0
- package/dist/http/application.mjs +12 -0
- package/dist/http/bootstrap.d.mts +43 -0
- package/dist/http/bootstrap.d.mts.map +1 -0
- package/dist/http/bootstrap.mjs +12 -0
- package/dist/http/context.d.mts +190 -0
- package/dist/http/context.d.mts.map +1 -0
- package/dist/http/context.mjs +225 -0
- package/dist/http/context.mjs.map +1 -0
- package/dist/http/middleware/cors.d.mts +48 -0
- package/dist/http/middleware/cors.d.mts.map +1 -0
- package/dist/http/middleware/cors.mjs +83 -0
- package/dist/http/middleware/cors.mjs.map +1 -0
- package/dist/http/middleware/csrf.d.mts +52 -0
- package/dist/http/middleware/csrf.d.mts.map +1 -0
- package/dist/http/middleware/csrf.mjs +72 -0
- package/dist/http/middleware/csrf.mjs.map +1 -0
- package/dist/http/middleware/error-handler.d.mts +11 -0
- package/dist/http/middleware/error-handler.d.mts.map +1 -0
- package/dist/http/middleware/error-handler.mjs +52 -0
- package/dist/http/middleware/error-handler.mjs.map +1 -0
- package/dist/http/middleware/helmet.d.mts +41 -0
- package/dist/http/middleware/helmet.d.mts.map +1 -0
- package/dist/http/middleware/helmet.mjs +51 -0
- package/dist/http/middleware/helmet.mjs.map +1 -0
- package/dist/http/middleware/rate-limit.d.mts +56 -0
- package/dist/http/middleware/rate-limit.d.mts.map +1 -0
- package/dist/http/middleware/rate-limit.mjs +101 -0
- package/dist/http/middleware/rate-limit.mjs.map +1 -0
- package/dist/http/middleware/request-id.d.mts +10 -0
- package/dist/http/middleware/request-id.d.mts.map +1 -0
- package/dist/http/middleware/request-id.mjs +26 -0
- package/dist/http/middleware/request-id.mjs.map +1 -0
- package/dist/http/middleware/request-logger.d.mts +32 -0
- package/dist/http/middleware/request-logger.d.mts.map +1 -0
- package/dist/http/middleware/request-logger.mjs +49 -0
- package/dist/http/middleware/request-logger.mjs.map +1 -0
- package/dist/http/middleware/session.d.mts +67 -0
- package/dist/http/middleware/session.d.mts.map +1 -0
- package/dist/http/middleware/session.mjs +152 -0
- package/dist/http/middleware/session.mjs.map +1 -0
- package/dist/http/middleware/spa.d.mts +101 -0
- package/dist/http/middleware/spa.d.mts.map +1 -0
- package/dist/http/middleware/spa.mjs +108 -0
- package/dist/http/middleware/spa.mjs.map +1 -0
- package/dist/http/middleware/{upload.d.ts → upload.d.mts} +21 -17
- package/dist/http/middleware/upload.d.mts.map +1 -0
- package/dist/http/middleware/upload.mjs +191 -0
- package/dist/http/middleware/upload.mjs.map +1 -0
- package/dist/http/middleware/validate.d.mts +18 -0
- package/dist/http/middleware/validate.d.mts.map +1 -0
- package/dist/http/middleware/validate.mjs +62 -0
- package/dist/http/middleware/validate.mjs.map +1 -0
- package/dist/http/middleware/views.d.mts +62 -0
- package/dist/http/middleware/views.d.mts.map +1 -0
- package/dist/http/middleware/views.mjs +65 -0
- package/dist/http/middleware/views.mjs.map +1 -0
- package/dist/http/query/index.d.mts +3 -0
- package/dist/http/query/index.mjs +12 -0
- package/dist/http/{router-builder.d.ts → router-builder.d.mts} +9 -5
- package/dist/http/router-builder.d.mts.map +1 -0
- package/dist/http/router-builder.mjs +67 -0
- package/dist/http/router-builder.mjs.map +1 -0
- package/dist/index-4VM4dUJf.d.mts +107 -0
- package/dist/index-4VM4dUJf.d.mts.map +1 -0
- package/dist/index-rnK23QBD.d.mts +184 -0
- package/dist/index-rnK23QBD.d.mts.map +1 -0
- package/dist/index.d.mts +133 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +126 -0
- package/dist/index.mjs.map +1 -0
- package/dist/interfaces-D5ohYl6D.d.mts +52 -0
- package/dist/interfaces-D5ohYl6D.d.mts.map +1 -0
- package/dist/logger-BLdfUF5b.d.mts +119 -0
- package/dist/logger-BLdfUF5b.d.mts.map +1 -0
- package/dist/metadata-BqXgNTOf.mjs +76 -0
- package/dist/metadata-BqXgNTOf.mjs.map +1 -0
- package/dist/{core/path.d.ts → path-Dq5V-i-x.d.mts} +7 -3
- package/dist/path-Dq5V-i-x.d.mts.map +1 -0
- package/dist/plugin-D20muJwC.d.mts +95 -0
- package/dist/plugin-D20muJwC.d.mts.map +1 -0
- package/dist/query-vljPDFaZ.mjs +164 -0
- package/dist/query-vljPDFaZ.mjs.map +1 -0
- package/dist/{core/reactivity.d.ts → reactivity-CMAQh0gi.d.mts} +21 -20
- package/dist/reactivity-CMAQh0gi.d.mts.map +1 -0
- package/package.json +73 -43
- package/dist/chunk-DVVP7zzD.js +0 -7
- package/dist/core/adapter.d.ts +0 -109
- package/dist/core/adapter.d.ts.map +0 -1
- package/dist/core/adapter.js +0 -0
- package/dist/core/app-module.d.ts +0 -28
- package/dist/core/app-module.d.ts.map +0 -1
- package/dist/core/app-module.js +0 -0
- package/dist/core/cache.d.ts.map +0 -1
- package/dist/core/cache.js +0 -57
- package/dist/core/container.d.ts +0 -63
- package/dist/core/container.d.ts.map +0 -1
- package/dist/core/container.js +0 -117
- package/dist/core/cron.d.ts.map +0 -1
- package/dist/core/cron.js +0 -22
- package/dist/core/decorators.d.ts +0 -153
- package/dist/core/decorators.d.ts.map +0 -1
- package/dist/core/decorators.js +0 -141
- package/dist/core/errors.d.ts +0 -64
- package/dist/core/errors.d.ts.map +0 -1
- package/dist/core/errors.js +0 -67
- package/dist/core/index.d.ts +0 -14
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/interfaces.d.ts +0 -44
- package/dist/core/interfaces.d.ts.map +0 -1
- package/dist/core/interfaces.js +0 -25
- package/dist/core/logger.d.ts +0 -43
- package/dist/core/logger.d.ts.map +0 -1
- package/dist/core/logger.js +0 -54
- package/dist/core/path.d.ts.map +0 -1
- package/dist/core/path.js +0 -12
- package/dist/core/plugin.d.ts +0 -90
- package/dist/core/plugin.d.ts.map +0 -1
- package/dist/core/plugin.js +0 -0
- package/dist/core/reactivity.d.ts.map +0 -1
- package/dist/core/reactivity.js +0 -101
- package/dist/core-B6Okew3W.js +0 -7
- package/dist/http/application.d.ts +0 -103
- package/dist/http/application.d.ts.map +0 -1
- package/dist/http/application.js +0 -167
- package/dist/http/bootstrap.d.ts +0 -22
- package/dist/http/bootstrap.d.ts.map +0 -1
- package/dist/http/bootstrap.js +0 -40
- package/dist/http/context.d.ts +0 -129
- package/dist/http/context.d.ts.map +0 -1
- package/dist/http/context.js +0 -115
- package/dist/http/index.d.ts +0 -16
- package/dist/http/index.d.ts.map +0 -1
- package/dist/http/middleware/cors.d.ts +0 -43
- package/dist/http/middleware/cors.d.ts.map +0 -1
- package/dist/http/middleware/cors.js +0 -31
- package/dist/http/middleware/csrf.d.ts +0 -47
- package/dist/http/middleware/csrf.d.ts.map +0 -1
- package/dist/http/middleware/csrf.js +0 -25
- package/dist/http/middleware/error-handler.d.ts +0 -6
- package/dist/http/middleware/error-handler.d.ts.map +0 -1
- package/dist/http/middleware/error-handler.js +0 -37
- package/dist/http/middleware/helmet.d.ts +0 -36
- package/dist/http/middleware/helmet.d.ts.map +0 -1
- package/dist/http/middleware/helmet.js +0 -20
- package/dist/http/middleware/rate-limit.d.ts +0 -51
- package/dist/http/middleware/rate-limit.d.ts.map +0 -1
- package/dist/http/middleware/rate-limit.js +0 -46
- package/dist/http/middleware/request-id.d.ts +0 -5
- package/dist/http/middleware/request-id.d.ts.map +0 -1
- package/dist/http/middleware/request-id.js +0 -12
- package/dist/http/middleware/request-logger.d.ts +0 -27
- package/dist/http/middleware/request-logger.d.ts.map +0 -1
- package/dist/http/middleware/request-logger.js +0 -16
- package/dist/http/middleware/session.d.ts +0 -62
- package/dist/http/middleware/session.d.ts.map +0 -1
- package/dist/http/middleware/session.js +0 -76
- package/dist/http/middleware/spa.d.ts +0 -93
- package/dist/http/middleware/spa.d.ts.map +0 -1
- package/dist/http/middleware/spa.js +0 -52
- package/dist/http/middleware/upload.d.ts.map +0 -1
- package/dist/http/middleware/upload.js +0 -119
- package/dist/http/middleware/validate.d.ts +0 -13
- package/dist/http/middleware/validate.d.ts.map +0 -1
- package/dist/http/middleware/validate.js +0 -45
- package/dist/http/middleware/views.d.ts +0 -56
- package/dist/http/middleware/views.d.ts.map +0 -1
- package/dist/http/middleware/views.js +0 -18
- package/dist/http/query/index.d.ts +0 -4
- package/dist/http/query/index.d.ts.map +0 -1
- package/dist/http/query/index.js +0 -10
- package/dist/http/query/parse-query.d.ts +0 -44
- package/dist/http/query/parse-query.d.ts.map +0 -1
- package/dist/http/query/types.d.ts +0 -100
- package/dist/http/query/types.d.ts.map +0 -1
- package/dist/http/router-builder.d.ts.map +0 -1
- package/dist/http/router-builder.js +0 -37
- package/dist/index.d.ts +0 -25
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -103
- package/dist/query-Bym31XRp.js +0 -88
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
|
|
2
|
+
import { c as Scope, i as Constructor, r as ClassKind, s as PostConstructStatus } from "./interfaces-D5ohYl6D.mjs";
|
|
3
|
+
//#region src/core/token.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Collision-safe injection tokens with phantom type parameters.
|
|
6
|
+
*
|
|
7
|
+
* `createToken<T>(name)` is the recommended way to declare any DI token
|
|
8
|
+
* that isn't a class. Each call returns a unique frozen object — even if
|
|
9
|
+
* two files write `createToken<X>('Logger')`, they produce two distinct
|
|
10
|
+
* references that the container treats as different tokens. Collisions
|
|
11
|
+
* become impossible by construction, not by convention.
|
|
12
|
+
*
|
|
13
|
+
* The phantom type parameter `T` lets `container.resolve(token)` infer
|
|
14
|
+
* the correct return type without any codegen.
|
|
15
|
+
*
|
|
16
|
+
* ## Hardening layers
|
|
17
|
+
*
|
|
18
|
+
* KickJS has four DI token kinds, listed from safest to riskiest:
|
|
19
|
+
*
|
|
20
|
+
* 1. **Class identity** — `container.resolve(UserService)`. Reference
|
|
21
|
+
* equality, never collides. Type-safe via `Constructor<T>` overload.
|
|
22
|
+
* 2. **`createToken<T>(name)`** — frozen object identity, never collides.
|
|
23
|
+
* Type-safe via the `InjectionToken<T>` overload.
|
|
24
|
+
* 3. **Symbol** — `Symbol('foo')` is unique per call but `Symbol.for('foo')`
|
|
25
|
+
* is interned and CAN collide. Discouraged.
|
|
26
|
+
* 4. **Raw string `@Inject('foo')`** — high collision risk, untyped.
|
|
27
|
+
* Reserved for legacy code and runtime-computed token names.
|
|
28
|
+
*
|
|
29
|
+
* Prefer (1) and (2). Use (4) only when you have to.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* // src/tokens.ts
|
|
34
|
+
* export const DATABASE_URL = createToken<string>('config.database.url')
|
|
35
|
+
* export const FEATURE_FLAGS = createToken<FeatureFlags>('app.features')
|
|
36
|
+
*
|
|
37
|
+
* // bootstrap
|
|
38
|
+
* container.registerInstance(DATABASE_URL, process.env.DATABASE_URL!)
|
|
39
|
+
*
|
|
40
|
+
* // anywhere else
|
|
41
|
+
* const url = container.resolve(DATABASE_URL) // typed as `string`
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @module @forinda/kickjs/core/token
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* Symbol marker stamped on every InjectionToken so the container can
|
|
48
|
+
* detect them at runtime regardless of which package created them.
|
|
49
|
+
*
|
|
50
|
+
* Uses `Symbol.for()` so cross-package isolation (different copies of
|
|
51
|
+
* `@forinda/kickjs` loaded under different module identities) still
|
|
52
|
+
* shares the same marker.
|
|
53
|
+
*/
|
|
54
|
+
declare const INJECTION_TOKEN: unique symbol;
|
|
55
|
+
/**
|
|
56
|
+
* A type-safe DI token. Each `createToken()` call returns a unique frozen
|
|
57
|
+
* object identified by reference, not by the `name` string. Two
|
|
58
|
+
* `createToken<X>('foo')` calls in different files produce two distinct
|
|
59
|
+
* tokens that the container treats independently.
|
|
60
|
+
*
|
|
61
|
+
* The phantom `_type` parameter is never assigned at runtime — it exists
|
|
62
|
+
* solely to thread the type through `container.resolve(token)`.
|
|
63
|
+
*/
|
|
64
|
+
interface InjectionToken<T> {
|
|
65
|
+
readonly [INJECTION_TOKEN]: true;
|
|
66
|
+
/** Descriptive name used in error messages, logs, and devtools */
|
|
67
|
+
readonly name: string;
|
|
68
|
+
/** Phantom — never assigned at runtime */
|
|
69
|
+
readonly _type?: T;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Create a collision-safe injection token.
|
|
73
|
+
*
|
|
74
|
+
* The returned token is a frozen object identified by reference, not by
|
|
75
|
+
* the `name` string. The `name` is used only for error messages, logs,
|
|
76
|
+
* and debugging.
|
|
77
|
+
*/
|
|
78
|
+
declare function createToken<T>(name: string): InjectionToken<T>;
|
|
79
|
+
/** Type guard — returns `true` if `value` is an InjectionToken */
|
|
80
|
+
declare function isInjectionToken(value: unknown): value is InjectionToken<unknown>;
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/core/container.d.ts
|
|
83
|
+
/** Format a token for display in error messages */
|
|
84
|
+
declare function tokenName(token: any): string;
|
|
85
|
+
/** A single container change event */
|
|
86
|
+
interface ContainerChangeEvent {
|
|
87
|
+
token: string;
|
|
88
|
+
event: 'registered' | 'resolved' | 'invalidated';
|
|
89
|
+
kind?: ClassKind;
|
|
90
|
+
timestamp: number;
|
|
91
|
+
}
|
|
92
|
+
/** Listener that receives batched change events */
|
|
93
|
+
type ContainerChangeListener = (changes: ContainerChangeEvent[]) => void;
|
|
94
|
+
/**
|
|
95
|
+
* Type-safe registry of string DI tokens. Augmented by `kick typegen` —
|
|
96
|
+
* the generated `.kickjs/types/registry.d.ts` adds entries like:
|
|
97
|
+
*
|
|
98
|
+
* ```ts
|
|
99
|
+
* declare module '@forinda/kickjs' {
|
|
100
|
+
* interface KickJsRegistry {
|
|
101
|
+
* UserService: import('../../src/modules/users/user.service').UserService
|
|
102
|
+
* }
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* Once typegen has run, `container.resolve('UserService')` returns the
|
|
107
|
+
* correct type instead of `any`. Class-token resolution
|
|
108
|
+
* (`container.resolve(UserService)`) is already type-safe via the
|
|
109
|
+
* `Constructor<T>` overload and does not need typegen.
|
|
110
|
+
*/
|
|
111
|
+
interface KickJsRegistry {}
|
|
112
|
+
/**
|
|
113
|
+
* Inversion-of-Control (IoC) container that manages dependency registration,
|
|
114
|
+
* resolution, and lifecycle. Implements the Singleton pattern so all parts of
|
|
115
|
+
* the application share a single container instance.
|
|
116
|
+
*
|
|
117
|
+
* Supports constructor injection, property injection (@Autowired),
|
|
118
|
+
* factory registrations, and lifecycle hooks (@PostConstruct).
|
|
119
|
+
*
|
|
120
|
+
* Persistent state (DB connections, Redis, etc.) is stored on globalThis so
|
|
121
|
+
* it survives both Container.reset() and Vite module re-evaluation.
|
|
122
|
+
*/
|
|
123
|
+
declare class Container {
|
|
124
|
+
private static instance;
|
|
125
|
+
private registrations;
|
|
126
|
+
private resolving;
|
|
127
|
+
private changeListeners;
|
|
128
|
+
private pendingChanges;
|
|
129
|
+
private notifyTimer;
|
|
130
|
+
private static readonly DEBOUNCE_MS;
|
|
131
|
+
/** Callback set by the decorators module to flush pending registrations */
|
|
132
|
+
static _onReady: ((container: Container) => void) | null;
|
|
133
|
+
/** Callback invoked on reset so decorators can update their container reference */
|
|
134
|
+
static _onReset: ((container: Container) => void) | null;
|
|
135
|
+
/**
|
|
136
|
+
* Environment resolver for @Value decorator. Set by @forinda/kickjs-config
|
|
137
|
+
* to return Zod-validated, type-coerced env values instead of raw process.env strings.
|
|
138
|
+
*/
|
|
139
|
+
static _envResolver: ((key: string) => any) | null;
|
|
140
|
+
/**
|
|
141
|
+
* Request store provider for REQUEST-scoped DI. Set by @forinda/kickjs-http
|
|
142
|
+
* to return the current request's AsyncLocalStorage store.
|
|
143
|
+
* Returns { instances: Map, values: Map } or null if outside a request.
|
|
144
|
+
*/
|
|
145
|
+
static _requestStoreProvider: (() => {
|
|
146
|
+
instances: Map<any, any>;
|
|
147
|
+
values: Map<any, any>;
|
|
148
|
+
} | null) | null;
|
|
149
|
+
static getInstance(): Container;
|
|
150
|
+
/**
|
|
151
|
+
* Resets the container by replacing the singleton with a fresh instance.
|
|
152
|
+
* Persistent registrations (DB, Redis, etc.) are replayed from globalThis
|
|
153
|
+
* so they survive both reset() and Vite module re-evaluation.
|
|
154
|
+
*/
|
|
155
|
+
static reset(): void;
|
|
156
|
+
/**
|
|
157
|
+
* Create an isolated container instance (not the global singleton).
|
|
158
|
+
* Useful for concurrent tests that must not share DI state.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* const container = Container.create()
|
|
163
|
+
* container.register(UserService, UserService)
|
|
164
|
+
* const svc = container.resolve(UserService)
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
static create(): Container;
|
|
168
|
+
/** Register a class constructor under the given token */
|
|
169
|
+
register(token: any, target: Constructor, scope?: Scope): void;
|
|
170
|
+
/** Register a factory function under the given token */
|
|
171
|
+
registerFactory(token: any, factory: () => any, scope?: Scope): void;
|
|
172
|
+
/** Register a pre-constructed singleton instance */
|
|
173
|
+
registerInstance(token: any, instance: any): void;
|
|
174
|
+
/** Check if a binding exists for the given token */
|
|
175
|
+
has(token: any): boolean;
|
|
176
|
+
/** Return a snapshot of all registered tokens with their scope and instantiation status */
|
|
177
|
+
getRegistrations(): Array<{
|
|
178
|
+
token: string;
|
|
179
|
+
scope: string;
|
|
180
|
+
kind: ClassKind;
|
|
181
|
+
instantiated: boolean;
|
|
182
|
+
resolveCount: number;
|
|
183
|
+
lastResolvedAt?: number;
|
|
184
|
+
firstResolvedAt?: number;
|
|
185
|
+
resolveDurationMs?: number;
|
|
186
|
+
postConstructStatus: PostConstructStatus;
|
|
187
|
+
dependencies: string[];
|
|
188
|
+
}>;
|
|
189
|
+
/**
|
|
190
|
+
* Resolve a dependency by its token.
|
|
191
|
+
*
|
|
192
|
+
* Four overloads, in order of preference:
|
|
193
|
+
* - **`InjectionToken<T>`** (from `createToken<T>(name)`) → returns `T`.
|
|
194
|
+
* Collision-safe by construction; no codegen required.
|
|
195
|
+
* - **Class constructor** → returns an instance of that class. Always
|
|
196
|
+
* type-safe; no codegen required.
|
|
197
|
+
* - **String token in `KickJsRegistry`** (populated by `kick typegen`) →
|
|
198
|
+
* returns the augmented type.
|
|
199
|
+
* - **Anything else** → returns `any`. Use this only for legacy code or
|
|
200
|
+
* string tokens that haven't been registered with typegen yet.
|
|
201
|
+
*/
|
|
202
|
+
resolve<T>(token: InjectionToken<T>): T;
|
|
203
|
+
resolve<T>(token: Constructor<T>): T;
|
|
204
|
+
resolve<K extends keyof KickJsRegistry & string>(token: K): KickJsRegistry[K];
|
|
205
|
+
resolve<T = any>(token: any): T;
|
|
206
|
+
/** Lifecycle hook called during Application.setup() after module registration */
|
|
207
|
+
bootstrap(): void;
|
|
208
|
+
/**
|
|
209
|
+
* Subscribe to container changes. Returns an unsubscribe function.
|
|
210
|
+
*
|
|
211
|
+
* Changes are batched (50ms debounce) so bulk operations like
|
|
212
|
+
* `kick g module` creating 10+ files emit ONE batch, not 10 events.
|
|
213
|
+
*
|
|
214
|
+
* Any adapter can subscribe:
|
|
215
|
+
* - SwaggerAdapter: re-build spec when controllers change
|
|
216
|
+
* - DevToolsAdapter: push SSE events to dashboard
|
|
217
|
+
* - WsAdapter: re-discover namespaces when controllers change
|
|
218
|
+
* - OtelAdapter: emit tracing spans for DI resolution
|
|
219
|
+
* - Custom user adapters
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* const unsub = container.onChange((changes) => {
|
|
224
|
+
* for (const c of changes) {
|
|
225
|
+
* console.log(`${c.event}: ${c.token} (${c.kind})`)
|
|
226
|
+
* }
|
|
227
|
+
* })
|
|
228
|
+
* // later:
|
|
229
|
+
* unsub()
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
onChange(callback: ContainerChangeListener): () => void;
|
|
233
|
+
/**
|
|
234
|
+
* Invalidate a specific registration. Clears the cached instance so the
|
|
235
|
+
* next resolve() creates a fresh one. Also invalidates dependents
|
|
236
|
+
* (anything that injected this token) by walking the dependency graph.
|
|
237
|
+
*
|
|
238
|
+
* Called by the Vite HMR plugin when a module file changes.
|
|
239
|
+
* Skips persistent registrations (DB connections, etc.).
|
|
240
|
+
*/
|
|
241
|
+
invalidate(token: any): void;
|
|
242
|
+
/** Batch-emit a change event (debounced, flushed after 50ms of quiet) */
|
|
243
|
+
private emit;
|
|
244
|
+
/** Flush pending change events immediately (useful in tests) */
|
|
245
|
+
flushChanges(): void;
|
|
246
|
+
private createInstance;
|
|
247
|
+
/** Extract dependency token names from constructor metadata */
|
|
248
|
+
private extractDependencies;
|
|
249
|
+
private injectProperties;
|
|
250
|
+
}
|
|
251
|
+
//#endregion
|
|
252
|
+
export { tokenName as a, createToken as c, KickJsRegistry as i, isInjectionToken as l, ContainerChangeEvent as n, INJECTION_TOKEN as o, ContainerChangeListener as r, InjectionToken as s, Container as t };
|
|
253
|
+
//# sourceMappingURL=container-CcgV8eHL.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-CcgV8eHL.d.mts","names":[],"sources":["../src/core/token.ts","../src/core/container.ts"],"mappings":";;;;;;;AAmDA;;;;;AAWA;;;;;;;;;;;AAeA;;;;;;;;;;AAQA;;;;;;;;;;;;ACnCA;;;;;AAqBA;;;AArBA,cDCa,eAAA;;;;;;;;AC4Bb;;UDjBiB,cAAA;EAAA,UACL,eAAA;ECgB0D;EAAA,SDd3D,IAAA;ECiCoB;EAAA,SD/BpB,KAAA,GAAQ,CAAA;AAAA;;AC8DnB;;;;;;iBDpDgB,WAAA,GAAA,CAAe,IAAA,WAAe,cAAA,CAAe,CAAA;;iBAQ7C,gBAAA,CAAiB,KAAA,YAAiB,KAAA,IAAS,cAAA;;;;iBCnC3C,SAAA,CAAU,KAAA;;UAqBT,oBAAA;EACf,KAAA;EACA,KAAA;EACA,IAAA,GAAO,SAAA;EACP,SAAA;AAAA;;KAIU,uBAAA,IAA2B,OAAA,EAAS,oBAAA;;;;;;;ADFhD;;;;;;;;;;AAQA;UCaiB,cAAA;;;;;;;;;;AAhDjB;;cA+Ea,SAAA;EAAA,eACI,QAAA;EAAA,QACP,aAAA;EAAA,QACA,SAAA;EAAA,QAGA,eAAA;EAAA,QACA,cAAA;EAAA,QACA,WAAA;EAAA,wBACgB,WAAA;EAjExB;EAAA,OAoEO,QAAA,IAAY,SAAA,EAAW,SAAA;EAnEvB;EAAA,OAqEA,QAAA,IAAY,SAAA,EAAW,SAAA;EApErB;;AAIX;;EAJW,OAyEF,YAAA,IAAgB,GAAA;EArEuB;;AAmBhD;;;EAnBgD,OA2EvC,qBAAA;IACM,SAAA,EAAW,GAAA;IAAe,MAAA,EAAQ,GAAA;EAAA;EAAA,OAGxC,WAAA,CAAA,GAAe,SAAA;EAjBQ;;;;;EAAA,OAkCvB,KAAA,CAAA;EA0DsB;;;;;;;;;;;EAAA,OALtB,MAAA,CAAA,GAAU,SAAA;EA2IO;EAtIxB,QAAA,CAAS,KAAA,OAAY,MAAA,EAAQ,WAAA,EAAa,KAAA,GAAO,KAAA;EAsIW;EAxH5D,eAAA,CAAgB,KAAA,OAAY,OAAA,aAAoB,KAAA,GAAO,KAAA;EAyHzB;EAlF9B,gBAAA,CAAiB,KAAA,OAAY,QAAA;EA+Ma;EAlL1C,GAAA,CAAI,KAAA;EAzLW;EA8Lf,gBAAA,CAAA,GAAoB,KAAA;IAClB,KAAA;IACA,KAAA;IACA,IAAA,EAAM,SAAA;IACN,YAAA;IACA,YAAA;IACA,cAAA;IACA,eAAA;IACA,iBAAA;IACA,mBAAA,EAAqB,mBAAA;IACrB,YAAA;EAAA;EAtLK;;;;;;;;;;;;;EAyNP,OAAA,GAAA,CAAW,KAAA,EAAO,cAAA,CAAe,CAAA,IAAK,CAAA;EACtC,OAAA,GAAA,CAAW,KAAA,EAAO,WAAA,CAAY,CAAA,IAAK,CAAA;EACnC,OAAA,iBAAwB,cAAA,UAAA,CAAyB,KAAA,EAAO,CAAA,GAAI,cAAA,CAAe,CAAA;EAC3E,OAAA,SAAA,CAAiB,KAAA,QAAa,CAAA;EAvIY;EAqO1C,SAAA,CAAA;EAvNgB;;;;;;;;;;;;;;;;;;;;;;;;EAsPhB,QAAA,CAAS,QAAA,EAAU,uBAAA;EAhID;;;;;;;;EA6IlB,UAAA,CAAW,KAAA;EA5IwB;EAAA,QAqK3B,IAAA;EApKA;EAsLR,YAAA,CAAA;EAAA,QAgBQ,cAAA;EAtMyC;EAAA,QAoQzC,mBAAA;EAAA,QASA,gBAAA;AAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
|
|
2
|
+
import { a as Cacheable, c as setCacheProvider, i as CacheProvider, n as CacheEvict, o as MemoryCacheProvider, r as CacheOptions, s as getCacheProvider, t as CACHEABLE_META } from "../cache-PufEhr0n.mjs";
|
|
3
|
+
export { CACHEABLE_META, CacheEvict, CacheOptions, CacheProvider, Cacheable, MemoryCacheProvider, getCacheProvider, setCacheProvider };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @forinda/kickjs v2.2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Felix Orinda
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import "reflect-metadata";
|
|
12
|
+
//#region src/core/cache.ts
|
|
13
|
+
const CACHEABLE_META = Symbol("kick:cacheable");
|
|
14
|
+
/**
|
|
15
|
+
* Default in-memory cache provider using a Map.
|
|
16
|
+
* Suitable for development and single-instance deployments.
|
|
17
|
+
* For multi-instance or production, use a Redis-backed provider.
|
|
18
|
+
*/
|
|
19
|
+
var MemoryCacheProvider = class {
|
|
20
|
+
store = /* @__PURE__ */ new Map();
|
|
21
|
+
async get(key) {
|
|
22
|
+
const entry = this.store.get(key);
|
|
23
|
+
if (!entry) return null;
|
|
24
|
+
if (entry.expiresAt <= Date.now()) {
|
|
25
|
+
this.store.delete(key);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return entry.data;
|
|
29
|
+
}
|
|
30
|
+
async set(key, value, ttlMs) {
|
|
31
|
+
this.store.set(key, {
|
|
32
|
+
data: value,
|
|
33
|
+
expiresAt: Date.now() + ttlMs
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async del(key) {
|
|
37
|
+
this.store.delete(key);
|
|
38
|
+
}
|
|
39
|
+
async delByPrefix(prefix) {
|
|
40
|
+
for (const key of this.store.keys()) if (key.startsWith(prefix)) this.store.delete(key);
|
|
41
|
+
}
|
|
42
|
+
async shutdown() {
|
|
43
|
+
this.store.clear();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
let _cacheProvider = new MemoryCacheProvider();
|
|
47
|
+
/**
|
|
48
|
+
* Set the global cache provider used by @Cacheable and @CacheEvict.
|
|
49
|
+
* Call this before bootstrapping your app.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { setCacheProvider } from '@forinda/kickjs-core'
|
|
54
|
+
* import { RedisCacheProvider } from './redis-cache'
|
|
55
|
+
*
|
|
56
|
+
* setCacheProvider(new RedisCacheProvider(redisClient))
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
function setCacheProvider(provider) {
|
|
60
|
+
_cacheProvider = provider;
|
|
61
|
+
}
|
|
62
|
+
/** Get the current cache provider */
|
|
63
|
+
function getCacheProvider() {
|
|
64
|
+
return _cacheProvider;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Cache the return value of a method for the specified TTL.
|
|
68
|
+
* Uses the globally registered CacheProvider (default: MemoryCacheProvider).
|
|
69
|
+
*
|
|
70
|
+
* Call `setCacheProvider()` to use Redis or any custom backend.
|
|
71
|
+
*
|
|
72
|
+
* @param ttl - Time-to-live in seconds (default: 60)
|
|
73
|
+
* @param options.key - Custom cache key prefix
|
|
74
|
+
*/
|
|
75
|
+
function Cacheable(ttl, options) {
|
|
76
|
+
return (_target, propertyKey, descriptor) => {
|
|
77
|
+
const original = descriptor.value;
|
|
78
|
+
const cacheTtl = (ttl ?? 60) * 1e3;
|
|
79
|
+
const keyPrefix = options?.key ?? String(propertyKey);
|
|
80
|
+
descriptor.value = async function(...args) {
|
|
81
|
+
const cacheKey = `${keyPrefix}:${JSON.stringify(args)}`;
|
|
82
|
+
const provider = getCacheProvider();
|
|
83
|
+
const cached = await provider.get(cacheKey);
|
|
84
|
+
if (cached !== null) return cached;
|
|
85
|
+
const result = await original.apply(this, args);
|
|
86
|
+
await provider.set(cacheKey, result, cacheTtl);
|
|
87
|
+
return result;
|
|
88
|
+
};
|
|
89
|
+
return descriptor;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Evict cached values matching a key prefix after the method executes.
|
|
94
|
+
* Works with any CacheProvider that implements `delByPrefix`.
|
|
95
|
+
*
|
|
96
|
+
* @param key - Cache key prefix to evict (matches the @Cacheable key)
|
|
97
|
+
*/
|
|
98
|
+
function CacheEvict(key) {
|
|
99
|
+
return (_target, _propertyKey, descriptor) => {
|
|
100
|
+
const original = descriptor.value;
|
|
101
|
+
descriptor.value = async function(...args) {
|
|
102
|
+
const result = await original.apply(this, args);
|
|
103
|
+
const provider = getCacheProvider();
|
|
104
|
+
if (provider.delByPrefix) await provider.delByPrefix(key);
|
|
105
|
+
return result;
|
|
106
|
+
};
|
|
107
|
+
return descriptor;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
export { CACHEABLE_META, CacheEvict, Cacheable, MemoryCacheProvider, getCacheProvider, setCacheProvider };
|
|
112
|
+
|
|
113
|
+
//# sourceMappingURL=cache.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.mjs","names":[],"sources":["../../src/core/cache.ts"],"sourcesContent":["import 'reflect-metadata'\n\nconst CACHEABLE_META = Symbol('kick:cacheable')\n\n// ── CacheProvider Interface ─────────────────────────────────────────────\n\n/**\n * Abstract cache backend. Implement this interface to use Redis, Memcached,\n * or any other cache store with @Cacheable and @CacheEvict.\n *\n * @example\n * ```ts\n * class RedisCacheProvider implements CacheProvider {\n * private client: RedisClient\n * constructor(client: RedisClient) { this.client = client }\n * async get(key: string) {\n * const val = await this.client.get(key)\n * return val ? JSON.parse(val) : null\n * }\n * async set(key: string, value: any, ttlMs: number) {\n * await this.client.set(key, JSON.stringify(value), 'PX', ttlMs)\n * }\n * async del(key: string) { await this.client.del(key) }\n * async delByPrefix(prefix: string) {\n * const keys = await this.client.keys(prefix + '*')\n * if (keys.length) await this.client.del(...keys)\n * }\n * }\n * ```\n */\nexport interface CacheProvider {\n /** Retrieve a cached value. Return null if not found or expired. */\n get(key: string): Promise<any | null>\n /** Store a value with a TTL in milliseconds. */\n set(key: string, value: any, ttlMs: number): Promise<void>\n /** Delete a specific cache key. */\n del(key: string): Promise<void>\n /** Delete all keys matching a prefix. Used by @CacheEvict. */\n delByPrefix?(prefix: string): Promise<void>\n /** Optional cleanup on shutdown. */\n shutdown?(): Promise<void>\n}\n\n// ── Built-in Memory Provider ────────────────────────────────────────────\n\n/**\n * Default in-memory cache provider using a Map.\n * Suitable for development and single-instance deployments.\n * For multi-instance or production, use a Redis-backed provider.\n */\nexport class MemoryCacheProvider implements CacheProvider {\n private store = new Map<string, { data: any; expiresAt: number }>()\n\n async get(key: string): Promise<any | null> {\n const entry = this.store.get(key)\n if (!entry) return null\n if (entry.expiresAt <= Date.now()) {\n this.store.delete(key)\n return null\n }\n return entry.data\n }\n\n async set(key: string, value: any, ttlMs: number): Promise<void> {\n this.store.set(key, { data: value, expiresAt: Date.now() + ttlMs })\n }\n\n async del(key: string): Promise<void> {\n this.store.delete(key)\n }\n\n async delByPrefix(prefix: string): Promise<void> {\n for (const key of this.store.keys()) {\n if (key.startsWith(prefix)) {\n this.store.delete(key)\n }\n }\n }\n\n async shutdown(): Promise<void> {\n this.store.clear()\n }\n}\n\n// ── Global Cache Registry ───────────────────────────────────────────────\n\nlet _cacheProvider: CacheProvider = new MemoryCacheProvider()\n\n/**\n * Set the global cache provider used by @Cacheable and @CacheEvict.\n * Call this before bootstrapping your app.\n *\n * @example\n * ```ts\n * import { setCacheProvider } from '@forinda/kickjs-core'\n * import { RedisCacheProvider } from './redis-cache'\n *\n * setCacheProvider(new RedisCacheProvider(redisClient))\n * ```\n */\nexport function setCacheProvider(provider: CacheProvider): void {\n _cacheProvider = provider\n}\n\n/** Get the current cache provider */\nexport function getCacheProvider(): CacheProvider {\n return _cacheProvider\n}\n\n// ── Cache Options ───────────────────────────────────────────────────────\n\nexport interface CacheOptions {\n /** Time-to-live in seconds (default: 60) */\n ttl?: number\n /** Cache key prefix (default: ClassName.methodName) */\n key?: string\n}\n\n// ── @Cacheable Decorator ────────────────────────────────────────────────\n\n/**\n * Cache the return value of a method for the specified TTL.\n * Uses the globally registered CacheProvider (default: MemoryCacheProvider).\n *\n * Call `setCacheProvider()` to use Redis or any custom backend.\n *\n * @param ttl - Time-to-live in seconds (default: 60)\n * @param options.key - Custom cache key prefix\n */\nexport function Cacheable(ttl?: number, options?: { key?: string }): MethodDecorator {\n return (_target, propertyKey, descriptor: PropertyDescriptor) => {\n const original = descriptor.value\n const cacheTtl = (ttl ?? 60) * 1000\n const keyPrefix = options?.key ?? String(propertyKey)\n\n descriptor.value = async function (...args: any[]) {\n const cacheKey = `${keyPrefix}:${JSON.stringify(args)}`\n const provider = getCacheProvider()\n\n const cached = await provider.get(cacheKey)\n if (cached !== null) {\n return cached\n }\n\n const result = await original.apply(this, args)\n await provider.set(cacheKey, result, cacheTtl)\n return result\n }\n\n return descriptor\n }\n}\n\n// ── @CacheEvict Decorator ───────────────────────────────────────────────\n\n/**\n * Evict cached values matching a key prefix after the method executes.\n * Works with any CacheProvider that implements `delByPrefix`.\n *\n * @param key - Cache key prefix to evict (matches the @Cacheable key)\n */\nexport function CacheEvict(key: string): MethodDecorator {\n return (_target, _propertyKey, descriptor: PropertyDescriptor) => {\n const original = descriptor.value\n\n descriptor.value = async function (...args: any[]) {\n const result = await original.apply(this, args)\n const provider = getCacheProvider()\n if (provider.delByPrefix) {\n await provider.delByPrefix(key)\n }\n return result\n }\n\n return descriptor\n }\n}\n\nexport { CACHEABLE_META }\n"],"mappings":";;;;;;;;;;;;AAEA,MAAM,iBAAiB,OAAO,iBAAiB;;;;;;AAgD/C,IAAa,sBAAb,MAA0D;CACxD,wBAAgB,IAAI,KAA+C;CAEnE,MAAM,IAAI,KAAkC;EAC1C,MAAM,QAAQ,KAAK,MAAM,IAAI,IAAI;AACjC,MAAI,CAAC,MAAO,QAAO;AACnB,MAAI,MAAM,aAAa,KAAK,KAAK,EAAE;AACjC,QAAK,MAAM,OAAO,IAAI;AACtB,UAAO;;AAET,SAAO,MAAM;;CAGf,MAAM,IAAI,KAAa,OAAY,OAA8B;AAC/D,OAAK,MAAM,IAAI,KAAK;GAAE,MAAM;GAAO,WAAW,KAAK,KAAK,GAAG;GAAO,CAAC;;CAGrE,MAAM,IAAI,KAA4B;AACpC,OAAK,MAAM,OAAO,IAAI;;CAGxB,MAAM,YAAY,QAA+B;AAC/C,OAAK,MAAM,OAAO,KAAK,MAAM,MAAM,CACjC,KAAI,IAAI,WAAW,OAAO,CACxB,MAAK,MAAM,OAAO,IAAI;;CAK5B,MAAM,WAA0B;AAC9B,OAAK,MAAM,OAAO;;;AAMtB,IAAI,iBAAgC,IAAI,qBAAqB;;;;;;;;;;;;;AAc7D,SAAgB,iBAAiB,UAA+B;AAC9D,kBAAiB;;;AAInB,SAAgB,mBAAkC;AAChD,QAAO;;;;;;;;;;;AAuBT,SAAgB,UAAU,KAAc,SAA6C;AACnF,SAAQ,SAAS,aAAa,eAAmC;EAC/D,MAAM,WAAW,WAAW;EAC5B,MAAM,YAAY,OAAO,MAAM;EAC/B,MAAM,YAAY,SAAS,OAAO,OAAO,YAAY;AAErD,aAAW,QAAQ,eAAgB,GAAG,MAAa;GACjD,MAAM,WAAW,GAAG,UAAU,GAAG,KAAK,UAAU,KAAK;GACrD,MAAM,WAAW,kBAAkB;GAEnC,MAAM,SAAS,MAAM,SAAS,IAAI,SAAS;AAC3C,OAAI,WAAW,KACb,QAAO;GAGT,MAAM,SAAS,MAAM,SAAS,MAAM,MAAM,KAAK;AAC/C,SAAM,SAAS,IAAI,UAAU,QAAQ,SAAS;AAC9C,UAAO;;AAGT,SAAO;;;;;;;;;AAYX,SAAgB,WAAW,KAA8B;AACvD,SAAQ,SAAS,cAAc,eAAmC;EAChE,MAAM,WAAW,WAAW;AAE5B,aAAW,QAAQ,eAAgB,GAAG,MAAa;GACjD,MAAM,SAAS,MAAM,SAAS,MAAM,MAAM,KAAK;GAC/C,MAAM,WAAW,kBAAkB;AACnC,OAAI,SAAS,YACX,OAAM,SAAS,YAAY,IAAI;AAEjC,UAAO;;AAGT,SAAO"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @forinda/kickjs v2.2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Felix Orinda
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import { n as tokenName, t as Container } from "../container-B7jFEbPE.mjs";
|
|
12
|
+
export { Container, tokenName };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @forinda/kickjs v2.2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Felix Orinda
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import { c as pushClassMeta, t as getClassMeta } from "../metadata-BqXgNTOf.mjs";
|
|
12
|
+
//#region src/core/cron.ts
|
|
13
|
+
const CRON_META = Symbol("kick:cron");
|
|
14
|
+
/**
|
|
15
|
+
* Schedule a method to run on a cron expression.
|
|
16
|
+
* Requires a CronAdapter to be registered in bootstrap().
|
|
17
|
+
*
|
|
18
|
+
* @param expression - Standard 5-part cron: minute hour day month weekday.
|
|
19
|
+
* Use forward-slash for intervals (e.g. every 5 min, every 2 hours).
|
|
20
|
+
* @param options.description - Human-readable label for logging
|
|
21
|
+
* @param options.timezone - IANA timezone (e.g. 'America/New_York', 'UTC')
|
|
22
|
+
* @param options.runOnInit - Run immediately on startup before first scheduled tick
|
|
23
|
+
*/
|
|
24
|
+
function Cron(expression, options) {
|
|
25
|
+
return (target, propertyKey) => {
|
|
26
|
+
pushClassMeta(CRON_META, target.constructor, {
|
|
27
|
+
expression,
|
|
28
|
+
handlerName: propertyKey,
|
|
29
|
+
description: options?.description,
|
|
30
|
+
timezone: options?.timezone,
|
|
31
|
+
runOnInit: options?.runOnInit
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Read cron jobs registered on a class */
|
|
36
|
+
function getCronJobs(target) {
|
|
37
|
+
return getClassMeta(CRON_META, target, []);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { CRON_META, Cron, getCronJobs };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=cron.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron.mjs","names":[],"sources":["../../src/core/cron.ts"],"sourcesContent":["import { pushClassMeta, getClassMeta } from './metadata'\n\nconst CRON_META = Symbol('kick:cron')\n\nexport interface CronJobMeta {\n expression: string\n handlerName: string\n description?: string\n timezone?: string\n runOnInit?: boolean\n}\n\n// Cron format: minute hour day month weekday\n// Examples:\n// '* * * * *' - every minute\n// '0 * * * *' - every hour\n// '0 0 * * *' - daily at midnight\n// '0 9 * * MON-FRI' - weekdays at 9am\n// '0 0 1 * *' - first of each month\n\n/**\n * Schedule a method to run on a cron expression.\n * Requires a CronAdapter to be registered in bootstrap().\n *\n * @param expression - Standard 5-part cron: minute hour day month weekday.\n * Use forward-slash for intervals (e.g. every 5 min, every 2 hours).\n * @param options.description - Human-readable label for logging\n * @param options.timezone - IANA timezone (e.g. 'America/New_York', 'UTC')\n * @param options.runOnInit - Run immediately on startup before first scheduled tick\n */\nexport function Cron(\n expression: string,\n options?: { description?: string; timezone?: string; runOnInit?: boolean },\n): MethodDecorator {\n return (target, propertyKey) => {\n pushClassMeta<CronJobMeta>(CRON_META, target.constructor, {\n expression,\n handlerName: propertyKey as string,\n description: options?.description,\n timezone: options?.timezone,\n runOnInit: options?.runOnInit,\n })\n }\n}\n\n/** Read cron jobs registered on a class */\nexport function getCronJobs(target: any): CronJobMeta[] {\n return getClassMeta<CronJobMeta[]>(CRON_META, target, [])\n}\n\nexport { CRON_META }\n"],"mappings":";;;;;;;;;;;;AAEA,MAAM,YAAY,OAAO,YAAY;;;;;;;;;;;AA4BrC,SAAgB,KACd,YACA,SACiB;AACjB,SAAQ,QAAQ,gBAAgB;AAC9B,gBAA2B,WAAW,OAAO,aAAa;GACxD;GACA,aAAa;GACb,aAAa,SAAS;GACtB,UAAU,SAAS;GACnB,WAAW,SAAS;GACrB,CAAC;;;;AAKN,SAAgB,YAAY,QAA4B;AACtD,QAAO,aAA4B,WAAW,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
|
|
2
|
+
import { C as Put, D as Value, E as Service, O as normalizeApiQueryParamsConfig, S as PostConstruct, T as RouteDefinition, _ as Injectable, a as Builder, b as Patch, c as Controller, d as EnvKey, f as FileTypeFilter, g as Inject, h as Get, i as BaseUploadOptions, l as Delete, m as FileUploadConfig, n as ApiQueryParamsConfig, o as ColumnApiQueryParamsConfig, p as FileUpload, r as Autowired, s as Component, t as ApiQueryParams, u as Env, v as Middleware, w as Repository, x as Post, y as MiddlewareHandler } from "../decorators-D3lBlmud.mjs";
|
|
3
|
+
export { ApiQueryParams, ApiQueryParamsConfig, Autowired, BaseUploadOptions, Builder, ColumnApiQueryParamsConfig, Component, Controller, Delete, Env, EnvKey, FileTypeFilter, FileUpload, FileUploadConfig, Get, Inject, Injectable, Middleware, MiddlewareHandler, Patch, Post, PostConstruct, Put, Repository, RouteDefinition, Service, Value, normalizeApiQueryParamsConfig };
|