truxie 0.1.0-test.13 → 0.1.0-test.15
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/dist/bullmq.d.ts +244 -0
- package/dist/bullmq.js +1 -0
- package/dist/cache.d.ts +1 -1
- package/dist/cache.js +1 -1
- package/dist/chunk-4IAZ6T72.js +1 -0
- package/dist/chunk-ASOZYX5T.js +1 -0
- package/dist/{chunk-2ACNLLXS.js → chunk-F3UTUZEO.js} +1 -1
- package/dist/{container-BQEpLL35.d.ts → container-4Q8Oq_GB.d.ts} +1 -1
- package/dist/cqrs.d.ts +1 -1
- package/dist/cqrs.js +1 -1
- package/dist/health.d.ts +1 -1
- package/dist/health.js +1 -1
- package/dist/index.d.ts +7 -37
- package/dist/index.js +2 -2
- package/dist/interfaces-0QqKD1vX.d.ts +34 -0
- package/dist/{interfaces-zvtMSS9r.d.ts → interfaces-ivJCgMba.d.ts} +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +1 -1
- package/dist/schedule.d.ts +1 -1
- package/dist/schedule.js +1 -1
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +1 -1
- package/dist/throttle.d.ts +3 -3
- package/dist/throttle.js +1 -1
- package/dist/{types-D-An5cXP.d.ts → types-CoyG1lE2.d.ts} +7 -7
- package/package.json +114 -104
- package/dist/chunk-IEQXYYZJ.js +0 -1
- package/dist/chunk-MF2CCNPQ.js +0 -1
package/dist/bullmq.d.ts
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { D as DynamicModule } from './types-CoyG1lE2.js';
|
|
2
|
+
import { ConnectionOptions, WorkerOptions, JobsOptions, QueueOptions, Queue, Worker, Job } from 'bullmq';
|
|
3
|
+
export { Job, JobsOptions, Queue, QueueOptions } from 'bullmq';
|
|
4
|
+
import { I as Inject, b as OnApplicationShutdown } from './interfaces-0QqKD1vX.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Per-class options applied when constructing the BullMQ Worker for a @Processor.
|
|
8
|
+
* Values here override the defaults set in BullModule.forRoot().
|
|
9
|
+
*/
|
|
10
|
+
type ProcessorOptions = Omit<WorkerOptions, 'connection' | 'prefix'> & {
|
|
11
|
+
/**
|
|
12
|
+
* Override the default queue prefix for this processor.
|
|
13
|
+
* Falls back to the prefix set in BullModule.forRoot().
|
|
14
|
+
*/
|
|
15
|
+
prefix?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Lifecycle events emitted by a BullMQ Worker that can be observed
|
|
19
|
+
* via the @OnWorkerEvent('<event>') method decorator.
|
|
20
|
+
*/
|
|
21
|
+
type WorkerEvent = 'active' | 'completed' | 'failed' | 'progress' | 'stalled' | 'error' | 'closing' | 'closed' | 'drained' | 'paused' | 'resumed' | 'ready';
|
|
22
|
+
interface BullModuleOptions {
|
|
23
|
+
/** Required: shared Redis connection used by every Worker registered via @Processor and every Queue registered via registerQueue. */
|
|
24
|
+
connection: ConnectionOptions;
|
|
25
|
+
/** Optional default queue prefix applied to every Worker / Queue (override per-call). */
|
|
26
|
+
prefix?: string;
|
|
27
|
+
/** Default WorkerOptions merged with per-processor options (per-processor wins). */
|
|
28
|
+
defaultWorkerOptions?: Omit<WorkerOptions, 'connection' | 'prefix'>;
|
|
29
|
+
/** Default JobsOptions merged with per-queue options (per-queue wins). */
|
|
30
|
+
defaultJobOptions?: JobsOptions;
|
|
31
|
+
/** Disable the explorer entirely (useful for HTTP-only processes that share AppModule). */
|
|
32
|
+
enabled?: boolean;
|
|
33
|
+
/** Hook called when a Worker emits 'error' or process() throws and no @OnWorkerEvent('failed') handler exists. */
|
|
34
|
+
onError?: (error: unknown, queueName: string) => void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Options accepted by `BullModule.registerQueue({...})` to declare a producer Queue.
|
|
38
|
+
*/
|
|
39
|
+
interface RegisterQueueOptions extends Omit<QueueOptions, 'connection' | 'prefix'> {
|
|
40
|
+
name: string;
|
|
41
|
+
/** Override the default prefix from forRoot(). */
|
|
42
|
+
prefix?: string;
|
|
43
|
+
}
|
|
44
|
+
interface WorkerEntry {
|
|
45
|
+
queueName: string;
|
|
46
|
+
className: string;
|
|
47
|
+
worker: Worker;
|
|
48
|
+
stop: () => Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
interface QueueEntry {
|
|
51
|
+
name: string;
|
|
52
|
+
queue: Queue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Enables `@Processor()` discovery for BullMQ Worker classes and exposes
|
|
57
|
+
* `registerQueue()` for the producer side.
|
|
58
|
+
*
|
|
59
|
+
* Import with `BullModule.forRoot({ connection })` in the root module of your
|
|
60
|
+
* long-running process. HTTP-only processes (Next.js / Vercel) should NOT
|
|
61
|
+
* import this module so workers never spin up there.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* @Module({
|
|
66
|
+
* imports: [
|
|
67
|
+
* BullModule.forRoot({
|
|
68
|
+
* connection: { host: 'localhost', port: 6379 },
|
|
69
|
+
* }),
|
|
70
|
+
*
|
|
71
|
+
* BullModule.registerQueue({
|
|
72
|
+
* name: 'mail',
|
|
73
|
+
* }),
|
|
74
|
+
* ],
|
|
75
|
+
* providers: [MailProcessor],
|
|
76
|
+
* })
|
|
77
|
+
* export class AppModule {}
|
|
78
|
+
*
|
|
79
|
+
* // Producer:
|
|
80
|
+
* @Injectable()
|
|
81
|
+
* export class MailService {
|
|
82
|
+
* constructor(@InjectQueue('mail') private readonly queue: Queue) {}
|
|
83
|
+
* send(payload: unknown) { return this.queue.add('send', payload) }
|
|
84
|
+
* }
|
|
85
|
+
*
|
|
86
|
+
* // Consumer:
|
|
87
|
+
* @Processor('mail')
|
|
88
|
+
* export class MailProcessor extends WorkerHost {
|
|
89
|
+
* async process(job: Job): Promise<void> { ... }
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
declare class BullModule {
|
|
94
|
+
/**
|
|
95
|
+
* Wires global Worker discovery + Queue registry. Call once at the root.
|
|
96
|
+
*/
|
|
97
|
+
static forRoot(options: BullModuleOptions): DynamicModule;
|
|
98
|
+
/**
|
|
99
|
+
* Declares a Queue producer that can be injected via `@InjectQueue('<name>')`.
|
|
100
|
+
* Multiple modules can call `registerQueue({ name })` for the same name —
|
|
101
|
+
* the token is keyed on the name (Symbol.for) so they all resolve to the
|
|
102
|
+
* same Queue instance.
|
|
103
|
+
*
|
|
104
|
+
* Must be combined with a `BullModule.forRoot({...})` call somewhere in the
|
|
105
|
+
* module graph — the factory reads the connection from there.
|
|
106
|
+
*/
|
|
107
|
+
static registerQueue(options: RegisterQueueOptions): DynamicModule;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Class decorator that marks a class as a BullMQ Worker processor for the given queue.
|
|
112
|
+
*
|
|
113
|
+
* The class MUST extend `WorkerHost` and implement `process(job)`.
|
|
114
|
+
* Requires `BullModule.forRoot({ connection })` in your module imports.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* @Processor('trade-execution', { concurrency: 5 })
|
|
119
|
+
* @Inject(ExecuteCryptoTradeUseCase)
|
|
120
|
+
* export class TradeProcessor extends WorkerHost {
|
|
121
|
+
* constructor(private readonly useCase: ExecuteCryptoTradeUseCase) { super() }
|
|
122
|
+
*
|
|
123
|
+
* async process(job: Job): Promise<unknown> {
|
|
124
|
+
* return this.useCase.execute(job.data)
|
|
125
|
+
* }
|
|
126
|
+
*
|
|
127
|
+
* @OnWorkerEvent('failed')
|
|
128
|
+
* onFailed(job: Job, err: Error) {
|
|
129
|
+
* console.error(`[${job.queueName}] ${job.id} failed:`, err)
|
|
130
|
+
* }
|
|
131
|
+
* }
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
declare function Processor(queueName: string, options?: ProcessorOptions): ClassDecorator;
|
|
135
|
+
/**
|
|
136
|
+
* Method decorator inside a `@Processor()` class that subscribes the method
|
|
137
|
+
* to a BullMQ Worker lifecycle event.
|
|
138
|
+
*/
|
|
139
|
+
declare function OnWorkerEvent(event: WorkerEvent): MethodDecorator;
|
|
140
|
+
/**
|
|
141
|
+
* Parameter / class decorator that injects a BullMQ Queue producer registered
|
|
142
|
+
* via `BullModule.registerQueue({ name })`.
|
|
143
|
+
*
|
|
144
|
+
* Equivalent to `@Inject(getQueueToken(name))` — provided as a separate alias for clarity.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* @Injectable()
|
|
149
|
+
* export class MailService {
|
|
150
|
+
* constructor(@InjectQueue('mail') private readonly mailQueue: Queue) {}
|
|
151
|
+
*
|
|
152
|
+
* send(payload: unknown) {
|
|
153
|
+
* return this.mailQueue.add('send', payload)
|
|
154
|
+
* }
|
|
155
|
+
* }
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
declare function InjectQueue(name: string): ReturnType<typeof Inject>;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Abstract base class for BullMQ Worker processors.
|
|
162
|
+
*
|
|
163
|
+
* Subclass and decorate with `@Processor('queue-name')`. Implement `process(job)` —
|
|
164
|
+
* the explorer will instantiate a BullMQ Worker for you using the connection
|
|
165
|
+
* configured in `BullMQModule.forRoot()`.
|
|
166
|
+
*
|
|
167
|
+
* The `worker` property is assigned by the explorer after construction, so you can
|
|
168
|
+
* access it from inside `@OnWorkerEvent` handlers if needed.
|
|
169
|
+
*/
|
|
170
|
+
declare abstract class WorkerHost<T = unknown, R = unknown, N extends string = string> {
|
|
171
|
+
/** @internal Set by WorkerExplorer after the BullMQ Worker is constructed. */
|
|
172
|
+
worker?: Worker<T, R, N>;
|
|
173
|
+
abstract process(job: Job<T, R, N>, token?: string): Promise<R>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Registry that tracks every Worker spun up by `@Processor` discovery.
|
|
178
|
+
* Inject this to programmatically pause/close workers at runtime.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* @Injectable()
|
|
183
|
+
* @Inject(WorkerRegistry)
|
|
184
|
+
* class AdminService {
|
|
185
|
+
* constructor(private readonly workers: WorkerRegistry) {}
|
|
186
|
+
*
|
|
187
|
+
* async drain() {
|
|
188
|
+
* await this.workers.closeAll()
|
|
189
|
+
* }
|
|
190
|
+
* }
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
declare class WorkerRegistry {
|
|
194
|
+
private workers;
|
|
195
|
+
/** @internal */
|
|
196
|
+
register(entry: WorkerEntry): void;
|
|
197
|
+
get(queueName: string): WorkerEntry | undefined;
|
|
198
|
+
getAll(): WorkerEntry[];
|
|
199
|
+
getQueueNames(): string[];
|
|
200
|
+
close(queueName: string): Promise<boolean>;
|
|
201
|
+
closeAll(): Promise<void>;
|
|
202
|
+
get size(): number;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Registry that tracks every Queue producer registered via `BullModule.registerQueue()`.
|
|
207
|
+
* Closes them in `onApplicationShutdown` so the Redis connection is released cleanly.
|
|
208
|
+
*
|
|
209
|
+
* Inject this to programmatically inspect the producer side at runtime.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* @Injectable()
|
|
214
|
+
* @Inject(QueueRegistry)
|
|
215
|
+
* class QueueAdmin {
|
|
216
|
+
* constructor(private readonly queues: QueueRegistry) {}
|
|
217
|
+
*
|
|
218
|
+
* names() { return this.queues.getNames() }
|
|
219
|
+
* }
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
declare class QueueRegistry implements OnApplicationShutdown {
|
|
223
|
+
private queues;
|
|
224
|
+
/** @internal Called from the registerQueue() factory provider. */
|
|
225
|
+
register(name: string, queue: Queue): void;
|
|
226
|
+
get(name: string): Queue | undefined;
|
|
227
|
+
getAll(): Queue[];
|
|
228
|
+
getNames(): string[];
|
|
229
|
+
close(name: string): Promise<boolean>;
|
|
230
|
+
onApplicationShutdown(): Promise<void>;
|
|
231
|
+
get size(): number;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
declare const BULL_OPTIONS: unique symbol;
|
|
235
|
+
/**
|
|
236
|
+
* Build the DI token used to register and inject a BullMQ Queue producer
|
|
237
|
+
* registered via `BullModule.registerQueue({ name })`.
|
|
238
|
+
*
|
|
239
|
+
* Two calls with the same `name` return the same Symbol via `Symbol.for`
|
|
240
|
+
* so producer and consumer modules don't need a shared imported constant.
|
|
241
|
+
*/
|
|
242
|
+
declare function getQueueToken(name: string): symbol;
|
|
243
|
+
|
|
244
|
+
export { BULL_OPTIONS, BullModule, type BullModuleOptions, InjectQueue, OnWorkerEvent, Processor, type ProcessorOptions, type QueueEntry, QueueRegistry, type RegisterQueueOptions, type WorkerEntry, type WorkerEvent, WorkerHost, WorkerRegistry, getQueueToken };
|
package/dist/bullmq.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a as a$2}from'./chunk-F3UTUZEO.js';import {e,f as f$1,m,l}from'./chunk-ASOZYX5T.js';import {a as a$1}from'./chunk-EI7MMDWY.js';import'reflect-metadata';var x=Symbol("truxie:bullmq:processor"),v=Symbol("truxie:bullmq:worker-event"),d=Symbol("truxie:bullmq:options");function w(n){return Symbol.for(`truxie:bullmq:queue:${n}`)}a$1(w,"getQueueToken");function P(n,e,t,o){var s=arguments.length,r=s<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,t,o);else for(var u=n.length-1;u>=0;u--)(i=n[u])&&(r=(s<3?i(r):s>3?i(e,t,r):i(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r}a$1(P,"_ts_decorate");var f=class{static{a$1(this,"QueueRegistry");}queues=new Map;register(e,t){this.queues.set(e,{name:e,queue:t});}get(e){return this.queues.get(e)?.queue}getAll(){return [...this.queues.values()].map(e=>e.queue)}getNames(){return [...this.queues.keys()]}async close(e){let t=this.queues.get(e);return t?(await t.queue.close(),this.queues.delete(e),true):false}async onApplicationShutdown(){let e=[...this.queues.values()];this.queues.clear(),await Promise.all(e.map(t=>t.queue.close()));}get size(){return this.queues.size}};f=P([e()],f);function A(n,e,t,o){var s=arguments.length,r=s<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,t,o);else for(var u=n.length-1;u>=0;u--)(i=n[u])&&(r=(s<3?i(r):s>3?i(e,t,r):i(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r}a$1(A,"_ts_decorate");var a=class{static{a$1(this,"WorkerRegistry");}workers=new Map;register(e){this.workers.has(e.queueName)&&this.workers.get(e.queueName).stop(),this.workers.set(e.queueName,e);}get(e){return this.workers.get(e)}getAll(){return [...this.workers.values()]}getQueueNames(){return [...this.workers.keys()]}async close(e){let t=this.workers.get(e);return t?(await t.stop(),this.workers.delete(e),true):false}async closeAll(){let e=[...this.workers.values()];this.workers.clear(),await Promise.all(e.map(t=>t.stop()));}get size(){return this.workers.size}};a=A([e()],a);function M(n,e){return t=>{let o={queueName:n,options:e??{}};Reflect.defineMetadata(x,o,t);}}a$1(M,"Processor");function T(n){return (e,t)=>{let o=Reflect.getOwnMetadata(v,e.constructor)??[];o.push({event:n,methodName:String(t)}),Reflect.defineMetadata(v,o,e.constructor);}}a$1(T,"OnWorkerEvent");function _(n){return f$1(w(n))}a$1(_,"InjectQueue");function E(n){return Reflect.getOwnMetadata(x,n)}a$1(E,"getProcessorMetadata");function j(n){return Reflect.getOwnMetadata(v,n)??[]}a$1(j,"getWorkerEventMetadata");var y=class{static{a$1(this,"WorkerHost");}worker};function N(n,e,t,o){var s=arguments.length,r=s<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,t,o);else for(var u=n.length-1;u>=0;u--)(i=n[u])&&(r=(s<3?i(r):s>3?i(e,t,r):i(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r}a$1(N,"_ts_decorate");function k(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)}a$1(k,"_ts_metadata");var h=class{static{a$1(this,"WorkerExplorer");}discovery;registry;options;onError;constructor(e,t,o){this.discovery=e,this.registry=t,this.options=o,this.onError=o.onError??S;}async onApplicationBootstrap(){if(this.options.enabled===false)return;let e;try{({Worker:e}=await import('bullmq'));}catch(o){throw new Error(`[truxie/bullmq] Failed to import 'bullmq' \u2014 install it as a peer dependency. ${o instanceof Error?o.message:String(o)}`)}let t=this.discovery.getProviders();for(let o of t){let s=this.discovery.getProviderClass(o);if(!s)continue;let r=E(s);if(!r)continue;let i=typeof o=="function"?o:o.provide,u;try{u=await this.discovery.resolve(i);}catch{continue}if(!(u instanceof y))throw new Error(`[truxie/bullmq] Class ${s.name} is decorated with @Processor() but does not extend WorkerHost.`);let l=this.buildWorker(e,u,s,r);u.worker=l,this.attachEventListeners(l,u,s),this.registry.register({queueName:r.queueName,className:s.name,worker:l,stop:a$1(()=>l.close(),"stop")});}}async onApplicationShutdown(){await this.registry.closeAll();}buildWorker(e,t,o,s){let r={...this.options.defaultWorkerOptions??{},...s.options,connection:this.options.connection,prefix:s.options.prefix??this.options.prefix},i=a$1(async(u,l)=>{try{return await t.process(u,l)}catch(p){throw this.onError(p,s.queueName),p}},"processFn");return new e(s.queueName,i,r)}attachEventListeners(e,t,o){let s=j(o);for(let r of s){let i=t[r.methodName];if(typeof i!="function")continue;let u=i.bind(t);e.on(r.event,async(...l)=>{try{await u(...l);}catch(p){this.onError(p,o.name);}});}}};h=N([e(),f$1(a$2,a,d),k("design:type",Function),k("design:paramtypes",[typeof a$2>"u"?Object:a$2,typeof a>"u"?Object:a,typeof BullModuleOptions>"u"?Object:BullModuleOptions])],h);function S(n,e){console.error(`[truxie/bullmq] Worker "${e}" error:`,n);}a$1(S,"defaultErrorHandler");function W(n,e,t,o){var s=arguments.length,r=s<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,t,o);else for(var u=n.length-1;u>=0;u--)(i=n[u])&&(r=(s<3?i(r):s>3?i(e,t,r):i(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r}a$1(W,"_ts_decorate");var b=class n{static{a$1(this,"BullModule");}static forRoot(e){return {module:n,global:true,providers:[{provide:d,useValue:e},f,a,h],exports:[f,a]}}static registerQueue(e){let{name:t,prefix:o,...s}=e,r=w(t);return {module:n,providers:[{provide:r,useFactory:a$1(async(i,u)=>{let{Queue:l}=await import('bullmq'),p=new l(t,{...s,connection:i.connection,prefix:o??i.prefix,defaultJobOptions:{...i.defaultJobOptions??{},...s.defaultJobOptions??{}}});return u.register(t,p),p},"useFactory"),inject:[d,f]}],exports:[r]}}};b=W([m(),l({})],b);export{d as BULL_OPTIONS,b as BullModule,_ as InjectQueue,T as OnWorkerEvent,M as Processor,f as QueueRegistry,y as WorkerHost,a as WorkerRegistry,w as getQueueToken};
|
package/dist/cache.d.ts
CHANGED
package/dist/cache.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-
|
|
1
|
+
import {a as a$1}from'./chunk-F3UTUZEO.js';import {b as b$1,e,f as f$1,m,l}from'./chunk-ASOZYX5T.js';import {a}from'./chunk-EI7MMDWY.js';import'reflect-metadata';var h=new b$1("CACHE_OPTIONS"),p=new b$1("CACHE_MANAGER");var v=class{static{a(this,"MemoryStore");}store=new Map;max;constructor(t=0){this.max=t;}async get(t){let r=this.store.get(t);if(r){if(r.expiresAt>0&&Date.now()>r.expiresAt){this.store.delete(t);return}return r.value}}async set(t,r,o){if(this.max>0&&this.store.size>=this.max&&!this.store.has(t)){let e=this.store.keys().next().value;e!==void 0&&this.store.delete(e);}let n=o&&o>0?Date.now()+o*1e3:0;this.store.set(t,{value:r,expiresAt:n});}async del(t){this.store.delete(t);}async clear(){this.store.clear();}};function P(c,t,r,o){var n=arguments.length,e=n<3?t:o===null?o=Object.getOwnPropertyDescriptor(t,r):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")e=Reflect.decorate(c,t,r,o);else for(var i=c.length-1;i>=0;i--)(a=c[i])&&(e=(n<3?a(e):n>3?a(t,r,e):a(t,r))||e);return n>3&&e&&Object.defineProperty(t,r,e),e}a(P,"_ts_decorate");function T(c,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(c,t)}a(T,"_ts_metadata");var f=class{static{a(this,"CacheManager");}store;defaultTtl;onError;constructor(t){this.store=t.store??new v(t.max),this.defaultTtl=t.ttl??0,this.onError=t.onError??S;}async get(t){try{return await this.store.get(t)}catch(r){this.onError(r,"get",t);return}}async set(t,r,o){try{await this.store.set(t,r,o??this.defaultTtl);}catch(n){this.onError(n,"set",t);}}async del(t){try{await this.store.del(t);}catch(r){this.onError(r,"del",t);}}async clear(){try{await this.store.clear();}catch(t){this.onError(t,"clear","*");}}getStore(){return this.store}};f=P([e(),f$1(h),T("design:type",Function),T("design:paramtypes",[typeof CacheModuleOptions>"u"?Object:CacheModuleOptions])],f);function S(c,t,r){console.error(`[Cache] ${t} failed for key "${r}":`,c);}a(S,"defaultOnError");var b=Symbol("cache:cacheable"),O=Symbol("cache:evict");function H(c){return (t,r,o)=>{let n=t.constructor,e=Reflect.getOwnMetadata(b,n)??[];Reflect.defineMetadata(b,[...e,{methodName:String(r),options:c}],n);}}a(H,"Cacheable");function I(c){return (t,r,o)=>{let n=t.constructor,e=Reflect.getOwnMetadata(O,n)??[];Reflect.defineMetadata(O,[...e,{methodName:String(r),options:c}],n);}}a(I,"CacheEvict");function x(c){return Reflect.getOwnMetadata(b,c)??[]}a(x,"getCacheableMetadata");function w(c){return Reflect.getOwnMetadata(O,c)??[]}a(w,"getCacheEvictMetadata");function R(c,t){return c.replace(/\{(\d+)\}/g,(r,o)=>{let n=parseInt(o,10),e=t[n];return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)})}a(R,"resolveKeyTemplate");function D(c,t,r,o){var n=arguments.length,e=n<3?t:o===null?o=Object.getOwnPropertyDescriptor(t,r):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")e=Reflect.decorate(c,t,r,o);else for(var i=c.length-1;i>=0;i--)(a=c[i])&&(e=(n<3?a(e):n>3?a(t,r,e):a(t,r))||e);return n>3&&e&&Object.defineProperty(t,r,e),e}a(D,"_ts_decorate");function N(c,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(c,t)}a(N,"_ts_metadata");var u=class{static{a(this,"CacheExplorer");}discovery;cache;constructor(t,r){this.discovery=t,this.cache=r;}async onApplicationBootstrap(){let t=this.discovery.getProviders();for(let r of t){let o=this.discovery.getProviderClass(r);if(!o)continue;let n=x(o),e=w(o);if(n.length===0&&e.length===0)continue;let a=typeof r=="function"?r:r.provide,i;try{i=await this.discovery.resolve(a);}catch{continue}for(let l of n)this.wrapCacheable(i,o,l.methodName,l.options.key,l.options.ttl);for(let l of e)this.wrapCacheEvict(i,o,l.methodName,l.options.key);}}wrapCacheable(t,r,o,n,e){let a=t[o];if(typeof a!="function")return;let i=this.cache;t[o]=async function(...l){let m=R(n,l),_=await i.get(m);if(_!==void 0)return _;let y=await a.apply(this,l);return y!=null&&await i.set(m,y,e),y};}wrapCacheEvict(t,r,o,n){let e=t[o];if(typeof e!="function")return;let a=this.cache;t[o]=async function(...i){let l=await e.apply(this,i),m=R(n,i);return await a.del(m),l};}};u=D([e(),f$1(a$1,p),N("design:type",Function),N("design:paramtypes",[typeof a$1>"u"?Object:a$1,typeof f>"u"?Object:f])],u);function G(c,t,r,o){var n=arguments.length,e=n<3?t:o===null?o=Object.getOwnPropertyDescriptor(t,r):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")e=Reflect.decorate(c,t,r,o);else for(var i=c.length-1;i>=0;i--)(a=c[i])&&(e=(n<3?a(e):n>3?a(t,r,e):a(t,r))||e);return n>3&&e&&Object.defineProperty(t,r,e),e}a(G,"_ts_decorate");var d=class c{static{a(this,"CacheModule");}static forRoot(t={}){return {module:c,global:true,providers:[{provide:h,useValue:t},f,{provide:p,useExisting:f},u],exports:[f,p]}}};d=G([m(),l({})],d);export{p as CACHE_MANAGER,h as CACHE_OPTIONS,I as CacheEvict,f as CacheManager,d as CacheModule,H as Cacheable,w as getCacheEvictMetadata,x as getCacheableMetadata};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {i as i$1}from'./chunk-RLQ7JJW6.js';import {d,h as h$1,a as a$1,i,j,k as k$1,b as b$1,n,o,e}from'./chunk-ASOZYX5T.js';import {a}from'./chunk-EI7MMDWY.js';import'reflect-metadata';var H=class s{static{a(this,"Container");}registrations=new Map;resolving=new Set;parent=null;children=[];register(...e){for(let t of e)this.registerOne(t);}registerOne(e){let t=e&&typeof e=="object"&&"forwardRef"in e?d(e):e;if(typeof t=="function"){let a=h$1(t)?.scope??a$1.SINGLETON;this.registrations.set(t,{provider:t,scope:a});return}let n=t.provide,o=a$1.SINGLETON,r=t;if("useClass"in t){let i=t.useClass,a=i&&typeof i=="object"&&"forwardRef"in i?d(i):i,f=h$1(a);o=t.scope??f?.scope??a$1.SINGLETON,r={...t,useClass:a};}else if("useExisting"in t){let i=t.useExisting,a=i&&typeof i=="object"&&"forwardRef"in i?d(i):i;r={...t,useExisting:a};}else "useFactory"in t&&(o=t.scope??a$1.SINGLETON);this.registrations.set(n,{provider:r,scope:o});}async resolve(e){let t=d(e),n=t!==e?t:e,o=this.registrations.get(n)??this.parent?.findRegistration(n);if(!o)throw new Error(`No provider found for ${M(n)}`);if(o.scope===a$1.SINGLETON&&o.instance!==void 0||o.scope===a$1.REQUEST&&this.parent!==null&&o.instance!==void 0)return o.instance;if(this.resolving.has(n))throw new Error(`Circular dependency detected for ${M(n)}`);this.resolving.add(n);try{let r=await this.createInstance(o);return (o.scope===a$1.SINGLETON||o.scope===a$1.REQUEST&&this.parent!==null)&&(o.instance=r),r}finally{this.resolving.delete(n);}}has(e){return this.registrations.has(e)||(this.parent?.has(e)??false)}hasRequestScoped(){for(let[,e]of this.registrations)if(e.scope===a$1.REQUEST)return true;return false}findRegistration(e){return this.registrations.get(e)??this.parent?.findRegistration(e)}createChild(){let e=new s;e.parent=this;for(let[t,n]of this.registrations)n.scope===a$1.REQUEST&&e.registrations.set(t,{provider:n.provider,scope:a$1.REQUEST,instance:void 0});return this.children.push(e),e}async dispose(){for(let e of this.children)await e.dispose();this.children=[];for(let[,e]of this.registrations)if(e.instance&&typeof e.instance=="object"&&e.instance!==null){let t=e.instance;typeof t.onModuleDestroy=="function"&&await t.onModuleDestroy();}this.registrations.clear(),this.resolving.clear();}async createInstance(e){let{provider:t}=e;if(typeof t=="function")return this.instantiateClass(t);if("useValue"in t)return t.useValue;if("useClass"in t)return this.instantiateClass(t.useClass);if("useFactory"in t){let n=t,o=[];if(n.inject)for(let r of n.inject)o.push(await this.resolve(r));return n.useFactory(...o)}if("useExisting"in t)return this.resolve(t.useExisting);throw new Error("Unknown provider type")}async instantiateClass(e){let t=Reflect.getMetadata("design:paramtypes",e)??[],n=i(e),o=j(e),r=k$1(e),i$1=o.size>0?Math.max(...o.keys())+1:0,a=Math.max(t.length,i$1,n.length),f=[];for(let p=0;p<a;p++){let m=o.get(p)??n[p]??t[p],w=r.has(p);try{f.push(await this.resolve(m));}catch{if(w)f.push(void 0);else throw new Error(`Cannot resolve parameter at index ${p} (${M(m)}) of ${e.name}`)}}return new e(...f)}};function M(s){return typeof s=="string"?s:typeof s=="symbol"||s instanceof b$1?s.toString():typeof s=="function"?s.name:String(s)}a(M,"tokenToString");var $=Symbol("controller:path"),b=Symbol("controller:guards"),R=Symbol("route:metadata"),T=Symbol("method:route"),v=Symbol("method:guards"),S=Symbol("method:noguard");function K(s){return e=>{Reflect.defineMetadata($,s,e);}}a(K,"Controller");function y(s){return (e="")=>(t,n,o)=>{let r=o!==void 0,i=String(r?n:n?.name??n),a=r?o?.value:t;if(typeof a=="function"&&(a[T]={method:s,path:e,methodName:i}),r){let f=Reflect.getOwnMetadata(R,t.constructor)??[];return f.push({method:s,path:e,methodName:i}),Reflect.defineMetadata(R,f,t.constructor),o}return t}}a(y,"createMethodDecorator");var ee=y("GET"),te=y("POST"),oe=y("PUT"),ne=y("DELETE"),re=y("PATCH");function se(...s){return (e,t,n)=>{if(t==null){Reflect.defineMetadata(b,s,e);return}if(n!==void 0){if(n?.value){let o=n.value[v]??[];n.value[v]=[...o,...s];}return n}if(typeof e=="function"){let o=e[v]??[];e[v]=[...o,...s];}return typeof e=="function"&&t?.kind==="class"&&Reflect.defineMetadata(b,s,e),e}}a(se,"RouteGuards");function ie(){return (s,e,t)=>t!==void 0?(t?.value&&(t.value[S]=true),t):(typeof s=="function"&&(s[S]=true),s)}a(ie,"NoGuard");function L(s){return Reflect.getOwnMetadata($,s)}a(L,"getControllerPath");function F(s){return Reflect.getOwnMetadata(b,s)??[]}a(F,"getControllerGuards");function ae(s){let e=[],t=s.prototype;if(t){let n=Object.getOwnPropertyNames(t);for(let o of n){if(o==="constructor")continue;let r=Object.getOwnPropertyDescriptor(t,o);if(!r||typeof r.value!="function")continue;let i=r.value;i[T]&&e.push(i[T]);}}return e.length>0?e:Reflect.getOwnMetadata(R,s)??[]}a(ae,"getRouteMetadata");function ce(s,e){let n=s.prototype?.[e],o=typeof n=="function"&&n[S]===true,r=typeof n=="function"&&n[v]||[];return o?r:[...F(s),...r]}a(ce,"getMethodGuards");var U=class{static{a(this,"ModuleRegistry");}resolved=new Map;sortedModules=[];scan(e){this.resolveModule(e),this.sortedModules=this.topologicalSort(),this.validateExports();}registerAll(e){let t=new Set;for(let n of this.sortedModules)if(n.global)for(let o of n.providers)t.add(o);t.size>0&&e.register(...t);for(let n of this.sortedModules){e.register(...n.providers);for(let o of n.metadata.imports??[]){let r=this.getModuleType(o),i=this.resolved.get(r);if(i)for(let a of i.exports){let f=this.findProvider(i,a)??this.findReExportedProvider(i,a);f&&e.register(f);}}}}getAllProviders(){let e=[];for(let t of this.sortedModules)e.push(...t.providers);return e}getAllControllers(){let e=new Set,t=[];for(let n of this.sortedModules){for(let o of n.controllers)e.has(o)||(e.add(o),t.push(o));for(let o of n.metadata.providers??[])typeof o=="function"&&L(o)!==void 0&&!e.has(o)&&(e.add(o),t.push(o));}return t}getAllGateways(){let e=new Set,t=[];for(let n of this.sortedModules)for(let o of n.providers)typeof o=="function"&&i$1(o)!==void 0&&!e.has(o)&&(e.add(o),t.push(o));return t}async callLifecycleHooks(e,t,n){for(let o of this.sortedModules)for(let r of o.providers){let i=typeof r=="function"?r:r.provide;if(e.has(i))try{let a=await e.resolve(i);a&&typeof a=="object"&&typeof a[t]=="function"&&await a[t](n);}catch{}}}resolveModule(e){let t=d(e),n$1=typeof t=="object"&&"module"in t,o$1=n$1?t.module:t;if(this.resolved.has(o$1))return this.resolved.get(o$1);let r=n(o$1)??{},i=n$1?e:{},a=[...r.controllers??[],...i.controllers??[]],f=[...r.providers??[],...i.providers??[]],p=[...r.exports??[],...i.exports??[]],m=f.map(d$1=>d$1&&typeof d$1=="object"&&"forwardRef"in d$1?d(d$1):d$1),w=p.map(d$1=>d$1&&typeof d$1=="object"&&"forwardRef"in d$1?d(d$1):d$1),O={imports:[...r.imports??[],...i.imports??[]],controllers:a,providers:m,exports:w},N={type:o$1,metadata:O,controllers:a,providers:[...a,...m],exports:new Set(w),global:n$1?e.global??o(o$1):o(o$1)};this.resolved.set(o$1,N);for(let d of O.imports??[])this.resolveModule(d);return N}getVisibleTokens(e){let t=new Set;for(let n of e.providers)t.add(this.getProviderToken(n));for(let n of e.metadata.imports??[]){let o=this.getModuleType(n),r=this.resolved.get(o);if(r)for(let i of r.exports)t.add(i);}for(let n of this.sortedModules)if(n.global)for(let o of n.providers)t.add(this.getProviderToken(o));return t}validateExports(){for(let e of this.sortedModules){let t=new Set(e.providers.map(o=>this.getProviderToken(o))),n=this.collectImportedExports(e);for(let o of e.exports)if(!t.has(o)&&!n.has(o)){let r=typeof o=="function"?o.name:String(o);throw new Error(`${e.type.name} exports ${r} but it is not in its providers and is not re-exported from an imported module`)}}}validateVisibility(){for(let e of this.sortedModules){let t=this.getVisibleTokens(e);for(let n of e.providers){if(typeof n!="function")continue;let o=i(n);for(let r of o)if(!t.has(r)){let i=typeof r=="function"?r.name:String(r);throw new Error(`${e.type.name}: ${n.name} depends on ${i}, but it is not provided in this module and not exported by any imported module`)}}}}getProviderToken(e){return typeof e=="function"?e:e.provide}collectImportedExports(e){let t=new Set;for(let n of e.metadata.imports??[]){let o=this.getModuleType(n),r=this.resolved.get(o);if(r)for(let i of r.exports)t.add(i);}return t}findProvider(e,t){return e.providers.find(n=>typeof n=="function"?n===t:n.provide===t)}findReExportedProvider(e,t){for(let n of e.metadata.imports??[]){let o=this.getModuleType(n),r=this.resolved.get(o);if(!r||!r.exports.has(t))continue;let i=this.findProvider(r,t);if(i)return i;let a=this.findReExportedProvider(r,t);if(a)return a}}getModuleType(e){let t=d(e);return typeof t=="object"&&"module"in t?t.module:t}topologicalSort(){let e=new Set,t=new Set,n=[],o=a(r=>{if(e.has(r))return;if(t.has(r))throw new Error(`Circular module dependency detected: ${r.name}`);t.add(r);let i=this.resolved.get(r);if(i){for(let a of i.metadata.imports??[])o(this.getModuleType(a));t.delete(r),e.add(r),n.push(i);}},"visit");for(let[r]of this.resolved)o(r);return n}};function V(s,e,t,n){var o=arguments.length,r=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(s,e,t,n);else for(var a=s.length-1;a>=0;a--)(i=s[a])&&(r=(o<3?i(r):o>3?i(e,t,r):i(e,t))||r);return o>3&&r&&Object.defineProperty(e,t,r),r}a(V,"_ts_decorate");function _(s,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,e)}a(_,"_ts_metadata");var h=class{static{a(this,"EventEmitter2");}handlers=new Map;pending=new Map;onError;constructor(){this.onError=Q;}setOptions(e){e.onError&&(this.onError=e.onError);}subscribe(e,t,n){let o=this.handlers.get(e)??[];o.push({instance:n?.instance??{},methodName:n?.methodName??"anonymous",handler:t}),this.handlers.set(e,o);}registerHandler(e,t,n){let o=t[n].bind(t);this.subscribe(e,o,{instance:t,methodName:n});}async emit(e){let t=this.handlers.get(e.type);if(!t||t.length===0)return;let n=this.executeHandlers(t,e);this.pending.set(n,e.type);try{await n;}finally{this.pending.delete(n);}}emitAsync(e){let t=this.handlers.get(e.type);if(!t||t.length===0)return;let n=this.executeHandlers(t,e).then(()=>{this.pending.delete(n);},()=>{this.pending.delete(n);});this.pending.set(n,e.type);}async waitForAllDone(...e){for(;;){let t=this.getPending(e);if(t.length===0)break;await Promise.allSettled(t);}}getPending(e){if(e.length===0)return [...this.pending.keys()];let t=[];for(let[n,o]of this.pending)e.includes(o)&&t.push(n);return t}hasHandlers(e){let t=this.handlers.get(e);return t!==void 0&&t.length>0}handlerCount(e){return this.handlers.get(e)?.length??0}clear(){this.handlers.clear();}async executeHandlers(e,t){let n=await Promise.allSettled(e.map(o=>o.handler(t)));for(let o=0;o<n.length;o++){let r=n[o];if(r.status==="rejected"){let i=e[o],a=`${i.instance.constructor?.name??"Unknown"}.${i.methodName}`;this.onError(r.reason,t.type,a);}}}};h=V([e(),_("design:type",Function),_("design:paramtypes",[])],h);function Q(s,e,t){console.error(`[EventEmitter2] Handler "${t}" failed for event "${e}":`,s);}a(Q,"defaultErrorHandler");var P=Symbol("on-event");function Me(s){return (e,t,n)=>{let o=Reflect.getOwnMetadata(P,e.constructor)??[];o.push({eventType:s,methodName:String(t)}),Reflect.defineMetadata(P,o,e.constructor);}}a(Me,"OnEvent");function k(s){return Reflect.getOwnMetadata(P,s)??[]}a(k,"getOnEventMetadata");async function Oe(s,e){let t=await s.resolve(h);for(let n of e){let o=z(n);if(!o)continue;let r=k(o);if(r.length===0)continue;let i=typeof n=="function"?n:n.provide,a;try{a=await s.resolve(i);}catch{continue}for(let f of r)typeof a[f.methodName]=="function"&&t.registerHandler(f.eventType,a,f.methodName);}}a(Oe,"scanEventHandlers");function z(s){return typeof s=="function"?h$1(s)?s:null:"useClass"in s?s.useClass:null}a(z,"getProviderClass");export{H as a,K as b,ee as c,te as d,oe as e,ne as f,re as g,se as h,ie as i,L as j,F as k,ae as l,ce as m,U as n,h as o,Me as p,Oe as q};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a}from'./chunk-EI7MMDWY.js';import'reflect-metadata';var u=(function(t){return t.SINGLETON="singleton",t.REQUEST="request",t.TRANSIENT="transient",t})({}),l=class{static{a(this,"InjectionToken");}description;constructor(n){this.description=n;}toString(){return `InjectionToken(${this.description})`}};function w(t){return {forwardRef:t}}a(w,"forwardRef");function c(t){return typeof t=="object"&&"forwardRef"in t?t.forwardRef():t}a(c,"resolveForwardRef");var s=Symbol("injectable"),f=Symbol("inject:param"),d=Symbol("inject:deps"),i=Symbol("optional");function g(t){return n=>{Reflect.defineMetadata(s,{scope:t?.scope??u.SINGLETON},n);}}a(g,"Injectable");function b(...t){return (n,o,r)=>{if(typeof r=="number"){let a=Reflect.getOwnMetadata(f,n)??new Map;a.set(r,t[0]),Reflect.defineMetadata(f,a,n);}else Reflect.defineMetadata(d,t,n);}}a(b,"Inject");function S(){return (t,n,o)=>{let r=Reflect.getOwnMetadata(i,t)??new Set;r.add(o),Reflect.defineMetadata(i,r,t);}}a(S,"Optional");function y(t){return Reflect.getOwnMetadata(s,t)}a(y,"getInjectableMetadata");function I(t){return (Reflect.getOwnMetadata(d,t)??[]).map(o=>c(o))}a(I,"getClassDeps");function N(t){let n=Reflect.getOwnMetadata(f,t)??new Map,o=new Map;for(let[r,a]of n)o.set(r,c(a));return o}a(N,"getInjectTokens");function _(t){return Reflect.getOwnMetadata(i,t)??new Set}a(_,"getOptionalParams");var p=Symbol("module"),M=Symbol("module:global");function G(t){return n=>{Reflect.defineMetadata(p,t,n);}}a(G,"Module");function v(){return t=>{Reflect.defineMetadata(M,true,t);}}a(v,"Global");function C(t){return Reflect.getOwnMetadata(p,t)}a(C,"getModuleMetadata");function P(t){return Reflect.getOwnMetadata(M,t)===true}a(P,"isGlobalModule");export{u as a,l as b,w as c,c as d,g as e,b as f,S as g,y as h,I as i,N as j,_ as k,G as l,v as m,C as n,P as o};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {e}from'./chunk-ASOZYX5T.js';import {a as a$1}from'./chunk-EI7MMDWY.js';function a(r,e,n,o){var s=arguments.length,t=s<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,n):o,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(r,e,n,o);else for(var f=r.length-1;f>=0;f--)(i=r[f])&&(t=(s<3?i(t):s>3?i(e,n,t):i(e,n))||t);return s>3&&t&&Object.defineProperty(e,n,t),t}a$1(a,"_ts_decorate");var l=class{static{a$1(this,"DiscoveryService");}container;providers=[];_init(e,n){this.container=e,this.providers=n;}getProviders(){return this.providers}async resolve(e){return this.container.resolve(e)}getProviderClass(e){return typeof e=="function"?e:"useClass"in e?e.useClass:null}};l=a([e()],l);export{l as a};
|
package/dist/cqrs.d.ts
CHANGED
package/dist/cqrs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-
|
|
1
|
+
import {a as a$1}from'./chunk-F3UTUZEO.js';import {e,f as f$1,m as m$1,l as l$1}from'./chunk-ASOZYX5T.js';import {a}from'./chunk-EI7MMDWY.js';import'reflect-metadata';function A(o,e,t,n){var s=arguments.length,r=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,e,t,n);else for(var i=o.length-1;i>=0;i--)(c=o[i])&&(r=(s<3?c(r):s>3?c(e,t,r):c(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r}a(A,"_ts_decorate");var f=class{static{a(this,"CommandBus");}handlers=new Map;register(e,t){if(this.handlers.has(e))throw new Error(`Duplicate command handler for ${e.name}. Each command must have exactly one handler.`);this.handlers.set(e,t);}async execute(e){let t=e.constructor,n=this.handlers.get(t);if(!n)throw new Error(`No handler registered for command ${t.name}`);return n.execute(e)}};f=A([e()],f);function H(o,e,t,n){var s=arguments.length,r=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,e,t,n);else for(var i=o.length-1;i>=0;i--)(c=o[i])&&(r=(s<3?c(r):s>3?c(e,t,r):c(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r}a(H,"_ts_decorate");var l=class{static{a(this,"QueryBus");}handlers=new Map;register(e,t){if(this.handlers.has(e))throw new Error(`Duplicate query handler for ${e.name}. Each query must have exactly one handler.`);this.handlers.set(e,t);}async execute(e){let t=e.constructor,n=this.handlers.get(t);if(!n)throw new Error(`No handler registered for query ${t.name}`);return n.execute(e)}};l=H([e()],l);function D(o,e,t,n){var s=arguments.length,r=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,e,t,n);else for(var i=o.length-1;i>=0;i--)(c=o[i])&&(r=(s<3?c(r):s>3?c(e,t,r):c(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r}a(D,"_ts_decorate");var u=class{static{a(this,"EventBus");}handlers=new Map;register(e,t){let n=this.handlers.get(e)??[];n.push(t),this.handlers.set(e,n);}async publish(e){let t=e.constructor,n=this.handlers.get(t);if(!n||n.length===0)return;let s=await Promise.allSettled(n.map(r=>r.handle(e)));for(let r of s)r.status==="rejected"&&console.error(`[CQRS EventBus] Handler failed for ${t.name}:`,r.reason);}async publishAll(e){for(let t of e)await this.publish(t);}};u=D([e()],u);var j=Symbol("cqrs:command-handler"),x=Symbol("cqrs:query-handler"),g=Symbol("cqrs:events-handler");function P(o){return e=>{Reflect.defineMetadata(j,o,e);}}a(P,"CommandHandler");function T(o){return e=>{Reflect.defineMetadata(x,o,e);}}a(T,"QueryHandler");function q(...o){return e=>{Reflect.defineMetadata(g,o,e);}}a(q,"EventsHandler");function w(o){return Reflect.getOwnMetadata(j,o)}a(w,"getCommandHandlerMetadata");function O(o){return Reflect.getOwnMetadata(x,o)}a(O,"getQueryHandlerMetadata");function M(o){return Reflect.getOwnMetadata(g,o)}a(M,"getEventsHandlerMetadata");function Q(o,e,t,n){var s=arguments.length,r=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,e,t,n);else for(var i=o.length-1;i>=0;i--)(c=o[i])&&(r=(s<3?c(r):s>3?c(e,t,r):c(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r}a(Q,"_ts_decorate");function B(o,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,e)}a(B,"_ts_metadata");var m=class{static{a(this,"CqrsExplorer");}discovery;commandBus;queryBus;eventBus;constructor(e,t,n,s){this.discovery=e,this.commandBus=t,this.queryBus=n,this.eventBus=s;}async onApplicationBootstrap(){let e=this.discovery.getProviders();for(let t of e){let n=this.discovery.getProviderClass(t);if(!n)continue;let s=w(n),r=O(n),c=M(n);if(!s&&!r&&!c)continue;let i=typeof t=="function"?t:t.provide,h;try{h=await this.discovery.resolve(i);}catch{continue}if(s&&this.commandBus.register(s,h),r&&this.queryBus.register(r,h),c)for(let _ of c)this.eventBus.register(_,h);}}};m=Q([e(),f$1(a$1,f,l,u),B("design:type",Function),B("design:paramtypes",[typeof a$1>"u"?Object:a$1,typeof f>"u"?Object:f,typeof l>"u"?Object:l,typeof u>"u"?Object:u])],m);function C(o,e,t,n){var s=arguments.length,r=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,e,t,n);else for(var i=o.length-1;i>=0;i--)(c=o[i])&&(r=(s<3?c(r):s>3?c(e,t,r):c(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r}a(C,"_ts_decorate");var p=class o{static{a(this,"CqrsModule");}static forRoot(){return {module:o,global:true,providers:[f,l,u,m],exports:[f,l,u]}}};p=C([m$1(),l$1({})],p);var y=class{static{a(this,"AggregateRoot");}uncommittedEvents=[];apply(e){this.uncommittedEvents.push(e);}getUncommittedEvents(){return [...this.uncommittedEvents]}async commit(e){let t=this.uncommittedEvents;this.uncommittedEvents=[],await e.publishAll(t);}clearEvents(){this.uncommittedEvents=[];}};export{y as AggregateRoot,f as CommandBus,P as CommandHandler,p as CqrsModule,u as EventBus,q as EventsHandler,l as QueryBus,T as QueryHandler};
|
package/dist/health.d.ts
CHANGED
package/dist/health.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b,
|
|
1
|
+
import {b,e,f,m,l as l$1}from'./chunk-ASOZYX5T.js';import {a}from'./chunk-EI7MMDWY.js';import {execSync}from'child_process';var l=new b("HEALTH_OPTIONS");function x(a,t,e,r){var s=arguments.length,o=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(a,t,e,r);else for(var c=a.length-1;c>=0;c--)(n=a[c])&&(o=(s<3?n(o):s>3?n(t,e,o):n(t,e))||o);return s>3&&o&&Object.defineProperty(t,e,o),o}a(x,"_ts_decorate");function T(a,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(a,t)}a(T,"_ts_metadata");var y=Date.now(),h=class{static{a(this,"HealthService");}indicators=new Map;constructor(t){for(let e of t.checks??[]){let r=typeof e.check=="function"?new e.check:e.check;this.indicators.set(e.name,r);}}async check(){let t={},e="up",r=[...this.indicators.entries()],s=await Promise.allSettled(r.map(async([o,n])=>{let c=await n.check();return {name:o,result:c}}));for(let o of s)if(o.status==="fulfilled"){let{name:n,result:c}=o.value;t[n]=c,c.status==="down"&&(e="down");}else {let n=s.indexOf(o),c=r[n]?.[0]??"unknown";t[c]={status:"down",details:{error:o.reason instanceof Error?o.reason.message:String(o.reason)}},e="down";}return {status:e,uptime:Math.round((Date.now()-y)/1e3),timestamp:new Date().toISOString(),checks:t}}addIndicator(t,e){this.indicators.set(t,e);}removeIndicator(t){this.indicators.delete(t);}};h=x([e(),f(l),T("design:type",Function),T("design:paramtypes",[typeof HealthModuleOptions>"u"?Object:HealthModuleOptions])],h);function H(a,t,e,r){var s=arguments.length,o=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(a,t,e,r);else for(var c=a.length-1;c>=0;c--)(n=a[c])&&(o=(s<3?n(o):s>3?n(t,e,o):n(t,e))||o);return s>3&&o&&Object.defineProperty(t,e,o),o}a(H,"_ts_decorate");var u=class a$1{static{a(this,"HealthModule");}static forRoot(t={}){return {module:a$1,global:true,providers:[{provide:l,useValue:t},h],exports:[h]}}};u=H([m(),l$1({})],u);var d=class{static{a(this,"MemoryHealthIndicator");}threshold;constructor(t=.9){this.threshold=t;}async check(){let t=process.memoryUsage(),e=t.heapUsed,r=t.heapTotal,s=r>0?e/r:0;return {status:s<this.threshold?"up":"down",details:{heapUsedMB:Math.round(e/1024/1024),heapTotalMB:Math.round(r/1024/1024),rssMB:Math.round(t.rss/1024/1024),usagePercent:Math.round(s*100),threshold:Math.round(this.threshold*100)}}}};var p=class{static{a(this,"DiskHealthIndicator");}threshold;path;constructor(t=.9,e="/"){this.threshold=t,this.path=e;}async check(){try{let e=execSync(`df -P "${this.path}" | tail -1`,{encoding:"utf8",timeout:5e3}).trim().split(/\s+/),r=parseInt(e[1]??"0",10),s=parseInt(e[2]??"0",10),o=r>0?s/r:0;return {status:o<this.threshold?"up":"down",details:{totalGB:Math.round(r/1024/1024*10)/10,usedGB:Math.round(s/1024/1024*10)/10,usagePercent:Math.round(o*100),threshold:Math.round(this.threshold*100),path:this.path}}}catch{return {status:"down",details:{error:"Failed to check disk usage",path:this.path}}}}};export{p as DiskHealthIndicator,l as HEALTH_OPTIONS,u as HealthModule,h as HealthService,d as MemoryHealthIndicator};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,30 +1,13 @@
|
|
|
1
|
-
import { C as Container } from './container-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { C as Container } from './container-4Q8Oq_GB.js';
|
|
2
|
+
export { I as Inject, a as Injectable, O as OnApplicationBootstrap, b as OnApplicationShutdown, c as OnModuleDestroy, d as OnModuleInit, e as Optional } from './interfaces-0QqKD1vX.js';
|
|
3
|
+
import { T as Type, F as ForwardRef, M as ModuleMetadata, D as DynamicModule, P as Provider, a as Token, b as ModuleAsyncOptions, I as InjectionToken } from './types-CoyG1lE2.js';
|
|
4
|
+
export { C as ClassProvider, E as ExistingProvider, c as FactoryProvider, d as InjectableOptions, e as ModuleOptionsFactory, S as Scope, V as ValueProvider } from './types-CoyG1lE2.js';
|
|
5
|
+
import { E as ExecutionContext, I as ICanActivateGuard } from './interfaces-ivJCgMba.js';
|
|
6
|
+
export { B as BaseExecutionContext, F as FormDataPart } from './interfaces-ivJCgMba.js';
|
|
6
7
|
import { E as EventBusOptions, a as EventEmitter2 } from './event-bus-BKPUV8M9.js';
|
|
7
8
|
export { D as DomainEvent, b as EventHandler } from './event-bus-BKPUV8M9.js';
|
|
8
9
|
import { W as WsPeer, a as WsMessage } from './types-G2NQp5Jb.js';
|
|
9
10
|
|
|
10
|
-
declare function Injectable(options?: InjectableOptions): ClassDecorator;
|
|
11
|
-
/**
|
|
12
|
-
* Dual-mode decorator for declaring constructor dependencies.
|
|
13
|
-
*
|
|
14
|
-
* Class decorator — spread the full dependency list in constructor order.
|
|
15
|
-
* Use when esbuild/swc strips design:paramtypes (i.e. always in this project).
|
|
16
|
-
*
|
|
17
|
-
* @Injectable()
|
|
18
|
-
* @Inject(AuthService, UserService)
|
|
19
|
-
* class MyController { ... }
|
|
20
|
-
*
|
|
21
|
-
* Parameter decorator — bind a specific token to one constructor parameter.
|
|
22
|
-
*
|
|
23
|
-
* constructor(@Inject(MY_TOKEN) private svc: MyService) {}
|
|
24
|
-
*/
|
|
25
|
-
declare function Inject(...deps: Token[]): any;
|
|
26
|
-
declare function Optional(): ParameterDecorator;
|
|
27
|
-
|
|
28
11
|
declare function forwardRef<T>(fn: () => Type<T>): ForwardRef<T>;
|
|
29
12
|
declare function resolveForwardRef<T>(ref: Type<T> | ForwardRef<T>): Type<T>;
|
|
30
13
|
|
|
@@ -416,19 +399,6 @@ declare function DefaultValuePipe(defaultValue: unknown): ParamPipe;
|
|
|
416
399
|
declare function UseFilters(...filters: FilterRef[]): ClassDecorator & MethodDecorator;
|
|
417
400
|
declare function Catch(...exceptions: Type<Error>[]): ClassDecorator;
|
|
418
401
|
|
|
419
|
-
interface OnModuleInit {
|
|
420
|
-
onModuleInit(): void | Promise<void>;
|
|
421
|
-
}
|
|
422
|
-
interface OnModuleDestroy {
|
|
423
|
-
onModuleDestroy(): void | Promise<void>;
|
|
424
|
-
}
|
|
425
|
-
interface OnApplicationBootstrap {
|
|
426
|
-
onApplicationBootstrap(): void | Promise<void>;
|
|
427
|
-
}
|
|
428
|
-
interface OnApplicationShutdown {
|
|
429
|
-
onApplicationShutdown(signal?: string): void | Promise<void>;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
402
|
/**
|
|
433
403
|
* Standard interface for UseCase classes.
|
|
434
404
|
*
|
|
@@ -872,4 +842,4 @@ declare class TruxieFactory {
|
|
|
872
842
|
static create(rootModule: Type | DynamicModule, options?: ApplicationOptions): Promise<TruxieApplication>;
|
|
873
843
|
}
|
|
874
844
|
|
|
875
|
-
export { AppError, type ApplicationOptions, Auth, type AuthExtractorFn, Body, Catch, type CompiledRoute, ConfigurableModuleBuilder, type ConfigurableModuleBuilderResult, type ConfigurableModuleClass, ConflictError, Container, Controller, ControllerRouter, Cookie, type CreatePipelineOptions, DefaultValuePipe, Delete, DiscoveryService, DynamicModule, EventBusOptions, EventEmitter2, type ExceptionFilter, ExecutionContext, type ExtraOptions, type FeatureConfig, type FilterRef, ForbiddenError, FormData, ForwardRef, Get, Global, type GuardClass, type GuardInstance, type GuardRef, type HandlerFn, Headers, type HttpDispatchResult, type HttpMethod, ICanActivateGuard, type IUseCase,
|
|
845
|
+
export { AppError, type ApplicationOptions, Auth, type AuthExtractorFn, Body, Catch, type CompiledRoute, ConfigurableModuleBuilder, type ConfigurableModuleBuilderResult, type ConfigurableModuleClass, ConflictError, Container, Controller, ControllerRouter, Cookie, type CreatePipelineOptions, DefaultValuePipe, Delete, DiscoveryService, DynamicModule, EventBusOptions, EventEmitter2, type ExceptionFilter, ExecutionContext, type ExtraOptions, type FeatureConfig, type FilterRef, ForbiddenError, FormData, ForwardRef, Get, Global, type GuardClass, type GuardInstance, type GuardRef, type HandlerFn, Headers, type HttpDispatchResult, type HttpMethod, ICanActivateGuard, type IUseCase, type Interceptor, type InterceptorRef, Ip, type Middleware, type MiddlewareRef, Module, ModuleAsyncOptions, ModuleMetadata, ModuleRegistry, NoGuard, NotFoundError, OnEvent, Param, type ParamPipe, type ParamPipeRef, ParseIdPipe, ParseIntPipe, Patch, type PipeRef, type PipeTransform, type PipelineOptions, Post, Provider, Put, Query, REDIRECT_BRAND, RawBody, type RedirectResult, RequestAbortedError, RouteGuards, type RouteMatch, type RouteMetadata, type RouteParamMetadata, type RouteParamType, Token, TruxieApplication, TruxieFactory, Type, UOW_INSTANCE_KEY, UOW_SESSION_KEY, UnauthorizedError, type UnitOfWork, type UnitOfWorkFactory, UnitOfWorkInterceptor, UseFilters, UseInterceptors, UseMiddleware, UsePipes, UserAgent, ValidationError, type WsHooks, type WsHooksAdapters, createParamDecorator, createPipeline, defineAuth, forwardRef, getControllerGuards, getControllerPath, getEffectiveInterceptors, getEffectiveMiddlewares, getInterceptorsMetadata, getMethodGuards, getMethodInterceptors, getMethodMiddlewares, getMiddlewaresMetadata, getModuleMetadata, getRouteMetadata, getRouteParams, isGlobalModule, isRedirect, isServerless, redirect, resolveForwardRef, resolveParamArgs };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {l,
|
|
1
|
+
import {j as j$1,l,m as m$1,a as a$1,n,o,q as q$1}from'./chunk-4IAZ6T72.js';export{a as Container,b as Controller,f as Delete,o as EventEmitter2,c as Get,n as ModuleRegistry,i as NoGuard,p as OnEvent,g as Patch,d as Post,e as Put,h as RouteGuards,k as getControllerGuards,j as getControllerPath,m as getMethodGuards,l as getRouteMetadata}from'./chunk-4IAZ6T72.js';import {n as n$1,i,j as j$2,k as k$1,m as m$2}from'./chunk-RLQ7JJW6.js';import {a as a$2}from'./chunk-F3UTUZEO.js';export{a as DiscoveryService}from'./chunk-F3UTUZEO.js';import {c,e,g as g$1}from'./chunk-PT5RXFB5.js';export{a as AppError,f as ConflictError,e as ForbiddenError,b as NotFoundError,g as RequestAbortedError,d as UnauthorizedError,c as ValidationError}from'./chunk-PT5RXFB5.js';import {b}from'./chunk-ASOZYX5T.js';export{m as Global,f as Inject,e as Injectable,l as Module,g as Optional,a as Scope,c as forwardRef,n as getModuleMetadata,o as isGlobalModule,d as resolveForwardRef}from'./chunk-ASOZYX5T.js';import {a}from'./chunk-EI7MMDWY.js';import'reflect-metadata';function ct(o,e){if("useFactory"in e&&e.useFactory){let t=e.useFactory;return [{provide:o,useFactory:t,inject:e.inject??[]}]}if("useClass"in e&&e.useClass){let t=e.useClass;return [{provide:o,useFactory:a(async r=>r.createModuleOptions(),"useFactory"),inject:[t]},t]}if("useExisting"in e&&e.useExisting){let t=e.useExisting;return [{provide:o,useFactory:a(async r=>r.createModuleOptions(),"useFactory"),inject:[t]}]}throw new Error("ModuleAsyncOptions must specify one of: useFactory, useClass, or useExisting")}a(ct,"createAsyncProviders");var F=class{static{a(this,"ConfigurableModuleBuilder");}description;featureDescription;onForRoot;onForFeature;constructor(e="MODULE_OPTIONS"){this.description=e,this.featureDescription=e+"_FEATURE";}setTokenDescription(e){return this.description=e,this}transformDynamicModule(e){return this.onForRoot=e,this}transformFeatureModule(e){return this.onForFeature=e,this}build(){let e=new b(this.description),t=new b(this.featureDescription),r=this.onForRoot,s=this.onForFeature;return {ConfigurableModuleClass:class{static{a(this,"ConfigurableModuleClassImpl");}static forRoot(u,d={}){let c={module:this,global:d.global??false,providers:[{provide:e,useValue:u}],exports:[e]};return r&&(c=r(c,u)),c}static forRootAsync(u){let d=ct(e,u);return {module:this,imports:u.imports??[],providers:d,exports:[e]}}static forFeature(u,d={}){let c={module:this,global:d.global??false,providers:[{provide:t,useValue:u}],exports:[t]};return s&&(c=s(c,u)),c}},MODULE_OPTIONS_TOKEN:e,MODULE_FEATURE_TOKEN:t}}};var _=class{static{a(this,"BaseExecutionContext");}nativeRequest;handler;container;query;params;body;rawBody;formData;auth;data=new Map;metadata=new Map;abortController;constructor(e,t,r,s={},a={},i){this.nativeRequest=e,this.handler=t,this.container=r,this.query=s,this.params=a,this.abortController=i??new AbortController;}getNativeRequest(){return this.nativeRequest}getHandler(){return this.handler}getBody(){return this.body}setBody(e){this.body=e;}getRawBody(){return this.rawBody}setRawBody(e){this.rawBody=e;}getFormData(){return this.formData}setFormData(e){this.formData=e;}getQuery(){return this.query}getParams(){return this.params}getAuth(){return this.auth}setAuth(e){this.auth=e;}getMetadata(e){return this.metadata.get(e)}setMetadata(e,t){this.metadata.set(e,t);}getData(e){return this.data.get(e)}setData(e,t){this.data.set(e,t);}getContainer(){return this.container}getSignal(){return this.abortController.signal}abort(e){this.abortController.abort(e);}};var $e=Symbol("filters"),Oe=Symbol("catch");function Be(...o){return (e,t,r)=>{let s=t?e.constructor:e,a=Reflect.getOwnMetadata($e,s)??[];Reflect.defineMetadata($e,[...a,...o],s);}}a(Be,"UseFilters");function ze(...o){return e=>{Reflect.defineMetadata(Oe,o,e);}}a(ze,"Catch");function K(o){return Reflect.getOwnMetadata(Oe,o)??[]}a(K,"getCatchMetadata");function T(o,e$1,t){return async r=>{let s=[...e$1.middlewares??[],...t.middlewares??[]],a$1=[...e$1.guards??[],...t.guards??[]],i=[...e$1.interceptors??[],...t.interceptors??[]],u=[...e$1.pipes??[],...t.pipes??[]],d=[...e$1.filters??[],...t.filters??[]],c=await A(o,d);try{g(r);let l=await A(o,s);return await ut(r,l,async()=>{g(r);let f=await A(o,a$1);for(let M of f)if(g(r),!await M.canActivate(r))throw new e("Access denied by guard");g(r);let h=await A(o,u);for(let M of h)g(r),await M.transform(r);g(r);let p=await A(o,i),ae=a(async()=>(g(r),t.handler(r)),"handlerCall");return p.length===0?ae():p.reduceRight((M,ie)=>async()=>(g(r),ie.intercept(r,M)),ae)()})}catch(l){return lt(l,r,c)}}}a(T,"createPipeline");async function ut(o,e,t){return e.length===0?t():e.reduceRight((s,a)=>()=>a.use(o,s),t)()}a(ut,"runMiddlewareChain");function g(o){if(o.getSignal().aborted)throw new g$1}a(g,"checkAborted");async function lt(o,e,t){for(let r of t){let s=K(r.constructor);if(s.length===0||o instanceof Error&&s.some(i=>o instanceof i))return r.catch(o,e)}throw o}a(lt,"handleError");async function A(o,e){let t=[];for(let r of e)typeof r=="function"?t.push(await o.resolve(r)):t.push(r);return t}a(A,"resolveRefs");var Y=Symbol("interceptors"),Q=Symbol("method:interceptors");function We(...o){return (e,t,r)=>{if(t!==void 0){let a=r?.value??e,i=a[Q]??[];return a[Q]=[...i,...o],r}let s=Reflect.getOwnMetadata(Y,e)??[];Reflect.defineMetadata(Y,[...s,...o],e);}}a(We,"UseInterceptors");function J(o){return Reflect.getOwnMetadata(Y,o)??[]}a(J,"getInterceptorsMetadata");function Z(o,e){let r=o.prototype?.[e];return typeof r=="function"&&r[Q]||[]}a(Z,"getMethodInterceptors");function k(o,e){return [...J(o),...Z(o,e)]}a(k,"getEffectiveInterceptors");var X="uow:session",ee="uow:instance",U=class{static{a(this,"UnitOfWorkInterceptor");}factory;constructor(e){this.factory=e;}async intercept(e,t){let r=this.factory();await r.start(),e.setData(X,r.getContext()),e.setData(ee,r);try{let s=await t();return await r.commit(),s}catch(s){throw await r.rollback(),s}}};var te=Symbol("middlewares"),re=Symbol("method:middlewares");function qe(...o){return (e,t,r)=>{if(t!==void 0){let a=r?.value??e,i=a[re]??[];return a[re]=[...i,...o],r}let s=Reflect.getOwnMetadata(te,e)??[];Reflect.defineMetadata(te,[...s,...o],e);}}a(qe,"UseMiddleware");function oe(o){return Reflect.getOwnMetadata(te,o)??[]}a(oe,"getMiddlewaresMetadata");function ne(o,e){let r=o.prototype?.[e];return typeof r=="function"&&r[re]||[]}a(ne,"getMethodMiddlewares");function G(o,e){return [...oe(o),...ne(o,e)]}a(G,"getEffectiveMiddlewares");var He=Symbol("pipes");function je(...o){return (e,t,r)=>{let s=t?e.constructor:e,a=Reflect.getOwnMetadata(He,s)??[];Reflect.defineMetadata(He,[...a,...o],s);}}a(je,"UsePipes");var dt=/^[0-9a-fA-F]{24}$/,$=class{static{a(this,"ParseIdPipe");}paramName;constructor(e="id"){this.paramName=e;}transform(e){let r=e.getParams()[this.paramName];if(!r||!dt.test(r))throw new c(`Invalid ${this.paramName}: must be a valid ObjectId`)}};var O=class{static{a(this,"ParseIntPipe");}transform(e){let t=Number(e);if(!Number.isInteger(t)||e===""||e===null||e===void 0)throw new c(`Expected an integer, received: ${JSON.stringify(e)}`);return t}};function Le(o){return {transform(e){return e??o}}}a(Le,"DefaultValuePipe");var B=class{static{a(this,"DomainEvent");}payload;timestamp;constructor(e){this.payload=e,this.timestamp=Date.now();}};var w=class{static{a(this,"ControllerRouter");}routes=[];globalPrefix;constructor(e=""){this.globalPrefix=e;}register(...e){for(let t of e){let r=j$1(t)??"",s=l(t);for(let a of s){let i=ft(`${this.globalPrefix}/${r}/${a.path}`);mt(i,t.name,a.methodName),this.checkDuplicate(i,a.method,t.name,a.methodName);let{pattern:u,paramNames:d}=pt(i),c=m$1(t,a.methodName),l=k(t,a.methodName),f=G(t,a.methodName);this.routes.push({method:a.method,pattern:u,paramNames:d,controllerClass:t,methodName:a.methodName,guardClasses:c,interceptorRefs:l,middlewareRefs:f,rawPath:i});}}this.routes.sort((t,r)=>Ve(t.rawPath)-Ve(r.rawPath));}checkDuplicate(e,t,r,s){let a=this.routes.find(i=>i.method===t&&i.rawPath===e);if(a)throw new Error(`Duplicate route: ${t} ${e}
|
|
2
2
|
Already registered by: ${a.controllerClass.name}.${a.methodName}
|
|
3
|
-
Conflicting with: ${t}.${s}`)}match(e,r){let t=e.toUpperCase();for(let s of this.routes){if(s.method!==t)continue;let a=s.pattern.exec(r);if(!a)continue;let i={};for(let u=0;u<s.paramNames.length;u++)i[s.paramNames[u]]=a[u+1]??"";return {route:s,params:i}}return null}getRoutes(){return this.routes}};function dt(o){return "/"+o.replace(/\/+/g,"/").replace(/^\/|\/$/g,"")}a(dt,"normalizePath");function ft(o){let e=[],r=o.split("/").map(t=>t.startsWith(":")?(e.push(t.slice(1)),"([^/]+)"):pt(t)).join("/");return {pattern:new RegExp(`^${r}$`),paramNames:e}}a(ft,"compilePath");function pt(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(pt,"escapeRegex");function je(o){return o.split("/").filter(Boolean).reduce((e,r)=>e+(r.startsWith(":")?1:0),0)}a(je,"routePriority");function ht(o,e,r){let t=`Invalid path "${o}" on ${e}.${r}:`;if(!o.startsWith("/"))throw new Error(`${t} must start with /`);let s=o.split("/").filter((i,u)=>u>0),a=new Set;for(let i of s){if(i==="")throw new Error(`${t} contains empty segment (double slash)`);if(i.startsWith(":")){let u=i.slice(1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u))throw new Error(`${t} invalid param name ":${u}" \u2014 must be a valid identifier`);if(a.has(u))throw new Error(`${t} duplicate param name ":${u}"`);a.add(u);}}}a(ht,"validatePath");var w=Symbol("route:params");function mt(o){return o==null?false:typeof o=="function"||typeof o=="object"&&typeof o.transform=="function"}a(mt,"isParamPipeRef");function z(o,e){return mt(o)?{key:void 0,pipes:[o,...e??[]]}:{key:o,pipes:e??[]}}a(z,"resolveArgs");function m(o,e,r=[]){return (t,s,a)=>{if(s===void 0)return;let i=t[s];if(typeof i!="function")return;let u=i[w]??[];i[w]=[...u,{index:a,type:o,key:e,pipes:r.length>0?r:void 0}];}}a(m,"buildBuiltinDecorator");function gt(o){return typeof o=="function"?new o:o}a(gt,"resolveParamPipe");function Ve(o,...e){let{key:r,pipes:t}=z(o,e);return m("query",r,t)}a(Ve,"Query");function Ke(o,...e){let{key:r,pipes:t}=z(o,e);return m("param",r,t)}a(Ke,"Param");function Ye(o,...e){let{key:r,pipes:t}=z(o,e);return m("body",r,t)}a(Ye,"Body");var Qe=a(()=>m("rawBody"),"RawBody"),Je=a(()=>m("formData"),"FormData"),Ze=a(()=>m("ip"),"Ip"),Xe=a(()=>m("userAgent"),"UserAgent"),et=a(o=>m("cookie",o),"Cookie");function tt(o,...e){let{key:r,pipes:t}=z(o,e);return m("headers",r,t)}a(tt,"Headers");function ne(o){return ()=>(e,r,t)=>{if(r===void 0)return;let s=e[r];if(typeof s!="function")return;let a=s[w]??[];s[w]=[...a,{index:t,type:"auth",extractor:o}];}}a(ne,"defineAuth");var rt=ne();function ot(o){return ()=>(e,r,t)=>{if(r===void 0)return;let s=e[r];if(typeof s!="function")return;let a=s[w]??[];s[w]=[...a,{index:t,type:"custom",extractor:o}];}}a(ot,"createParamDecorator");function q(o,e){let r=o.prototype[e];if(typeof r!="function")return null;let t=r[w];return t&&t.length>0?t:null}a(q,"getRouteParams");async function W(o,e){let r=Math.max(...o.map(s=>s.index)),t=new Array(r+1).fill(void 0);for(let{index:s,type:a,key:i,pipes:u,extractor:d}of o){let c;switch(a){case "query":{let l=e.getQuery();c=i!==void 0?l[i]:l;break}case "param":{let l=e.getParams();c=i!==void 0?l[i]:l;break}case "body":{let l=e.getBody()??{};c=i!==void 0?l[i]:l;break}case "rawBody":{c=e.getRawBody();break}case "formData":{c=e.getFormData();break}case "headers":{let l=e.getNativeRequest(),f=l?.node?.req?.headers??l?.headers??{};c=i!==void 0?f[i.toLowerCase()]:f;break}case "cookie":{let l=e.getNativeRequest(),f=l?.node?.req?.headers?.cookie??l?.headers?.cookie??"";if(i&&f){let h=f.split(";").map(p=>p.trim()).find(p=>p.startsWith(i+"="));c=h?decodeURIComponent(h.slice(i.length+1)):void 0;}else c=void 0;break}case "ip":{let l=e.getNativeRequest(),f=l?.node?.req?.headers??{},h=f["cf-connecting-ip"];if(h){c=h.trim();break}let p=f["x-forwarded-for"];if(p){c=(String(p).split(",")[0]??"").trim();break}c=l?.node?.req?.socket?.remoteAddress??"";break}case "userAgent":{c=(e.getNativeRequest()?.node?.req?.headers??{})["user-agent"]??"";break}case "auth":{c=d?await d(e):e.getAuth();break}case "custom":{c=d?await d(e):void 0;break}}if(u&&u.length>0)for(let l of u)c=gt(l).transform(c);t[s]=c;}return t}a(W,"resolveParamArgs");var nt="__redirect";function st(o,e=302){return {__redirect:true,url:o,statusCode:e}}a(st,"redirect");function H(o){return o!==null&&typeof o=="object"&&o.__redirect===true}a(H,"isRedirect");function at(){return !!(process.env.VERCEL||process.env.AWS_LAMBDA_FUNCTION_NAME||process.env.LAMBDA_TASK_ROOT||process.env.FUNCTIONS_WORKER_RUNTIME||process.env.K_SERVICE||process.env.NETLIFY)}a(at,"isServerless");var A=class{static{a(this,"TruxieApplication");}container;registry;initialized=false;rootModule;options;eventEmitter;prefix="";router;filters=[];gateways=new Map;wsInitialized=false;constructor(e,r={}){this.rootModule=e,this.options=r,this.container=new c$1,this.registry=new p;}async init(){if(this.initialized)return;this.eventEmitter=new q$1,this.options.eventBus&&this.eventEmitter.setOptions(this.options.eventBus),this.container.register({provide:q$1,useValue:this.eventEmitter});let e=new a$1;this.container.register({provide:a$1,useValue:e}),this.registry.scan(this.rootModule),this.registry.registerAll(this.container);let r=this.registry.getAllProviders();e._init(this.container,r),await this.registry.callLifecycleHooks(this.container,"onModuleInit"),await s(this.container,r),await this.registry.callLifecycleHooks(this.container,"onApplicationBootstrap"),this.router=new E(this.prefix),this.router.register(...this.registry.getAllControllers()),this.filters=this.options.globalFilters??[],this.initialized=true;}setGlobalPrefix(e){return this.prefix=e,this}getGlobalPrefix(){return this.prefix}async resolve(e){return this.ensureInitialized(),this.container.resolve(e)}has(e){return this.container.has(e)}getContainer(){return this.container}matchRoute(e,r){return this.ensureInitialized(),this.router.match(e,r)??null}async handleRequest(e$1,r){this.ensureInitialized();let{container:t,dispose:s}=this.createRequestContext();try{let a=await t.resolve(e$1.controllerClass),i=a[e$1.methodName].bind(a),u=q(e$1.controllerClass,e$1.methodName);try{for(let c of e$1.guardClasses)if(!await(t.has(c)?await t.resolve(c):new c).canActivate(r))throw new e("Access denied by guard");let d=u?await i(...await W(u,r)):await i(r);if(H(d)){let c=d;return {value:d,isRedirect:!0,redirectUrl:c.url,redirectStatus:c.statusCode}}return {value:d,isRedirect:!1}}catch(d){for(let c of this.filters)try{return {value:await c.catch(d,r),isRedirect:!1}}catch{continue}throw d}}finally{await s();}}hasGateways(){return this.ensureInitialized(),this.registry.getAllGateways().length>0}async createWebSocketHooks(e){this.ensureInitialized(),await this.initGateways();let r=this;return {async open(t){let a="/"+(e.getUrl(t).split("?")[0]??"/").replace(/^\/+|\/+$/g,""),i=r.matchGatewayPath(a);if(!i)return;let u=t.context;u&&(u._gatewayPath=i);let d=r.gateways.get(i),c=e.adaptPeer(t);for(let l of d.serverProps)d.instance[l]={peers:e.getPeers(t)??new Set};if(d.hasConnection)try{await d.instance.handleConnection(c);}catch(l){console.error(`[WS] ${d.className}.handleConnection error:`,l);}},async message(t,s){let i=t.context?._gatewayPath;if(!i)return;let u=r.gateways.get(i);if(!u)return;let d=e.adaptPeer(t),c=e.adaptMessage(s),l;try{l=c.json();}catch{return}if(!l.event||typeof l.event!="string")return;let f=u.messageHandlers.get(l.event);if(f)try{let h=n$1(f.paramMeta,d,c,l.data),p=await f.method(...h);p!=null&&d.send(p);}catch(h){console.error(`[WS] ${u.className}.${l.event} error:`,h);}},async close(t,s){let i=t.context?._gatewayPath;if(!i)return;let u=r.gateways.get(i);if(!u?.hasDisconnect)return;let d=e.adaptPeer(t);try{await u.instance.handleDisconnect(d,s);}catch(c){console.error(`[WS] ${u.className}.handleDisconnect error:`,c);}},async error(t,s){let a=t?.id??"unknown";console.error(`[WS] Peer ${String(a)} error:`,s);}}}getControllers(){return this.ensureInitialized(),this.registry.getAllControllers()}getGateways(){return this.ensureInitialized(),this.registry.getAllGateways()}getProviders(){return this.ensureInitialized(),this.registry.getAllProviders()}getEventEmitter(){return this.ensureInitialized(),this.eventEmitter}getRouter(){return this.ensureInitialized(),this.router}createHandler(e){return this.ensureInitialized(),T(this.container,this.getGlobalOptions(),e)}async shutdown(){this.initialized&&(await this.registry.callLifecycleHooks(this.container,"onModuleDestroy"),await this.registry.callLifecycleHooks(this.container,"onApplicationShutdown"),this.eventEmitter.clear(),await this.container.dispose(),this.initialized=false);}createRequestContext(){if(!this.container.hasRequestScoped())return {container:this.container,dispose:a(async()=>{},"dispose")};let e=this.container.createChild();return {container:e,dispose:a(()=>e.dispose(),"dispose")}}matchGatewayPath(e){if(this.gateways.has(e))return e;for(let r of this.gateways.keys())if(e.endsWith(r))return r;if(this.gateways.has("/"))return "/"}async initGateways(){if(!this.wsInitialized){for(let e of this.registry.getAllGateways()){let r=i(e);if(!r)continue;let t=await this.container.resolve(e),s=new Map;for(let a of j(e)){let i=t[a.methodName];typeof i=="function"&&s.set(a.event,{method:i.bind(t),paramMeta:k$1(e.prototype[a.methodName])});}if(this.gateways.set(r.path,{instance:t,className:e.name,messageHandlers:s,hasConnection:typeof t.handleConnection=="function",hasDisconnect:typeof t.handleDisconnect=="function",serverProps:m$1(e)}),typeof t.afterInit=="function")try{await t.afterInit();}catch{}}this.wsInitialized=true;}}getGlobalOptions(){return {guards:this.options.globalGuards,interceptors:this.options.globalInterceptors,pipes:this.options.globalPipes,filters:this.options.globalFilters}}ensureInitialized(){if(!this.initialized)throw new Error("TruxieApplication not initialized. Call TruxieFactory.create() or app.init().")}},L=class{static{a(this,"TruxieFactory");}static async create(e,r){let t=new A(e,r);return await t.init(),t}};export{rt as Auth,_ as BaseExecutionContext,Ye as Body,Oe as Catch,F as ConfigurableModuleBuilder,E as ControllerRouter,et as Cookie,Le as DefaultValuePipe,O as DomainEvent,Je as FormData,tt as Headers,Ze as Ip,Ke as Param,$ as ParseIdPipe,B as ParseIntPipe,Ve as Query,nt as REDIRECT_BRAND,Qe as RawBody,A as TruxieApplication,L as TruxieFactory,X as UOW_INSTANCE_KEY,Z as UOW_SESSION_KEY,U as UnitOfWorkInterceptor,Be as UseFilters,ze as UseInterceptors,qe as UseMiddleware,He as UsePipes,Xe as UserAgent,ot as createParamDecorator,T as createPipeline,ne as defineAuth,k as getEffectiveInterceptors,G as getEffectiveMiddlewares,Q as getInterceptorsMetadata,J as getMethodInterceptors,oe as getMethodMiddlewares,re as getMiddlewaresMetadata,q as getRouteParams,H as isRedirect,at as isServerless,st as redirect,W as resolveParamArgs};
|
|
3
|
+
Conflicting with: ${r}.${s}`)}match(e,t){let r=e.toUpperCase();for(let s of this.routes){if(s.method!==r)continue;let a=s.pattern.exec(t);if(!a)continue;let i={};for(let u=0;u<s.paramNames.length;u++)i[s.paramNames[u]]=a[u+1]??"";return {route:s,params:i}}return null}getRoutes(){return this.routes}};function ft(o){return "/"+o.replace(/\/+/g,"/").replace(/^\/|\/$/g,"")}a(ft,"normalizePath");function pt(o){let e=[],t=o.split("/").map(r=>r.startsWith(":")?(e.push(r.slice(1)),"([^/]+)"):ht(r)).join("/");return {pattern:new RegExp(`^${t}$`),paramNames:e}}a(pt,"compilePath");function ht(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(ht,"escapeRegex");function Ve(o){return o.split("/").filter(Boolean).reduce((e,t)=>e+(t.startsWith(":")?1:0),0)}a(Ve,"routePriority");function mt(o,e,t){let r=`Invalid path "${o}" on ${e}.${t}:`;if(!o.startsWith("/"))throw new Error(`${r} must start with /`);let s=o.split("/").filter((i,u)=>u>0),a=new Set;for(let i of s){if(i==="")throw new Error(`${r} contains empty segment (double slash)`);if(i.startsWith(":")){let u=i.slice(1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u))throw new Error(`${r} invalid param name ":${u}" \u2014 must be a valid identifier`);if(a.has(u))throw new Error(`${r} duplicate param name ":${u}"`);a.add(u);}}}a(mt,"validatePath");var y=Symbol("route:params");function gt(o){return o==null?false:typeof o=="function"||typeof o=="object"&&typeof o.transform=="function"}a(gt,"isParamPipeRef");function W(o,e){return gt(o)?{key:void 0,pipes:[o,...e??[]]}:{key:o,pipes:e??[]}}a(W,"resolveArgs");function m(o,e,t=[]){return (r,s,a)=>{if(s===void 0)return;let i=r[s];if(typeof i!="function")return;let u=i[y]??[];i[y]=[...u,{index:a,type:o,key:e,pipes:t.length>0?t:void 0}];}}a(m,"buildBuiltinDecorator");function wt(o){return typeof o=="function"?new o:o}a(wt,"resolveParamPipe");function Ke(o,...e){let{key:t,pipes:r}=W(o,e);return m("query",t,r)}a(Ke,"Query");function Ye(o,...e){let{key:t,pipes:r}=W(o,e);return m("param",t,r)}a(Ye,"Param");function Qe(o,...e){let{key:t,pipes:r}=W(o,e);return m("body",t,r)}a(Qe,"Body");var Je=a(()=>m("rawBody"),"RawBody"),Ze=a(()=>m("formData"),"FormData"),Xe=a(()=>m("ip"),"Ip"),et=a(()=>m("userAgent"),"UserAgent"),tt=a(o=>m("cookie",o),"Cookie");function rt(o,...e){let{key:t,pipes:r}=W(o,e);return m("headers",t,r)}a(rt,"Headers");function se(o){return ()=>(e,t,r)=>{if(t===void 0)return;let s=e[t];if(typeof s!="function")return;let a=s[y]??[];s[y]=[...a,{index:r,type:"auth",extractor:o}];}}a(se,"defineAuth");var ot=se();function nt(o){return ()=>(e,t,r)=>{if(t===void 0)return;let s=e[t];if(typeof s!="function")return;let a=s[y]??[];s[y]=[...a,{index:r,type:"custom",extractor:o}];}}a(nt,"createParamDecorator");function q(o,e){let t=o.prototype[e];if(typeof t!="function")return null;let r=t[y];return r&&r.length>0?r:null}a(q,"getRouteParams");function z(o){let e=o?.node?.req?.headers;if(e&&typeof e=="object")return e;let t=o?.headers;return t&&typeof t.entries=="function"?Object.fromEntries(t.entries()):t&&typeof t=="object"?t:{}}a(z,"getHeadersAsRecord");async function H(o,e){let t=Math.max(...o.map(s=>s.index)),r=new Array(t+1).fill(void 0);for(let{index:s,type:a,key:i,pipes:u,extractor:d}of o){let c;switch(a){case "query":{let l=e.getQuery();c=i!==void 0?l[i]:l;break}case "param":{let l=e.getParams();c=i!==void 0?l[i]:l;break}case "body":{let l=e.getBody()??{};c=i!==void 0?l[i]:l;break}case "rawBody":{c=e.getRawBody();break}case "formData":{c=e.getFormData();break}case "headers":{let l=z(e.getNativeRequest());c=i!==void 0?l[i.toLowerCase()]:l;break}case "cookie":{let f=z(e.getNativeRequest()).cookie??"";if(i&&f){let h=f.split(";").map(p=>p.trim()).find(p=>p.startsWith(i+"="));c=h?decodeURIComponent(h.slice(i.length+1)):void 0;}else c=void 0;break}case "ip":{let l=e.getNativeRequest(),f=z(l),h=f["cf-connecting-ip"];if(h){c=h.trim();break}let p=f["x-forwarded-for"];if(p){c=(String(p).split(",")[0]??"").trim();break}c=l?.node?.req?.socket?.remoteAddress??"";break}case "userAgent":{c=z(e.getNativeRequest())["user-agent"]??"";break}case "auth":{c=d?await d(e):e.getAuth();break}case "custom":{c=d?await d(e):void 0;break}}if(u&&u.length>0)for(let l of u)c=wt(l).transform(c);r[s]=c;}return r}a(H,"resolveParamArgs");var st="__redirect";function at(o,e=302){return {__redirect:true,url:o,statusCode:e}}a(at,"redirect");function j(o){return o!==null&&typeof o=="object"&&o.__redirect===true}a(j,"isRedirect");function it(){return !!(process.env.VERCEL||process.env.AWS_LAMBDA_FUNCTION_NAME||process.env.LAMBDA_TASK_ROOT||process.env.FUNCTIONS_WORKER_RUNTIME||process.env.K_SERVICE||process.env.NETLIFY)}a(it,"isServerless");var C=class{static{a(this,"TruxieApplication");}container;registry;initialized=false;rootModule;options;eventEmitter;prefix="";router;filters=[];gateways=new Map;wsInitialized=false;constructor(e,t={}){this.rootModule=e,this.options=t,this.container=new a$1,this.registry=new n;}async init(){if(this.initialized)return;this.eventEmitter=new o,this.options.eventBus&&this.eventEmitter.setOptions(this.options.eventBus),this.container.register({provide:o,useValue:this.eventEmitter});let e=new a$2;this.container.register({provide:a$2,useValue:e}),this.registry.scan(this.rootModule),this.registry.registerAll(this.container);let t=this.registry.getAllProviders();e._init(this.container,t),await this.registry.callLifecycleHooks(this.container,"onModuleInit"),await q$1(this.container,t),await this.registry.callLifecycleHooks(this.container,"onApplicationBootstrap"),this.router=new w(this.prefix),this.router.register(...this.registry.getAllControllers()),this.filters=this.options.globalFilters??[],this.initialized=true;}setGlobalPrefix(e){return this.prefix=e,this.initialized&&(this.router=new w(this.prefix),this.router.register(...this.registry.getAllControllers())),this}getGlobalPrefix(){return this.prefix}async resolve(e){return this.ensureInitialized(),this.container.resolve(e)}has(e){return this.container.has(e)}getContainer(){return this.container}matchRoute(e,t){return this.ensureInitialized(),this.router.match(e,t)??null}async handleRequest(e$1,t){this.ensureInitialized();let{container:r,dispose:s}=this.createRequestContext();try{let a=await r.resolve(e$1.controllerClass),i=a[e$1.methodName].bind(a),u=q(e$1.controllerClass,e$1.methodName);try{for(let c of e$1.guardClasses)if(!await(r.has(c)?await r.resolve(c):new c).canActivate(t))throw new e("Access denied by guard");let d=u?await i(...await H(u,t)):await i(t);if(j(d)){let c=d;return {value:d,isRedirect:!0,redirectUrl:c.url,redirectStatus:c.statusCode}}return {value:d,isRedirect:!1}}catch(d){for(let c of this.filters)try{return {value:await c.catch(d,t),isRedirect:!1}}catch{continue}throw d}}finally{await s();}}hasGateways(){return this.ensureInitialized(),this.registry.getAllGateways().length>0}async createWebSocketHooks(e){this.ensureInitialized(),await this.initGateways();let t=this;return {async open(r){let a="/"+(e.getUrl(r).split("?")[0]??"/").replace(/^\/+|\/+$/g,""),i=t.matchGatewayPath(a);if(!i)return;let u=r.context;u&&(u._gatewayPath=i);let d=t.gateways.get(i),c=e.adaptPeer(r);for(let l of d.serverProps)d.instance[l]={peers:e.getPeers(r)??new Set};if(d.hasConnection)try{await d.instance.handleConnection(c);}catch(l){console.error(`[WS] ${d.className}.handleConnection error:`,l);}},async message(r,s){let i=r.context?._gatewayPath;if(!i)return;let u=t.gateways.get(i);if(!u)return;let d=e.adaptPeer(r),c=e.adaptMessage(s),l;try{l=c.json();}catch{return}if(!l.event||typeof l.event!="string")return;let f=u.messageHandlers.get(l.event);if(f)try{let h=n$1(f.paramMeta,d,c,l.data),p=await f.method(...h);p!=null&&d.send(p);}catch(h){console.error(`[WS] ${u.className}.${l.event} error:`,h);}},async close(r,s){let i=r.context?._gatewayPath;if(!i)return;let u=t.gateways.get(i);if(!u?.hasDisconnect)return;let d=e.adaptPeer(r);try{await u.instance.handleDisconnect(d,s);}catch(c){console.error(`[WS] ${u.className}.handleDisconnect error:`,c);}},async error(r,s){let a=r?.id??"unknown";console.error(`[WS] Peer ${String(a)} error:`,s);}}}getControllers(){return this.ensureInitialized(),this.registry.getAllControllers()}getGateways(){return this.ensureInitialized(),this.registry.getAllGateways()}getProviders(){return this.ensureInitialized(),this.registry.getAllProviders()}getEventEmitter(){return this.ensureInitialized(),this.eventEmitter}getRouter(){return this.ensureInitialized(),this.router}createHandler(e){return this.ensureInitialized(),T(this.container,this.getGlobalOptions(),e)}async shutdown(){this.initialized&&(await this.registry.callLifecycleHooks(this.container,"onModuleDestroy"),await this.registry.callLifecycleHooks(this.container,"onApplicationShutdown"),this.eventEmitter.clear(),await this.container.dispose(),this.initialized=false);}createRequestContext(){if(!this.container.hasRequestScoped())return {container:this.container,dispose:a(async()=>{},"dispose")};let e=this.container.createChild();return {container:e,dispose:a(()=>e.dispose(),"dispose")}}matchGatewayPath(e){if(this.gateways.has(e))return e;for(let t of this.gateways.keys())if(e.endsWith(t))return t;if(this.gateways.has("/"))return "/"}async initGateways(){if(!this.wsInitialized){for(let e of this.registry.getAllGateways()){let t=i(e);if(!t)continue;let r=await this.container.resolve(e),s=new Map;for(let a of j$2(e)){let i=r[a.methodName];typeof i=="function"&&s.set(a.event,{method:i.bind(r),paramMeta:k$1(e.prototype[a.methodName])});}if(this.gateways.set(t.path,{instance:r,className:e.name,messageHandlers:s,hasConnection:typeof r.handleConnection=="function",hasDisconnect:typeof r.handleDisconnect=="function",serverProps:m$2(e)}),typeof r.afterInit=="function")try{await r.afterInit();}catch{}}this.wsInitialized=true;}}getGlobalOptions(){return {guards:this.options.globalGuards,interceptors:this.options.globalInterceptors,pipes:this.options.globalPipes,filters:this.options.globalFilters}}ensureInitialized(){if(!this.initialized)throw new Error("TruxieApplication not initialized. Call TruxieFactory.create() or app.init().")}},L=class{static{a(this,"TruxieFactory");}static async create(e,t){let r=new C(e,t);return await r.init(),r}};export{ot as Auth,_ as BaseExecutionContext,Qe as Body,ze as Catch,F as ConfigurableModuleBuilder,w as ControllerRouter,tt as Cookie,Le as DefaultValuePipe,B as DomainEvent,Ze as FormData,rt as Headers,Xe as Ip,Ye as Param,$ as ParseIdPipe,O as ParseIntPipe,Ke as Query,st as REDIRECT_BRAND,Je as RawBody,C as TruxieApplication,L as TruxieFactory,ee as UOW_INSTANCE_KEY,X as UOW_SESSION_KEY,U as UnitOfWorkInterceptor,Be as UseFilters,We as UseInterceptors,qe as UseMiddleware,je as UsePipes,et as UserAgent,nt as createParamDecorator,T as createPipeline,se as defineAuth,k as getEffectiveInterceptors,G as getEffectiveMiddlewares,J as getInterceptorsMetadata,Z as getMethodInterceptors,ne as getMethodMiddlewares,oe as getMiddlewaresMetadata,q as getRouteParams,j as isRedirect,it as isServerless,at as redirect,H as resolveParamArgs};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { a as Token, F as ForwardRef, d as InjectableOptions } from './types-CoyG1lE2.js';
|
|
2
|
+
|
|
3
|
+
declare function Injectable(options?: InjectableOptions): ClassDecorator;
|
|
4
|
+
/**
|
|
5
|
+
* Dual-mode decorator for declaring constructor dependencies.
|
|
6
|
+
*
|
|
7
|
+
* Class decorator — spread the full dependency list in constructor order.
|
|
8
|
+
* Use when esbuild/swc strips design:paramtypes (i.e. always in this project).
|
|
9
|
+
*
|
|
10
|
+
* @Injectable()
|
|
11
|
+
* @Inject(AuthService, UserService)
|
|
12
|
+
* class MyController { ... }
|
|
13
|
+
*
|
|
14
|
+
* Parameter decorator — bind a specific token to one constructor parameter.
|
|
15
|
+
*
|
|
16
|
+
* constructor(@Inject(MY_TOKEN) private svc: MyService) {}
|
|
17
|
+
*/
|
|
18
|
+
declare function Inject(...deps: Array<Token | ForwardRef>): any;
|
|
19
|
+
declare function Optional(): ParameterDecorator;
|
|
20
|
+
|
|
21
|
+
interface OnModuleInit {
|
|
22
|
+
onModuleInit(): void | Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
interface OnModuleDestroy {
|
|
25
|
+
onModuleDestroy(): void | Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
interface OnApplicationBootstrap {
|
|
28
|
+
onApplicationBootstrap(): void | Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
interface OnApplicationShutdown {
|
|
31
|
+
onApplicationShutdown(signal?: string): void | Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { Inject as I, type OnApplicationBootstrap as O, Injectable as a, type OnApplicationShutdown as b, type OnModuleDestroy as c, type OnModuleInit as d, Optional as e };
|
package/dist/logger.d.ts
CHANGED
package/dist/logger.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b,
|
|
1
|
+
import {b,e,f,m,l as l$1}from'./chunk-ASOZYX5T.js';import {a}from'./chunk-EI7MMDWY.js';import'reflect-metadata';var g=new b("LOGGER_OPTIONS"),h=new b("LOGGER");var R=class{static{a(this,"ConsoleTransport");}log(e){let t=e.context?`[${e.context}]`:"",r=new Date(e.timestamp).toISOString(),c=e.data?` ${JSON.stringify(e.data)}`:"";switch(e.level){case "debug":console.debug(`${r} DEBUG ${t} ${e.message}${c}`);break;case "info":console.info(`${r} INFO ${t} ${e.message}${c}`);break;case "warn":console.warn(`${r} WARN ${t} ${e.message}${c}`);break;case "error":console.error(`${r} ERROR ${t} ${e.message}${c}`);break}}};function T(o,e,t,r){var c=arguments.length,n=c<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,r);else for(var s=o.length-1;s>=0;s--)(i=o[s])&&(n=(c<3?i(n):c>3?i(e,t,n):i(e,t))||n);return c>3&&n&&Object.defineProperty(e,t,n),n}a(T,"_ts_decorate");function I(o,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,e)}a(I,"_ts_metadata");var S={debug:0,info:1,warn:2,error:3},l=class o{static{a(this,"Logger");}transport;minLevel;context;constructor(e,t){this.transport=e.transport??new R,this.minLevel=S[e.level??"info"],this.context=t;}child(e){let t=Object.create(o.prototype);return t.transport=this.transport,t.minLevel=this.minLevel,t.context=e,t}debug(e,t){this.log("debug",e,t);}info(e,t){this.log("info",e,t);}warn(e,t){this.log("warn",e,t);}error(e,t){this.log("error",e,t);}log(e,t,r){S[e]<this.minLevel||this.transport.log({level:e,message:t,context:this.context,timestamp:Date.now(),data:r});}};l=T([e(),f(g),I("design:type",Function),I("design:paramtypes",[typeof LoggerModuleOptions>"u"?Object:LoggerModuleOptions])],l);function D(o,e,t,r){var c=arguments.length,n=c<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,r);else for(var s=o.length-1;s>=0;s--)(i=o[s])&&(n=(c<3?i(n):c>3?i(e,t,n):i(e,t))||n);return c>3&&n&&Object.defineProperty(e,t,n),n}a(D,"_ts_decorate");var p=class o{static{a(this,"LoggerModule");}static forRoot(e={}){return {module:o,global:true,providers:[{provide:g,useValue:e},l,{provide:h,useExisting:l}],exports:[l,h]}}};p=D([m(),l$1({})],p);var x=Symbol("logger:log");function y(o={}){return (e,t,r)=>{let c=r.value;if(typeof c!="function")return r;let n=String(t),i=e.constructor.name,s=o.message??`${i}.${n}`,m=o.level??"debug",_=o.logArgs??false,$=o.logDuration??true;r.value=async function(...d){let f=this.logger;if(!f||typeof f[m]!="function")return c.apply(this,d);let b={};_&&d.length>0&&(b.args=d),f[m](`\u2192 ${s}`,Object.keys(b).length>0?b:void 0);let w=$?performance.now():0;try{let u=await c.apply(this,d);if($){let O=Math.round(performance.now()-w);f[m](`\u2190 ${s}`,{durationMs:O});}else f[m](`\u2190 ${s}`);return u}catch(u){let O=u instanceof Error?u.message:String(u);if($){let P=Math.round(performance.now()-w);f.error(`\u2717 ${s}`,{error:O,durationMs:P});}else f.error(`\u2717 ${s}`,{error:O});throw u}};let G=e.constructor,N=Reflect.getOwnMetadata(x,G)??[];return Reflect.defineMetadata(x,[...N,{methodName:n,options:o}],G),r}}a(y,"Log");function A(o){return Reflect.getOwnMetadata(x,o)??[]}a(A,"getLogMetadata");export{h as LOGGER,g as LOGGER_OPTIONS,y as Log,l as Logger,p as LoggerModule,A as getLogMetadata};
|
package/dist/schedule.d.ts
CHANGED
package/dist/schedule.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-
|
|
1
|
+
import {a as a$1}from'./chunk-F3UTUZEO.js';import {e,f,m,l as l$1}from'./chunk-ASOZYX5T.js';import {a}from'./chunk-EI7MMDWY.js';import'reflect-metadata';import {Cron}from'croner';var g=Symbol("schedule:cron"),b=Symbol("schedule:interval"),v=Symbol("schedule:timeout"),T=Symbol("schedule:options");function x(n,t){return (r,e,s)=>{let o=Reflect.getOwnMetadata(g,r.constructor)??[];o.push({expression:n,methodName:String(e),options:t??{}}),Reflect.defineMetadata(g,o,r.constructor);}}a(x,"Cron");function I(n,t){return (r,e,s)=>{let o=Reflect.getOwnMetadata(b,r.constructor)??[];o.push({ms:n,methodName:String(e),options:t??{}}),Reflect.defineMetadata(b,o,r.constructor);}}a(I,"Interval");function N(n,t){return (r,e,s)=>{let o=Reflect.getOwnMetadata(v,r.constructor)??[];o.push({ms:n,methodName:String(e),options:t??{}}),Reflect.defineMetadata(v,o,r.constructor);}}a(N,"Timeout");function E(n){return Reflect.getOwnMetadata(g,n)??[]}a(E,"getCronMetadata");function A(n){return Reflect.getOwnMetadata(b,n)??[]}a(A,"getIntervalMetadata");function S(n){return Reflect.getOwnMetadata(v,n)??[]}a(S,"getTimeoutMetadata");function j(n,t,r,e){var s=arguments.length,o=s<3?t:e===null?e=Object.getOwnPropertyDescriptor(t,r):e,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(n,t,r,e);else for(var c=n.length-1;c>=0;c--)(i=n[c])&&(o=(s<3?i(o):s>3?i(t,r,o):i(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}a(j,"_ts_decorate");var l=class{static{a(this,"SchedulerRegistry");}tasks=new Map;register(t){this.tasks.has(t.name)&&this.tasks.get(t.name).stop(),this.tasks.set(t.name,t);}getTask(t){return this.tasks.get(t)}stopTask(t){let r=this.tasks.get(t);return r?(r.stop(),this.tasks.delete(t),true):false}stopAll(){for(let t of this.tasks.values())t.stop();this.tasks.clear();}getTaskNames(){return [...this.tasks.keys()]}get size(){return this.tasks.size}};l=j([e()],l);function w(n,t,r,e){var s=arguments.length,o=s<3?t:e===null?e=Object.getOwnPropertyDescriptor(t,r):e,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(n,t,r,e);else for(var c=n.length-1;c>=0;c--)(i=n[c])&&(o=(s<3?i(o):s>3?i(t,r,o):i(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}a(w,"_ts_decorate");function _(n,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,t)}a(_,"_ts_metadata");var p=class{static{a(this,"ScheduleExplorer");}discovery;registry;options;onError;constructor(t,r,e){this.discovery=t,this.registry=r,this.options=e,this.onError=e.onError??D;}async onApplicationBootstrap(){if(this.options.enabled===false)return;let t=this.discovery.getProviders();for(let r of t){let e=this.discovery.getProviderClass(r);if(!e)continue;let s=E(e),o=A(e),i=S(e);if(s.length===0&&o.length===0&&i.length===0)continue;let c=typeof r=="function"?r:r.provide,f;try{f=await this.discovery.resolve(c);}catch{continue}let O=e.name;for(let u of s)this.registerCron(f,O,u);for(let u of o)this.registerInterval(f,O,u);for(let u of i)this.registerTimeout(f,O,u);}}onApplicationShutdown(){this.registry.stopAll();}registerCron(t,r,e){let s=e.options.enabled!==false,o=e.options.name??`${r}.${e.methodName}`,i=t[e.methodName].bind(t),c=new Cron(e.expression,{paused:!s},async()=>{try{await i();}catch(f){this.onError(f,o);}});this.registry.register({type:"cron",name:o,stop:a(()=>c.stop(),"stop")});}registerInterval(t,r,e){let s=e.options.enabled!==false,o=e.options.name??`${r}.${e.methodName}`;if(!s)return;let i=t[e.methodName].bind(t),c=setInterval(async()=>{try{await i();}catch(f){this.onError(f,o);}},e.ms);this.registry.register({type:"interval",name:o,stop:a(()=>clearInterval(c),"stop")});}registerTimeout(t,r,e){let s=e.options.enabled!==false,o=e.options.name??`${r}.${e.methodName}`;if(!s)return;let i=t[e.methodName].bind(t),c=setTimeout(async()=>{try{await i();}catch(f){this.onError(f,o);}},e.ms);this.registry.register({type:"timeout",name:o,stop:a(()=>clearTimeout(c),"stop")});}};p=w([e(),f(a$1,l,T),_("design:type",Function),_("design:paramtypes",[typeof a$1>"u"?Object:a$1,typeof l>"u"?Object:l,typeof ScheduleModuleOptions>"u"?Object:ScheduleModuleOptions])],p);function D(n,t){console.error(`[Schedule] Task "${t}" failed:`,n);}a(D,"defaultErrorHandler");function P(n,t,r,e){var s=arguments.length,o=s<3?t:e===null?e=Object.getOwnPropertyDescriptor(t,r):e,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(n,t,r,e);else for(var c=n.length-1;c>=0;c--)(i=n[c])&&(o=(s<3?i(o):s>3?i(t,r,o):i(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}a(P,"_ts_decorate");var d=class n{static{a(this,"ScheduleModule");}static forRoot(t){return {module:n,global:true,providers:[{provide:T,useValue:t??{}},l,p],exports:[l]}}};d=P([m(),l$1({})],d);export{x as Cron,I as Interval,d as ScheduleModule,l as SchedulerRegistry,N as Timeout};
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Container } from './container-
|
|
2
|
-
import { M as ModuleMetadata,
|
|
1
|
+
import { C as Container } from './container-4Q8Oq_GB.js';
|
|
2
|
+
import { M as ModuleMetadata, T as Type, D as DynamicModule, a as Token } from './types-CoyG1lE2.js';
|
|
3
3
|
import { a as EventEmitter2 } from './event-bus-BKPUV8M9.js';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/testing.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {a as a$1,o,n,q}from'./chunk-4IAZ6T72.js';import'./chunk-RLQ7JJW6.js';import {a as a$2}from'./chunk-F3UTUZEO.js';import {d}from'./chunk-ASOZYX5T.js';import {a}from'./chunk-EI7MMDWY.js';var y=class{static{a(this,"TestBuilder");}metadata;overrides=new Map;constructor(e){this.metadata=e;}overrideProvider(e){return {useValue:a(t=>(this.overrides.set(e,{provide:e,useValue:t}),this),"useValue"),useClass:a(t=>(this.overrides.set(e,{provide:e,useClass:t}),this),"useClass"),useFactory:a((t,n)=>(this.overrides.set(e,{provide:e,useFactory:t,inject:n??[]}),this),"useFactory")}}async compile(){let e=new a$1,t=new o;e.register({provide:o,useValue:t});let n$1=new a$2;e.register({provide:a$2,useValue:n$1});let s=this.metadata;if(h(s)){let r=(s.providers??[]).map(a=>a&&typeof a=="object"&&"forwardRef"in a?d(a):a);if(e.register(...r),s.imports&&s.imports.length>0){let a$1=new n,w={module:class{static{a(this,"TempTestModule");}},imports:s.imports,providers:r,exports:s.exports??[]};a$1.scan(w),a$1.registerAll(e);}}else {let r=new n;r.scan(s),r.registerAll(e);}for(let[,r]of this.overrides)e.register(r);let i=this.collectProviders(s);return n$1._init(e,i),await this.callHook(e,i,"onModuleInit"),await q(e,i),await this.callHook(e,i,"onApplicationBootstrap"),{resolve:a(r=>e.resolve(r),"resolve"),has:a(r=>e.has(r),"has"),getContainer:a(()=>e,"getContainer"),getEventEmitter:a(()=>t,"getEventEmitter"),shutdown:a(async()=>{await this.callHook(e,i,"onModuleDestroy"),await this.callHook(e,i,"onApplicationShutdown"),t.clear(),await e.dispose();},"shutdown")}}collectProviders(e){return h(e)?(e.providers??[]).map(t=>t&&typeof t=="object"&&"forwardRef"in t?d(t):t):[]}async callHook(e,t,n){for(let s of t){let i=typeof s=="function"?s:s.provide;if(e.has(i))try{let r=await e.resolve(i);r&&typeof r=="object"&&typeof r[n]=="function"&&await r[n]();}catch{}}}};function h(c){return !(typeof c=="function"||c&&typeof c=="object"&&"module"in c)}a(h,"isModuleMetadata");var p=class{static{a(this,"Test");}static createTestingModule(e){return new y(e)}};export{p as Test};
|
package/dist/throttle.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DynamicModule,
|
|
2
|
-
import { E as ExecutionContext, I as ICanActivateGuard } from './interfaces-
|
|
3
|
-
import './container-
|
|
1
|
+
import { D as DynamicModule, I as InjectionToken } from './types-CoyG1lE2.js';
|
|
2
|
+
import { E as ExecutionContext, I as ICanActivateGuard } from './interfaces-ivJCgMba.js';
|
|
3
|
+
import './container-4Q8Oq_GB.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Pluggable throttle store interface.
|
package/dist/throttle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$2}from'./chunk-PT5RXFB5.js';import {b as b$1,
|
|
1
|
+
import {a as a$2}from'./chunk-PT5RXFB5.js';import {b as b$1,e,f,m as m$1,l as l$1}from'./chunk-ASOZYX5T.js';import {a as a$1}from'./chunk-EI7MMDWY.js';import'reflect-metadata';var a=new b$1("THROTTLE_OPTIONS");var m=class{static{a$1(this,"MemoryThrottleStore");}entries=new Map;cleanupTimer;constructor(){this.cleanupTimer=setInterval(()=>this.cleanup(),6e4),this.cleanupTimer.unref&&this.cleanupTimer.unref();}async increment(t,e){let r=Date.now(),i=this.entries.get(t);if(i&&i.expiresAt>r)return i.count++,{count:i.count,ttlRemaining:Math.ceil((i.expiresAt-r)/1e3)};let n=r+e*1e3;return this.entries.set(t,{count:1,expiresAt:n}),{count:1,ttlRemaining:e}}async reset(t){this.entries.delete(t);}cleanup(){let t=Date.now();for(let[e,r]of this.entries)r.expiresAt<=t&&this.entries.delete(e);}destroy(){clearInterval(this.cleanupTimer),this.entries.clear();}};function A(o,t,e,r){var i=arguments.length,n=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,t,e,r);else for(var f=o.length-1;f>=0;f--)(s=o[f])&&(n=(i<3?s(n):i>3?s(t,e,n):s(t,e))||n);return i>3&&n&&Object.defineProperty(t,e,n),n}a$1(A,"_ts_decorate");function b(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)}a$1(b,"_ts_metadata");var l=class{static{a$1(this,"ThrottleGuard");}store;defaultLimit;defaultWindow;keyFactory;constructor(t){this.store=t.store??new m,this.defaultLimit=t.limit??60,this.defaultWindow=t.window??60,this.keyFactory=t.keyFactory??j;}async canActivate(t){let e=t.getHandler();if(!e)return true;let r=e.name||"";t._controllerClass;let n=e[Symbol.for("throttle:options")];if(e[Symbol.for("throttle:skip")])return true;let f=n?.limit??this.defaultLimit,_=n?.window??this.defaultWindow,g=`throttle:${await(n?.keyFactory??this.keyFactory)(t)}:${r}`,{count:v,ttlRemaining:h}=await this.store.increment(g,_);if(v>f)throw new d(`Rate limit exceeded. Try again in ${h} seconds.`,h);return true}};l=A([e(),f(a),b("design:type",Function),b("design:paramtypes",[typeof ThrottleModuleOptions>"u"?Object:ThrottleModuleOptions])],l);var d=class extends a$2{static{a$1(this,"TooManyRequestsError");}retryAfter;constructor(t="Too many requests",e=60){super(t,429),this.retryAfter=e;}};function j(o){let t=o.getNativeRequest(),e=t?.node?.req?.headers??{},r=e["cf-connecting-ip"];if(r)return r.trim();let i=e["x-forwarded-for"];return i?(String(i).split(",")[0]??"").trim():t?.node?.req?.socket?.remoteAddress??"unknown"}a$1(j,"defaultKeyFactory");function k(o,t,e,r){var i=arguments.length,n=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,t,e,r);else for(var f=o.length-1;f>=0;f--)(s=o[f])&&(n=(i<3?s(n):i>3?s(t,e,n):s(t,e))||n);return i>3&&n&&Object.defineProperty(t,e,n),n}a$1(k,"_ts_decorate");var u=class o{static{a$1(this,"ThrottleModule");}static forRoot(t={}){return {module:o,global:true,providers:[{provide:a,useValue:t},l],exports:[l]}}};u=k([m$1(),l$1({})],u);var p=Symbol("throttle:options"),S=Symbol("throttle:skip");function I(o){return (t,e,r)=>{if(e!==void 0){let i=r?.value??t;return i[p]=o,r}Reflect.defineMetadata(p,o,t);}}a$1(I,"Throttle");function L(){return (o,t,e)=>{let r=e.value;return typeof r=="function"&&(r[S]=true),e}}a$1(L,"SkipThrottle");function M(o,t){if(t){let e=o.prototype?.[t];if(typeof e=="function"&&e[p])return e[p]}return Reflect.getOwnMetadata(p,o)}a$1(M,"getThrottleMetadata");function P(o,t){let e=o.prototype?.[t];return typeof e=="function"&&e[S]===true}a$1(P,"isThrottleSkipped");export{L as SkipThrottle,a as THROTTLE_OPTIONS,I as Throttle,l as ThrottleGuard,u as ThrottleModule,M as getThrottleMetadata,P as isThrottleSkipped};
|
|
@@ -40,17 +40,17 @@ interface ForwardRef<T = unknown> {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
interface ModuleMetadata {
|
|
43
|
-
imports?: Array<Type | DynamicModule>;
|
|
43
|
+
imports?: Array<Type | DynamicModule | ForwardRef>;
|
|
44
44
|
controllers?: Type[];
|
|
45
|
-
providers?: Provider
|
|
46
|
-
exports?: Token
|
|
45
|
+
providers?: Array<Provider | ForwardRef>;
|
|
46
|
+
exports?: Array<Token | ForwardRef>;
|
|
47
47
|
}
|
|
48
48
|
interface DynamicModule {
|
|
49
49
|
module: Type;
|
|
50
|
-
imports?: Array<Type | DynamicModule>;
|
|
50
|
+
imports?: Array<Type | DynamicModule | ForwardRef>;
|
|
51
51
|
controllers?: Type[];
|
|
52
|
-
providers?: Provider
|
|
53
|
-
exports?: Token
|
|
52
|
+
providers?: Array<Provider | ForwardRef>;
|
|
53
|
+
exports?: Array<Token | ForwardRef>;
|
|
54
54
|
global?: boolean;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
@@ -85,4 +85,4 @@ type ModuleAsyncOptions<T> = {
|
|
|
85
85
|
useClass?: never;
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
export { type ClassProvider as C, type DynamicModule as D, type ExistingProvider as E, type ForwardRef as F,
|
|
88
|
+
export { type ClassProvider as C, type DynamicModule as D, type ExistingProvider as E, type ForwardRef as F, InjectionToken as I, type ModuleMetadata as M, type Provider as P, Scope as S, type Type as T, type ValueProvider as V, type Token as a, type ModuleAsyncOptions as b, type FactoryProvider as c, type InjectableOptions as d, type ModuleOptionsFactory as e };
|
package/package.json
CHANGED
|
@@ -1,104 +1,114 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "truxie",
|
|
3
|
-
"version": "0.1.0-test.
|
|
4
|
-
"description": "NestJS-like structural backend library with DI, modules, guards, interceptors, pipes, and exception filters",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"module": "dist/index.js",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.js",
|
|
13
|
-
"default": "./dist/index.js"
|
|
14
|
-
},
|
|
15
|
-
"./schedule": {
|
|
16
|
-
"types": "./dist/schedule.d.ts",
|
|
17
|
-
"import": "./dist/schedule.js",
|
|
18
|
-
"default": "./dist/schedule.js"
|
|
19
|
-
},
|
|
20
|
-
"./
|
|
21
|
-
"types": "./dist/
|
|
22
|
-
"import": "./dist/
|
|
23
|
-
"default": "./dist/
|
|
24
|
-
},
|
|
25
|
-
"./
|
|
26
|
-
"types": "./dist/
|
|
27
|
-
"import": "./dist/
|
|
28
|
-
"default": "./dist/
|
|
29
|
-
},
|
|
30
|
-
"./
|
|
31
|
-
"types": "./dist/
|
|
32
|
-
"import": "./dist/
|
|
33
|
-
"default": "./dist/
|
|
34
|
-
},
|
|
35
|
-
"./
|
|
36
|
-
"types": "./dist/
|
|
37
|
-
"import": "./dist/
|
|
38
|
-
"default": "./dist/
|
|
39
|
-
},
|
|
40
|
-
"./
|
|
41
|
-
"types": "./dist/
|
|
42
|
-
"import": "./dist/
|
|
43
|
-
"default": "./dist/
|
|
44
|
-
},
|
|
45
|
-
"./
|
|
46
|
-
"types": "./dist/
|
|
47
|
-
"import": "./dist/
|
|
48
|
-
"default": "./dist/
|
|
49
|
-
},
|
|
50
|
-
"./
|
|
51
|
-
"types": "./dist/
|
|
52
|
-
"import": "./dist/
|
|
53
|
-
"default": "./dist/
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"zod":
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
},
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
"
|
|
101
|
-
|
|
102
|
-
"
|
|
103
|
-
|
|
104
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "truxie",
|
|
3
|
+
"version": "0.1.0-test.15",
|
|
4
|
+
"description": "NestJS-like structural backend library with DI, modules, guards, interceptors, pipes, and exception filters",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./schedule": {
|
|
16
|
+
"types": "./dist/schedule.d.ts",
|
|
17
|
+
"import": "./dist/schedule.js",
|
|
18
|
+
"default": "./dist/schedule.js"
|
|
19
|
+
},
|
|
20
|
+
"./bullmq": {
|
|
21
|
+
"types": "./dist/bullmq.d.ts",
|
|
22
|
+
"import": "./dist/bullmq.js",
|
|
23
|
+
"default": "./dist/bullmq.js"
|
|
24
|
+
},
|
|
25
|
+
"./testing": {
|
|
26
|
+
"types": "./dist/testing.d.ts",
|
|
27
|
+
"import": "./dist/testing.js",
|
|
28
|
+
"default": "./dist/testing.js"
|
|
29
|
+
},
|
|
30
|
+
"./cache": {
|
|
31
|
+
"types": "./dist/cache.d.ts",
|
|
32
|
+
"import": "./dist/cache.js",
|
|
33
|
+
"default": "./dist/cache.js"
|
|
34
|
+
},
|
|
35
|
+
"./throttle": {
|
|
36
|
+
"types": "./dist/throttle.d.ts",
|
|
37
|
+
"import": "./dist/throttle.js",
|
|
38
|
+
"default": "./dist/throttle.js"
|
|
39
|
+
},
|
|
40
|
+
"./logger": {
|
|
41
|
+
"types": "./dist/logger.d.ts",
|
|
42
|
+
"import": "./dist/logger.js",
|
|
43
|
+
"default": "./dist/logger.js"
|
|
44
|
+
},
|
|
45
|
+
"./health": {
|
|
46
|
+
"types": "./dist/health.d.ts",
|
|
47
|
+
"import": "./dist/health.js",
|
|
48
|
+
"default": "./dist/health.js"
|
|
49
|
+
},
|
|
50
|
+
"./ws": {
|
|
51
|
+
"types": "./dist/ws.d.ts",
|
|
52
|
+
"import": "./dist/ws.js",
|
|
53
|
+
"default": "./dist/ws.js"
|
|
54
|
+
},
|
|
55
|
+
"./cqrs": {
|
|
56
|
+
"types": "./dist/cqrs.d.ts",
|
|
57
|
+
"import": "./dist/cqrs.js",
|
|
58
|
+
"default": "./dist/cqrs.js"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"files": [
|
|
62
|
+
"dist",
|
|
63
|
+
"README.md"
|
|
64
|
+
],
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "tsup",
|
|
67
|
+
"dev": "tsup --watch",
|
|
68
|
+
"typecheck": "tsc --noEmit",
|
|
69
|
+
"clean": "rm -rf dist"
|
|
70
|
+
},
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"reflect-metadata": "^0.2.2"
|
|
73
|
+
},
|
|
74
|
+
"peerDependencies": {
|
|
75
|
+
"bullmq": "^5.0.0",
|
|
76
|
+
"croner": "^9.0.0 || ^10.0.0",
|
|
77
|
+
"zod": "^3.22.0 || ^4.0.0"
|
|
78
|
+
},
|
|
79
|
+
"peerDependenciesMeta": {
|
|
80
|
+
"bullmq": {
|
|
81
|
+
"optional": true
|
|
82
|
+
},
|
|
83
|
+
"croner": {
|
|
84
|
+
"optional": true
|
|
85
|
+
},
|
|
86
|
+
"zod": {
|
|
87
|
+
"optional": true
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"devDependencies": {
|
|
91
|
+
"@swc/core": "^1.15.18",
|
|
92
|
+
"@types/node": "^22.10.5",
|
|
93
|
+
"bullmq": "^5.76.6",
|
|
94
|
+
"croner": "^10.0.1",
|
|
95
|
+
"tsup": "^8.0.0",
|
|
96
|
+
"typescript": "^5.0.0",
|
|
97
|
+
"vitest": "^4.0.18",
|
|
98
|
+
"zod": "^4.4.3"
|
|
99
|
+
},
|
|
100
|
+
"keywords": [
|
|
101
|
+
"nestjs",
|
|
102
|
+
"di",
|
|
103
|
+
"dependency-injection",
|
|
104
|
+
"backend",
|
|
105
|
+
"modules",
|
|
106
|
+
"guards",
|
|
107
|
+
"interceptors",
|
|
108
|
+
"pipes"
|
|
109
|
+
],
|
|
110
|
+
"license": "MIT",
|
|
111
|
+
"engines": {
|
|
112
|
+
"node": ">=18.0.0"
|
|
113
|
+
}
|
|
114
|
+
}
|
package/dist/chunk-IEQXYYZJ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {f,a as a$1,g,h as h$1,i,b,l,m as m$1,c}from'./chunk-MF2CCNPQ.js';import {i as i$1}from'./chunk-RLQ7JJW6.js';import {a}from'./chunk-EI7MMDWY.js';import'reflect-metadata';function V(r){return {forwardRef:r}}a(V,"forwardRef");function G(r){return typeof r=="object"&&"forwardRef"in r?r.forwardRef():r}a(G,"resolveForwardRef");var j=class r{static{a(this,"Container");}registrations=new Map;resolving=new Set;parent=null;children=[];register(...t){for(let e of t)this.registerOne(e);}registerOne(t){if(typeof t=="function"){let s=f(t)?.scope??a$1.SINGLETON;this.registrations.set(t,{provider:t,scope:s});return}let e=t.provide,o=a$1.SINGLETON;if("useClass"in t){let n=f(t.useClass);o=t.scope??n?.scope??a$1.SINGLETON;}else "useFactory"in t&&(o=t.scope??a$1.SINGLETON);this.registrations.set(e,{provider:t,scope:o});}async resolve(t){let e=G(t),o=e!==t?e:t,n=this.registrations.get(o)??this.parent?.findRegistration(o);if(!n)throw new Error(`No provider found for ${y(o)}`);if(n.scope===a$1.SINGLETON&&n.instance!==void 0||n.scope===a$1.REQUEST&&this.parent!==null&&n.instance!==void 0)return n.instance;if(this.resolving.has(o))throw new Error(`Circular dependency detected for ${y(o)}`);this.resolving.add(o);try{let s=await this.createInstance(n);return (n.scope===a$1.SINGLETON||n.scope===a$1.REQUEST&&this.parent!==null)&&(n.instance=s),s}finally{this.resolving.delete(o);}}has(t){return this.registrations.has(t)||(this.parent?.has(t)??false)}hasRequestScoped(){for(let[,t]of this.registrations)if(t.scope===a$1.REQUEST)return true;return false}findRegistration(t){return this.registrations.get(t)??this.parent?.findRegistration(t)}createChild(){let t=new r;t.parent=this;for(let[e,o]of this.registrations)o.scope===a$1.REQUEST&&t.registrations.set(e,{provider:o.provider,scope:a$1.REQUEST,instance:void 0});return this.children.push(t),t}async dispose(){for(let t of this.children)await t.dispose();this.children=[];for(let[,t]of this.registrations)if(t.instance&&typeof t.instance=="object"&&t.instance!==null){let e=t.instance;typeof e.onModuleDestroy=="function"&&await e.onModuleDestroy();}this.registrations.clear(),this.resolving.clear();}async createInstance(t){let{provider:e}=t;if(typeof e=="function")return this.instantiateClass(e);if("useValue"in e)return e.useValue;if("useClass"in e)return this.instantiateClass(e.useClass);if("useFactory"in e){let o=e,n=[];if(o.inject)for(let s of o.inject)n.push(await this.resolve(s));return o.useFactory(...n)}if("useExisting"in e)return this.resolve(e.useExisting);throw new Error("Unknown provider type")}async instantiateClass(t){let e=Reflect.getMetadata("design:paramtypes",t)??[],o=g(t),n=h$1(t),s=i(t),i$1=n.size>0?Math.max(...n.keys())+1:0,a=Math.max(e.length,i$1,o.length),f=[];for(let l=0;l<a;l++){let T=n.get(l)??o[l]??e[l],U=s.has(l);try{f.push(await this.resolve(T));}catch{if(U)f.push(void 0);else throw new Error(`Cannot resolve parameter at index ${l} (${y(T)}) of ${t.name}`)}}return new t(...f)}};function y(r){return typeof r=="string"?r:typeof r=="symbol"||r instanceof b?r.toString():typeof r=="function"?r.name:String(r)}a(y,"tokenToString");var A=Symbol("controller:path"),E=Symbol("controller:guards"),w=Symbol("route:metadata"),M=Symbol("method:route"),h=Symbol("method:guards"),x=Symbol("method:noguard");function K(r){return t=>{Reflect.defineMetadata(A,r,t);}}a(K,"Controller");function m(r){return (t="")=>(e,o,n)=>{let s=n!==void 0,i=String(s?o:o?.name??o),a=s?n?.value:e;if(typeof a=="function"&&(a[M]={method:r,path:t,methodName:i}),s){let f=Reflect.getOwnMetadata(w,e.constructor)??[];return f.push({method:r,path:t,methodName:i}),Reflect.defineMetadata(w,f,e.constructor),n}return e}}a(m,"createMethodDecorator");var tt=m("GET"),et=m("POST"),ot=m("PUT"),nt=m("DELETE"),st=m("PATCH");function rt(...r){return (t,e,o)=>{if(e==null){Reflect.defineMetadata(E,r,t);return}if(o!==void 0){if(o?.value){let n=o.value[h]??[];o.value[h]=[...n,...r];}return o}if(typeof t=="function"){let n=t[h]??[];t[h]=[...n,...r];}return typeof t=="function"&&e?.kind==="class"&&Reflect.defineMetadata(E,r,t),t}}a(rt,"RouteGuards");function it(){return (r,t,e)=>e!==void 0?(e?.value&&(e.value[x]=true),e):(typeof r=="function"&&(r[x]=true),r)}a(it,"NoGuard");function I(r){return Reflect.getOwnMetadata(A,r)}a(I,"getControllerPath");function _(r){return Reflect.getOwnMetadata(E,r)??[]}a(_,"getControllerGuards");function at(r){let t=[],e=r.prototype;if(e){let o=Object.getOwnPropertyNames(e);for(let n of o){if(n==="constructor")continue;let s=e[n];typeof s=="function"&&s[M]&&t.push(s[M]);}}return t.length>0?t:Reflect.getOwnMetadata(w,r)??[]}a(at,"getRouteMetadata");function ct(r,t){let o=r.prototype?.[t],n=typeof o=="function"&&o[x]===true,s=typeof o=="function"&&o[h]||[];return n?s:[..._(r),...s]}a(ct,"getMethodGuards");var H=class{static{a(this,"ModuleRegistry");}resolved=new Map;sortedModules=[];scan(t){this.resolveModule(t),this.sortedModules=this.topologicalSort(),this.validateExports();}registerAll(t){let e=new Set;for(let o of this.sortedModules)if(o.global)for(let n of o.providers)e.add(n);e.size>0&&t.register(...e);for(let o of this.sortedModules){t.register(...o.providers);for(let n of o.metadata.imports??[]){let s=this.getModuleType(n),i=this.resolved.get(s);if(i)for(let a of i.exports){let f=this.findProvider(i,a)??this.findReExportedProvider(i,a);f&&t.register(f);}}}}getAllProviders(){let t=[];for(let e of this.sortedModules)t.push(...e.providers);return t}getAllControllers(){let t=new Set,e=[];for(let o of this.sortedModules){for(let n of o.controllers)t.has(n)||(t.add(n),e.push(n));for(let n of o.metadata.providers??[])typeof n=="function"&&I(n)!==void 0&&!t.has(n)&&(t.add(n),e.push(n));}return e}getAllGateways(){let t=new Set,e=[];for(let o of this.sortedModules)for(let n of o.providers)typeof n=="function"&&i$1(n)!==void 0&&!t.has(n)&&(t.add(n),e.push(n));return e}async callLifecycleHooks(t,e,o){for(let n of this.sortedModules)for(let s of n.providers){let i=typeof s=="function"?s:s.provide;if(t.has(i))try{let a=await t.resolve(i);a&&typeof a=="object"&&typeof a[e]=="function"&&await a[e](o);}catch{}}}resolveModule(t){let e=typeof t=="object"&&"module"in t,o=e?t.module:t;if(this.resolved.has(o))return this.resolved.get(o);let n=l(o)??{},s=e?t:{},i=[...n.controllers??[],...s.controllers??[]],a={imports:[...n.imports??[],...s.imports??[]],controllers:i,providers:[...n.providers??[],...s.providers??[]],exports:[...n.exports??[],...s.exports??[]]},f={type:o,metadata:a,controllers:i,providers:[...i,...a.providers??[]],exports:new Set(a.exports??[]),global:e?t.global??m$1(o):m$1(o)};this.resolved.set(o,f);for(let l of a.imports??[])this.resolveModule(l);return f}getVisibleTokens(t){let e=new Set;for(let o of t.providers)e.add(this.getProviderToken(o));for(let o of t.metadata.imports??[]){let n=this.getModuleType(o),s=this.resolved.get(n);if(s)for(let i of s.exports)e.add(i);}for(let o of this.sortedModules)if(o.global)for(let n of o.providers)e.add(this.getProviderToken(n));return e}validateExports(){for(let t of this.sortedModules){let e=new Set(t.providers.map(n=>this.getProviderToken(n))),o=this.collectImportedExports(t);for(let n of t.exports)if(!e.has(n)&&!o.has(n)){let s=typeof n=="function"?n.name:String(n);throw new Error(`${t.type.name} exports ${s} but it is not in its providers and is not re-exported from an imported module`)}}}validateVisibility(){for(let t of this.sortedModules){let e=this.getVisibleTokens(t);for(let o of t.providers){if(typeof o!="function")continue;let n=g(o);for(let s of n)if(!e.has(s)){let i=typeof s=="function"?s.name:String(s);throw new Error(`${t.type.name}: ${o.name} depends on ${i}, but it is not provided in this module and not exported by any imported module`)}}}}getProviderToken(t){return typeof t=="function"?t:t.provide}collectImportedExports(t){let e=new Set;for(let o of t.metadata.imports??[]){let n=this.getModuleType(o),s=this.resolved.get(n);if(s)for(let i of s.exports)e.add(i);}return e}findProvider(t,e){return t.providers.find(o=>typeof o=="function"?o===e:o.provide===e)}findReExportedProvider(t,e){for(let o of t.metadata.imports??[]){let n=this.getModuleType(o),s=this.resolved.get(n);if(!s||!s.exports.has(e))continue;let i=this.findProvider(s,e);if(i)return i;let a=this.findReExportedProvider(s,e);if(a)return a}}getModuleType(t){return typeof t=="object"&&"module"in t?t.module:t}topologicalSort(){let t=new Set,e=new Set,o=[],n=a(s=>{if(t.has(s))return;if(e.has(s))throw new Error(`Circular module dependency detected: ${s.name}`);e.add(s);let i=this.resolved.get(s);if(i){for(let a of i.metadata.imports??[])n(this.getModuleType(a));e.delete(s),t.add(s),o.push(i);}},"visit");for(let[s]of this.resolved)n(s);return o}};function D(r,t,e,o){var n=arguments.length,s=n<3?t:o===null?o=Object.getOwnPropertyDescriptor(t,e):o,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,t,e,o);else for(var a=r.length-1;a>=0;a--)(i=r[a])&&(s=(n<3?i(s):n>3?i(t,e,s):i(t,e))||s);return n>3&&s&&Object.defineProperty(t,e,s),s}a(D,"_ts_decorate");function $(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}a($,"_ts_metadata");var u=class{static{a(this,"EventEmitter2");}handlers=new Map;pending=new Map;onError;constructor(){this.onError=k;}setOptions(t){t.onError&&(this.onError=t.onError);}subscribe(t,e,o){let n=this.handlers.get(t)??[];n.push({instance:o?.instance??{},methodName:o?.methodName??"anonymous",handler:e}),this.handlers.set(t,n);}registerHandler(t,e,o){let n=e[o].bind(e);this.subscribe(t,n,{instance:e,methodName:o});}async emit(t){let e=this.handlers.get(t.type);if(!e||e.length===0)return;let o=this.executeHandlers(e,t);this.pending.set(o,t.type);try{await o;}finally{this.pending.delete(o);}}emitAsync(t){let e=this.handlers.get(t.type);if(!e||e.length===0)return;let o=this.executeHandlers(e,t).then(()=>{this.pending.delete(o);},()=>{this.pending.delete(o);});this.pending.set(o,t.type);}async waitForAllDone(...t){for(;;){let e=this.getPending(t);if(e.length===0)break;await Promise.allSettled(e);}}getPending(t){if(t.length===0)return [...this.pending.keys()];let e=[];for(let[o,n]of this.pending)t.includes(n)&&e.push(o);return e}hasHandlers(t){let e=this.handlers.get(t);return e!==void 0&&e.length>0}handlerCount(t){return this.handlers.get(t)?.length??0}clear(){this.handlers.clear();}async executeHandlers(t,e){let o=await Promise.allSettled(t.map(n=>n.handler(e)));for(let n=0;n<o.length;n++){let s=o[n];if(s.status==="rejected"){let i=t[n],a=`${i.instance.constructor?.name??"Unknown"}.${i.methodName}`;this.onError(s.reason,e.type,a);}}}};u=D([c(),$("design:type",Function),$("design:paramtypes",[])],u);function k(r,t,e){console.error(`[EventEmitter2] Handler "${e}" failed for event "${t}":`,r);}a(k,"defaultErrorHandler");var R=Symbol("on-event");function Mt(r){return (t,e,o)=>{let n=Reflect.getOwnMetadata(R,t.constructor)??[];n.push({eventType:r,methodName:String(e)}),Reflect.defineMetadata(R,n,t.constructor);}}a(Mt,"OnEvent");function L(r){return Reflect.getOwnMetadata(R,r)??[]}a(L,"getOnEventMetadata");async function Pt(r,t){let e=await r.resolve(u);for(let o of t){let n=F(o);if(!n)continue;let s=L(n);if(s.length===0)continue;let i=typeof o=="function"?o:o.provide,a;try{a=await r.resolve(i);}catch{continue}for(let f of s)typeof a[f.methodName]=="function"&&e.registerHandler(f.eventType,a,f.methodName);}}a(Pt,"scanEventHandlers");function F(r){return typeof r=="function"?f(r)?r:null:"useClass"in r?r.useClass:null}a(F,"getProviderClass");export{V as a,G as b,j as c,K as d,tt as e,et as f,ot as g,nt as h,st as i,rt as j,it as k,I as l,_ as m,at as n,ct as o,H as p,u as q,Mt as r,Pt as s};
|
package/dist/chunk-MF2CCNPQ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-EI7MMDWY.js';import'reflect-metadata';var f=(function(t){return t.SINGLETON="singleton",t.REQUEST="request",t.TRANSIENT="transient",t})({}),l=class{static{a$1(this,"InjectionToken");}description;constructor(n){this.description=n;}toString(){return `InjectionToken(${this.description})`}};var u=Symbol("injectable"),a=Symbol("inject:param"),d=Symbol("inject:deps"),r=Symbol("optional");function R(t){return n=>{Reflect.defineMetadata(u,{scope:t?.scope??f.SINGLETON},n);}}a$1(R,"Injectable");function O(...t){return (n,c,o)=>{if(typeof o=="number"){let i=Reflect.getOwnMetadata(a,n)??new Map;i.set(o,t[0]),Reflect.defineMetadata(a,i,n);}else Reflect.defineMetadata(d,t,n);}}a$1(O,"Inject");function g(){return (t,n,c)=>{let o=Reflect.getOwnMetadata(r,t)??new Set;o.add(c),Reflect.defineMetadata(r,o,t);}}a$1(g,"Optional");function m(t){return Reflect.getOwnMetadata(u,t)}a$1(m,"getInjectableMetadata");function x(t){return Reflect.getOwnMetadata(d,t)??[]}a$1(x,"getClassDeps");function b(t){return Reflect.getOwnMetadata(a,t)??new Map}a$1(b,"getInjectTokens");function S(t){return Reflect.getOwnMetadata(r,t)??new Set}a$1(S,"getOptionalParams");var p=Symbol("module"),s=Symbol("module:global");function N(t){return n=>{Reflect.defineMetadata(p,t,n);}}a$1(N,"Module");function _(){return t=>{Reflect.defineMetadata(s,true,t);}}a$1(_,"Global");function D(t){return Reflect.getOwnMetadata(p,t)}a$1(D,"getModuleMetadata");function j(t){return Reflect.getOwnMetadata(s,t)===true}a$1(j,"isGlobalModule");export{f as a,l as b,R as c,O as d,g as e,m as f,x as g,b as h,S as i,N as j,_ as k,D as l,j as m};
|