@asenajs/ioc 0.0.0-stage → 0.1.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 (147) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +219 -2
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +2 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/CircularDependencyDetector.d.ts +49 -0
  7. package/dist/lib/CircularDependencyDetector.js +69 -0
  8. package/dist/lib/CircularDependencyDetector.js.map +1 -0
  9. package/dist/lib/Container.d.ts +247 -0
  10. package/dist/lib/Container.js +563 -0
  11. package/dist/lib/Container.js.map +1 -0
  12. package/dist/lib/IocApplication.d.ts +88 -0
  13. package/dist/lib/IocApplication.js +110 -0
  14. package/dist/lib/IocApplication.js.map +1 -0
  15. package/dist/lib/IocEngine.d.ts +173 -0
  16. package/dist/lib/IocEngine.js +725 -0
  17. package/dist/lib/IocEngine.js.map +1 -0
  18. package/dist/lib/component/Scope.d.ts +4 -0
  19. package/dist/lib/component/Scope.js +6 -0
  20. package/dist/lib/component/Scope.js.map +1 -0
  21. package/dist/lib/component/componentRegistry.d.ts +34 -0
  22. package/dist/lib/component/componentRegistry.js +134 -0
  23. package/dist/lib/component/componentRegistry.js.map +1 -0
  24. package/dist/lib/component/componentUtils.d.ts +16 -0
  25. package/dist/lib/component/componentUtils.js +44 -0
  26. package/dist/lib/component/componentUtils.js.map +1 -0
  27. package/dist/lib/component/decorators/Component.d.ts +8 -0
  28. package/dist/lib/component/decorators/Component.js +12 -0
  29. package/dist/lib/component/decorators/Component.js.map +1 -0
  30. package/dist/lib/component/decorators/Implements.d.ts +7 -0
  31. package/dist/lib/component/decorators/Implements.js +14 -0
  32. package/dist/lib/component/decorators/Implements.js.map +1 -0
  33. package/dist/lib/component/decorators/Inject.d.ts +29 -0
  34. package/dist/lib/component/decorators/Inject.js +82 -0
  35. package/dist/lib/component/decorators/Inject.js.map +1 -0
  36. package/dist/lib/component/decorators/OnStart.d.ts +20 -0
  37. package/dist/lib/component/decorators/OnStart.js +33 -0
  38. package/dist/lib/component/decorators/OnStart.js.map +1 -0
  39. package/dist/lib/component/decorators/OnStop.d.ts +15 -0
  40. package/dist/lib/component/decorators/OnStop.js +28 -0
  41. package/dist/lib/component/decorators/OnStop.js.map +1 -0
  42. package/dist/lib/component/decorators/PostConstruct.d.ts +14 -0
  43. package/dist/lib/component/decorators/PostConstruct.js +16 -0
  44. package/dist/lib/component/decorators/PostConstruct.js.map +1 -0
  45. package/dist/lib/component/decorators/PostProcessor.d.ts +25 -0
  46. package/dist/lib/component/decorators/PostProcessor.js +29 -0
  47. package/dist/lib/component/decorators/PostProcessor.js.map +1 -0
  48. package/dist/lib/component/decorators/Service.d.ts +8 -0
  49. package/dist/lib/component/decorators/Service.js +12 -0
  50. package/dist/lib/component/decorators/Service.js.map +1 -0
  51. package/dist/lib/component/decorators/Strategy.d.ts +9 -0
  52. package/dist/lib/component/decorators/Strategy.js +29 -0
  53. package/dist/lib/component/decorators/Strategy.js.map +1 -0
  54. package/dist/lib/component/decorators/Value.d.ts +29 -0
  55. package/dist/lib/component/decorators/Value.js +41 -0
  56. package/dist/lib/component/decorators/Value.js.map +1 -0
  57. package/dist/lib/component/decorators/index.d.ts +11 -0
  58. package/dist/lib/component/decorators/index.js +12 -0
  59. package/dist/lib/component/decorators/index.js.map +1 -0
  60. package/dist/lib/component/decorators/legacyDecorator.d.ts +15 -0
  61. package/dist/lib/component/decorators/legacyDecorator.js +24 -0
  62. package/dist/lib/component/decorators/legacyDecorator.js.map +1 -0
  63. package/dist/lib/component/index.d.ts +3 -0
  64. package/dist/lib/component/index.js +4 -0
  65. package/dist/lib/component/index.js.map +1 -0
  66. package/dist/lib/constants/ComponentConstants.d.ts +21 -0
  67. package/dist/lib/constants/ComponentConstants.js +25 -0
  68. package/dist/lib/constants/ComponentConstants.js.map +1 -0
  69. package/dist/lib/constants/index.d.ts +1 -0
  70. package/dist/lib/constants/index.js +2 -0
  71. package/dist/lib/constants/index.js.map +1 -0
  72. package/dist/lib/decorators/CoreService.d.ts +11 -0
  73. package/dist/lib/decorators/CoreService.js +30 -0
  74. package/dist/lib/decorators/CoreService.js.map +1 -0
  75. package/dist/lib/decorators/index.d.ts +1 -0
  76. package/dist/lib/decorators/index.js +2 -0
  77. package/dist/lib/decorators/index.js.map +1 -0
  78. package/dist/lib/helper/fileHelper.d.ts +1 -0
  79. package/dist/lib/helper/fileHelper.js +29 -0
  80. package/dist/lib/helper/fileHelper.js.map +1 -0
  81. package/dist/lib/helper/iocHelper.d.ts +2 -0
  82. package/dist/lib/helper/iocHelper.js +12 -0
  83. package/dist/lib/helper/iocHelper.js.map +1 -0
  84. package/dist/lib/helper/valueResolver.d.ts +24 -0
  85. package/dist/lib/helper/valueResolver.js +37 -0
  86. package/dist/lib/helper/valueResolver.js.map +1 -0
  87. package/dist/lib/index.d.ts +12 -0
  88. package/dist/lib/index.js +13 -0
  89. package/dist/lib/index.js.map +1 -0
  90. package/dist/lib/lifecycle/LifecycleService.d.ts +78 -0
  91. package/dist/lib/lifecycle/LifecycleService.js +181 -0
  92. package/dist/lib/lifecycle/LifecycleService.js.map +1 -0
  93. package/dist/lib/lifecycle/LifecycleState.d.ts +20 -0
  94. package/dist/lib/lifecycle/LifecycleState.js +22 -0
  95. package/dist/lib/lifecycle/LifecycleState.js.map +1 -0
  96. package/dist/lib/lifecycle/index.d.ts +2 -0
  97. package/dist/lib/lifecycle/index.js +3 -0
  98. package/dist/lib/lifecycle/index.js.map +1 -0
  99. package/dist/lib/logger/IocLogger.d.ts +35 -0
  100. package/dist/lib/logger/IocLogger.js +2 -0
  101. package/dist/lib/logger/IocLogger.js.map +1 -0
  102. package/dist/lib/logger/index.d.ts +1 -0
  103. package/dist/lib/logger/index.js +2 -0
  104. package/dist/lib/logger/index.js.map +1 -0
  105. package/dist/lib/types/Class.d.ts +1 -0
  106. package/dist/lib/types/Class.js +2 -0
  107. package/dist/lib/types/Class.js.map +1 -0
  108. package/dist/lib/types/ComponentPostProcessor.d.ts +30 -0
  109. package/dist/lib/types/ComponentPostProcessor.js +2 -0
  110. package/dist/lib/types/ComponentPostProcessor.js.map +1 -0
  111. package/dist/lib/types/ContainerService.d.ts +6 -0
  112. package/dist/lib/types/ContainerService.js +2 -0
  113. package/dist/lib/types/ContainerService.js.map +1 -0
  114. package/dist/lib/types/ICoreService.d.ts +9 -0
  115. package/dist/lib/types/ICoreService.js +2 -0
  116. package/dist/lib/types/ICoreService.js.map +1 -0
  117. package/dist/lib/types/ICoreServiceNames.d.ts +10 -0
  118. package/dist/lib/types/ICoreServiceNames.js +12 -0
  119. package/dist/lib/types/ICoreServiceNames.js.map +1 -0
  120. package/dist/lib/types/InjectableComponent.d.ts +42 -0
  121. package/dist/lib/types/InjectableComponent.js +2 -0
  122. package/dist/lib/types/InjectableComponent.js.map +1 -0
  123. package/dist/lib/types/IocConfig.d.ts +11 -0
  124. package/dist/lib/types/IocConfig.js +2 -0
  125. package/dist/lib/types/IocConfig.js.map +1 -0
  126. package/dist/lib/types/LifecycleComponent.d.ts +29 -0
  127. package/dist/lib/types/LifecycleComponent.js +2 -0
  128. package/dist/lib/types/LifecycleComponent.js.map +1 -0
  129. package/dist/lib/types/decorators/ComponentParams.d.ts +5 -0
  130. package/dist/lib/types/decorators/ComponentParams.js +2 -0
  131. package/dist/lib/types/decorators/ComponentParams.js.map +1 -0
  132. package/dist/lib/types/decorators/ComponentType.d.ts +14 -0
  133. package/dist/lib/types/decorators/ComponentType.js +10 -0
  134. package/dist/lib/types/decorators/ComponentType.js.map +1 -0
  135. package/dist/lib/types/decorators/ServiceParams.d.ts +2 -0
  136. package/dist/lib/types/decorators/ServiceParams.js +2 -0
  137. package/dist/lib/types/decorators/ServiceParams.js.map +1 -0
  138. package/dist/lib/types/index.d.ts +11 -0
  139. package/dist/lib/types/index.js +12 -0
  140. package/dist/lib/types/index.js.map +1 -0
  141. package/dist/lib/utils/errorChain.d.ts +4 -0
  142. package/dist/lib/utils/errorChain.js +29 -0
  143. package/dist/lib/utils/errorChain.js.map +1 -0
  144. package/dist/lib/utils/typedMetadata.d.ts +54 -0
  145. package/dist/lib/utils/typedMetadata.js +97 -0
  146. package/dist/lib/utils/typedMetadata.js.map +1 -0
  147. package/package.json +73 -4
@@ -0,0 +1,78 @@
1
+ import { type ICoreService } from '../types';
2
+ import { LifecycleState } from './LifecycleState';
3
+ /**
4
+ * @description LifecycleService - runs component start and stop hooks.
5
+ *
6
+ * The container used to run `@PostConstruct` inside `register()`, which put a component's
7
+ * initialisation in the middle of the scan: the graph was half-built, and there was no
8
+ * counterpart to release what the hook had acquired. Every component that opened a
9
+ * connection therefore leaked it past shutdown.
10
+ *
11
+ * Both halves now live here, and they are symmetric:
12
+ * - start walks the components in registration order, so dependencies start first
13
+ * - stop walks them backwards, so a component still has its dependencies while it lets go
14
+ *
15
+ * The two failure policies are deliberately different. A start hook that throws aborts the
16
+ * start - a half-initialised application should not go on to do its work - and the components
17
+ * that already started are rolled back first. A stop hook that throws or hangs is logged and
18
+ * skipped, because a shutdown that gives up halfway leaves more behind than one that limps to
19
+ * the end.
20
+ */
21
+ export declare class LifecycleService implements ICoreService {
22
+ readonly serviceName = "LifecycleService";
23
+ private logger;
24
+ private container;
25
+ private _state;
26
+ get state(): LifecycleState;
27
+ /**
28
+ * @description Run every pending start hook, in registration order.
29
+ *
30
+ * Components registered in immediate mode - core services and the post-processor closure -
31
+ * ran theirs at construction and are skipped here.
32
+ *
33
+ * @returns {Promise<void>}
34
+ * @throws When a hook fails, after rolling back the components that already started
35
+ */
36
+ start(): Promise<void>;
37
+ /**
38
+ * @description Run stop hooks for everything that started, in reverse order.
39
+ *
40
+ * Safe to call on an application that never started, or that failed while starting: the components
41
+ * that never ran their start hooks are skipped, so nothing gets torn down that was never
42
+ * brought up. Safe to call twice - a stopped component is not stopped again.
43
+ *
44
+ * @param {number} hookTimeout - Per-hook ceiling in milliseconds
45
+ * @returns {Promise<number>} How many hooks threw, rejected or ran out of time
46
+ */
47
+ stop(hookTimeout?: number): Promise<number>;
48
+ /**
49
+ * @description Flip to STOPPING before any teardown begins.
50
+ *
51
+ * For a shutdown that has work to do before the stop hooks run: calling this first makes
52
+ * {@link LifecycleService.state} say so for the whole drain, not just for the instant between
53
+ * the hooks finishing and the process exiting.
54
+ *
55
+ * @returns {void}
56
+ */
57
+ markStopping(): void;
58
+ /**
59
+ * @description Walk components backwards running their @OnStop hooks, containing every failure.
60
+ * @param {LifecycleComponent[]} components - The registration-ordered list
61
+ * @param {number} hookTimeout - Per-hook ceiling in milliseconds
62
+ * @returns {Promise<{ stopped: number; failedHooks: number }>} Components stopped, and hooks that failed
63
+ */
64
+ private stopComponents;
65
+ /**
66
+ * @description Bound wait on a hook.
67
+ *
68
+ * A hook that never settles would otherwise hold the process open forever - the exact failure
69
+ * a graceful shutdown is supposed to prevent. The timer is always cleared, including on the
70
+ * happy path, so a fast shutdown is not held up by a pending timeout.
71
+ *
72
+ * @param {unknown} result - Whatever the hook returned
73
+ * @param {number} ms - Ceiling in milliseconds
74
+ * @param {string} label - Hook name for the error message
75
+ * @returns {Promise<void>}
76
+ */
77
+ private withTimeout;
78
+ }
@@ -0,0 +1,181 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Inject } from '../component';
11
+ import { CoreService } from '../decorators';
12
+ import { ICoreServiceNames } from '../types';
13
+ import { describeErrorChain } from '../utils/errorChain';
14
+ import { LifecycleState } from './LifecycleState';
15
+ /** Per-hook ceiling when none is configured. */
16
+ const DEFAULT_HOOK_TIMEOUT = 5000;
17
+ /**
18
+ * @description LifecycleService - runs component start and stop hooks.
19
+ *
20
+ * The container used to run `@PostConstruct` inside `register()`, which put a component's
21
+ * initialisation in the middle of the scan: the graph was half-built, and there was no
22
+ * counterpart to release what the hook had acquired. Every component that opened a
23
+ * connection therefore leaked it past shutdown.
24
+ *
25
+ * Both halves now live here, and they are symmetric:
26
+ * - start walks the components in registration order, so dependencies start first
27
+ * - stop walks them backwards, so a component still has its dependencies while it lets go
28
+ *
29
+ * The two failure policies are deliberately different. A start hook that throws aborts the
30
+ * start - a half-initialised application should not go on to do its work - and the components
31
+ * that already started are rolled back first. A stop hook that throws or hangs is logged and
32
+ * skipped, because a shutdown that gives up halfway leaves more behind than one that limps to
33
+ * the end.
34
+ */
35
+ let LifecycleService = class LifecycleService {
36
+ serviceName = 'LifecycleService';
37
+ logger;
38
+ container;
39
+ _state = LifecycleState.NEW;
40
+ get state() {
41
+ return this._state;
42
+ }
43
+ /**
44
+ * @description Run every pending start hook, in registration order.
45
+ *
46
+ * Components registered in immediate mode - core services and the post-processor closure -
47
+ * ran theirs at construction and are skipped here.
48
+ *
49
+ * @returns {Promise<void>}
50
+ * @throws When a hook fails, after rolling back the components that already started
51
+ */
52
+ async start() {
53
+ this._state = LifecycleState.STARTING;
54
+ const components = this.container.lifecycle;
55
+ let started = 0;
56
+ for (const component of components) {
57
+ if (component.started)
58
+ continue;
59
+ try {
60
+ await this.container.executeStartHooks(component.instance, component.Class);
61
+ // Set after the hooks succeed, and regardless of whether the class declared any: it is
62
+ // what makes the component eligible for its stop hooks, and a component with only an
63
+ // @OnStop still has something to release.
64
+ component.started = true;
65
+ started++;
66
+ }
67
+ catch (error) {
68
+ this._state = LifecycleState.FAILED;
69
+ this.logger.error(`[Lifecycle] ${component.key} failed to start: ${describeErrorChain(error)} - rolling back ${started} started component(s)`);
70
+ await this.stopComponents(components, DEFAULT_HOOK_TIMEOUT);
71
+ throw error;
72
+ }
73
+ }
74
+ this._state = LifecycleState.STARTED;
75
+ if (started > 0) {
76
+ this.logger.debug?.(`[Lifecycle] started ${started} component(s)`);
77
+ }
78
+ }
79
+ /**
80
+ * @description Run stop hooks for everything that started, in reverse order.
81
+ *
82
+ * Safe to call on an application that never started, or that failed while starting: the components
83
+ * that never ran their start hooks are skipped, so nothing gets torn down that was never
84
+ * brought up. Safe to call twice - a stopped component is not stopped again.
85
+ *
86
+ * @param {number} hookTimeout - Per-hook ceiling in milliseconds
87
+ * @returns {Promise<number>} How many hooks threw, rejected or ran out of time
88
+ */
89
+ async stop(hookTimeout = DEFAULT_HOOK_TIMEOUT) {
90
+ this.markStopping();
91
+ const { stopped, failedHooks } = await this.stopComponents(this.container.lifecycle, hookTimeout);
92
+ this._state = LifecycleState.STOPPED;
93
+ if (stopped > 0) {
94
+ this.logger.debug?.(`[Lifecycle] stopped ${stopped} component(s)`);
95
+ }
96
+ return failedHooks;
97
+ }
98
+ /**
99
+ * @description Flip to STOPPING before any teardown begins.
100
+ *
101
+ * For a shutdown that has work to do before the stop hooks run: calling this first makes
102
+ * {@link LifecycleService.state} say so for the whole drain, not just for the instant between
103
+ * the hooks finishing and the process exiting.
104
+ *
105
+ * @returns {void}
106
+ */
107
+ markStopping() {
108
+ this._state = LifecycleState.STOPPING;
109
+ }
110
+ /**
111
+ * @description Walk components backwards running their @OnStop hooks, containing every failure.
112
+ * @param {LifecycleComponent[]} components - The registration-ordered list
113
+ * @param {number} hookTimeout - Per-hook ceiling in milliseconds
114
+ * @returns {Promise<{ stopped: number; failedHooks: number }>} Components stopped, and hooks that failed
115
+ */
116
+ async stopComponents(components, hookTimeout) {
117
+ let stopped = 0;
118
+ let failedHooks = 0;
119
+ for (let index = components.length - 1; index >= 0; index--) {
120
+ const component = components[index];
121
+ if (!component.started)
122
+ continue;
123
+ // Cleared before the hooks run, not after: a hook that throws has already done whatever
124
+ // part of its teardown it managed, and running it a second time on the next stop() would
125
+ // be worse than skipping it.
126
+ component.started = false;
127
+ stopped++;
128
+ for (const hook of this.container.getStopHooks(component.Class)) {
129
+ const label = `${component.Class.name}.${hook}()`;
130
+ try {
131
+ await this.withTimeout(component.instance[hook](), hookTimeout, label);
132
+ }
133
+ catch (error) {
134
+ failedHooks++;
135
+ this.logger.error(`[Lifecycle] @OnStop hook '${label}' failed, continuing shutdown: ${describeErrorChain(error)}`);
136
+ }
137
+ }
138
+ }
139
+ return { stopped, failedHooks };
140
+ }
141
+ /**
142
+ * @description Bound wait on a hook.
143
+ *
144
+ * A hook that never settles would otherwise hold the process open forever - the exact failure
145
+ * a graceful shutdown is supposed to prevent. The timer is always cleared, including on the
146
+ * happy path, so a fast shutdown is not held up by a pending timeout.
147
+ *
148
+ * @param {unknown} result - Whatever the hook returned
149
+ * @param {number} ms - Ceiling in milliseconds
150
+ * @param {string} label - Hook name for the error message
151
+ * @returns {Promise<void>}
152
+ */
153
+ async withTimeout(result, ms, label) {
154
+ let timer;
155
+ try {
156
+ await Promise.race([
157
+ Promise.resolve(result),
158
+ new Promise((_, reject) => {
159
+ timer = setTimeout(() => reject(new Error(`${label} did not finish within ${ms}ms`)), ms);
160
+ }),
161
+ ]);
162
+ }
163
+ finally {
164
+ if (timer)
165
+ clearTimeout(timer);
166
+ }
167
+ }
168
+ };
169
+ __decorate([
170
+ Inject(ICoreServiceNames.LOGGER),
171
+ __metadata("design:type", Object)
172
+ ], LifecycleService.prototype, "logger", void 0);
173
+ __decorate([
174
+ Inject(ICoreServiceNames.CONTAINER),
175
+ __metadata("design:type", Function)
176
+ ], LifecycleService.prototype, "container", void 0);
177
+ LifecycleService = __decorate([
178
+ CoreService(ICoreServiceNames.LIFECYCLE_SERVICE)
179
+ ], LifecycleService);
180
+ export { LifecycleService };
181
+ //# sourceMappingURL=LifecycleService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,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GAAG,KAAK,0BAA0B,EAAE,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC5F,CAAC,CAAC;aACH,CAAC,CAAC;QACL,CAAC;gBAAS,CAAC;YACT,IAAI,KAAK;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;CACF,CAAA;AAhKS;IADP,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC;;gDACN;AAGnB;IADP,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC;;mDACN;AAPnB,gBAAgB;IAD5B,WAAW,CAAC,iBAAiB,CAAC,iBAAiB,CAAC;GACpC,gBAAgB,CAoK5B"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @description Where the application is in its start/stop cycle.
3
+ *
4
+ * Runtime state: it goes back and forth, anything reporting readiness reads it, and `stop()`
5
+ * uses it to decide what may be torn down.
6
+ */
7
+ export declare enum LifecycleState {
8
+ /** Constructed, `start()` not called yet. */
9
+ NEW = "NEW",
10
+ /** Inside `start()` - start hooks are running. */
11
+ STARTING = "STARTING",
12
+ /** Every start hook completed; the application is running. */
13
+ STARTED = "STARTED",
14
+ /** Inside `stop()` - already draining, so no longer ready for work. */
15
+ STOPPING = "STOPPING",
16
+ /** Stopped. Stop hooks have run for everything that started. */
17
+ STOPPED = "STOPPED",
18
+ /** A start hook threw. Whatever had started was rolled back. */
19
+ FAILED = "FAILED"
20
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @description Where the application is in its start/stop cycle.
3
+ *
4
+ * Runtime state: it goes back and forth, anything reporting readiness reads it, and `stop()`
5
+ * uses it to decide what may be torn down.
6
+ */
7
+ export var LifecycleState;
8
+ (function (LifecycleState) {
9
+ /** Constructed, `start()` not called yet. */
10
+ LifecycleState["NEW"] = "NEW";
11
+ /** Inside `start()` - start hooks are running. */
12
+ LifecycleState["STARTING"] = "STARTING";
13
+ /** Every start hook completed; the application is running. */
14
+ LifecycleState["STARTED"] = "STARTED";
15
+ /** Inside `stop()` - already draining, so no longer ready for work. */
16
+ LifecycleState["STOPPING"] = "STOPPING";
17
+ /** Stopped. Stop hooks have run for everything that started. */
18
+ LifecycleState["STOPPED"] = "STOPPED";
19
+ /** A start hook threw. Whatever had started was rolled back. */
20
+ LifecycleState["FAILED"] = "FAILED";
21
+ })(LifecycleState || (LifecycleState = {}));
22
+ //# sourceMappingURL=LifecycleState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LifecycleState.js","sourceRoot":"","sources":["../../../lib/lifecycle/LifecycleState.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAN,IAAY,cAaX;AAbD,WAAY,cAAc;IACxB,6CAA6C;IAC7C,6BAAW,CAAA;IACX,kDAAkD;IAClD,uCAAqB,CAAA;IACrB,8DAA8D;IAC9D,qCAAmB,CAAA;IACnB,uEAAuE;IACvE,uCAAqB,CAAA;IACrB,gEAAgE;IAChE,qCAAmB,CAAA;IACnB,gEAAgE;IAChE,mCAAiB,CAAA;AACnB,CAAC,EAbW,cAAc,KAAd,cAAc,QAazB"}
@@ -0,0 +1,2 @@
1
+ export * from './LifecycleService';
2
+ export * from './LifecycleState';
@@ -0,0 +1,3 @@
1
+ export * from './LifecycleService';
2
+ export * from './LifecycleState';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/lifecycle/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Where the container reports what it finds while registering, starting and stopping components.
3
+ *
4
+ * Deliberately narrow, so that any logger with these methods can be passed as it is.
5
+ */
6
+ export interface IocLogger {
7
+ /**
8
+ * Logs an informational message.
9
+ * @param message - The message to log.
10
+ * @param meta - Optional metadata to include with the log.
11
+ */
12
+ info: (message: string, meta?: any) => void;
13
+ /**
14
+ * Logs a warning message.
15
+ * @param message - The message to log.
16
+ * @param meta - Optional metadata to include with the log.
17
+ */
18
+ warn: (message: string, meta?: any) => void;
19
+ /**
20
+ * Logs an error message.
21
+ * @param message - The message to log.
22
+ * @param meta - Optional metadata to include with the log.
23
+ */
24
+ error: (message: string, meta?: any) => void;
25
+ /**
26
+ * Logs a debug message.
27
+ *
28
+ * Optional, and callers fall back to silence when it is absent: everything the container
29
+ * sends here is a diagnostic that should stay quiet unless someone is looking.
30
+ *
31
+ * @param message - The message to log.
32
+ * @param meta - Optional metadata to include with the log.
33
+ */
34
+ debug?: (message: string, meta?: any) => void;
35
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IocLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IocLogger.js","sourceRoot":"","sources":["../../../lib/logger/IocLogger.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from './IocLogger';
@@ -0,0 +1,2 @@
1
+ export * from './IocLogger';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/logger/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
@@ -0,0 +1 @@
1
+ export type Class<T = any> = new (...args: any[]) => T;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Class.js","sourceRoot":"","sources":["../../../lib/types/Class.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Interface for post-processing component instances after creation.
3
+ *
4
+ * PostProcessors run once at startup during component creation (NOT on every method call).
5
+ * They are registered in FIFO order and executed sequentially.
6
+ *
7
+ * Two usage modes:
8
+ * - **Mode 1 (Instance Transformation):** Return a modified instance (e.g., Proxy wrapper for tracing)
9
+ * - **Mode 2 (Metadata Collection):** Read metadata and return the original instance unchanged
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * @PostProcessor()
14
+ * class TracingPostProcessor implements ComponentPostProcessor {
15
+ * postProcess<T>(instance: T, Class: any): T {
16
+ * return new Proxy(instance, { ... }); // Mode 1: wrap with Proxy
17
+ * }
18
+ * }
19
+ * ```
20
+ */
21
+ export interface ComponentPostProcessor {
22
+ /**
23
+ * Process a component instance after creation and dependency injection.
24
+ *
25
+ * @param instance - The fully initialized component instance (after DI + PostConstruct)
26
+ * @param Class - The original class constructor (for metadata reading)
27
+ * @returns The processed instance (same or modified). Return null/undefined to keep original.
28
+ */
29
+ postProcess<T>(instance: T, Class: any): T | Promise<T>;
30
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ComponentPostProcessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComponentPostProcessor.js","sourceRoot":"","sources":["../../../lib/types/ComponentPostProcessor.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { Class } from './Class';
2
+ export interface ContainerService {
3
+ Class: Class;
4
+ instance: any | null;
5
+ singleton: boolean;
6
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ContainerService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContainerService.js","sourceRoot":"","sources":["../../../lib/types/ContainerService.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @description Interface for core services
3
+ * Provides lifecycle hooks for initialization and cleanup
4
+ */
5
+ export interface ICoreService {
6
+ readonly serviceName: string;
7
+ onInit?(): Promise<void> | void;
8
+ onDestroy?(): Promise<void> | void;
9
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ICoreService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ICoreService.js","sourceRoot":"","sources":["../../../lib/types/ICoreService.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @description The names the container's own services are registered under.
3
+ * Components inject them by these names, e.g. `@Inject(ICoreServiceNames.CONTAINER)`.
4
+ */
5
+ export declare enum ICoreServiceNames {
6
+ CONTAINER = "Container",
7
+ LOGGER = "IocLogger",
8
+ IOC_ENGINE = "IocEngine",
9
+ LIFECYCLE_SERVICE = "LifecycleService"
10
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @description The names the container's own services are registered under.
3
+ * Components inject them by these names, e.g. `@Inject(ICoreServiceNames.CONTAINER)`.
4
+ */
5
+ export var ICoreServiceNames;
6
+ (function (ICoreServiceNames) {
7
+ ICoreServiceNames["CONTAINER"] = "Container";
8
+ ICoreServiceNames["LOGGER"] = "IocLogger";
9
+ ICoreServiceNames["IOC_ENGINE"] = "IocEngine";
10
+ ICoreServiceNames["LIFECYCLE_SERVICE"] = "LifecycleService";
11
+ })(ICoreServiceNames || (ICoreServiceNames = {}));
12
+ //# sourceMappingURL=ICoreServiceNames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ICoreServiceNames.js","sourceRoot":"","sources":["../../../lib/types/ICoreServiceNames.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,4CAAuB,CAAA;IACvB,yCAAoB,CAAA;IACpB,6CAAwB,CAAA;IACxB,2DAAsC,CAAA;AACxC,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B"}
@@ -0,0 +1,42 @@
1
+ import type { Class } from './Class';
2
+ export interface InjectableComponent {
3
+ Class: Class;
4
+ interface: string;
5
+ }
6
+ export interface Dependencies {
7
+ [key: string]: string;
8
+ }
9
+ /**
10
+ * Maps a field name to the class reference it was injected with.
11
+ *
12
+ * Only populated for class-based injections (`@Inject(UserService)`); string-based
13
+ * injections (`@Inject('UserService')`) carry no class reference and are absent here.
14
+ * Lets tooling derive the real class shape - to generate method mocks, for instance.
15
+ */
16
+ export interface DependencyClasses {
17
+ [key: string]: Class;
18
+ }
19
+ export interface Expressions {
20
+ [key: string]: (injectedClass: any) => any;
21
+ }
22
+ export interface Strategies {
23
+ [key: string]: string;
24
+ }
25
+ /**
26
+ * Options accepted by the @Value decorator. `default` is applied when the environment
27
+ * variable is not set; `parse` converts the raw string before it lands on the field.
28
+ */
29
+ export interface ValueOptions {
30
+ default?: unknown;
31
+ parse?: (raw: string) => unknown;
32
+ }
33
+ /**
34
+ * The stored @Value metadata for one field. `default` is only present when the option
35
+ * was given, so "was a default provided?" stays distinguishable from its value.
36
+ */
37
+ export interface ValueSpec extends ValueOptions {
38
+ key: string;
39
+ }
40
+ export interface ValueFields {
41
+ [field: string]: ValueSpec;
42
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=InjectableComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InjectableComponent.js","sourceRoot":"","sources":["../../../lib/types/InjectableComponent.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ export interface IocConfig {
2
+ sourceFolder: string;
3
+ rootFile?: string;
4
+ /**
5
+ * Milliseconds a single component file may take to import before the engine
6
+ * warns about it. Set to 0 to disable the warning.
7
+ *
8
+ * @default 10000
9
+ */
10
+ importTimeout?: number;
11
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IocConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IocConfig.js","sourceRoot":"","sources":["../../../lib/types/IocConfig.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import type { Class } from './Class';
2
+ /**
3
+ * Whether the container runs start hooks during construction or hands them to LifecycleService.
4
+ *
5
+ * @see Container.setStartHookMode
6
+ */
7
+ export type StartHookMode = 'immediate' | 'deferred';
8
+ /**
9
+ * A singleton taking part in the start/stop lifecycle.
10
+ *
11
+ * Recorded in registration order, which the IoC engine topologically sorted, so walking the
12
+ * list forwards starts dependencies before dependents and walking it backwards stops dependents
13
+ * before the dependencies they still need.
14
+ */
15
+ export interface LifecycleComponent {
16
+ /** The key it was registered under - used to name the component in logs. */
17
+ key: string;
18
+ /** The post-processed instance, i.e. the one every dependent was injected with. */
19
+ instance: any;
20
+ Class: Class;
21
+ /**
22
+ * Its start hooks have completed.
23
+ *
24
+ * The gate for stopping: a component that never started has nothing to unwind, and a
25
+ * `stop()` on an application that failed halfway through its start must not call stop hooks for the
26
+ * components that never got their turn.
27
+ */
28
+ started: boolean;
29
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=LifecycleComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LifecycleComponent.js","sourceRoot":"","sources":["../../../lib/types/LifecycleComponent.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { Scope } from '../../component';
2
+ export interface ComponentParams {
3
+ name?: string;
4
+ scope?: Scope;
5
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ComponentParams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComponentParams.js","sourceRoot":"","sources":["../../../../lib/types/decorators/ComponentParams.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The component kinds this package defines itself.
3
+ */
4
+ export declare enum ComponentType {
5
+ COMPONENT = "COMPONENT",
6
+ SERVICE = "SERVICE",
7
+ POST_PROCESSOR = "POST_PROCESSOR"
8
+ }
9
+ /**
10
+ * What marks a class as one kind of component. The set is open: anything built on the container
11
+ * passes its own strings or symbols to `defineComponent` and reads them back with
12
+ * `Container.resolveAll`.
13
+ */
14
+ export type ComponentKind = string | symbol;