hexok 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/dist/app/api-use-case.d.ts +52 -0
  2. package/dist/app/api-use-case.d.ts.map +1 -0
  3. package/dist/app/api-use-case.js +59 -0
  4. package/dist/app/api-use-case.js.map +1 -0
  5. package/dist/app/callable-use-case.d.ts +34 -0
  6. package/dist/app/callable-use-case.d.ts.map +1 -0
  7. package/dist/app/callable-use-case.js +41 -0
  8. package/dist/app/callable-use-case.js.map +1 -0
  9. package/dist/app/contract.d.ts +46 -0
  10. package/dist/app/contract.d.ts.map +1 -0
  11. package/dist/app/contract.js +28 -0
  12. package/dist/app/contract.js.map +1 -0
  13. package/dist/app/error-factory.d.ts +9 -0
  14. package/dist/app/error-factory.d.ts.map +1 -0
  15. package/dist/app/error-factory.js +30 -0
  16. package/dist/app/error-factory.js.map +1 -0
  17. package/dist/app/event-channel.d.ts +133 -0
  18. package/dist/app/event-channel.d.ts.map +1 -0
  19. package/dist/app/event-channel.js +49 -0
  20. package/dist/app/event-channel.js.map +1 -0
  21. package/dist/app/event-use-case.d.ts +47 -0
  22. package/dist/app/event-use-case.d.ts.map +1 -0
  23. package/dist/app/event-use-case.js +54 -0
  24. package/dist/app/event-use-case.js.map +1 -0
  25. package/dist/app/execute-ctx.d.ts +92 -0
  26. package/dist/app/execute-ctx.d.ts.map +1 -0
  27. package/dist/app/execute-ctx.js +2 -0
  28. package/dist/app/execute-ctx.js.map +1 -0
  29. package/dist/app/external-use-case.d.ts +25 -0
  30. package/dist/app/external-use-case.d.ts.map +1 -0
  31. package/dist/app/external-use-case.js +25 -0
  32. package/dist/app/external-use-case.js.map +1 -0
  33. package/dist/app/index.d.ts +9 -0
  34. package/dist/app/index.d.ts.map +1 -0
  35. package/dist/app/index.js +8 -0
  36. package/dist/app/index.js.map +1 -0
  37. package/dist/app/internal-use-case.d.ts +26 -0
  38. package/dist/app/internal-use-case.d.ts.map +1 -0
  39. package/dist/app/internal-use-case.js +26 -0
  40. package/dist/app/internal-use-case.js.map +1 -0
  41. package/dist/app/nest.d.ts +9 -0
  42. package/dist/app/nest.d.ts.map +1 -0
  43. package/dist/app/nest.js +28 -0
  44. package/dist/app/nest.js.map +1 -0
  45. package/dist/app/types.d.ts +153 -0
  46. package/dist/app/types.d.ts.map +1 -0
  47. package/dist/app/types.js +17 -0
  48. package/dist/app/types.js.map +1 -0
  49. package/dist/core/coded-error.d.ts +24 -0
  50. package/dist/core/coded-error.d.ts.map +1 -0
  51. package/dist/core/coded-error.js +32 -0
  52. package/dist/core/coded-error.js.map +1 -0
  53. package/dist/core/error-map.d.ts +21 -0
  54. package/dist/core/error-map.d.ts.map +1 -0
  55. package/dist/core/error-map.js +5 -0
  56. package/dist/core/error-map.js.map +1 -0
  57. package/dist/core/index.d.ts +6 -0
  58. package/dist/core/index.d.ts.map +1 -0
  59. package/dist/core/index.js +5 -0
  60. package/dist/core/index.js.map +1 -0
  61. package/dist/core/result.d.ts +23 -0
  62. package/dist/core/result.d.ts.map +1 -0
  63. package/dist/core/result.js +11 -0
  64. package/dist/core/result.js.map +1 -0
  65. package/dist/core/schema.d.ts +19 -0
  66. package/dist/core/schema.d.ts.map +1 -0
  67. package/dist/core/schema.js +28 -0
  68. package/dist/core/schema.js.map +1 -0
  69. package/dist/core/standard-schema.d.ts +51 -0
  70. package/dist/core/standard-schema.d.ts.map +1 -0
  71. package/dist/core/standard-schema.js +2 -0
  72. package/dist/core/standard-schema.js.map +1 -0
  73. package/dist/domain/capabilities.d.ts +42 -0
  74. package/dist/domain/capabilities.d.ts.map +1 -0
  75. package/dist/domain/capabilities.js +2 -0
  76. package/dist/domain/capabilities.js.map +1 -0
  77. package/dist/domain/catalog.d.ts +46 -0
  78. package/dist/domain/catalog.d.ts.map +1 -0
  79. package/dist/domain/catalog.js +114 -0
  80. package/dist/domain/catalog.js.map +1 -0
  81. package/dist/domain/channel.d.ts +36 -0
  82. package/dist/domain/channel.d.ts.map +1 -0
  83. package/dist/domain/channel.js +2 -0
  84. package/dist/domain/channel.js.map +1 -0
  85. package/dist/domain/cow-draft.d.ts +10 -0
  86. package/dist/domain/cow-draft.d.ts.map +1 -0
  87. package/dist/domain/cow-draft.js +147 -0
  88. package/dist/domain/cow-draft.js.map +1 -0
  89. package/dist/domain/entity.d.ts +120 -0
  90. package/dist/domain/entity.d.ts.map +1 -0
  91. package/dist/domain/entity.js +263 -0
  92. package/dist/domain/entity.js.map +1 -0
  93. package/dist/domain/envelope.d.ts +59 -0
  94. package/dist/domain/envelope.d.ts.map +1 -0
  95. package/dist/domain/envelope.js +2 -0
  96. package/dist/domain/envelope.js.map +1 -0
  97. package/dist/domain/event.d.ts +44 -0
  98. package/dist/domain/event.d.ts.map +1 -0
  99. package/dist/domain/event.js +21 -0
  100. package/dist/domain/event.js.map +1 -0
  101. package/dist/domain/index.d.ts +8 -0
  102. package/dist/domain/index.d.ts.map +1 -0
  103. package/dist/domain/index.js +5 -0
  104. package/dist/domain/index.js.map +1 -0
  105. package/dist/domain/port.d.ts +45 -0
  106. package/dist/domain/port.d.ts.map +1 -0
  107. package/dist/domain/port.js +41 -0
  108. package/dist/domain/port.js.map +1 -0
  109. package/dist/infra/adapter.d.ts +22 -0
  110. package/dist/infra/adapter.d.ts.map +1 -0
  111. package/dist/infra/adapter.js +18 -0
  112. package/dist/infra/adapter.js.map +1 -0
  113. package/dist/infra/index.d.ts +3 -0
  114. package/dist/infra/index.d.ts.map +1 -0
  115. package/dist/infra/index.js +3 -0
  116. package/dist/infra/index.js.map +1 -0
  117. package/dist/infra/mapper.d.ts +48 -0
  118. package/dist/infra/mapper.d.ts.map +1 -0
  119. package/dist/infra/mapper.js +77 -0
  120. package/dist/infra/mapper.js.map +1 -0
  121. package/dist/runtime/app.d.ts +100 -0
  122. package/dist/runtime/app.d.ts.map +1 -0
  123. package/dist/runtime/app.js +292 -0
  124. package/dist/runtime/app.js.map +1 -0
  125. package/dist/runtime/channel.d.ts +34 -0
  126. package/dist/runtime/channel.d.ts.map +1 -0
  127. package/dist/runtime/channel.js +110 -0
  128. package/dist/runtime/channel.js.map +1 -0
  129. package/dist/runtime/client.d.ts +21 -0
  130. package/dist/runtime/client.d.ts.map +1 -0
  131. package/dist/runtime/client.js +2 -0
  132. package/dist/runtime/client.js.map +1 -0
  133. package/dist/runtime/completeness.d.ts +89 -0
  134. package/dist/runtime/completeness.d.ts.map +1 -0
  135. package/dist/runtime/completeness.js +2 -0
  136. package/dist/runtime/completeness.js.map +1 -0
  137. package/dist/runtime/envelope.d.ts +7 -0
  138. package/dist/runtime/envelope.d.ts.map +1 -0
  139. package/dist/runtime/envelope.js +69 -0
  140. package/dist/runtime/envelope.js.map +1 -0
  141. package/dist/runtime/events.d.ts +6 -0
  142. package/dist/runtime/events.d.ts.map +1 -0
  143. package/dist/runtime/events.js +48 -0
  144. package/dist/runtime/events.js.map +1 -0
  145. package/dist/runtime/http-status.d.ts +3 -0
  146. package/dist/runtime/http-status.d.ts.map +1 -0
  147. package/dist/runtime/http-status.js +11 -0
  148. package/dist/runtime/http-status.js.map +1 -0
  149. package/dist/runtime/http.d.ts +4 -0
  150. package/dist/runtime/http.d.ts.map +1 -0
  151. package/dist/runtime/http.js +58 -0
  152. package/dist/runtime/http.js.map +1 -0
  153. package/dist/runtime/index.d.ts +10 -0
  154. package/dist/runtime/index.d.ts.map +1 -0
  155. package/dist/runtime/index.js +6 -0
  156. package/dist/runtime/index.js.map +1 -0
  157. package/dist/runtime/interceptor.d.ts +61 -0
  158. package/dist/runtime/interceptor.d.ts.map +1 -0
  159. package/dist/runtime/interceptor.js +7 -0
  160. package/dist/runtime/interceptor.js.map +1 -0
  161. package/dist/runtime/invoke.d.ts +34 -0
  162. package/dist/runtime/invoke.d.ts.map +1 -0
  163. package/dist/runtime/invoke.js +235 -0
  164. package/dist/runtime/invoke.js.map +1 -0
  165. package/dist/runtime/middleware.d.ts +20 -0
  166. package/dist/runtime/middleware.d.ts.map +1 -0
  167. package/dist/runtime/middleware.js +2 -0
  168. package/dist/runtime/middleware.js.map +1 -0
  169. package/dist/runtime/rpc.d.ts +24 -0
  170. package/dist/runtime/rpc.d.ts.map +1 -0
  171. package/dist/runtime/rpc.js +16 -0
  172. package/dist/runtime/rpc.js.map +1 -0
  173. package/dist/testing/app-test.d.ts +77 -0
  174. package/dist/testing/app-test.d.ts.map +1 -0
  175. package/dist/testing/app-test.js +109 -0
  176. package/dist/testing/app-test.js.map +1 -0
  177. package/dist/testing/in-memory-broker.d.ts +18 -0
  178. package/dist/testing/in-memory-broker.d.ts.map +1 -0
  179. package/dist/testing/in-memory-broker.js +42 -0
  180. package/dist/testing/in-memory-broker.js.map +1 -0
  181. package/dist/testing/in-memory-bus.d.ts +19 -0
  182. package/dist/testing/in-memory-bus.d.ts.map +1 -0
  183. package/dist/testing/in-memory-bus.js +31 -0
  184. package/dist/testing/in-memory-bus.js.map +1 -0
  185. package/dist/testing/in-memory-channel.d.ts +32 -0
  186. package/dist/testing/in-memory-channel.d.ts.map +1 -0
  187. package/dist/testing/in-memory-channel.js +65 -0
  188. package/dist/testing/in-memory-channel.js.map +1 -0
  189. package/dist/testing/in-memory-queue.d.ts +24 -0
  190. package/dist/testing/in-memory-queue.d.ts.map +1 -0
  191. package/dist/testing/in-memory-queue.js +66 -0
  192. package/dist/testing/in-memory-queue.js.map +1 -0
  193. package/dist/testing/in-memory-repository.d.ts +44 -0
  194. package/dist/testing/in-memory-repository.d.ts.map +1 -0
  195. package/dist/testing/in-memory-repository.js +60 -0
  196. package/dist/testing/in-memory-repository.js.map +1 -0
  197. package/dist/testing/index.d.ts +6 -0
  198. package/dist/testing/index.d.ts.map +1 -0
  199. package/dist/testing/index.js +6 -0
  200. package/dist/testing/index.js.map +1 -0
  201. package/package.json +60 -0
@@ -0,0 +1,44 @@
1
+ import type { Infer, StandardSchemaV1 } from '../core/index.js';
2
+ /**
3
+ * Domain events are classes. Construction types the payload;
4
+ * validation happens at the use-case edge, not in the constructor.
5
+ *
6
+ * ```ts
7
+ * class IncidentClosed extends DomainEvent {
8
+ * static readonly key = 'incident.closed'
9
+ * static readonly schema = z.object({ id: z.string(), closedAt: z.date() })
10
+ * constructor(public readonly payload: Infer<typeof IncidentClosed.schema>) {
11
+ * super()
12
+ * }
13
+ * }
14
+ * ```
15
+ */
16
+ export declare abstract class DomainEvent<P = unknown> {
17
+ /** Dotted event name, e.g. `'incident.closed'`. Declare on each subclass. */
18
+ static readonly key: string;
19
+ /** Standard Schema for the payload, applied at the use-case edge. */
20
+ static readonly schema: StandardSchemaV1;
21
+ /** Event body. Typed by the subclass constructor; not validated here. */
22
+ abstract readonly payload: P;
23
+ }
24
+ /** Event subclass constructor: `key`, `schema`, and `new (payload)`. */
25
+ export type EventClass<P = never> = {
26
+ /** Dotted event name, e.g. `'incident.closed'`. */
27
+ readonly key: string;
28
+ /** Standard Schema for the payload, applied at the use-case edge. */
29
+ readonly schema: StandardSchemaV1;
30
+ new (payload: P, ...args: never[]): DomainEvent<unknown>;
31
+ };
32
+ /** Payload type inferred from an event class's `schema`. */
33
+ export type EventPayload<E extends EventClass> = Infer<E['schema']>;
34
+ type EventKeyOf<E> = E extends {
35
+ readonly key: infer K extends string;
36
+ } ? K : string;
37
+ /** `catalog.event()` argument when the catalog declared `.ctx<T>()`. */
38
+ export type EventWithCtx<E extends EventClass, Ctx> = [
39
+ InstanceType<E>
40
+ ] extends [{
41
+ ctx: Ctx;
42
+ }] ? E : `hexok: event "${EventKeyOf<E>}" is missing ctx for this catalog`;
43
+ export {};
44
+ //# sourceMappingURL=event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/domain/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEhE;;;;;;;;;;;;;GAaG;AACH,8BAAsB,WAAW,CAAC,CAAC,GAAG,OAAO;IAC3C,6EAA6E;IAC7E,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IACzC,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;CAC9B;AAED,wEAAwE;AACxE,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,KAAK,IAAI;IAClC,mDAAmD;IACnD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,KAAK,OAAO,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;CAC1D,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,UAAU,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEpE,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;CAAE,GACnE,CAAC,GACD,MAAM,CAAC;AAEX,wEAAwE;AACxE,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,UAAU,EAAE,GAAG,IAAI;IACpD,YAAY,CAAC,CAAC,CAAC;CAChB,SAAS,CAAC;IAAE,GAAG,EAAE,GAAG,CAAA;CAAE,CAAC,GACpB,CAAC,GACD,iBAAiB,UAAU,CAAC,CAAC,CAAC,mCAAmC,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Domain events are classes. Construction types the payload;
3
+ * validation happens at the use-case edge, not in the constructor.
4
+ *
5
+ * ```ts
6
+ * class IncidentClosed extends DomainEvent {
7
+ * static readonly key = 'incident.closed'
8
+ * static readonly schema = z.object({ id: z.string(), closedAt: z.date() })
9
+ * constructor(public readonly payload: Infer<typeof IncidentClosed.schema>) {
10
+ * super()
11
+ * }
12
+ * }
13
+ * ```
14
+ */
15
+ export class DomainEvent {
16
+ /** Dotted event name, e.g. `'incident.closed'`. Declare on each subclass. */
17
+ static key;
18
+ /** Standard Schema for the payload, applied at the use-case edge. */
19
+ static schema;
20
+ }
21
+ //# sourceMappingURL=event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/domain/event.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAgB,WAAW;IAC/B,6EAA6E;IAC7E,MAAM,CAAU,GAAG,CAAS;IAC5B,qEAAqE;IACrE,MAAM,CAAU,MAAM,CAAmB;CAG1C"}
@@ -0,0 +1,8 @@
1
+ export type { CrudRepository, RequestScoped, Transactional, UnitOfWork, } from './capabilities.js';
2
+ export { type AnyEventCatalog, type CatalogEvents, EventCatalog, } from './catalog.js';
3
+ export type { ChannelAdapter, ChannelConnection, } from './channel.js';
4
+ export { type DeepReadonly, Entity, type EntityConstructor, } from './entity.js';
5
+ export type { BusAdapter, CatalogKind, Envelope, EventAdapter, QueueAdapter, QueueConsumeCtx, } from './envelope.js';
6
+ export { DomainEvent, type EventClass, type EventPayload, type EventWithCtx, } from './event.js';
7
+ export { Port, type PortCapabilities, PortToken, type PortType, } from './port.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/domain/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,aAAa,EACb,aAAa,EACb,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,cAAc,EACd,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,YAAY,EACjB,MAAM,EACN,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,EACX,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,IAAI,EACJ,KAAK,gBAAgB,EACrB,SAAS,EACT,KAAK,QAAQ,GACd,MAAM,WAAW,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { EventCatalog, } from './catalog.js';
2
+ export { Entity, } from './entity.js';
3
+ export { DomainEvent, } from './event.js';
4
+ export { Port, PortToken, } from './port.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/domain/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,YAAY,GACb,MAAM,cAAc,CAAC;AAKtB,OAAO,EAEL,MAAM,GAEP,MAAM,aAAa,CAAC;AASrB,OAAO,EACL,WAAW,GAIZ,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,IAAI,EAEJ,SAAS,GAEV,MAAM,WAAW,CAAC"}
@@ -0,0 +1,45 @@
1
+ declare const portType: unique symbol;
2
+ /** Runtime flags checked by `App.provide`. Type the port with `Transactional` / `RequestScoped` as well. */
3
+ export type PortCapabilities = {
4
+ transactional?: boolean;
5
+ requestScoped?: boolean;
6
+ };
7
+ /**
8
+ * A port is a TypeScript interface plus a token used at compose time.
9
+ *
10
+ * ```ts
11
+ * export interface IncidentRepository {
12
+ * get(id: string): Promise<Incident | null>
13
+ * save(incident: Incident): Promise<void>
14
+ * }
15
+ * export const IncidentRepository = Port.token<IncidentRepository>(
16
+ * 'IncidentRepository',
17
+ * )
18
+ * ```
19
+ *
20
+ * `.build()` names a missing port by its use-case alias
21
+ * (`ports: { incidents: IncidentRepository }` → `"incidents"`).
22
+ * Pass `{ transactional: true }` / `{ requestScoped: true }` so `provide`
23
+ * throws if the impl is missing `bindTo` / `fork`.
24
+ */
25
+ export declare class PortToken<out I> {
26
+ /** Name used in runtime provide/completeness errors. */
27
+ readonly key: string;
28
+ /** Runtime capability flags. `provide()` checks `bindTo` / `fork` when set. */
29
+ readonly capabilities: {
30
+ readonly transactional: boolean;
31
+ readonly requestScoped: boolean;
32
+ };
33
+ readonly [portType]: I;
34
+ private constructor();
35
+ /** Create a token for interface `I`. Prefer `Port.token<I>('Name')` at call sites. */
36
+ static token<I>(key: string, capabilities?: PortCapabilities): PortToken<I>;
37
+ }
38
+ /** `Port.token<I>('Name')` — the usual way to create a `PortToken`. */
39
+ export declare const Port: {
40
+ token: typeof PortToken.token;
41
+ };
42
+ /** Interface stored on a `PortToken`. */
43
+ export type PortType<T> = T extends PortToken<infer I> ? I : never;
44
+ export {};
45
+ //# sourceMappingURL=port.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../../src/domain/port.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,EAAE,OAAO,MAAM,CAAC;AAEtC,4GAA4G;AAC5G,MAAM,MAAM,gBAAgB,GAAG;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,SAAS,CAAC,GAAG,CAAC,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,QAAQ,CAAC,YAAY,EAAE;QACrB,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;QAChC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;KACjC,CAAC;IACF,SAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE/B,OAAO;IASP,sFAAsF;IACtF,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAAC,CAAC;CAG5E;AAED,uEAAuE;AACvE,eAAO,MAAM,IAAI,EAAE;IAAE,KAAK,EAAE,OAAO,SAAS,CAAC,KAAK,CAAA;CAEjD,CAAC;AAEF,yCAAyC;AACzC,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * A port is a TypeScript interface plus a token used at compose time.
3
+ *
4
+ * ```ts
5
+ * export interface IncidentRepository {
6
+ * get(id: string): Promise<Incident | null>
7
+ * save(incident: Incident): Promise<void>
8
+ * }
9
+ * export const IncidentRepository = Port.token<IncidentRepository>(
10
+ * 'IncidentRepository',
11
+ * )
12
+ * ```
13
+ *
14
+ * `.build()` names a missing port by its use-case alias
15
+ * (`ports: { incidents: IncidentRepository }` → `"incidents"`).
16
+ * Pass `{ transactional: true }` / `{ requestScoped: true }` so `provide`
17
+ * throws if the impl is missing `bindTo` / `fork`.
18
+ */
19
+ export class PortToken {
20
+ /** Name used in runtime provide/completeness errors. */
21
+ key;
22
+ /** Runtime capability flags. `provide()` checks `bindTo` / `fork` when set. */
23
+ capabilities;
24
+ constructor(key, capabilities) {
25
+ this.key = key;
26
+ this.capabilities = Object.freeze({
27
+ transactional: capabilities?.transactional === true,
28
+ requestScoped: capabilities?.requestScoped === true,
29
+ });
30
+ Object.freeze(this);
31
+ }
32
+ /** Create a token for interface `I`. Prefer `Port.token<I>('Name')` at call sites. */
33
+ static token(key, capabilities) {
34
+ return new PortToken(key, capabilities);
35
+ }
36
+ }
37
+ /** `Port.token<I>('Name')` — the usual way to create a `PortToken`. */
38
+ export const Port = {
39
+ token: PortToken.token,
40
+ };
41
+ //# sourceMappingURL=port.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"port.js","sourceRoot":"","sources":["../../src/domain/port.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,SAAS;IACpB,wDAAwD;IAC/C,GAAG,CAAS;IACrB,+EAA+E;IACtE,YAAY,CAGnB;IAGF,YAAoB,GAAW,EAAE,YAA+B;QAC9D,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;YAChC,aAAa,EAAE,YAAY,EAAE,aAAa,KAAK,IAAI;YACnD,aAAa,EAAE,YAAY,EAAE,aAAa,KAAK,IAAI;SACpD,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAED,sFAAsF;IACtF,MAAM,CAAC,KAAK,CAAI,GAAW,EAAE,YAA+B;QAC1D,OAAO,IAAI,SAAS,CAAI,GAAG,EAAE,YAAY,CAAC,CAAC;IAC7C,CAAC;CACF;AAED,uEAAuE;AACvE,MAAM,CAAC,MAAM,IAAI,GAAsC;IACrD,KAAK,EAAE,SAAS,CAAC,KAAK;CACvB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { PortToken } from '../domain/index.js';
2
+ /**
3
+ * Typed factory holder. Pass the **impl** to `provide`, or use `App.adapt(factory, ...deps)`.
4
+ *
5
+ * ```ts
6
+ * const factory = Adapter.of(IncidentRepository, (db: Pool) => new PgIncidentRepo(db))
7
+ * const app = App.from(useCases).adapt(factory, pool)
8
+ * ```
9
+ */
10
+ export declare const Adapter: {
11
+ /**
12
+ * Pair a port token with a factory. Call `create(...deps)` and pass the impl
13
+ * to `App.provide` — not this holder.
14
+ */
15
+ of<I, Deps extends unknown[]>(token: PortToken<I>, create: (...deps: Deps) => I): {
16
+ /** Port token for this adapter. Use with `App.provide(token, impl)`. */
17
+ token: PortToken<I>;
18
+ /** Build the adapter impl. Composition receives that value, not the holder. */
19
+ create: (...deps: Deps) => I;
20
+ };
21
+ };
22
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/infra/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO;IAClB;;;OAGG;OACA,CAAC,EAAE,IAAI,SAAS,OAAO,EAAE,SACnB,SAAS,CAAC,CAAC,CAAC,UACX,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,GAC3B;QACD,wEAAwE;QACxE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;QACpB,+EAA+E;QAC/E,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,CAAC;KAC9B;CAGF,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Typed factory holder. Pass the **impl** to `provide`, or use `App.adapt(factory, ...deps)`.
3
+ *
4
+ * ```ts
5
+ * const factory = Adapter.of(IncidentRepository, (db: Pool) => new PgIncidentRepo(db))
6
+ * const app = App.from(useCases).adapt(factory, pool)
7
+ * ```
8
+ */
9
+ export const Adapter = {
10
+ /**
11
+ * Pair a port token with a factory. Call `create(...deps)` and pass the impl
12
+ * to `App.provide` — not this holder.
13
+ */
14
+ of(token, create) {
15
+ return { token, create };
16
+ },
17
+ };
18
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/infra/adapter.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB;;;OAGG;IACH,EAAE,CACA,KAAmB,EACnB,MAA4B;QAO5B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC3B,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { Adapter } from './adapter.js';
2
+ export { Mapper } from './mapper.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/infra/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { Adapter } from './adapter.js';
2
+ export { Mapper } from './mapper.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/infra/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { type Result } from '../core/index.js';
2
+ import type { EntityConstructor } from '../domain/index.js';
3
+ /**
4
+ * One entity, two functions. Inbound `from` wraps the mapping.
5
+ * `restore` does not run the schema; `parse` does (untyped trust
6
+ * boundary). `VALIDATION` from `parse` / `create` / `set` is rethrown
7
+ * with a mapper message.
8
+ *
9
+ * ```ts
10
+ * const IncidentMapper = Mapper.for(Incident)
11
+ * .to((e) => ({ id: e.id, closed_at: e.closedAt?.toISOString() ?? null }))
12
+ * .from((row) => Incident.restore({
13
+ * id: row.id,
14
+ * closedAt: row.closed_at ? new Date(row.closed_at) : null,
15
+ * }))
16
+ * ```
17
+ */
18
+ export declare class Mapper<E extends EntityConstructor, Row> {
19
+ #private;
20
+ private constructor();
21
+ /** Start a mapper for this entity class. Chain `.to` then `.from`. */
22
+ static for<E extends EntityConstructor>(_entity: E): MapperTo<E>;
23
+ /** Outbound. No parse. */
24
+ to(entity: E['prototype']): Row;
25
+ /** Run the inbound mapping. Rethrows `VALIDATION` from `parse` / `create` / `set`. */
26
+ from(row: Row): E['prototype'];
27
+ /**
28
+ * Same mapping, but `from` returns `Result` instead of throwing.
29
+ */
30
+ unsafe(): {
31
+ to: Mapper<E, Row>['to'];
32
+ from: (row: Row) => Result<E['prototype'], 'VALIDATION'>;
33
+ };
34
+ }
35
+ /** Next step after `Mapper.for`. Call `.to` with the outbound mapping. */
36
+ export type MapperTo<E extends EntityConstructor> = {
37
+ /** Set the outbound mapping (entity → row). Returns the `.from` builder. */
38
+ to<Row>(toFn: (entity: E['prototype']) => Row): MapperFrom<E, Row>;
39
+ };
40
+ /** Next step after `.to`. Call `.from` with the inbound mapping to finish. */
41
+ export type MapperFrom<E extends EntityConstructor, Row> = {
42
+ /**
43
+ * Set the inbound mapping (row → entity) and return the mapper.
44
+ * `restore` does not run the schema; `parse` does.
45
+ */
46
+ from(fromFn: (row: Row) => E['prototype']): Mapper<E, Row>;
47
+ };
48
+ //# sourceMappingURL=mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../src/infra/mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,MAAM,EAEZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAI5D;;;;;;;;;;;;;;GAcG;AACH,qBAAa,MAAM,CAAC,CAAC,SAAS,iBAAiB,EAAE,GAAG;;IAIlD,OAAO;IAQP,sEAAsE;IACtE,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,iBAAiB,EAAE,OAAO,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IAQhE,0BAA0B;IAC1B,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,GAAG;IAI/B,sFAAsF;IACtF,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,WAAW,CAAC;IAe9B;;OAEG;IACH,MAAM,IAAI;QACR,EAAE,EAAE,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;QACzB,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,YAAY,CAAC,CAAC;KAC1D;CAoBF;AAED,0EAA0E;AAC1E,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,iBAAiB,IAAI;IAClD,4EAA4E;IAC5E,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,WAAW,CAAC,KAAK,GAAG,GAAG,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;CACpE,CAAC;AAEF,8EAA8E;AAC9E,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,iBAAiB,EAAE,GAAG,IAAI;IACzD;;;OAGG;IACH,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;CAC5D,CAAC"}
@@ -0,0 +1,77 @@
1
+ import { CodedError, fail, ok, } from '../core/index.js';
2
+ const TRUST = 'hexok: model.from() failed entity.parse (trust boundary)';
3
+ /**
4
+ * One entity, two functions. Inbound `from` wraps the mapping.
5
+ * `restore` does not run the schema; `parse` does (untyped trust
6
+ * boundary). `VALIDATION` from `parse` / `create` / `set` is rethrown
7
+ * with a mapper message.
8
+ *
9
+ * ```ts
10
+ * const IncidentMapper = Mapper.for(Incident)
11
+ * .to((e) => ({ id: e.id, closed_at: e.closedAt?.toISOString() ?? null }))
12
+ * .from((row) => Incident.restore({
13
+ * id: row.id,
14
+ * closedAt: row.closed_at ? new Date(row.closed_at) : null,
15
+ * }))
16
+ * ```
17
+ */
18
+ export class Mapper {
19
+ #toFn;
20
+ #fromFn;
21
+ constructor(toFn, fromFn) {
22
+ this.#toFn = toFn;
23
+ this.#fromFn = fromFn;
24
+ }
25
+ /** Start a mapper for this entity class. Chain `.to` then `.from`. */
26
+ static for(_entity) {
27
+ return {
28
+ to: (toFn) => ({
29
+ from: (fromFn) => new Mapper(toFn, fromFn),
30
+ }),
31
+ };
32
+ }
33
+ /** Outbound. No parse. */
34
+ to(entity) {
35
+ return this.#toFn(entity);
36
+ }
37
+ /** Run the inbound mapping. Rethrows `VALIDATION` from `parse` / `create` / `set`. */
38
+ from(row) {
39
+ try {
40
+ return this.#fromFn(row);
41
+ }
42
+ catch (error) {
43
+ if (isValidation(error)) {
44
+ throw new CodedError({
45
+ code: error.code,
46
+ message: TRUST,
47
+ ...(error.data !== undefined ? { data: error.data } : {}),
48
+ });
49
+ }
50
+ throw error;
51
+ }
52
+ }
53
+ /**
54
+ * Same mapping, but `from` returns `Result` instead of throwing.
55
+ */
56
+ unsafe() {
57
+ return {
58
+ to: (entity) => this.to(entity),
59
+ from: (row) => {
60
+ try {
61
+ return ok(this.#fromFn(row));
62
+ }
63
+ catch (error) {
64
+ if (isValidation(error)) {
65
+ const issues = error.data?.issues;
66
+ return fail('VALIDATION', issues);
67
+ }
68
+ throw error;
69
+ }
70
+ },
71
+ };
72
+ }
73
+ }
74
+ function isValidation(error) {
75
+ return error instanceof CodedError && error.code === 'VALIDATION';
76
+ }
77
+ //# sourceMappingURL=mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapper.js","sourceRoot":"","sources":["../../src/infra/mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,IAAI,EACJ,EAAE,GAGH,MAAM,kBAAkB,CAAC;AAG1B,MAAM,KAAK,GAAG,0DAA0D,CAAC;AAEzE;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,MAAM;IACjB,KAAK,CAAkC;IACvC,OAAO,CAA+B;IAEtC,YACE,IAAqC,EACrC,MAAoC;QAEpC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,sEAAsE;IACtE,MAAM,CAAC,GAAG,CAA8B,OAAU;QAChD,OAAO;YACL,EAAE,EAAE,CAAM,IAAqC,EAAsB,EAAE,CA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MAAM,KAAK,CAAC;gBACd,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAiBD,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,UAAU,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC;AACpE,CAAC"}
@@ -0,0 +1,100 @@
1
+ import { type AsUseCaseBag, type ChannelSession, type CheckUseCase, type DerivedContract, type EventChannelCtor, type EventUseCaseCtor, type UseCaseBag } from '../app/index.js';
2
+ import type { BusAdapter, CatalogKind, ChannelAdapter, Envelope, EventAdapter, EventCatalog, EventClass, PortToken, QueueAdapter } from '../domain/index.js';
3
+ import { type ChannelGateways } from './channel.js';
4
+ import type { NestedClient } from './client.js';
5
+ import type { ChannelKindError, DuplicateCatalogError, DuplicateChannelError, DuplicatePortError, MissingMessages } from './completeness.js';
6
+ import { type Interceptor } from './interceptor.js';
7
+ import type { ApiMiddleware } from './middleware.js';
8
+ import { type RpcContract } from './rpc.js';
9
+ /** Built app: in-process client, HTTP RPC, event lifecycle, and routed channels. */
10
+ export type AppInstance<Bag extends UseCaseBag, Ctx = unknown, Routed = never> = {
11
+ /** Nested API contract (`incident.close` → `contract.incident.close`). Event and internal use cases are omitted (`trigger !== 'external'`). */
12
+ contract: DerivedContract<Bag>;
13
+ /** `fetch` handler for `POST /rpc/...`. Event handlers still require `start()`. */
14
+ router: {
15
+ fetch: (request: Request) => Promise<Response>;
16
+ };
17
+ /** In-process nested client. Same keys as `contract`; pass `{ ctx, signal }` as the second argument. */
18
+ local: NestedClient<Bag, Ctx>;
19
+ /** Event use-case constructors grouped by catalog key then event key. They subscribe only after `start()`. */
20
+ handlers: Record<string, Record<string, EventUseCaseCtor[]>>;
21
+ /** Routed channel gateways keyed by catalog key. Routing starts on `start()`. */
22
+ channels: ChannelGateways<Routed>;
23
+ /** Publish an envelope to its bound adapter now. Does not start handlers. */
24
+ publish(envelope: Envelope): Promise<void>;
25
+ /** Subscribe event handlers and start channel routing. Throws if called twice without `stop()`. */
26
+ start(): Promise<void>;
27
+ /** Stop channel and event adapters. Safe to call more than once. */
28
+ stop(): Promise<void>;
29
+ /** Nested RPC catalog (`rpc.incident.close.path`) plus flat `routes`. */
30
+ readonly rpc: RpcContract<Bag>;
31
+ };
32
+ /** Adapter `bind` expects for a catalog kind. */
33
+ export type AdapterFor<K extends CatalogKind> = K extends 'bus' ? BusAdapter : K extends 'queue' ? QueueAdapter : EventAdapter;
34
+ type ChannelCatalogKind<C> = C extends {
35
+ catalog: EventCatalog<string, infer Kind, infer _E, infer _Ctx>;
36
+ } ? Kind : CatalogKind;
37
+ type ChannelCatalogKey<C> = C extends {
38
+ catalog: EventCatalog<infer K extends string, infer _Kind, infer _E, infer _Ctx>;
39
+ } ? K : string;
40
+ /** Fluent composition. `build` is callable only after every required port, catalog, and channel is wired. */
41
+ export declare class AppBuilder<Bag extends UseCaseBag, Provided = never, Bound = never, Ctx = unknown, Routed = never> {
42
+ #private;
43
+ private constructor();
44
+ /** Start composition from a map of use-case classes. */
45
+ static from<Bag extends {
46
+ [K in keyof Bag]: CheckUseCase<Bag[K]>;
47
+ }>(useCases: Bag): AppBuilder<AsUseCaseBag<Bag>, never, never, unknown>;
48
+ /** Register a port implementation. A second `provide` for the same token is a compile-time error and a runtime throw. */
49
+ provide<I>(token: [PortToken<I>] extends [Provided] ? DuplicatePortError : PortToken<I>, impl: I): AppBuilder<Bag, Provided | PortToken<I>, Bound, Ctx, Routed>;
50
+ /** Bind an event adapter to a catalog. Adapter `kind` must match; a second bind of the same catalog fails. */
51
+ bind<Key extends string, Kind extends CatalogKind, Events extends EventClass = never, CatCtx = undefined>(catalog: [EventCatalog<Key, Kind, Events, CatCtx>] extends [Bound] ? DuplicateCatalogError<Key> : EventCatalog<Key, Kind, Events, CatCtx>, adapter: AdapterFor<Kind>): AppBuilder<Bag, Provided, Bound | EventCatalog<Key, Kind, Events, CatCtx>, Ctx, Routed>;
52
+ /** Route a channel class to a presence adapter. The channel catalog must be a bus and still needs `bind`. */
53
+ route<C extends EventChannelCtor>(channel: ChannelCatalogKind<C> extends 'bus' ? [C] extends [Routed] ? DuplicateChannelError<ChannelCatalogKey<C>> : C : ChannelKindError<ChannelCatalogKey<C>, ChannelCatalogKind<C> & string>, adapter: ChannelAdapter<ChannelSession<C>>): AppBuilder<Bag, Provided, Bound, Ctx, Routed | C>;
54
+ /** Set the default request context for `local`, HTTP, and event handlers. Per-call `ctx` overrides it. */
55
+ ctx<C>(defaults?: C): AppBuilder<Bag, Provided, Bound, C, Routed>;
56
+ /**
57
+ * Set HTTP request context from the `Request`. `body.ctx` is ignored.
58
+ * Call `.ctx<C>()` first so `ctx` is typed. `local` still uses `.ctx()` / per-call `{ ctx }`.
59
+ */
60
+ ctxFrom(fn: (args: {
61
+ request: Request;
62
+ ctx: Ctx;
63
+ }) => Ctx | Promise<Ctx>): this;
64
+ /**
65
+ * Provide a factory from `Adapter.of` by calling `create(...deps)`.
66
+ * Same as `.provide(factory.token, factory.create(...deps))`.
67
+ */
68
+ adapt<I, Deps extends unknown[]>(factory: {
69
+ token: [PortToken<I>] extends [Provided] ? DuplicatePortError : PortToken<I>;
70
+ create: (...deps: Deps) => I;
71
+ }, ...deps: Deps): AppBuilder<Bag, Provided | PortToken<I>, Bound, Ctx, Routed>;
72
+ /** Register middleware around external `execute` (`local` and HTTP) — not event handlers or nested `run`. */
73
+ use(middleware: ApiMiddleware): this;
74
+ /** Register an interceptor. First registered is outer for execute, adapter, publish, and dispatch. Duplicate `key` throws. */
75
+ intercept(interceptor: Interceptor): this;
76
+ /**
77
+ * Complete the graph. Incomplete builders expose `build` as the missing
78
+ * port/catalog message (not callable). Runtime throws the same sentences.
79
+ */
80
+ get build(): [MissingMessages<Bag, Provided, Bound, Routed>] extends [never] ? () => AppInstance<Bag, Ctx, Routed> : MissingMessages<Bag, Provided, Bound, Routed>;
81
+ }
82
+ /**
83
+ * Composition root. `build()` is only callable when every required port
84
+ * and event catalog is provided.
85
+ *
86
+ * ```ts
87
+ * const app = App.from({ close: CloseIncident })
88
+ * .provide(IncidentRepository, repo)
89
+ * .provide(Clock, clock)
90
+ * .bind(DomainEvents, bus)
91
+ * .build()
92
+ * await app.local.incident.close({ id: '1' })
93
+ * ```
94
+ */
95
+ export declare const App: {
96
+ /** Start composition from a map of use-case classes. */
97
+ from: typeof AppBuilder.from;
98
+ };
99
+ export {};
100
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/runtime/app.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,eAAe,EAEpB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EAMrB,KAAK,UAAU,EAGhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAEV,UAAU,EACV,WAAW,EACX,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,SAAS,EACT,YAAY,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,eAAe,EAMrB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,KAAK,WAAW,EAAqB,MAAM,kBAAkB,CAAC;AAEvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvD,oFAAoF;AACpF,MAAM,MAAM,WAAW,CACrB,GAAG,SAAS,UAAU,EACtB,GAAG,GAAG,OAAO,EACb,MAAM,GAAG,KAAK,IACZ;IACF,+IAA+I;IAC/I,QAAQ,EAAE,eAAe,CAAC,GAAG,CAAC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