opinionated-machine 6.8.2 → 6.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +307 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/AbstractModule.d.ts +73 -3
- package/dist/lib/AbstractModule.js.map +1 -1
- package/dist/lib/AbstractTestContextFactory.d.ts +1 -1
- package/dist/lib/AbstractTestContextFactory.js.map +1 -1
- package/dist/lib/DIContext.d.ts +1 -1
- package/dist/lib/DIContext.js.map +1 -1
- package/dist/lib/resolverFunctions.d.ts +52 -15
- package/dist/lib/resolverFunctions.js +2 -1
- package/dist/lib/resolverFunctions.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ Very opinionated DI framework for fastify, built on top of awilix
|
|
|
4
4
|
## Table of Contents
|
|
5
5
|
|
|
6
6
|
- [Basic usage](#basic-usage)
|
|
7
|
+
- [Managing global public dependencies across modules](#managing-global-public-dependencies-across-modules)
|
|
8
|
+
- [Avoiding circular dependencies in typed cradle parameters](#avoiding-circular-dependencies-in-typed-cradle-parameters)
|
|
7
9
|
- [Defining controllers](#defining-controllers)
|
|
8
10
|
- [Putting it all together](#putting-it-all-together)
|
|
9
11
|
- [Resolver Functions](#resolver-functions)
|
|
@@ -69,20 +71,12 @@ Very opinionated DI framework for fastify, built on top of awilix
|
|
|
69
71
|
Define a module, or several modules, that will be used for resolving dependency graphs, using awilix:
|
|
70
72
|
|
|
71
73
|
```ts
|
|
72
|
-
import { AbstractModule, asSingletonClass, asMessageQueueHandlerClass,
|
|
74
|
+
import { AbstractModule, type InferModuleDependencies, asSingletonClass, asMessageQueueHandlerClass, asEnqueuedJobWorkerClass, asJobQueueClass, asControllerClass } from 'opinionated-machine'
|
|
73
75
|
|
|
74
|
-
export
|
|
75
|
-
service: Service
|
|
76
|
-
messageQueueConsumer: MessageQueueConsumer
|
|
77
|
-
jobWorker: JobWorker
|
|
78
|
-
queueManager: QueueManager
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export class MyModule extends AbstractModule<ModuleDependencies, ExternalDependencies> {
|
|
76
|
+
export class MyModule extends AbstractModule {
|
|
82
77
|
resolveDependencies(
|
|
83
78
|
diOptions: DependencyInjectionOptions,
|
|
84
|
-
|
|
85
|
-
): MandatoryNameAndRegistrationPair<ModuleDependencies> {
|
|
79
|
+
) {
|
|
86
80
|
return {
|
|
87
81
|
service: asSingletonClass(Service),
|
|
88
82
|
|
|
@@ -103,7 +97,7 @@ export class MyModule extends AbstractModule<ModuleDependencies, ExternalDepende
|
|
|
103
97
|
}),
|
|
104
98
|
|
|
105
99
|
// by default disposal methods from `background-jobs-commons` job queue manager
|
|
106
|
-
// will be assumed. If different values are necessary, specify "asyncDispose" fields
|
|
100
|
+
// will be assumed. If different values are necessary, specify "asyncDispose" fields
|
|
107
101
|
// in the second config object
|
|
108
102
|
queueManager: asJobQueueClass(
|
|
109
103
|
QueueManager,
|
|
@@ -125,6 +119,299 @@ export class MyModule extends AbstractModule<ModuleDependencies, ExternalDepende
|
|
|
125
119
|
}
|
|
126
120
|
}
|
|
127
121
|
}
|
|
122
|
+
|
|
123
|
+
// Dependencies are inferred from the return type of resolveDependencies()
|
|
124
|
+
export type ModuleDependencies = InferModuleDependencies<MyModule>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The `InferModuleDependencies` utility type extracts the dependency types from the resolvers returned by `resolveDependencies()`, so you don't need to maintain a separate type manually.
|
|
128
|
+
|
|
129
|
+
When a module is used as a secondary module, only resolvers marked as **public** (`asServiceClass`, `asUseCaseClass`, `asJobQueueClass`, `asEnqueuedJobQueueManagerFunction`) are exposed. Use `InferPublicModuleDependencies` to infer only the public dependencies (private ones are omitted entirely):
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
// Inferred as { service: Service } — private resolvers are omitted
|
|
133
|
+
export type MyModulePublicDependencies = InferPublicModuleDependencies<MyModule>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Managing global public dependencies across modules
|
|
137
|
+
|
|
138
|
+
When your application has multiple secondary modules, you need a single type that combines all their public dependencies. The library exports an empty `PublicDependencies` interface that each module can augment via TypeScript's [module augmentation](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation). Each module file adds its own public deps to this shared interface using `declare module`. The augmentations are **project-wide** — they apply everywhere as long as the augmenting file is part of your TypeScript compilation (included in `tsconfig.json`), with no explicit import chain required.
|
|
139
|
+
|
|
140
|
+
Start with a `CommonModule` that provides shared infrastructure dependencies (logger, config, etc.), then add domain modules that each augment the same interface independently.
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
// CommonModule.ts — shared infrastructure
|
|
144
|
+
import { AbstractModule, type InferPublicModuleDependencies } from 'opinionated-machine'
|
|
145
|
+
|
|
146
|
+
export class CommonModule extends AbstractModule {
|
|
147
|
+
resolveDependencies(diOptions: DependencyInjectionOptions) {
|
|
148
|
+
return {
|
|
149
|
+
config: asSingletonFunction(() => loadConfig()), // private — omitted
|
|
150
|
+
logger: asServiceClass(Logger), // public
|
|
151
|
+
eventEmitter: asServiceClass(AppEventEmitter), // public
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
declare module 'opinionated-machine' {
|
|
157
|
+
interface PublicDependencies extends InferPublicModuleDependencies<CommonModule> {}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
// UsersModule.ts — no need to import CommonModule's type
|
|
163
|
+
import { AbstractModule, type InferPublicModuleDependencies } from 'opinionated-machine'
|
|
164
|
+
|
|
165
|
+
export class UsersModule extends AbstractModule {
|
|
166
|
+
resolveDependencies(diOptions: DependencyInjectionOptions) {
|
|
167
|
+
return {
|
|
168
|
+
userService: asServiceClass(UserService), // public
|
|
169
|
+
userRepository: asRepositoryClass(UserRepository), // private — omitted
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
declare module 'opinionated-machine' {
|
|
175
|
+
interface PublicDependencies extends InferPublicModuleDependencies<UsersModule> {}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
// BillingModule.ts — independent, no chain
|
|
181
|
+
import { AbstractModule, type InferPublicModuleDependencies } from 'opinionated-machine'
|
|
182
|
+
|
|
183
|
+
export class BillingModule extends AbstractModule {
|
|
184
|
+
resolveDependencies(diOptions: DependencyInjectionOptions) {
|
|
185
|
+
return {
|
|
186
|
+
billingService: asServiceClass(BillingService), // public
|
|
187
|
+
paymentGateway: asRepositoryClass(PaymentGateway), // private — omitted
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
declare module 'opinionated-machine' {
|
|
193
|
+
interface PublicDependencies extends InferPublicModuleDependencies<BillingModule> {}
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Importing `PublicDependencies` from anywhere gives you the full accumulated type: `{ logger: Logger; eventEmitter: AppEventEmitter; userService: UserService; billingService: BillingService }`. Private dependencies (`config`, `userRepository`, `paymentGateway`) are omitted automatically. No explicit import chain between modules is needed — each module augments the interface independently.
|
|
198
|
+
|
|
199
|
+
#### Typing constructor dependencies within a module
|
|
200
|
+
|
|
201
|
+
Classes within a module can access both the module's own dependencies (including private ones like repositories) and all public dependencies from other modules. Combine `InferModuleDependencies` with `PublicDependencies` to get the full cradle type available at runtime:
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
// UsersModule.ts
|
|
205
|
+
import {
|
|
206
|
+
AbstractModule,
|
|
207
|
+
type InferModuleDependencies,
|
|
208
|
+
type InferPublicModuleDependencies,
|
|
209
|
+
type PublicDependencies,
|
|
210
|
+
} from 'opinionated-machine'
|
|
211
|
+
|
|
212
|
+
// Module's own deps (public + private) merged with all public deps from other modules
|
|
213
|
+
type UsersModuleInjectables = InferModuleDependencies<UsersModule> & PublicDependencies
|
|
214
|
+
|
|
215
|
+
export class UserService {
|
|
216
|
+
private readonly repository: UserRepository
|
|
217
|
+
private readonly logger: Logger // from CommonModule's public deps
|
|
218
|
+
|
|
219
|
+
constructor(dependencies: UsersModuleInjectables) {
|
|
220
|
+
this.repository = dependencies.userRepository // own private dep — accessible
|
|
221
|
+
this.logger = dependencies.logger // public dep from another module — accessible
|
|
222
|
+
// dependencies.billingRepository // private dep from another module — type error
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
class UserRepository {}
|
|
227
|
+
|
|
228
|
+
export class UsersModule extends AbstractModule {
|
|
229
|
+
resolveDependencies(diOptions: DependencyInjectionOptions) {
|
|
230
|
+
return {
|
|
231
|
+
userService: asServiceClass(UserService),
|
|
232
|
+
userRepository: asRepositoryClass(UserRepository),
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
declare module 'opinionated-machine' {
|
|
238
|
+
interface PublicDependencies extends InferPublicModuleDependencies<UsersModule> {}
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
This gives each class access to exactly what the DI container provides at runtime: the module's own registered dependencies plus all public dependencies from secondary modules. Private dependencies from other modules are excluded at the type level, matching the runtime behavior.
|
|
243
|
+
|
|
244
|
+
#### Constructing the combined dependency type for `DIContext`
|
|
245
|
+
|
|
246
|
+
Use `PublicDependencies` when building the full dependency type:
|
|
247
|
+
|
|
248
|
+
```ts
|
|
249
|
+
import type { PublicDependencies } from 'opinionated-machine'
|
|
250
|
+
|
|
251
|
+
type Dependencies = InferModuleDependencies<PrimaryModule> & PublicDependencies
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Avoiding circular dependencies in typed cradle parameters
|
|
255
|
+
|
|
256
|
+
Because `InferModuleDependencies` is inferred from the module's own `resolveDependencies()` return type, classes and functions that reference it inside the same module could create a circular type dependency. The library handles this automatically for class-based resolvers. For function-based resolvers, use the indexed access pattern described below.
|
|
257
|
+
|
|
258
|
+
#### Class-based resolvers (recommended — works automatically)
|
|
259
|
+
|
|
260
|
+
All class-based resolver functions (`asSingletonClass`, `asServiceClass`, `asRepositoryClass`, etc.) use a `ClassValue<T>` type internally, which infers the instance type from the class's `prototype` property rather than its constructor signature. This means classes can freely reference `InferModuleDependencies` in their constructors without causing circular type dependencies:
|
|
261
|
+
|
|
262
|
+
```ts
|
|
263
|
+
import { AbstractModule, type InferModuleDependencies, asServiceClass, asSingletonClass } from 'opinionated-machine'
|
|
264
|
+
|
|
265
|
+
export class MyService {
|
|
266
|
+
// Constructor references ModuleDependencies — no circular dependency!
|
|
267
|
+
constructor({ myHelper }: ModuleDependencies) {
|
|
268
|
+
// myHelper is fully typed as MyHelper
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export class MyHelper {
|
|
273
|
+
process() {}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export class MyModule extends AbstractModule {
|
|
277
|
+
resolveDependencies(diOptions: DependencyInjectionOptions) {
|
|
278
|
+
return {
|
|
279
|
+
myService: asServiceClass(MyService), // ClassValue<T> breaks the cycle
|
|
280
|
+
myHelper: asSingletonClass(MyHelper),
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export type ModuleDependencies = InferModuleDependencies<MyModule>
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Prefer class-based resolvers wherever possible** — they provide full type safety with no `any` fallback and no extra annotations needed.
|
|
289
|
+
|
|
290
|
+
#### Function-based resolvers (`asSingletonFunction`)
|
|
291
|
+
|
|
292
|
+
Function-based resolvers (`asSingletonFunction`) cannot use the `ClassValue<T>` trick because functions don't have a `prototype` property that separates return type from parameter types. Use **indexed access** on `InferModuleDependencies` to type individual dependencies without triggering a circular reference:
|
|
293
|
+
|
|
294
|
+
```ts
|
|
295
|
+
// Inside resolveDependencies():
|
|
296
|
+
myHelper: asSingletonClass(MyHelper),
|
|
297
|
+
myService: asServiceClass(MyService),
|
|
298
|
+
|
|
299
|
+
myFactory: asSingletonFunction(
|
|
300
|
+
({ myHelper, myService }: {
|
|
301
|
+
myHelper: ModuleDependencies['myHelper']
|
|
302
|
+
myService: ModuleDependencies['myService']
|
|
303
|
+
}) => {
|
|
304
|
+
return () => myHelper.process()
|
|
305
|
+
},
|
|
306
|
+
),
|
|
307
|
+
|
|
308
|
+
// ...
|
|
309
|
+
|
|
310
|
+
// At the bottom of the file:
|
|
311
|
+
export type ModuleDependencies = InferModuleDependencies<MyModule>
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
This works because TypeScript resolves indexed access types (`ModuleDependencies['myHelper']`) **lazily** — it looks up individual properties without computing the entire `ModuleDependencies` type, avoiding the cycle. Each dependency is fully typed and stays in sync with the module's resolvers automatically. No explicit return type annotation is needed.
|
|
315
|
+
|
|
316
|
+
For cross-module dependencies, use `InferPublicModuleDependencies`:
|
|
317
|
+
|
|
318
|
+
```ts
|
|
319
|
+
type OtherDeps = InferPublicModuleDependencies<OtherModule>
|
|
320
|
+
|
|
321
|
+
myFactory: asSingletonFunction(
|
|
322
|
+
({ externalService }: { externalService: OtherDeps['externalService'] }) => {
|
|
323
|
+
return new MyFactory(externalService)
|
|
324
|
+
},
|
|
325
|
+
),
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
**Note:** `Pick<ModuleDependencies, 'a' | 'b'>` does **not** work — `Pick` requires `keyof ModuleDependencies`, which forces TypeScript to resolve the entire type and triggers the circular reference. Each property must be accessed individually via indexed access.
|
|
329
|
+
|
|
330
|
+
**Alternative: class wrapper**
|
|
331
|
+
|
|
332
|
+
When adapting a third-party class with an incompatible constructor, `asSingletonFunction` is typically used to bridge the gap between the DI cradle and the library's API. If the adapter needs many dependencies, the indexed access syntax can become verbose. In that case, wrap the adaptation logic in a class and use `asSingletonClass` instead — the constructor can reference `ModuleDependencies` directly since `ClassValue<T>` breaks the cycle automatically:
|
|
333
|
+
|
|
334
|
+
```ts
|
|
335
|
+
// Third-party library — constructor is incompatible with DI cradle
|
|
336
|
+
import { S3Client } from '@aws-sdk/client-s3'
|
|
337
|
+
|
|
338
|
+
// With asSingletonFunction, each dep needs indexed access:
|
|
339
|
+
s3Client: asSingletonFunction(
|
|
340
|
+
({ config, logger }: {
|
|
341
|
+
config: ModuleDependencies['config']
|
|
342
|
+
logger: ModuleDependencies['logger']
|
|
343
|
+
}) => {
|
|
344
|
+
return new S3Client({
|
|
345
|
+
region: config.awsRegion,
|
|
346
|
+
credentials: { accessKeyId: config.awsAccessKey, secretAccessKey: config.awsSecretKey },
|
|
347
|
+
logger,
|
|
348
|
+
})
|
|
349
|
+
},
|
|
350
|
+
),
|
|
351
|
+
|
|
352
|
+
// With a class wrapper, reference ModuleDependencies directly.
|
|
353
|
+
// If you need to add domain-specific methods, the wrapper becomes a full adapter:
|
|
354
|
+
class S3StorageAdapter {
|
|
355
|
+
private readonly client: S3Client
|
|
356
|
+
|
|
357
|
+
constructor({ config, logger }: ModuleDependencies) {
|
|
358
|
+
this.client = new S3Client({
|
|
359
|
+
region: config.awsRegion,
|
|
360
|
+
credentials: { accessKeyId: config.awsAccessKey, secretAccessKey: config.awsSecretKey },
|
|
361
|
+
logger,
|
|
362
|
+
})
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
async upload(bucket: string, key: string, body: Buffer): Promise<string> {
|
|
366
|
+
await this.client.send(new PutObjectCommand({ Bucket: bucket, Key: key, Body: body }))
|
|
367
|
+
return `https://${bucket}.s3.amazonaws.com/${key}`
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// In resolveDependencies():
|
|
372
|
+
s3StorageAdapter: asSingletonClass(S3StorageAdapter),
|
|
373
|
+
|
|
374
|
+
// If you just need the third-party instance as-is without adding any logic,
|
|
375
|
+
// use a simple container to avoid re-wrapping every method:
|
|
376
|
+
class S3ClientProvider {
|
|
377
|
+
readonly client: S3Client
|
|
378
|
+
|
|
379
|
+
constructor({ config, logger }: ModuleDependencies) {
|
|
380
|
+
this.client = new S3Client({
|
|
381
|
+
region: config.awsRegion,
|
|
382
|
+
credentials: { accessKeyId: config.awsAccessKey, secretAccessKey: config.awsSecretKey },
|
|
383
|
+
logger,
|
|
384
|
+
})
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// In resolveDependencies():
|
|
389
|
+
s3ClientProvider: asSingletonClass(S3ClientProvider),
|
|
390
|
+
|
|
391
|
+
// Consumers access the original instance directly:
|
|
392
|
+
// this.s3ClientProvider.client.send(new PutObjectCommand({ ... }))
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
This is more heavyweight than a function resolver but provides full type safety with no indexed access needed, and scales cleanly to any number of dependencies.
|
|
396
|
+
|
|
397
|
+
You can also use the explicit generic pattern if you prefer (e.g. for `isolatedDeclarations` mode):
|
|
398
|
+
|
|
399
|
+
```ts
|
|
400
|
+
export type ModuleDependencies = {
|
|
401
|
+
service: Service
|
|
402
|
+
messageQueueConsumer: MessageQueueConsumer
|
|
403
|
+
jobWorker: JobWorker
|
|
404
|
+
queueManager: QueueManager
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export class MyModule extends AbstractModule<ModuleDependencies, ExternalDependencies> {
|
|
408
|
+
resolveDependencies(
|
|
409
|
+
diOptions: DependencyInjectionOptions,
|
|
410
|
+
_externalDependencies: ExternalDependencies,
|
|
411
|
+
): MandatoryNameAndRegistrationPair<ModuleDependencies> {
|
|
412
|
+
return { /* ... */ }
|
|
413
|
+
}
|
|
414
|
+
}
|
|
128
415
|
```
|
|
129
416
|
|
|
130
417
|
## Defining controllers
|
|
@@ -633,9 +920,9 @@ export class SimpleSSEController extends AbstractSSEController<Contracts> {
|
|
|
633
920
|
Use `asSSEControllerClass` in your module's `resolveControllers` method alongside REST controllers. SSE controllers are automatically detected via the `isSSEController` flag and registered in the DI container:
|
|
634
921
|
|
|
635
922
|
```ts
|
|
636
|
-
import { AbstractModule, asControllerClass, asSSEControllerClass, asServiceClass, type DependencyInjectionOptions } from 'opinionated-machine'
|
|
923
|
+
import { AbstractModule, type InferModuleDependencies, asControllerClass, asSSEControllerClass, asServiceClass, type DependencyInjectionOptions } from 'opinionated-machine'
|
|
637
924
|
|
|
638
|
-
export class NotificationsModule extends AbstractModule
|
|
925
|
+
export class NotificationsModule extends AbstractModule {
|
|
639
926
|
resolveDependencies() {
|
|
640
927
|
return {
|
|
641
928
|
notificationService: asServiceClass(NotificationService),
|
|
@@ -651,6 +938,8 @@ export class NotificationsModule extends AbstractModule<Dependencies> {
|
|
|
651
938
|
}
|
|
652
939
|
}
|
|
653
940
|
}
|
|
941
|
+
|
|
942
|
+
export type NotificationsModuleDependencies = InferModuleDependencies<NotificationsModule>
|
|
654
943
|
```
|
|
655
944
|
|
|
656
945
|
### Registering SSE Routes
|
|
@@ -1723,12 +2012,13 @@ Use `asDualModeControllerClass` in your module:
|
|
|
1723
2012
|
```ts
|
|
1724
2013
|
import {
|
|
1725
2014
|
AbstractModule,
|
|
2015
|
+
type InferModuleDependencies,
|
|
1726
2016
|
asControllerClass,
|
|
1727
2017
|
asDualModeControllerClass,
|
|
1728
2018
|
asServiceClass,
|
|
1729
2019
|
} from 'opinionated-machine'
|
|
1730
2020
|
|
|
1731
|
-
export class ChatModule extends AbstractModule
|
|
2021
|
+
export class ChatModule extends AbstractModule {
|
|
1732
2022
|
resolveDependencies() {
|
|
1733
2023
|
return {
|
|
1734
2024
|
aiService: asServiceClass(AIService),
|
|
@@ -1744,6 +2034,8 @@ export class ChatModule extends AbstractModule<Dependencies> {
|
|
|
1744
2034
|
}
|
|
1745
2035
|
}
|
|
1746
2036
|
}
|
|
2037
|
+
|
|
2038
|
+
export type ChatModuleDependencies = InferModuleDependencies<ChatModule>
|
|
1747
2039
|
```
|
|
1748
2040
|
|
|
1749
2041
|
Register dual-mode routes after the `@fastify/sse` plugin:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { AbstractController, type BuildRoutesReturnType } from './lib/AbstractController.js';
|
|
2
|
-
export { AbstractModule, type MandatoryNameAndRegistrationPair, type
|
|
2
|
+
export { AbstractModule, type InferModuleDependencies, type InferPublicModuleDependencies, type MandatoryNameAndRegistrationPair, type PublicDependencies, } from './lib/AbstractModule.js';
|
|
3
3
|
export { AbstractTestContextFactory, type CreateTestContextParams, } from './lib/AbstractTestContextFactory.js';
|
|
4
4
|
export type { NestedPartial } from './lib/configUtils.js';
|
|
5
5
|
export { type DependencyInjectionOptions, DIContext, type RegisterDependenciesParams, } from './lib/DIContext.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA8B,MAAM,6BAA6B,CAAA;AAC5F,OAAO,EACL,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA8B,MAAM,6BAA6B,CAAA;AAC5F,OAAO,EACL,cAAc,GAKf,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,0BAA0B,GAE3B,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EAEL,SAAS,GAEV,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,UAAU,EACV,gCAAgC,EAChC,2BAA2B,EAC3B,iBAAiB,EACjB,6BAA6B,EAC7B,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,wBAAwB,CAAA;AAC/B,yBAAyB;AACzB,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,iCAAiC;AACjC,cAAc,uBAAuB,CAAA;AACrC,MAAM;AACN,cAAc,oBAAoB,CAAA;AAClC,wBAAwB;AACxB,cAAc,wBAAwB,CAAA"}
|
|
@@ -4,10 +4,80 @@ export type MandatoryNameAndRegistrationPair<T> = {
|
|
|
4
4
|
[U in keyof T]: Resolver<T[U]>;
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Infers the module's dependency types from the return type of `resolveDependencies()`.
|
|
8
|
+
*
|
|
9
|
+
* This eliminates the need to manually define a `ModuleDependencies` type that duplicates
|
|
10
|
+
* information already present in the resolver return value.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* export class MyModule extends AbstractModule {
|
|
15
|
+
* resolveDependencies(diOptions: DependencyInjectionOptions) {
|
|
16
|
+
* return {
|
|
17
|
+
* myService: asServiceClass(MyService),
|
|
18
|
+
* myRepo: asRepositoryClass(MyRepository),
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* // Inferred as { myService: MyService; myRepo: MyRepository }
|
|
24
|
+
* export type MyModuleDependencies = InferModuleDependencies<MyModule>
|
|
25
|
+
* ```
|
|
8
26
|
*/
|
|
9
|
-
export type
|
|
10
|
-
|
|
27
|
+
export type InferModuleDependencies<M extends AbstractModule> = ReturnType<M['resolveDependencies']> extends infer R ? {
|
|
28
|
+
[K in keyof R]: R[K] extends Resolver<infer T> ? T : never;
|
|
29
|
+
} : never;
|
|
30
|
+
/**
|
|
31
|
+
* Infers only the **public** dependency types from the return type of `resolveDependencies()`,
|
|
32
|
+
* omitting non-public dependencies entirely.
|
|
33
|
+
*
|
|
34
|
+
* When a module is used as a secondary module, only resolvers marked with `public: true`
|
|
35
|
+
* (i.e. those created via `asServiceClass`, `asUseCaseClass`, `asJobQueueClass`, or
|
|
36
|
+
* `asEnqueuedJobQueueManagerFunction`) are exposed. Non-public resolvers are filtered out.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* export class MyModule extends AbstractModule {
|
|
41
|
+
* resolveDependencies(diOptions: DependencyInjectionOptions) {
|
|
42
|
+
* return {
|
|
43
|
+
* myService: asServiceClass(MyService), // public → MyService
|
|
44
|
+
* myRepo: asRepositoryClass(MyRepository), // private → omitted
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
*
|
|
49
|
+
* // Inferred as { myService: MyService }
|
|
50
|
+
* export type MyModulePublicDependencies = InferPublicModuleDependencies<MyModule>
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export type InferPublicModuleDependencies<M extends AbstractModule> = ReturnType<M['resolveDependencies']> extends infer R ? {
|
|
54
|
+
[K in keyof R as R[K] extends {
|
|
55
|
+
readonly __publicResolver: true;
|
|
56
|
+
} ? K : never]: R[K] extends Resolver<infer T> ? T : never;
|
|
57
|
+
} : never;
|
|
58
|
+
/**
|
|
59
|
+
* Augmentation target for accumulating public dependencies across modules.
|
|
60
|
+
*
|
|
61
|
+
* Each module augments this interface via `declare module` to register its
|
|
62
|
+
* public dependencies. The augmentations are project-wide — they apply
|
|
63
|
+
* everywhere as long as the augmenting file is part of the TypeScript
|
|
64
|
+
* compilation, with no explicit import chain required.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* // In your module file:
|
|
69
|
+
* declare module 'opinionated-machine' {
|
|
70
|
+
* interface PublicDependencies extends InferPublicModuleDependencies<MyModule> {}
|
|
71
|
+
* }
|
|
72
|
+
*
|
|
73
|
+
* // In any consumer file:
|
|
74
|
+
* import type { PublicDependencies } from 'opinionated-machine'
|
|
75
|
+
* // PublicDependencies contains all augmented public deps
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export interface PublicDependencies {
|
|
79
|
+
}
|
|
80
|
+
export declare abstract class AbstractModule<ModuleDependencies = unknown, ExternalDependencies = never> {
|
|
11
81
|
abstract resolveDependencies(diOptions: DependencyInjectionOptions, externalDependencies: ExternalDependencies): MandatoryNameAndRegistrationPair<ModuleDependencies>;
|
|
12
82
|
/**
|
|
13
83
|
* Override to register REST and SSE controllers.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractModule.js","sourceRoot":"","sources":["../../lib/AbstractModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AbstractModule.js","sourceRoot":"","sources":["../../lib/AbstractModule.ts"],"names":[],"mappings":"AAwFA,MAAM,OAAgB,cAAc;IAMlC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACI,kBAAkB,CACvB,UAAsC;QAEtC,OAAO,EAAE,CAAA;IACX,CAAC;CACF"}
|
|
@@ -14,7 +14,7 @@ export declare abstract class AbstractTestContextFactory<Dependencies extends ob
|
|
|
14
14
|
private readonly externalDependencies;
|
|
15
15
|
protected configDependencyId: string;
|
|
16
16
|
private readonly allModules;
|
|
17
|
-
constructor(externalDependencies: ExternalDependencies, allModules: readonly AbstractModule<unknown>[], diContainer?: AwilixContainer);
|
|
17
|
+
constructor(externalDependencies: ExternalDependencies, allModules: readonly AbstractModule<unknown>[], diContainer?: AwilixContainer<Dependencies>);
|
|
18
18
|
resetExternalDependencies(): void;
|
|
19
19
|
abstract resolveBaseAppConfig(): Config;
|
|
20
20
|
createTestContext(params?: CreateTestContextParams<Dependencies, Config>): Promise<DIContext<Dependencies, Config, ExternalDependencies>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractTestContextFactory.js","sourceRoot":"","sources":["../../lib/AbstractTestContextFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,eAAe,EAAgC,MAAM,QAAQ,CAAA;AAG5F,OAAO,EAAmC,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAU3E,MAAM,OAAgB,0BAA0B;IAKvC,WAAW,CAA+B;IAChC,oBAAoB,CAAsB;IACjD,kBAAkB,GAAG,QAAQ,CAAA,CAAC,oCAAoC;IAC3D,UAAU,CAAoC;IAE/D,YACE,oBAA0C,EAC1C,UAA8C,EAC9C,
|
|
1
|
+
{"version":3,"file":"AbstractTestContextFactory.js","sourceRoot":"","sources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 export declare class DIContext<Dependencies extends object, Config extends objec
|
|
|
32
32
|
private readonly sseControllerNames;
|
|
33
33
|
private readonly dualModeControllerNames;
|
|
34
34
|
private readonly appConfig;
|
|
35
|
-
constructor(diContainer: AwilixContainer
|
|
35
|
+
constructor(diContainer: AwilixContainer<Dependencies>, options: DependencyInjectionOptions, appConfig: Config, awilixManager?: AwilixManager);
|
|
36
36
|
private registerModule;
|
|
37
37
|
registerDependencies(params: RegisterDependenciesParams<Dependencies, Config, ExternalDependencies>, externalDependencies: ExternalDependencies, resolveControllers?: boolean): void;
|
|
38
38
|
registerRoutes(app: FastifyInstance<any, any, any, any>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../lib/DIContext.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE9C,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAGpC,OAAO,EAAE,iCAAiC,EAAsB,MAAM,kBAAkB,CAAA;AAGxF,OAAO,EACL,iBAAiB,GAGlB,MAAM,mBAAmB,CAAA;AAwB1B,MAAM,OAAO,SAAS;IAKH,OAAO,CAA4B;IACpC,aAAa,CAAe;IAC5B,WAAW,CAA+B;IAC1D,8EAA8E;IAC7D,mBAAmB,CAAiB;IACrD,mFAAmF;IAClE,kBAAkB,CAAU;IAC7C,yFAAyF;IACxE,uBAAuB,CAAU;IACjC,SAAS,CAAQ;IAElC,YACE,
|
|
1
|
+
{"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../lib/DIContext.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE9C,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAGpC,OAAO,EAAE,iCAAiC,EAAsB,MAAM,kBAAkB,CAAA;AAGxF,OAAO,EACL,iBAAiB,GAGlB,MAAM,mBAAmB,CAAA;AAwB1B,MAA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;YAClB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAA;QACtB,KAAK,CAAC,UAAU,GAAG,CAAC,GAAG,cAAc,EAAE,GAAG,QAAQ,CAAC,CAAA;IACrD,CAAC;IAEO,cAAc,CACpB,KAAmB,EACnB,SAA6D;QAE7D,2EAA2E;QAC3E,MAAM,eAAe,GAAG,KAAwC,CAAA;QAChE,eAAe,CAAC,MAAM,GAAG;YACvB,GAAG,CAAC,eAAe,CAAC,MAAM,IAAI,EAAE,CAAC;YACjC,SAAS;SACV,CAAA;IACH,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAA;QACzC,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;IAClC,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAA;IACxC,CAAC;CACF"}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
import type { BuildResolver, BuildResolverOptions,
|
|
1
|
+
import type { BuildResolver, BuildResolverOptions, DisposableResolver } from 'awilix';
|
|
2
2
|
import type { FunctionReturning } from 'awilix/lib/container';
|
|
3
3
|
import type { DependencyInjectionOptions } from './DIContext.js';
|
|
4
|
+
/**
|
|
5
|
+
* Type-level representation of a class value that infers the instance type
|
|
6
|
+
* from the `prototype` property rather than from the constructor signature.
|
|
7
|
+
*
|
|
8
|
+
* This breaks circular type dependencies that occur when a class constructor
|
|
9
|
+
* references a type derived from the module's own resolver return type
|
|
10
|
+
* (e.g. `InferModuleDependencies`), because TypeScript can resolve the
|
|
11
|
+
* instance type (prototype) without evaluating constructor parameter types.
|
|
12
|
+
*
|
|
13
|
+
* Constructor parameter types are still fully checked — the cycle is only
|
|
14
|
+
* broken at the resolver inference level.
|
|
15
|
+
*/
|
|
16
|
+
type ClassValue<T> = {
|
|
17
|
+
prototype: T;
|
|
18
|
+
};
|
|
4
19
|
declare module 'awilix' {
|
|
5
20
|
interface ResolverOptions<T> {
|
|
6
21
|
public?: boolean;
|
|
@@ -8,10 +23,16 @@ declare module 'awilix' {
|
|
|
8
23
|
isDualModeController?: boolean;
|
|
9
24
|
}
|
|
10
25
|
}
|
|
26
|
+
export type PublicResolver<T> = BuildResolver<T> & DisposableResolver<T> & {
|
|
27
|
+
readonly __publicResolver: true;
|
|
28
|
+
};
|
|
11
29
|
export interface EnqueuedJobQueueManager {
|
|
12
30
|
start(enabled?: string[] | boolean): Promise<void>;
|
|
13
31
|
}
|
|
14
|
-
export declare function asSingletonClass<T = object>(Type:
|
|
32
|
+
export declare function asSingletonClass<T = object>(Type: ClassValue<T>, opts: BuildResolverOptions<T> & {
|
|
33
|
+
public: true;
|
|
34
|
+
}): PublicResolver<T>;
|
|
35
|
+
export declare function asSingletonClass<T = object>(Type: ClassValue<T>, opts?: BuildResolverOptions<T>): BuildResolver<T> & DisposableResolver<T>;
|
|
15
36
|
/**
|
|
16
37
|
* Register a class with an additional config parameter passed to the constructor.
|
|
17
38
|
* Uses asFunction wrapper internally to pass the config as a second parameter.
|
|
@@ -22,12 +43,21 @@ export declare function asSingletonClass<T = object>(Type: Constructor<T>, opts?
|
|
|
22
43
|
* myService: asClassWithConfig(MyService, { enableFeature: true }),
|
|
23
44
|
* ```
|
|
24
45
|
*/
|
|
25
|
-
export declare function asClassWithConfig<T = object, Config = unknown>(Type:
|
|
46
|
+
export declare function asClassWithConfig<T = object, Config = unknown>(Type: ClassValue<T>, config: Config, opts?: BuildResolverOptions<T>): BuildResolver<T> & DisposableResolver<T>;
|
|
47
|
+
export declare function asSingletonFunction<T>(fn: FunctionReturning<T>, opts: BuildResolverOptions<T> & {
|
|
48
|
+
public: true;
|
|
49
|
+
}): PublicResolver<T>;
|
|
26
50
|
export declare function asSingletonFunction<T>(fn: FunctionReturning<T>, opts?: BuildResolverOptions<T>): BuildResolver<T> & DisposableResolver<T>;
|
|
27
|
-
export declare function asServiceClass<T = object>(Type:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export declare function
|
|
51
|
+
export declare function asServiceClass<T = object>(Type: ClassValue<T>, opts: BuildResolverOptions<T> & {
|
|
52
|
+
public: false;
|
|
53
|
+
}): BuildResolver<T> & DisposableResolver<T>;
|
|
54
|
+
export declare function asServiceClass<T = object>(Type: ClassValue<T>, opts?: BuildResolverOptions<T>): PublicResolver<T>;
|
|
55
|
+
export declare function asUseCaseClass<T = object>(Type: ClassValue<T>, opts: BuildResolverOptions<T> & {
|
|
56
|
+
public: false;
|
|
57
|
+
}): BuildResolver<T> & DisposableResolver<T>;
|
|
58
|
+
export declare function asUseCaseClass<T = object>(Type: ClassValue<T>, opts?: BuildResolverOptions<T>): PublicResolver<T>;
|
|
59
|
+
export declare function asRepositoryClass<T = object>(Type: ClassValue<T>, opts?: BuildResolverOptions<T>): BuildResolver<T> & DisposableResolver<T>;
|
|
60
|
+
export declare function asControllerClass<T = object>(Type: ClassValue<T>, opts?: BuildResolverOptions<T>): BuildResolver<T> & DisposableResolver<T>;
|
|
31
61
|
export type SSEControllerModuleOptions = {
|
|
32
62
|
diOptions: DependencyInjectionOptions;
|
|
33
63
|
};
|
|
@@ -49,7 +79,7 @@ export type SSEControllerModuleOptions = {
|
|
|
49
79
|
* notificationsSSEController: asSSEControllerClass(NotificationsSSEController, { diOptions }),
|
|
50
80
|
* ```
|
|
51
81
|
*/
|
|
52
|
-
export declare function asSSEControllerClass<T = object>(Type:
|
|
82
|
+
export declare function asSSEControllerClass<T = object>(Type: ClassValue<T>, sseOptions?: SSEControllerModuleOptions, opts?: BuildResolverOptions<T>): BuildResolver<T> & DisposableResolver<T>;
|
|
53
83
|
export type DualModeControllerModuleOptions = {
|
|
54
84
|
diOptions: DependencyInjectionOptions;
|
|
55
85
|
};
|
|
@@ -72,17 +102,17 @@ export type DualModeControllerModuleOptions = {
|
|
|
72
102
|
* chatController: asDualModeControllerClass(ChatController, { diOptions }),
|
|
73
103
|
* ```
|
|
74
104
|
*/
|
|
75
|
-
export declare function asDualModeControllerClass<T = object>(Type:
|
|
105
|
+
export declare function asDualModeControllerClass<T = object>(Type: ClassValue<T>, dualModeOptions?: DualModeControllerModuleOptions, opts?: BuildResolverOptions<T>): BuildResolver<T> & DisposableResolver<T>;
|
|
76
106
|
export type MessageQueueConsumerModuleOptions = {
|
|
77
107
|
queueName: string;
|
|
78
108
|
diOptions: DependencyInjectionOptions;
|
|
79
109
|
};
|
|
80
|
-
export declare function asMessageQueueHandlerClass<T = object>(Type:
|
|
110
|
+
export declare function asMessageQueueHandlerClass<T = object>(Type: ClassValue<T>, mqOptions: MessageQueueConsumerModuleOptions, opts?: BuildResolverOptions<T>): BuildResolver<T> & DisposableResolver<T>;
|
|
81
111
|
export type EnqueuedJobWorkerModuleOptions = {
|
|
82
112
|
queueName: string;
|
|
83
113
|
diOptions: DependencyInjectionOptions;
|
|
84
114
|
};
|
|
85
|
-
export declare function asEnqueuedJobWorkerClass<T = object>(Type:
|
|
115
|
+
export declare function asEnqueuedJobWorkerClass<T = object>(Type: ClassValue<T>, workerOptions: EnqueuedJobWorkerModuleOptions, opts?: BuildResolverOptions<T>): BuildResolver<T> & DisposableResolver<T>;
|
|
86
116
|
/**
|
|
87
117
|
* Helper function to register a pg-boss job processor class with the DI container.
|
|
88
118
|
* Handles asyncInit/asyncDispose lifecycle and enabled check based on diOptions.
|
|
@@ -98,15 +128,22 @@ export declare function asEnqueuedJobWorkerClass<T = object>(Type: Constructor<T
|
|
|
98
128
|
export declare function asPgBossProcessorClass<T extends {
|
|
99
129
|
start(): Promise<void>;
|
|
100
130
|
stop(): Promise<void>;
|
|
101
|
-
}>(Type:
|
|
131
|
+
}>(Type: ClassValue<T>, processorOptions: EnqueuedJobWorkerModuleOptions, opts?: BuildResolverOptions<T>): BuildResolver<T> & DisposableResolver<T>;
|
|
102
132
|
export type PeriodicJobOptions = {
|
|
103
133
|
jobName: string;
|
|
104
134
|
diOptions: DependencyInjectionOptions;
|
|
105
135
|
};
|
|
106
|
-
export declare function asPeriodicJobClass<T = object>(Type:
|
|
136
|
+
export declare function asPeriodicJobClass<T = object>(Type: ClassValue<T>, workerOptions: PeriodicJobOptions, opts?: BuildResolverOptions<T>): BuildResolver<T> & DisposableResolver<T>;
|
|
107
137
|
export type JobQueueModuleOptions = {
|
|
108
138
|
queueName?: string;
|
|
109
139
|
diOptions: DependencyInjectionOptions;
|
|
110
140
|
};
|
|
111
|
-
export declare function asJobQueueClass<T = object>(Type:
|
|
112
|
-
|
|
141
|
+
export declare function asJobQueueClass<T = object>(Type: ClassValue<T>, queueOptions: JobQueueModuleOptions, opts: BuildResolverOptions<T> & {
|
|
142
|
+
public: false;
|
|
143
|
+
}): BuildResolver<T> & DisposableResolver<T>;
|
|
144
|
+
export declare function asJobQueueClass<T = object>(Type: ClassValue<T>, queueOptions: JobQueueModuleOptions, opts?: BuildResolverOptions<T>): PublicResolver<T>;
|
|
145
|
+
export declare function asEnqueuedJobQueueManagerFunction<T extends EnqueuedJobQueueManager>(fn: FunctionReturning<T>, diOptions: DependencyInjectionOptions, opts: BuildResolverOptions<T> & {
|
|
146
|
+
public: false;
|
|
147
|
+
}): BuildResolver<T> & DisposableResolver<T>;
|
|
148
|
+
export declare function asEnqueuedJobQueueManagerFunction<T extends EnqueuedJobQueueManager>(fn: FunctionReturning<T>, diOptions: DependencyInjectionOptions, opts?: BuildResolverOptions<T>): PublicResolver<T>;
|
|
149
|
+
export {};
|
|
@@ -17,8 +17,9 @@ export function asSingletonClass(Type, opts) {
|
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
export function asClassWithConfig(Type, config, opts) {
|
|
20
|
+
const Ctor = Type;
|
|
20
21
|
// biome-ignore lint/suspicious/noExplicitAny: Dynamic constructor invocation with cradle proxy
|
|
21
|
-
return asFunction((cradle) => new
|
|
22
|
+
return asFunction((cradle) => new Ctor(cradle, config), {
|
|
22
23
|
...opts,
|
|
23
24
|
lifetime: opts?.lifetime ?? 'SINGLETON',
|
|
24
25
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolverFunctions.js","sourceRoot":"","sources":["../../lib/resolverFunctions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAG5C,OAAO,EACL,2BAA2B,EAC3B,iBAAiB,EACjB,6BAA6B,EAC7B,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"resolverFunctions.js","sourceRoot":"","sources":["../../lib/resolverFunctions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAG5C,OAAO,EACL,2BAA2B,EAC3B,iBAAiB,EACjB,6BAA6B,EAC7B,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,oBAAoB,CAAA;AAwC3B,MAAM,UAAU,gBAAgB,CAC9B,IAAmB,EACnB,IAA8B;IAE9B,OAAO,OAAO,CAAC,IAAiC,EAAE;QAChD,GAAG,IAAI;QACP,QAAQ,EAAE,WAAW;KACtB,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAmB,EACnB,MAAc,EACd,IAA8B;IAE9B,MAAM,IAAI,GAAG,IAAiC,CAAA;IAC9C,+FAA+F;IAC/F,OAAO,UAAU,CAAC,CAAC,MAAW,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;QAC3D,GAAG,IAAI;QACP,QAAQ,EAAE,IAAI,EAAE,QAAQ,IAAI,WAAW;KACxC,CAAC,CAAA;AACJ,CAAC;AAUD,MAAM,UAAU,mBAAmB,CACjC,EAAwB,EACxB,IAA8B;IAE9B,OAAO,UAAU,CAAC,EAAE,EAAE;QACpB,GAAG,IAAI;QACP,QAAQ,EAAE,WAAW;KACtB,CAAC,CAAA;AACJ,CAAC;AAUD,MAAM,UAAU,cAAc,CA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,IAAI;KACR,CAAC,CAAA;AACJ,CAAC;AAYD,MAAM,UAAU,iCAAiC,CAC/C,EAAwB,EACxB,SAAqC,EACrC,IAA8B;IAE9B,OAAO,UAAU,CAAC,EAAE,EAAE;QACpB,kDAAkD;QAClD,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;QACzE,YAAY,EAAE,SAAS;QACvB,iBAAiB,EAAE,EAAE;QACrB,oBAAoB,EAAE,EAAE;QACxB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,iBAAiB,CAAC,SAAS,CAAC,gBAAgB,CAAC;QACtD,QAAQ,EAAE,WAAW;QACrB,GAAG,IAAI;KACR,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opinionated-machine",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0",
|
|
4
4
|
"description": "Very opinionated DI framework for fastify, built on top of awilix ",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@lokalise/api-contracts": ">=6.5.1",
|
|
38
|
-
"@lokalise/fastify-api-contracts": ">=5.
|
|
38
|
+
"@lokalise/fastify-api-contracts": ">=5.3.0",
|
|
39
39
|
"@lokalise/node-core": ">=14.7.4",
|
|
40
|
-
"awilix": ">=
|
|
40
|
+
"awilix": ">=13.0.0",
|
|
41
41
|
"awilix-manager": ">=6.0.0",
|
|
42
42
|
"fastify": ">=5.0.0",
|
|
43
43
|
"fastify-type-provider-zod": ">=6.1.0",
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^22.19.7",
|
|
48
|
-
"@biomejs/biome": "2.3.
|
|
48
|
+
"@biomejs/biome": "2.3.15",
|
|
49
49
|
"@lokalise/api-contracts": "^6.5.3",
|
|
50
50
|
"@lokalise/biome-config": "^3.1.1",
|
|
51
|
-
"@lokalise/fastify-api-contracts": "^5.
|
|
51
|
+
"@lokalise/fastify-api-contracts": "^5.3.0",
|
|
52
52
|
"@lokalise/node-core": "^14.7.4",
|
|
53
53
|
"@lokalise/tsconfig": "^3.1.0",
|
|
54
54
|
"@vitest/coverage-v8": "^4.0.18",
|
|
55
|
-
"awilix": "^
|
|
55
|
+
"awilix": "^13.0.0",
|
|
56
56
|
"awilix-manager": "^6.3.0",
|
|
57
|
-
"fastify": "^5.7.
|
|
57
|
+
"fastify": "^5.7.4",
|
|
58
58
|
"fastify-type-provider-zod": "^6.1.0",
|
|
59
59
|
"vitest": "^4.0.18",
|
|
60
60
|
"rimraf": "^6.1.2",
|