@ddd-ts-kit/di 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -41
- package/dist/declared/declared-tokens.d.ts +11 -0
- package/dist/declared/declared-tokens.d.ts.map +1 -0
- package/dist/declared/declared-tokens.js +33 -0
- package/dist/declared/declared-tokens.js.map +1 -0
- package/dist/declared/dependencies-of.d.ts +18 -0
- package/dist/declared/dependencies-of.d.ts.map +1 -0
- package/dist/declared/dependencies-of.js +49 -0
- package/dist/declared/dependencies-of.js.map +1 -0
- package/dist/declared/include-declared.d.ts.map +1 -1
- package/dist/declared/include-declared.js +3 -2
- package/dist/declared/include-declared.js.map +1 -1
- package/dist/discovery/discover-context.d.ts +3 -1
- package/dist/discovery/discover-context.d.ts.map +1 -1
- package/dist/discovery/discover-context.js +5 -1
- package/dist/discovery/discover-context.js.map +1 -1
- package/dist/discovery/load-dependency-lists.d.ts +14 -0
- package/dist/discovery/load-dependency-lists.d.ts.map +1 -0
- package/dist/discovery/load-dependency-lists.js +28 -0
- package/dist/discovery/load-dependency-lists.js.map +1 -0
- package/dist/errors/wiring-error.d.ts +1 -1
- package/dist/errors/wiring-error.d.ts.map +1 -1
- package/dist/errors/wiring-error.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -59,10 +59,10 @@ export class IssueInvoice extends AuthorizedCommand<string> {
|
|
|
59
59
|
|
|
60
60
|
```ts
|
|
61
61
|
// contexts/billing/application/commands/issue-invoice/issue-invoice.handler.ts
|
|
62
|
-
import { Clock, IdGenerator } from '@ddd-ts-kit/kernel';
|
|
62
|
+
import type { Clock, IdGenerator } from '@ddd-ts-kit/kernel';
|
|
63
63
|
import { CommandHandler } from '@ddd-ts-kit/kernel/declarations';
|
|
64
64
|
|
|
65
|
-
@CommandHandler(IssueInvoice
|
|
65
|
+
@CommandHandler(IssueInvoice)
|
|
66
66
|
export class IssueInvoiceHandler implements CommandHandler<IssueInvoice> {
|
|
67
67
|
constructor(
|
|
68
68
|
private readonly invoices: InvoiceRepository,
|
|
@@ -94,7 +94,7 @@ export class GetInvoice extends Query<InvoiceView | undefined> {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
@QueryHandler(GetInvoice
|
|
97
|
+
@QueryHandler(GetInvoice)
|
|
98
98
|
export class GetInvoiceHandler implements QueryHandler<GetInvoice> { /* ... */ }
|
|
99
99
|
```
|
|
100
100
|
|
|
@@ -102,9 +102,9 @@ export class GetInvoiceHandler implements QueryHandler<GetInvoice> { /* ... */ }
|
|
|
102
102
|
// contexts/billing/application/integration/handlers/invoice-on-order-placed.integration-handler.ts
|
|
103
103
|
import { CommandBus, systemActor, type IntegrationEvent } from '@ddd-ts-kit/kernel';
|
|
104
104
|
import { IntegrationEventHandler } from '@ddd-ts-kit/kernel/declarations';
|
|
105
|
-
import { OrderPlaced, type OrderPlacedPayload } from '@/contexts/ordering/published-language/index
|
|
105
|
+
import { OrderPlaced, type OrderPlacedPayload } from '@/contexts/ordering/published-language/index';
|
|
106
106
|
|
|
107
|
-
@IntegrationEventHandler(OrderPlaced, { consumer: 'billing.invoice-on-order-placed' }
|
|
107
|
+
@IntegrationEventHandler(OrderPlaced, { consumer: 'billing.invoice-on-order-placed' })
|
|
108
108
|
export class InvoiceOnOrderPlaced implements IntegrationEventHandler<OrderPlacedPayload> {
|
|
109
109
|
constructor(private readonly commands: CommandBus) {}
|
|
110
110
|
|
|
@@ -119,7 +119,7 @@ export class InvoiceOnOrderPlaced implements IntegrationEventHandler<OrderPlaced
|
|
|
119
119
|
import { IdGenerator, IntegrationEventPublisher } from '@ddd-ts-kit/kernel';
|
|
120
120
|
import { DomainEventHandler } from '@ddd-ts-kit/kernel/declarations';
|
|
121
121
|
|
|
122
|
-
@DomainEventHandler(InvoiceIssued, { name: 'billing.invoice.issued' }
|
|
122
|
+
@DomainEventHandler(InvoiceIssued, { name: 'billing.invoice.issued' })
|
|
123
123
|
export class InvoiceIssuedPublisher implements DomainEventHandler<InvoiceIssued> {
|
|
124
124
|
constructor(
|
|
125
125
|
private readonly publisher: IntegrationEventPublisher,
|
|
@@ -135,7 +135,7 @@ export class InvoiceIssuedPublisher implements DomainEventHandler<InvoiceIssued>
|
|
|
135
135
|
import { Clock, ExecutionScope } from '@ddd-ts-kit/kernel';
|
|
136
136
|
import { Repository } from '@ddd-ts-kit/kernel/declarations';
|
|
137
137
|
|
|
138
|
-
@Repository(InvoiceRepository
|
|
138
|
+
@Repository(InvoiceRepository)
|
|
139
139
|
export class KnexInvoiceRepository implements InvoiceRepository { /* ... */ }
|
|
140
140
|
```
|
|
141
141
|
|
|
@@ -144,7 +144,7 @@ export class KnexInvoiceRepository implements InvoiceRepository { /* ... */ }
|
|
|
144
144
|
import { Gateway } from '@ddd-ts-kit/kernel/declarations';
|
|
145
145
|
import { retry, timeout } from '@ddd-ts-kit/aspects';
|
|
146
146
|
|
|
147
|
-
@Gateway(PaymentGateway, { aspects: [retry({ attempts: 3 }), timeout(2000)] }
|
|
147
|
+
@Gateway(PaymentGateway, { aspects: [retry({ attempts: 3 }), timeout(2000)] })
|
|
148
148
|
export class HttpPaymentGateway implements PaymentGateway { /* ... */ }
|
|
149
149
|
```
|
|
150
150
|
|
|
@@ -165,7 +165,7 @@ const invoiceId = await app.resolve(CommandBus).execute(new IssueInvoice(actor,
|
|
|
165
165
|
```ts
|
|
166
166
|
// main.ts, listed: one generated barrel per context and nothing else
|
|
167
167
|
import { contextModule } from '@ddd-ts-kit/di';
|
|
168
|
-
import * as billing from '@/contexts/billing/billing.declarations
|
|
168
|
+
import * as billing from '@/contexts/billing/billing.declarations';
|
|
169
169
|
|
|
170
170
|
const app = createApplication({ modules: [kernelModule(), platformModule, contextModule('billing', billing)] });
|
|
171
171
|
```
|
|
@@ -174,8 +174,9 @@ const app = createApplication({ modules: [kernelModule(), platformModule, contex
|
|
|
174
174
|
|
|
175
175
|
### A port is an abstract class
|
|
176
176
|
|
|
177
|
-
The class names the dependency and carries its type: a
|
|
178
|
-
|
|
177
|
+
The class names the dependency and carries its type: a constructor parameter typed by it
|
|
178
|
+
names what is injected, `app.resolve(Clock)` answers a `Clock`, and nothing else stands for
|
|
179
|
+
the port. The
|
|
179
180
|
ports of the kernel (`Clock`, `IdGenerator`, `UnitOfWork`, `CommandBus`, `QueryBus`,
|
|
180
181
|
`IntegrationEventPublisher`, `ExecutionScope`...) are abstract classes imported from
|
|
181
182
|
`@ddd-ts-kit/kernel`; yours are written the same way.
|
|
@@ -226,18 +227,23 @@ Where the declaration or the statement is written, with no run:
|
|
|
226
227
|
|---|---|
|
|
227
228
|
| the class does not implement the port | `bind(Mailer).toClass(SmsSender)`, `@Repository(InvoiceRepository)` on a class missing `findById` |
|
|
228
229
|
| the value does not have the shape of the port | `bind(Clock).toValue('noon')`, `fake(OrderRepository, { save })`, `override(Clock, 12)` |
|
|
229
|
-
|
|
|
230
|
-
|
|
|
231
|
-
|
|
|
232
|
-
|
|
|
230
|
+
| a list names a port of another type | `handledBy(GetOrderHandler, [Clock])` for a constructor taking an `OrderRepository` |
|
|
231
|
+
| a list is in another order than the constructor | `[IdGenerator, Clock]` for `(clock: Clock, ids: IdGenerator)` |
|
|
232
|
+
| a list is one short or one too many, or a statement of an explicit module has none | `toClass(ReserveStock)` for a constructor with parameters |
|
|
233
|
+
| a list names a concrete class where its port is expected | `[InMemoryOrderRepository]` for a parameter typed `OrderRepository` |
|
|
233
234
|
| the handler does not handle that message or answers another result | `command(PlaceOrder).handledBy(CancelOrderHandler, ...)` |
|
|
234
235
|
| the event handler handles another payload | `on(ParcelShipped, ...).handledBy(InvoiceOnOrderPlaced, ...)` |
|
|
235
236
|
| `.requires(...)` on a message that carries no actor | `query(GetCatalog).requires(permission)` |
|
|
236
237
|
|
|
238
|
+
A list is the one of a statement of an explicit module (`toClass`, `handledBy`), of a
|
|
239
|
+
generated `injected(Class, [..])`, or of a decorator that still writes one. A decorator
|
|
240
|
+
without a list accepts any constructor: the signature is then the statement, and what the
|
|
241
|
+
generated file registers from it is checked the same way (see "Constructor injection").
|
|
242
|
+
|
|
237
243
|
Two limits of a structural type system. A concrete class is told apart from its port by what
|
|
238
244
|
it adds: a class with no member of its own, private ones included, is the port for the
|
|
239
|
-
compiler. And a constructor whose parameters are all optional still has parameters:
|
|
240
|
-
|
|
245
|
+
compiler. And a constructor whose parameters are all optional still has parameters: a
|
|
246
|
+
statement of an explicit module gives it a list.
|
|
241
247
|
|
|
242
248
|
### Identity
|
|
243
249
|
|
|
@@ -267,15 +273,15 @@ The full list, with the options of each, is in the README of `@ddd-ts-kit/kernel
|
|
|
267
273
|
| Declaration | Becomes |
|
|
268
274
|
|---|---|
|
|
269
275
|
| `@Requires(permission, options?)` / `@Public()` on a command or a query | the access of the use case: what `.requires(...)` and `.public()` say in an explicit module, read by `authorization: 'required'` and by the authorization module |
|
|
270
|
-
| `@CommandHandler(Message
|
|
271
|
-
| `@IntegrationEventHandler(contract, { consumer }
|
|
272
|
-
| `@DomainEventHandler(Event, { name, phase? }
|
|
273
|
-
| `@Projection(name
|
|
274
|
-
| `@Scheduled(name, schedule and options
|
|
275
|
-
| `@Repository(Port, options
|
|
276
|
-
| `@Gateway(Port, options
|
|
277
|
-
| `@Adapter(Port, { kind? }
|
|
278
|
-
| `@Policy(permission, { name }
|
|
276
|
+
| `@CommandHandler(Message)`, `@QueryHandler(Message)` | a singleton of kind `use-case`, registered on `CommandBus` or `QueryBus` |
|
|
277
|
+
| `@IntegrationEventHandler(contract, { consumer })` | a singleton of kind `consumer`, subscribed by `start()` on the subscriber of its context, idempotent per consumer name, run in the execution context of the event, its mark and its work in one unit of work |
|
|
278
|
+
| `@DomainEventHandler(Event, { name, phase? })` | a singleton of kind `domain-event-handler`, attached to `DomainEventDispatcher` when the application is created, in its phase: `before-commit` (default), at the end of the unit of work and inside its transaction, or `after-commit`, once it has committed; an event dispatched under the name and built from another class is left alone |
|
|
279
|
+
| `@Projection(name)`, with `@On(definition)` or `@On(Event, { name })` on its methods | a singleton of kind `consumer`. Each integration event it applies is subscribed by `start()` under the name of the projection, exactly as a handler of integration events is: its own execution context, idempotent per name, its mark and its write in one unit of work. Each domain event of its own context is attached to `DomainEventDispatcher` and applied inside the save. See "Projections" |
|
|
280
|
+
| `@Scheduled(name, schedule and options)` | a singleton of kind `job`, registered on `JobScheduler` when the application is created, started by `start()` after the consumers and stopped first by `stop()`; see "Scheduled jobs" |
|
|
281
|
+
| `@Repository(Port, options?)` | the binding of the port, kind `repository`: its save hands the domain events of the aggregate to the unit of work, which dispatches them at its end |
|
|
282
|
+
| `@Gateway(Port, options?)` | the binding of the port, kind `gateway` |
|
|
283
|
+
| `@Adapter(Port, { kind? })` | the binding of the port, kind `external` (default) or `publisher` |
|
|
284
|
+
| `@Policy(permission, { name })` | a singleton listed in `DeclaredPolicies`, which the authorization module evaluates |
|
|
279
285
|
|
|
280
286
|
A handler, a job, a policy and an event handler are bound under themselves: the class is what
|
|
281
287
|
builds them, and `app.resolve(IssueInvoiceHandler)` answers the instance the bus runs. One
|
|
@@ -284,7 +290,7 @@ class is therefore one binding: listing a declared class in two modules is refus
|
|
|
284
290
|
The options of a repository, a gateway and an adapter are the ones of an explicit binding:
|
|
285
291
|
`transient: true` for `.transient()`, `aspects: [...]` for `.with(...)`, the first outermost,
|
|
286
292
|
and `replaces: true` for `rebind`, which a platform adapter uses to take the place of a default
|
|
287
|
-
of the kernel module (`@Adapter(UnitOfWork, { replaces: true }
|
|
293
|
+
of the kernel module (`@Adapter(UnitOfWork, { replaces: true })`). The kind
|
|
288
294
|
reaches the `decorate` hook, so tracing and global aspects see declared adapters as they see
|
|
289
295
|
explicit ones. A handler is built on the first message it handles; nothing is built when a
|
|
290
296
|
class is declared or when a module is created.
|
|
@@ -302,7 +308,8 @@ a bundler follows every class, and so does a dead-code analysis.
|
|
|
302
308
|
From `@ddd-ts-kit/di/discovery`, the one entry of this package that reads the disk. It loads,
|
|
303
309
|
in the order of their paths, every file under `application/` and `infrastructure/` of the
|
|
304
310
|
context whose name ends with a role suffix, and keeps the exported classes that declare
|
|
305
|
-
themselves
|
|
311
|
+
themselves; then `<name>.dependencies` of the same directory when it exists, the generated
|
|
312
|
+
file that registers what their constructors take (see "Constructor injection"):
|
|
306
313
|
|
|
307
314
|
| Suffix | Folder | Declares |
|
|
308
315
|
|---|---|---|
|
|
@@ -353,6 +360,81 @@ Prefer `contextModule` with a barrel for anything bundled, for a serverless cold
|
|
|
353
360
|
whenever the tooling should see the classes; prefer discovery when adding a file must be all
|
|
354
361
|
it takes.
|
|
355
362
|
|
|
363
|
+
## Constructor injection
|
|
364
|
+
|
|
365
|
+
A declared class states what it depends on once, in its constructor, and its decorator lists
|
|
366
|
+
nothing:
|
|
367
|
+
|
|
368
|
+
```ts
|
|
369
|
+
@CommandHandler(IssueInvoice)
|
|
370
|
+
export class IssueInvoiceHandler implements CommandHandler<IssueInvoice> {
|
|
371
|
+
constructor(
|
|
372
|
+
private readonly invoices: InvoiceRepository,
|
|
373
|
+
private readonly ids: IdGenerator,
|
|
374
|
+
private readonly clock: Clock,
|
|
375
|
+
) {}
|
|
376
|
+
}
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
The container does not ask the compiler for those types: `design:paramtypes` exists only with
|
|
380
|
+
legacy decorators compiled by `tsc` or swc, so it is absent with standard decorators and under
|
|
381
|
+
`tsx` or esbuild, and it is `Object` for a port imported with `import type`. Instead
|
|
382
|
+
`ddd-ts-kit docs` (and every `generate`, and every start of the `dev` script) reads the
|
|
383
|
+
constructor signatures from the sources and writes, in the generated file of the context, what
|
|
384
|
+
each class is given:
|
|
385
|
+
|
|
386
|
+
```ts
|
|
387
|
+
// contexts/billing/billing.declarations.ts (generated)
|
|
388
|
+
import { injected } from '@ddd-ts-kit/kernel/declarations';
|
|
389
|
+
// ... one import per class and per token
|
|
390
|
+
|
|
391
|
+
export * from '@/contexts/billing/application/commands/issue-invoice/issue-invoice.handler';
|
|
392
|
+
// ... one export per role file
|
|
393
|
+
|
|
394
|
+
injected(IssueInvoiceHandler, [InvoiceRepository, IdGenerator, Clock]);
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
`injected` registers the list in a registry of the kernel, shared by every copy of the kernel
|
|
398
|
+
a process loads, and is typed like the list of a statement: the compiler refuses a generated
|
|
399
|
+
list that does not match the constructor. When a module is recorded, each declared class is
|
|
400
|
+
given, in this order:
|
|
401
|
+
|
|
402
|
+
1. the list of its decorator, when it wrote one (`@CommandHandler(IssueInvoice, [InvoiceRepository, IdGenerator, Clock])`:
|
|
403
|
+
the form 0.1 projects wrote, still supported, and it wins);
|
|
404
|
+
2. the list `injected` registered for it;
|
|
405
|
+
3. nothing, when its constructor takes no parameter.
|
|
406
|
+
|
|
407
|
+
Anything else stops `createApplication` before a single instance is built:
|
|
408
|
+
|
|
409
|
+
| Code | When | The message says |
|
|
410
|
+
|---|---|---|
|
|
411
|
+
| `MISSING_DEPENDENCIES` | the constructor takes parameters, the decorator lists nothing and no generated file that was loaded registered a list | the class, its file when discovery loaded it, the module, and to run `ddd-ts-kit docs` and assemble the context from the generated file |
|
|
412
|
+
| `DEPENDENCY_ARITY` | the registered list has another length than the constructor (the file is stale), or the list of a decorator is shorter than the constructor (a cast, plain JavaScript) | both lengths, the tokens of the list, and the same command |
|
|
413
|
+
|
|
414
|
+
So nothing is ever injected as `undefined`. Where the lists come from, per assembly:
|
|
415
|
+
|
|
416
|
+
| | The lists are in | Loaded by |
|
|
417
|
+
|---|---|---|
|
|
418
|
+
| `contextModule('billing', billing)` with the barrel | `billing.declarations.ts`, after the exports | the `import * as billing` of the composition root, or of a test |
|
|
419
|
+
| `discoverContext('billing', directory)` | `billing.dependencies.ts` (`.js` once compiled), next to the layers of the context | the scan, with the role files, under the preferred extension; a context whose classes take nothing has none |
|
|
420
|
+
| an explicit module, `bind(..).toClass(C, [..])`, `handledBy(H, [..])` | the statement: explicit stays explicit, nothing is read from a signature | the module file |
|
|
421
|
+
| `builder.include(SomeDeclaredClass)` in an explicit module | the list of its decorator, or the generated file of its context when that file is imported | the module file |
|
|
422
|
+
|
|
423
|
+
A test assembles a context from its generated file, as the composition root does. To build
|
|
424
|
+
one class alone, take it from that file:
|
|
425
|
+
`contextModule('billing', { IssueInvoiceHandler: billing.IssueInvoiceHandler })`. A class
|
|
426
|
+
imported from its own file and handed over alone has no list, and is refused by name.
|
|
427
|
+
|
|
428
|
+
`declaredTokens(declared)` answers the token each declared class of a source is bound under
|
|
429
|
+
(its port for an adapter, the class itself for a handler, a job, a policy or a projection):
|
|
430
|
+
`declaredTokens(billing).map((token) => app.resolve(token))` builds every class of a
|
|
431
|
+
context, which is how a test proves that none is left without what it takes.
|
|
432
|
+
|
|
433
|
+
What keeps a generated list current is outside this package: `declarations/barrel-current`
|
|
434
|
+
of `ddd-ts-kit check` and `ddd-ts-kit docs --check` fail, naming the class, when a constructor
|
|
435
|
+
changed without regeneration, and `declarations/constructor-injection` refuses a parameter
|
|
436
|
+
that names no single class.
|
|
437
|
+
|
|
356
438
|
## Decorator modes
|
|
357
439
|
|
|
358
440
|
The declarations work under both decorator modes of TypeScript, with the same source line:
|
|
@@ -366,7 +448,8 @@ A declaration decorator is a function of the class alone. The legacy call hands
|
|
|
366
448
|
the standard call hands it the class and a context that it does not read, so the same
|
|
367
449
|
function serves both and stores the declaration in a registry of the kernel, never in
|
|
368
450
|
`Symbol.metadata`. Neither mode needs `emitDecoratorMetadata`, and no parameter decorator
|
|
369
|
-
exists in either:
|
|
451
|
+
exists in either: what a constructor takes is read from the source and registered by a
|
|
452
|
+
generated file, the one mechanism in both modes. Vitest lowers legacy decorators by
|
|
370
453
|
itself; for standard ones add `decorators()` of `@ddd-ts-kit/testing/vitest` to the Vitest
|
|
371
454
|
config.
|
|
372
455
|
|
|
@@ -381,7 +464,7 @@ in the same files.
|
|
|
381
464
|
// contexts/ordering/ordering.module.ts
|
|
382
465
|
import { Clock, CommandBus, IdGenerator, IntegrationEventPublisher } from '@ddd-ts-kit/kernel';
|
|
383
466
|
import { defineContextModule } from '@ddd-ts-kit/di';
|
|
384
|
-
import { PaymentCaptured } from '@/contexts/billing/published-language/index
|
|
467
|
+
import { PaymentCaptured } from '@/contexts/billing/published-language/index';
|
|
385
468
|
|
|
386
469
|
export const orderingModule = defineContextModule({
|
|
387
470
|
name: 'ordering',
|
|
@@ -548,15 +631,15 @@ without the kernel module needs one of the two bound, `IntegrationEventSubscribe
|
|
|
548
631
|
## Projections
|
|
549
632
|
|
|
550
633
|
A projection is a class of `application/projections/`, in a `*.projection.ts` file, declared
|
|
551
|
-
with `@Projection('<context>.<name>'
|
|
634
|
+
with `@Projection('<context>.<name>')`; the README of `@ddd-ts-kit/kernel`
|
|
552
635
|
("Projections") says what it may do and why its writes are idempotent and ordered. Here it is
|
|
553
636
|
wired: `contextModule` and `discoverContext` find it like any declared class, and an explicit
|
|
554
637
|
module takes it with `builder.include(AppointmentListProjection)`.
|
|
555
638
|
|
|
556
|
-
The CLI
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
639
|
+
The CLI knows the role: `application/projections/` is a directory of the canonical tree,
|
|
640
|
+
`ddd-ts-kit generate projection <context> <Name> <event-type>` writes one with its spec, the
|
|
641
|
+
generated barrel exports it and registers what its constructor takes, and `describe` and the
|
|
642
|
+
reference of `CONTEXT.md` list it with the events it applies.
|
|
560
643
|
|
|
561
644
|
```ts
|
|
562
645
|
const app = createTestApplication({ modules: [contextModule('reporting', reporting)] });
|
|
@@ -659,8 +742,8 @@ barrel instead of discovery the two lines become `contextModule('ordering', orde
|
|
|
659
742
|
| `RateLimiter` | `InMemoryRateLimiter` on `Clock`: this process only | `rateLimiter` |
|
|
660
743
|
| `JobScheduler` | `InProcessJobScheduler` of `@ddd-ts-kit/scheduling` on `Clock`, `Lock`, `ExecutionScope`, `IdGenerator`, `Logger`, `Metrics` and `ErrorReporter` | `jobScheduler` |
|
|
661
744
|
|
|
662
|
-
The ports are the abstract classes of `@ddd-ts-kit/kernel`: a handler
|
|
663
|
-
|
|
745
|
+
The ports are the abstract classes of `@ddd-ts-kit/kernel`: a handler types a constructor
|
|
746
|
+
parameter by `Clock` without importing this package.
|
|
664
747
|
|
|
665
748
|
An option is an instance or a `(resolve) => instance` factory. An adapter with dependencies of
|
|
666
749
|
its own reads better in the module that owns them:
|
|
@@ -690,7 +773,7 @@ else registers it.
|
|
|
690
773
|
import { CommandBus, systemActor } from '@ddd-ts-kit/kernel';
|
|
691
774
|
import { Scheduled, type JobExecution, type ScheduledJob } from '@ddd-ts-kit/kernel/declarations';
|
|
692
775
|
|
|
693
|
-
@Scheduled('billing.send-reminders', { cron: '0 7 * * 1-5', timeZone: 'Europe/Paris' }
|
|
776
|
+
@Scheduled('billing.send-reminders', { cron: '0 7 * * 1-5', timeZone: 'Europe/Paris' })
|
|
694
777
|
export class SendRemindersJob implements ScheduledJob {
|
|
695
778
|
constructor(private readonly commands: CommandBus) {}
|
|
696
779
|
|
|
@@ -842,6 +925,9 @@ never share instances.
|
|
|
842
925
|
- `BUS_WITHOUT_REGISTER`: handlers declared for a bus that cannot receive them;
|
|
843
926
|
- `UNKNOWN_FAKE`: see above;
|
|
844
927
|
- `UNDECLARED_CLASS`: a class listed in `contextModule` or `include` without a declaration;
|
|
928
|
+
- `MISSING_DEPENDENCIES`: a declared class whose constructor takes parameters and that no list
|
|
929
|
+
covers: its decorator names none and no generated file that was loaded registered one;
|
|
930
|
+
- `DEPENDENCY_ARITY`: a list of another length than the constructor it is for;
|
|
845
931
|
- `DUPLICATE_JOB`: two jobs sharing a name, both modules named: the name is the lock, the
|
|
846
932
|
actor and the label of a job;
|
|
847
933
|
- `UNKNOWN_JOB`: settings given for a job that no module declares;
|
|
@@ -939,7 +1025,7 @@ the database is an `after-commit` handler when it may be lost, an integration ev
|
|
|
939
1025
|
outbox when it must not:
|
|
940
1026
|
|
|
941
1027
|
```ts
|
|
942
|
-
@DomainEventHandler(InvoiceIssued, { name: 'billing.invoice.issued', phase: 'after-commit' }
|
|
1028
|
+
@DomainEventHandler(InvoiceIssued, { name: 'billing.invoice.issued', phase: 'after-commit' })
|
|
943
1029
|
export class InvoiceIssuedEventHandler implements DomainEventHandler<InvoiceIssued> {
|
|
944
1030
|
constructor(private readonly cache: Cache) {}
|
|
945
1031
|
|
|
@@ -1057,6 +1143,12 @@ takes an `actor` option, and lets every message through unless a listed module b
|
|
|
1057
1143
|
written below the declaration, so that the declaration lands on the class that is exported.
|
|
1058
1144
|
A decorator that only annotates, as `@Injectable()` does, composes in either order.
|
|
1059
1145
|
- A declaration is not inherited: a subclass declares itself or is bound explicitly.
|
|
1146
|
+
- What a constructor takes reaches the container through a generated file, never through
|
|
1147
|
+
compiler metadata: a declared class edited where nothing regenerates that file (`docs`,
|
|
1148
|
+
`generate`, the `dev` script) is refused at composition time until it is.
|
|
1149
|
+
- A class that inherits its constructor has a `length` of zero, so a missing list for it
|
|
1150
|
+
cannot be seen at run time: `declarations/constructor-injection` of `ddd-ts-kit check`
|
|
1151
|
+
reads the base class of the project, and refuses one it cannot read.
|
|
1060
1152
|
- A consumer name, a policy name, a job name and the name of a domain event are written in the
|
|
1061
1153
|
declaration; they are not derived from the class, which a refactoring renames.
|
|
1062
1154
|
- A port of your own is identified by its class: see "Identity" for a port loaded twice.
|
|
@@ -1065,12 +1157,12 @@ takes an `actor` option, and lets every message through unless a listed module b
|
|
|
1065
1157
|
|
|
1066
1158
|
```jsonc
|
|
1067
1159
|
// knip.json
|
|
1068
|
-
{ "entry": ["src/main.ts", "src/contexts/*/{application,infrastructure}/**/*.{command,query,handler,integration-handler,publisher,event-handler,policy,job,projection,repository,gateway,adapter}.ts"] }
|
|
1160
|
+
{ "entry": ["src/main.ts", "src/contexts/*/{application,infrastructure}/**/*.{command,query,handler,integration-handler,publisher,event-handler,policy,job,projection,repository,gateway,adapter}.ts", "src/contexts/*/*.dependencies.ts"] }
|
|
1069
1161
|
```
|
|
1070
1162
|
|
|
1071
1163
|
```js
|
|
1072
1164
|
// .dependency-cruiser.cjs, in the pathNot of the no-orphans rule
|
|
1073
|
-
'\\.(command|query|handler|integration-handler|publisher|event-handler|policy|job|projection|repository|gateway|adapter)\\.ts$'
|
|
1165
|
+
'\\.(command|query|handler|integration-handler|publisher|event-handler|policy|job|projection|repository|gateway|adapter|dependencies)\\.ts$'
|
|
1074
1166
|
```
|
|
1075
1167
|
|
|
1076
1168
|
With a barrel and `contextModule` neither setting is needed.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Token } from '@ddd-ts-kit/kernel/declarations';
|
|
2
|
+
import type { DeclaredSource } from './declared-source.js';
|
|
3
|
+
/**
|
|
4
|
+
* The token each declared class of a source is bound under: its port for a repository, a
|
|
5
|
+
* gateway or an adapter, the class itself for a handler, a policy, a job or a projection. A
|
|
6
|
+
* message is bound under nothing and an undeclared value is left out. What a test resolves to
|
|
7
|
+
* prove that every class of a context can be built:
|
|
8
|
+
* `declaredTokens(billing).forEach((token) => application.resolve(token))`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function declaredTokens(source: DeclaredSource): Token<unknown>[];
|
|
11
|
+
//# sourceMappingURL=declared-tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declared-tokens.d.ts","sourceRoot":"","sources":["../../src/declared/declared-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAChG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,CAEvE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { declarationOf } from '@ddd-ts-kit/kernel/declarations';
|
|
2
|
+
/**
|
|
3
|
+
* The token each declared class of a source is bound under: its port for a repository, a
|
|
4
|
+
* gateway or an adapter, the class itself for a handler, a policy, a job or a projection. A
|
|
5
|
+
* message is bound under nothing and an undeclared value is left out. What a test resolves to
|
|
6
|
+
* prove that every class of a context can be built:
|
|
7
|
+
* `declaredTokens(billing).forEach((token) => application.resolve(token))`.
|
|
8
|
+
*/
|
|
9
|
+
export function declaredTokens(source) {
|
|
10
|
+
return [...new Set(classesOf(source).flatMap(tokenOf))];
|
|
11
|
+
}
|
|
12
|
+
function classesOf(source) {
|
|
13
|
+
if (typeof source === 'function') {
|
|
14
|
+
return [source];
|
|
15
|
+
}
|
|
16
|
+
if (isList(source)) {
|
|
17
|
+
return source.flatMap((part) => classesOf(part));
|
|
18
|
+
}
|
|
19
|
+
return Object.values(source).filter((value) => declarationOf(value) !== undefined);
|
|
20
|
+
}
|
|
21
|
+
function isList(source) {
|
|
22
|
+
return Array.isArray(source);
|
|
23
|
+
}
|
|
24
|
+
function tokenOf(target) {
|
|
25
|
+
const declaration = declarationOf(target);
|
|
26
|
+
if (declaration === undefined || declaration.role === 'message') {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
return ['repository', 'gateway', 'adapter'].includes(declaration.role) && 'token' in declaration
|
|
30
|
+
? [declaration.token]
|
|
31
|
+
: [target];
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=declared-tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declared-tokens.js","sourceRoot":"","sources":["../../src/declared/declared-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAkC,MAAM,iCAAiC,CAAC;AAGhG;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,MAAsB;IACnD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,SAAS,CAAC,MAAsB;IACvC,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;QACjC,OAAO,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACnB,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAA0B,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,CAAC;AAC7G,CAAC;AAED,SAAS,MAAM,CAAC,MAAsB;IACpC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,OAAO,CAAC,MAAqB;IACpC,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAE1C,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAChE,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,CAAC,YAAY,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,OAAO,IAAI,WAAW;QAC9F,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC;QACrB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Dependencies } from '@ddd-ts-kit/kernel/declarations';
|
|
2
|
+
import type { Declarer } from '../wiring/declarer.js';
|
|
3
|
+
interface Declared {
|
|
4
|
+
readonly implementation: new (...args: never) => unknown;
|
|
5
|
+
/** The list of the decorator, when it wrote one. */
|
|
6
|
+
readonly listed: Dependencies | undefined;
|
|
7
|
+
readonly module: string;
|
|
8
|
+
readonly declaredBy: Declarer;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* What the constructor of a declared class receives: the list of its decorator when there is
|
|
12
|
+
* one, the list the generated file of its context registered from its constructor signature
|
|
13
|
+
* otherwise. A class that takes parameters and has no list, or a list of another length, is
|
|
14
|
+
* refused here, at composition time: nothing is ever injected as `undefined`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function dependenciesOf(declared: Declared): Dependencies;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=dependencies-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies-of.d.ts","sourceRoot":"","sources":["../../src/declared/dependencies-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEzG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAKtD,UAAU,QAAQ;IAChB,QAAQ,CAAC,cAAc,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC;IACzD,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,YAAY,CAa/D"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { describeToken, injectedDependencies } from '@ddd-ts-kit/kernel/declarations';
|
|
2
|
+
import { WiringError } from '../errors/wiring-error.js';
|
|
3
|
+
const REGENERATE = 'Run `ddd-ts-kit docs`, which reads the constructors and rewrites the generated file of the context (<context>.declarations.ts, or <context>.dependencies.ts under discovery), and assemble the context from that file';
|
|
4
|
+
/**
|
|
5
|
+
* What the constructor of a declared class receives: the list of its decorator when there is
|
|
6
|
+
* one, the list the generated file of its context registered from its constructor signature
|
|
7
|
+
* otherwise. A class that takes parameters and has no list, or a list of another length, is
|
|
8
|
+
* refused here, at composition time: nothing is ever injected as `undefined`.
|
|
9
|
+
*/
|
|
10
|
+
export function dependenciesOf(declared) {
|
|
11
|
+
const { implementation, listed } = declared;
|
|
12
|
+
const dependencies = listed ?? injectedDependencies(implementation);
|
|
13
|
+
if (dependencies === undefined) {
|
|
14
|
+
return implementation.length === 0 ? [] : refuse('MISSING_DEPENDENCIES', declared, noList(declared));
|
|
15
|
+
}
|
|
16
|
+
if (isShort(declared, dependencies) || isStale(declared, dependencies)) {
|
|
17
|
+
return refuse('DEPENDENCY_ARITY', declared, otherLength(declared, dependencies));
|
|
18
|
+
}
|
|
19
|
+
return dependencies;
|
|
20
|
+
}
|
|
21
|
+
function isShort({ implementation }, dependencies) {
|
|
22
|
+
return dependencies.length < implementation.length;
|
|
23
|
+
}
|
|
24
|
+
/** A generated list is derived from the constructor: longer than it, it was read from another one. */
|
|
25
|
+
function isStale({ implementation, listed }, dependencies) {
|
|
26
|
+
return listed === undefined && implementation.length > 0 && dependencies.length !== implementation.length;
|
|
27
|
+
}
|
|
28
|
+
function refuse(code, declared, message) {
|
|
29
|
+
throw new WiringError(code, `${whoOf(declared)} ${message}`);
|
|
30
|
+
}
|
|
31
|
+
function whoOf({ implementation, module, declaredBy }) {
|
|
32
|
+
const file = declaredBy.file === undefined ? '' : ` (${declaredBy.file})`;
|
|
33
|
+
return `Class ${implementation.name}${file} of module "${module}"`;
|
|
34
|
+
}
|
|
35
|
+
function noList({ implementation }) {
|
|
36
|
+
return `takes ${countOf(implementation.length)} and no dependency list is known for it: its decorator names none, and no generated file that was loaded registered one. ${REGENERATE}; the composition root then injects each parameter by its type.`;
|
|
37
|
+
}
|
|
38
|
+
function otherLength({ implementation, listed }, dependencies) {
|
|
39
|
+
const named = dependencies.map((token) => describeToken(token)).join(', ');
|
|
40
|
+
const source = listed === undefined ? 'the generated file of its context registered' : 'its decorator lists';
|
|
41
|
+
const fix = listed === undefined
|
|
42
|
+
? `The generated file is stale. ${REGENERATE}.`
|
|
43
|
+
: 'Name one token per constructor parameter, in order, or remove the list and let the constructor state the dependencies.';
|
|
44
|
+
return `takes ${countOf(implementation.length)} and ${source} ${dependencies.length} ([${named}]): a parameter would be left undefined. ${fix}`;
|
|
45
|
+
}
|
|
46
|
+
function countOf(parameters) {
|
|
47
|
+
return parameters === 1 ? '1 constructor parameter' : `${parameters} constructor parameters`;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=dependencies-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies-of.js","sourceRoot":"","sources":["../../src/declared/dependencies-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAqB,MAAM,iCAAiC,CAAC;AACzG,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,MAAM,UAAU,GACd,uNAAuN,CAAC;AAU1N;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,QAAkB;IAC/C,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC;IAC5C,MAAM,YAAY,GAAG,MAAM,IAAI,oBAAoB,CAAC,cAAc,CAAC,CAAC;IAEpE,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,cAAc,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,sBAAsB,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvG,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC,IAAI,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC;QACvE,OAAO,MAAM,CAAC,kBAAkB,EAAE,QAAQ,EAAE,WAAW,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;IACnF,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,OA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C;IAE7G,MAAM,GAAG,GACP,MAAM,KAAK,SAAS;QAClB,CAAC,CAAC,gCAAgC,UAAU,GAAG;QAC/C,CAAC,CAAC,wHAAwH,CAAC;IAE/H,OAAO,SAAS,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,MAAM,IAAI,YAAY,CAAC,MAAM,MAAM,KAAK,4CAA4C,GAAG,EAAE,CAAC;AAClJ,CAAC;AAED,SAAS,OAAO,CAAC,UAAkB;IACjC,OAAO,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,GAAG,UAAU,yBAAyB,CAAC;AAC/F,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"include-declared.d.ts","sourceRoot":"","sources":["../../src/declared/include-declared.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"include-declared.d.ts","sourceRoot":"","sources":["../../src/declared/include-declared.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAK3D,UAAU,SAAS;IACjB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,iGAAiG;AACjG,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAUlF"}
|
|
@@ -4,6 +4,7 @@ import { WiringError } from '../errors/wiring-error.js';
|
|
|
4
4
|
import { assertPort } from '../wiring/assert-port.js';
|
|
5
5
|
import { classRecipe } from '../wiring/recipe.js';
|
|
6
6
|
import { consumptionOf } from './consumption-of.js';
|
|
7
|
+
import { dependenciesOf } from './dependencies-of.js';
|
|
7
8
|
import { declarerOf } from './discovered-files.js';
|
|
8
9
|
import { projectionOf } from './projection-of.js';
|
|
9
10
|
/** Turns every declaration of the source into bindings of the module, in the order they come. */
|
|
@@ -77,7 +78,7 @@ function registerHandler(registration, declaration) {
|
|
|
77
78
|
/** A declared class is bound under itself: the class is the token of what it builds. */
|
|
78
79
|
function underItself({ module, declaredBy }, { implementation, dependencies, kind }) {
|
|
79
80
|
return {
|
|
80
|
-
...classRecipe(implementation, dependencies),
|
|
81
|
+
...classRecipe(implementation, dependenciesOf({ implementation, listed: dependencies, module, declaredBy })),
|
|
81
82
|
token: implementation,
|
|
82
83
|
module,
|
|
83
84
|
declaredBy,
|
|
@@ -154,7 +155,7 @@ function registerPort(registration, declaration) {
|
|
|
154
155
|
const { draft, module, declaredBy } = registration;
|
|
155
156
|
const { implementation, dependencies, lifetime, kind, aspects } = declaration;
|
|
156
157
|
const binding = {
|
|
157
|
-
...classRecipe(implementation, dependencies),
|
|
158
|
+
...classRecipe(implementation, dependenciesOf({ implementation, listed: dependencies, module, declaredBy })),
|
|
158
159
|
token: declaration.token,
|
|
159
160
|
module,
|
|
160
161
|
declaredBy,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"include-declared.js","sourceRoot":"","sources":["../../src/declared/include-declared.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,GAgBd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAE/E,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAItD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM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AK,EAAE,WAAW,CAAC,KAAK;QACxB,MAAM;QACN,UAAU;QACV,QAAQ;QACR,IAAI;QACJ,OAAO;KACR,CAAC;IAEF,UAAU,CAAC,WAAW,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;IAEtD,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;QACzB,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC"}
|
|
@@ -17,7 +17,9 @@ export interface DiscoveryOptions {
|
|
|
17
17
|
* The module of a bounded context, found by loading every file of its `application/` and
|
|
18
18
|
* `infrastructure/` folders that carries a role suffix (`*.handler`, `*.repository`, ...) and
|
|
19
19
|
* keeping the classes that declare themselves:
|
|
20
|
-
* `await discoverContext('billing', new URL('.', import.meta.url))`.
|
|
20
|
+
* `await discoverContext('billing', new URL('.', import.meta.url))`. What each constructor
|
|
21
|
+
* receives comes from the generated `<context>.dependencies` file of the same directory, loaded
|
|
22
|
+
* with them; nothing is read from compiler metadata.
|
|
21
23
|
*
|
|
22
24
|
* It reads the disk and imports at startup, and what it finds is reachable by no import: use
|
|
23
25
|
* `contextModule` with a list or a barrel wherever a bundler or a dead-code analysis must
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover-context.d.ts","sourceRoot":"","sources":["../../src/discovery/discover-context.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"discover-context.d.ts","sourceRoot":"","sources":["../../src/discovery/discover-context.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAIjE,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAChD,6FAA6F;IAC7F,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAC5C;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC;AAMD;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,GAAG,GAAG,MAAM,EACvB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,aAAa,CAAC,CAcxB"}
|
|
@@ -4,13 +4,16 @@ import { declarationOf } from '@ddd-ts-kit/kernel/declarations';
|
|
|
4
4
|
import { contextModule } from '../declared/context-module.js';
|
|
5
5
|
import { rememberFile } from '../declared/discovered-files.js';
|
|
6
6
|
import { WiringError } from '../errors/wiring-error.js';
|
|
7
|
+
import { loadDependencyLists } from './load-dependency-lists.js';
|
|
7
8
|
import { roleFilesOf } from './role-files-of.js';
|
|
8
9
|
const DEFAULT_EXTENSIONS = ['.js', '.mjs', '.ts', '.mts'];
|
|
9
10
|
/**
|
|
10
11
|
* The module of a bounded context, found by loading every file of its `application/` and
|
|
11
12
|
* `infrastructure/` folders that carries a role suffix (`*.handler`, `*.repository`, ...) and
|
|
12
13
|
* keeping the classes that declare themselves:
|
|
13
|
-
* `await discoverContext('billing', new URL('.', import.meta.url))`.
|
|
14
|
+
* `await discoverContext('billing', new URL('.', import.meta.url))`. What each constructor
|
|
15
|
+
* receives comes from the generated `<context>.dependencies` file of the same directory, loaded
|
|
16
|
+
* with them; nothing is read from compiler metadata.
|
|
14
17
|
*
|
|
15
18
|
* It reads the disk and imports at startup, and what it finds is reachable by no import: use
|
|
16
19
|
* `contextModule` with a list or a barrel wherever a bundler or a dead-code analysis must
|
|
@@ -25,6 +28,7 @@ export async function discoverContext(name, directory, options = {}) {
|
|
|
25
28
|
assertInItsFolder(file, name);
|
|
26
29
|
declared.push(...declaredIn(file, await loaded(file, load), name));
|
|
27
30
|
}
|
|
31
|
+
await loadDependencyLists(root, name, { extensions, load });
|
|
28
32
|
return contextModule(name, declared);
|
|
29
33
|
}
|
|
30
34
|
function assertInItsFolder({ relative, rule }, context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover-context.js","sourceRoot":"","sources":["../../src/discovery/discover-context.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,aAAa,EAAsB,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,WAAW,EAAiB,MAAM,oBAAoB,CAAC;AAmBhE,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAE1D
|
|
1
|
+
{"version":3,"file":"discover-context.js","sourceRoot":"","sources":["../../src/discovery/discover-context.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,aAAa,EAAsB,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAiB,MAAM,oBAAoB,CAAC;AAmBhE,MAAM,kBAAkB,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AC;IAED,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC9B,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAClC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,aAAa,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC;AAC5C,CAAC;AAED,SAAS,eAAe,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAY,EAAE,OAAe;IACpE,OAAO,IAAI,WAAW,CACpB,kBAAkB,EAClB,GAAG,QAAQ,gBAAgB,OAAO,YAAY,IAAI,CAAC,MAAM,4IAA4I,CACtM,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAqB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAY;IAC9E,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC;IAEzC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACpD,OAAO;IACT,CAAC;IAED,MAAM,IAAI,WAAW,CACnB,uBAAuB,EACvB,SAAS,MAAM,CAAC,IAAI,uBAAuB,IAAI,OAAO,QAAQ,SAAS,IAAI,CAAC,MAAM,6BAA6B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAC1I,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface Loading {
|
|
2
|
+
readonly extensions: readonly string[];
|
|
3
|
+
readonly load: (file: URL) => Promise<unknown>;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Loads `<context>.dependencies`, the generated file of a discovered context that registers
|
|
7
|
+
* what each constructor receives (`ddd-ts-kit docs` writes it from the constructor signatures),
|
|
8
|
+
* under the preferred extension it exists with. A context whose classes take nothing, or list
|
|
9
|
+
* their dependencies in their decorators, has none: a class left without a list is refused
|
|
10
|
+
* when the application is composed.
|
|
11
|
+
*/
|
|
12
|
+
export declare function loadDependencyLists(root: string, context: string, loading: Loading): Promise<void>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=load-dependency-lists.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-dependency-lists.d.ts","sourceRoot":"","sources":["../../src/discovery/load-dependency-lists.ts"],"names":[],"mappings":"AAKA,UAAU,OAAO;IACf,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAChD;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBxG"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { readdir } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
import { WiringError } from '../errors/wiring-error.js';
|
|
5
|
+
/**
|
|
6
|
+
* Loads `<context>.dependencies`, the generated file of a discovered context that registers
|
|
7
|
+
* what each constructor receives (`ddd-ts-kit docs` writes it from the constructor signatures),
|
|
8
|
+
* under the preferred extension it exists with. A context whose classes take nothing, or list
|
|
9
|
+
* their dependencies in their decorators, has none: a class left without a list is refused
|
|
10
|
+
* when the application is composed.
|
|
11
|
+
*/
|
|
12
|
+
export async function loadDependencyLists(root, context, loading) {
|
|
13
|
+
const present = new Set(await readdir(root));
|
|
14
|
+
const file = loading.extensions
|
|
15
|
+
.map((extension) => `${context}.dependencies${extension}`)
|
|
16
|
+
.find((candidate) => present.has(candidate));
|
|
17
|
+
if (file === undefined) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const absolute = path.join(root, file);
|
|
21
|
+
try {
|
|
22
|
+
await loading.load(pathToFileURL(absolute));
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
throw new WiringError('DISCOVERY_FAILED', `${absolute} could not be loaded: ${error instanceof Error ? error.message : String(error)}. It is generated: run \`ddd-ts-kit docs\` to rewrite it.`, { cause: error });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=load-dependency-lists.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-dependency-lists.js","sourceRoot":"","sources":["../../src/discovery/load-dependency-lists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAOxD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,IAAY,EAAE,OAAe,EAAE,OAAgB;IACvF,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAE7C,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU;SAC5B,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,OAAO,gBAAgB,SAAS,EAAE,CAAC;SACzD,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;IAE/C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO;IACT,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAEvC,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,WAAW,CACnB,kBAAkB,EAClB,GAAG,QAAQ,yBAAyB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,2DAA2D,EACrJ,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type WiringErrorCode = 'DUPLICATE_BINDING' | 'INCOMPLETE_BINDING' | 'NOTHING_TO_REBIND' | 'INVALID_PORT' | 'UNBOUND_DEPENDENCY' | 'UNBOUND_TOKEN' | 'DEPENDENCY_CYCLE' | 'DUPLICATE_HANDLER' | 'DUPLICATE_CONSUMER' | 'BUS_WITHOUT_REGISTER' | 'UNKNOWN_FAKE' | 'UNDECLARED_AUTHORIZATION' | 'AUTHORIZATION_NOT_ENFORCED' | 'UNDECLARED_CLASS' | 'DISCOVERY_FAILED' | 'NOTHING_DECLARED' | 'MISPLACED_DECLARATION' | 'DUPLICATE_JOB' | 'UNKNOWN_JOB' | 'INVALID_JOB_SETTINGS' | 'DUPLICATE_PROJECTION';
|
|
1
|
+
export type WiringErrorCode = 'DUPLICATE_BINDING' | 'INCOMPLETE_BINDING' | 'NOTHING_TO_REBIND' | 'INVALID_PORT' | 'UNBOUND_DEPENDENCY' | 'UNBOUND_TOKEN' | 'DEPENDENCY_CYCLE' | 'DUPLICATE_HANDLER' | 'DUPLICATE_CONSUMER' | 'BUS_WITHOUT_REGISTER' | 'UNKNOWN_FAKE' | 'UNDECLARED_AUTHORIZATION' | 'AUTHORIZATION_NOT_ENFORCED' | 'UNDECLARED_CLASS' | 'DISCOVERY_FAILED' | 'NOTHING_DECLARED' | 'MISPLACED_DECLARATION' | 'DUPLICATE_JOB' | 'UNKNOWN_JOB' | 'INVALID_JOB_SETTINGS' | 'DUPLICATE_PROJECTION' | 'MISSING_DEPENDENCIES' | 'DEPENDENCY_ARITY';
|
|
2
2
|
/** A mistake in the composition root. Never a business failure, hence not a DomainError. */
|
|
3
3
|
export declare class WiringError extends Error {
|
|
4
4
|
readonly code: WiringErrorCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wiring-error.d.ts","sourceRoot":"","sources":["../../src/errors/wiring-error.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GACvB,mBAAmB,GACnB,oBAAoB,GACpB,mBAAmB,GACnB,cAAc,GACd,oBAAoB,GACpB,eAAe,GACf,kBAAkB,GAClB,mBAAmB,GACnB,oBAAoB,GACpB,sBAAsB,GACtB,cAAc,GACd,0BAA0B,GAC1B,4BAA4B,GAC5B,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,uBAAuB,GACvB,eAAe,GACf,aAAa,GACb,sBAAsB,GACtB,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"wiring-error.d.ts","sourceRoot":"","sources":["../../src/errors/wiring-error.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GACvB,mBAAmB,GACnB,oBAAoB,GACpB,mBAAmB,GACnB,cAAc,GACd,oBAAoB,GACpB,eAAe,GACf,kBAAkB,GAClB,mBAAmB,GACnB,oBAAoB,GACpB,sBAAsB,GACtB,cAAc,GACd,0BAA0B,GAC1B,4BAA4B,GAC5B,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,uBAAuB,GACvB,eAAe,GACf,aAAa,GACb,sBAAsB,GACtB,sBAAsB,GACtB,sBAAsB,GACtB,kBAAkB,CAAC;AAEvB,4FAA4F;AAC5F,qBAAa,WAAY,SAAQ,KAAK;IAElC,QAAQ,CAAC,IAAI,EAAE,eAAe;IADhC,YACW,IAAI,EAAE,eAAe,EAC9B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY,EAIvB;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wiring-error.js","sourceRoot":"","sources":["../../src/errors/wiring-error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wiring-error.js","sourceRoot":"","sources":["../../src/errors/wiring-error.ts"],"names":[],"mappings":"AAyBA,4FAA4F;AAC5F,MAAM,OAAO,WAAY,SAAQ,KAAK;IAEzB,IAAI;IADf,YACW,IAAqB,EAC9B,OAAe,EACf,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;oBAJf,IAAI;QAKb,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export type { PolicyBinding } from './wiring/policy-binding.js';
|
|
|
20
20
|
export type { Resolve } from './wiring/resolve.js';
|
|
21
21
|
export { contextModule } from './declared/context-module.js';
|
|
22
22
|
export type { DeclaredSource } from './declared/declared-source.js';
|
|
23
|
+
export { declaredTokens } from './declared/declared-tokens.js';
|
|
23
24
|
export type { ConsumerOptions } from './consumer/consumer-options.js';
|
|
24
25
|
export type { ConsumerRuntime } from './consumer/consumer-runtime.js';
|
|
25
26
|
export { UnreadableEventError } from './consumer/unreadable-event-error.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC7E,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd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E,YAAY,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AACjF,YAAY,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACxE,YAAY,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC/G,YAAY,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,YAAY,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AACpF,YAAY,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,YAAY,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { describeToken, tokenIdentity } from '@ddd-ts-kit/kernel/declarations';
|
|
|
6
6
|
export { WiringError } from './errors/wiring-error.js';
|
|
7
7
|
export { defineContextModule } from './module/define-context-module.js';
|
|
8
8
|
export { contextModule } from './declared/context-module.js';
|
|
9
|
+
export { declaredTokens } from './declared/declared-tokens.js';
|
|
9
10
|
export { UnreadableEventError } from './consumer/unreadable-event-error.js';
|
|
10
11
|
export { createApplication } from './application/create-application.js';
|
|
11
12
|
export { overrideForTests } from './application/override-for-tests.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,wFAAwF;AACxF,wFAAwF;AACxF,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAc,MAAM,iCAAiC,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAwB,MAAM,0BAA0B,CAAC;AAgB7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAYxE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,wFAAwF;AACxF,wFAAwF;AACxF,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAc,MAAM,iCAAiC,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAwB,MAAM,0BAA0B,CAAC;AAgB7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAYxE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAK5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAiB,MAAM,2BAA2B,CAAC;AAcpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAIxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAmD,MAAM,6BAA6B,CAAC;AAE/G,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-ts-kit/di",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Port classes and context modules on top of tsyringe, for projects without a heavy framework.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@ddd-ts-kit/kernel": "0.
|
|
34
|
-
"@ddd-ts-kit/scheduling": "0.
|
|
33
|
+
"@ddd-ts-kit/kernel": "0.2.0",
|
|
34
|
+
"@ddd-ts-kit/scheduling": "0.2.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"tsyringe": "^4.10.0",
|