@zudojs/runtime 0.0.1

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/README.md +37 -0
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/dependencyGraph/dependencyGraph.core.d.ts +18 -0
  4. package/dist/dependencyGraph/dependencyGraph.core.d.ts.map +1 -0
  5. package/dist/dependencyGraph/dependencyGraph.core.js +124 -0
  6. package/dist/dependencyGraph/dependencyGraph.core.js.map +1 -0
  7. package/dist/dependencyGraph/dependencyGraph.type.d.ts +43 -0
  8. package/dist/dependencyGraph/dependencyGraph.type.d.ts.map +1 -0
  9. package/dist/dependencyGraph/dependencyGraph.type.js +2 -0
  10. package/dist/dependencyGraph/dependencyGraph.type.js.map +1 -0
  11. package/dist/dependencyGraph/index.d.ts +6 -0
  12. package/dist/dependencyGraph/index.d.ts.map +1 -0
  13. package/dist/dependencyGraph/index.js +5 -0
  14. package/dist/dependencyGraph/index.js.map +1 -0
  15. package/dist/index.d.ts +28 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +27 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/lifecycle/index.d.ts +6 -0
  20. package/dist/lifecycle/index.d.ts.map +1 -0
  21. package/dist/lifecycle/index.js +5 -0
  22. package/dist/lifecycle/index.js.map +1 -0
  23. package/dist/lifecycle/lifecycle.core.d.ts +47 -0
  24. package/dist/lifecycle/lifecycle.core.d.ts.map +1 -0
  25. package/dist/lifecycle/lifecycle.core.js +267 -0
  26. package/dist/lifecycle/lifecycle.core.js.map +1 -0
  27. package/dist/lifecycle/lifecycle.type.d.ts +51 -0
  28. package/dist/lifecycle/lifecycle.type.d.ts.map +1 -0
  29. package/dist/lifecycle/lifecycle.type.js +2 -0
  30. package/dist/lifecycle/lifecycle.type.js.map +1 -0
  31. package/dist/readiness/index.d.ts +6 -0
  32. package/dist/readiness/index.d.ts.map +1 -0
  33. package/dist/readiness/index.js +5 -0
  34. package/dist/readiness/index.js.map +1 -0
  35. package/dist/readiness/readiness.core.d.ts +45 -0
  36. package/dist/readiness/readiness.core.d.ts.map +1 -0
  37. package/dist/readiness/readiness.core.js +115 -0
  38. package/dist/readiness/readiness.core.js.map +1 -0
  39. package/dist/readiness/readiness.type.d.ts +40 -0
  40. package/dist/readiness/readiness.type.d.ts.map +1 -0
  41. package/dist/readiness/readiness.type.js +2 -0
  42. package/dist/readiness/readiness.type.js.map +1 -0
  43. package/dist/registry/index.d.ts +5 -0
  44. package/dist/registry/index.d.ts.map +1 -0
  45. package/dist/registry/index.js +5 -0
  46. package/dist/registry/index.js.map +1 -0
  47. package/dist/registry/registry.core.d.ts +74 -0
  48. package/dist/registry/registry.core.d.ts.map +1 -0
  49. package/dist/registry/registry.core.js +126 -0
  50. package/dist/registry/registry.core.js.map +1 -0
  51. package/dist/runtime/runtime.core.d.ts +97 -0
  52. package/dist/runtime/runtime.core.d.ts.map +1 -0
  53. package/dist/runtime/runtime.core.js +253 -0
  54. package/dist/runtime/runtime.core.js.map +1 -0
  55. package/dist/runtimeContext/index.d.ts +7 -0
  56. package/dist/runtimeContext/index.d.ts.map +1 -0
  57. package/dist/runtimeContext/index.js +6 -0
  58. package/dist/runtimeContext/index.js.map +1 -0
  59. package/dist/runtimeContext/runtimeContext.core.d.ts +11 -0
  60. package/dist/runtimeContext/runtimeContext.core.d.ts.map +1 -0
  61. package/dist/runtimeContext/runtimeContext.core.js +41 -0
  62. package/dist/runtimeContext/runtimeContext.core.js.map +1 -0
  63. package/dist/runtimeContext/runtimeContext.factory.d.ts +14 -0
  64. package/dist/runtimeContext/runtimeContext.factory.d.ts.map +1 -0
  65. package/dist/runtimeContext/runtimeContext.factory.js +20 -0
  66. package/dist/runtimeContext/runtimeContext.factory.js.map +1 -0
  67. package/dist/runtimeContext/runtimeContext.type.d.ts +59 -0
  68. package/dist/runtimeContext/runtimeContext.type.d.ts.map +1 -0
  69. package/dist/runtimeContext/runtimeContext.type.js +2 -0
  70. package/dist/runtimeContext/runtimeContext.type.js.map +1 -0
  71. package/dist/runtimeError/index.d.ts +5 -0
  72. package/dist/runtimeError/index.d.ts.map +1 -0
  73. package/dist/runtimeError/index.js +5 -0
  74. package/dist/runtimeError/index.js.map +1 -0
  75. package/dist/runtimeError/runtimeError.base.d.ts +80 -0
  76. package/dist/runtimeError/runtimeError.base.d.ts.map +1 -0
  77. package/dist/runtimeError/runtimeError.base.js +149 -0
  78. package/dist/runtimeError/runtimeError.base.js.map +1 -0
  79. package/dist/runtimeEvents/index.d.ts +6 -0
  80. package/dist/runtimeEvents/index.d.ts.map +1 -0
  81. package/dist/runtimeEvents/index.js +5 -0
  82. package/dist/runtimeEvents/index.js.map +1 -0
  83. package/dist/runtimeEvents/runtimeEvents.core.d.ts +28 -0
  84. package/dist/runtimeEvents/runtimeEvents.core.d.ts.map +1 -0
  85. package/dist/runtimeEvents/runtimeEvents.core.js +63 -0
  86. package/dist/runtimeEvents/runtimeEvents.core.js.map +1 -0
  87. package/dist/runtimeEvents/runtimeEvents.type.d.ts +75 -0
  88. package/dist/runtimeEvents/runtimeEvents.type.d.ts.map +1 -0
  89. package/dist/runtimeEvents/runtimeEvents.type.js +2 -0
  90. package/dist/runtimeEvents/runtimeEvents.type.js.map +1 -0
  91. package/dist/runtimeOptions/index.d.ts +7 -0
  92. package/dist/runtimeOptions/index.d.ts.map +1 -0
  93. package/dist/runtimeOptions/index.js +6 -0
  94. package/dist/runtimeOptions/index.js.map +1 -0
  95. package/dist/runtimeOptions/runtimeOptions.core.d.ts +14 -0
  96. package/dist/runtimeOptions/runtimeOptions.core.d.ts.map +1 -0
  97. package/dist/runtimeOptions/runtimeOptions.core.js +37 -0
  98. package/dist/runtimeOptions/runtimeOptions.core.js.map +1 -0
  99. package/dist/runtimeOptions/runtimeOptions.type.d.ts +94 -0
  100. package/dist/runtimeOptions/runtimeOptions.type.d.ts.map +1 -0
  101. package/dist/runtimeOptions/runtimeOptions.type.js +14 -0
  102. package/dist/runtimeOptions/runtimeOptions.type.js.map +1 -0
  103. package/dist/runtimeState/index.d.ts +6 -0
  104. package/dist/runtimeState/index.d.ts.map +1 -0
  105. package/dist/runtimeState/index.js +5 -0
  106. package/dist/runtimeState/index.js.map +1 -0
  107. package/dist/runtimeState/runtimeState.core.d.ts +50 -0
  108. package/dist/runtimeState/runtimeState.core.d.ts.map +1 -0
  109. package/dist/runtimeState/runtimeState.core.js +88 -0
  110. package/dist/runtimeState/runtimeState.core.js.map +1 -0
  111. package/dist/runtimeState/runtimeState.type.d.ts +71 -0
  112. package/dist/runtimeState/runtimeState.type.d.ts.map +1 -0
  113. package/dist/runtimeState/runtimeState.type.js +2 -0
  114. package/dist/runtimeState/runtimeState.type.js.map +1 -0
  115. package/dist/shutdown/index.d.ts +5 -0
  116. package/dist/shutdown/index.d.ts.map +1 -0
  117. package/dist/shutdown/index.js +5 -0
  118. package/dist/shutdown/index.js.map +1 -0
  119. package/dist/shutdown/shutdown.core.d.ts +8 -0
  120. package/dist/shutdown/shutdown.core.d.ts.map +1 -0
  121. package/dist/shutdown/shutdown.core.js +87 -0
  122. package/dist/shutdown/shutdown.core.js.map +1 -0
  123. package/dist/signalHandler/index.d.ts +5 -0
  124. package/dist/signalHandler/index.d.ts.map +1 -0
  125. package/dist/signalHandler/index.js +5 -0
  126. package/dist/signalHandler/index.js.map +1 -0
  127. package/dist/signalHandler/signalHandler.core.d.ts +44 -0
  128. package/dist/signalHandler/signalHandler.core.d.ts.map +1 -0
  129. package/dist/signalHandler/signalHandler.core.js +90 -0
  130. package/dist/signalHandler/signalHandler.core.js.map +1 -0
  131. package/dist/startup/index.d.ts +5 -0
  132. package/dist/startup/index.d.ts.map +1 -0
  133. package/dist/startup/index.js +5 -0
  134. package/dist/startup/index.js.map +1 -0
  135. package/dist/startup/startup.core.d.ts +12 -0
  136. package/dist/startup/startup.core.d.ts.map +1 -0
  137. package/dist/startup/startup.core.js +91 -0
  138. package/dist/startup/startup.core.js.map +1 -0
  139. package/dist/testRuntime/index.d.ts +5 -0
  140. package/dist/testRuntime/index.d.ts.map +1 -0
  141. package/dist/testRuntime/index.js +5 -0
  142. package/dist/testRuntime/index.js.map +1 -0
  143. package/dist/testRuntime/testRuntime.core.d.ts +34 -0
  144. package/dist/testRuntime/testRuntime.core.d.ts.map +1 -0
  145. package/dist/testRuntime/testRuntime.core.js +81 -0
  146. package/dist/testRuntime/testRuntime.core.js.map +1 -0
  147. package/package.json +61 -0
@@ -0,0 +1,253 @@
1
+ import { canTransition, isRunning, createStatus, } from "../runtimeState/index.js";
2
+ import { createRuntimeOptions } from "../runtimeOptions/index.js";
3
+ import { createRuntimeContext } from "../runtimeContext/index.js";
4
+ import { createRuntimeId } from "../runtimeContext/index.js";
5
+ import { LifecycleManager } from "../lifecycle/index.js";
6
+ import { executeStartup, rollbackStartup } from "../startup/index.js";
7
+ import { executeShutdown } from "../shutdown/index.js";
8
+ import { SignalHandler } from "../signalHandler/index.js";
9
+ import { ReadinessTracker } from "../readiness/index.js";
10
+ import { createRuntimeEventPayload, createFailureEventPayload, createHealthEventPayload, createReadinessEventPayload, } from "../runtimeEvents/index.js";
11
+ import { createEvent } from "@zudojs/events";
12
+ import { RuntimeStartError, RuntimeStopError, RuntimeStateError, RuntimeTimeoutError, RuntimeRollbackError, toRuntimeError, } from "../runtimeError/index.js";
13
+ /**
14
+ * Default runtime implementation.
15
+ */
16
+ export class DefaultRuntime {
17
+ _state = "created";
18
+ _status;
19
+ _context;
20
+ _ready = false;
21
+ _startedAt;
22
+ _stoppedAt;
23
+ _failedAt;
24
+ _error;
25
+ options;
26
+ modules;
27
+ logger;
28
+ lifecycle;
29
+ signalHandler;
30
+ readinessTracker;
31
+ startPromise;
32
+ stopPromise;
33
+ constructor(dependencies, options) {
34
+ this.options = createRuntimeOptions(options);
35
+ this.modules = dependencies.modules;
36
+ this.logger = dependencies.logger;
37
+ this._context = createRuntimeContext({
38
+ runtimeId: this.options.runtimeId,
39
+ environment: this.options.environment,
40
+ applicationName: this.options.applicationName,
41
+ applicationVersion: this.options.applicationVersion,
42
+ logger: dependencies.logger,
43
+ container: dependencies.container,
44
+ eventBus: dependencies.eventBus,
45
+ });
46
+ this._status = createStatus("created");
47
+ this.lifecycle = new LifecycleManager(this.modules, this.logger, dependencies.container, this.options.runtimeId, this.options.environment, {
48
+ shutdownTimeout: this.options.shutdownTimeout,
49
+ continueOnFailure: false,
50
+ });
51
+ this.signalHandler = new SignalHandler(this.logger, {
52
+ handleSignals: this.options.handleSignals,
53
+ handleFatalErrors: this.options.handleFatalErrors,
54
+ });
55
+ this.readinessTracker = new ReadinessTracker({
56
+ autoMarkReady: this.options.trackReadiness,
57
+ });
58
+ }
59
+ /**
60
+ * Current runtime state.
61
+ */
62
+ get state() {
63
+ return this._state;
64
+ }
65
+ /**
66
+ * Current runtime status.
67
+ */
68
+ get status() {
69
+ return this._status;
70
+ }
71
+ /**
72
+ * Runtime context.
73
+ */
74
+ get context() {
75
+ return this._context;
76
+ }
77
+ /**
78
+ * Whether the runtime is ready.
79
+ */
80
+ get ready() {
81
+ return this._ready;
82
+ }
83
+ /**
84
+ * Starts the runtime.
85
+ */
86
+ async start() {
87
+ if (this._state === "running") {
88
+ return;
89
+ }
90
+ if (this.startPromise) {
91
+ return this.startPromise;
92
+ }
93
+ if (!canTransition(this._state, "initializing")) {
94
+ throw new RuntimeStateError(`Cannot start runtime from state "${this._state}".`);
95
+ }
96
+ this.startPromise = this.performStart();
97
+ try {
98
+ await this.startPromise;
99
+ }
100
+ finally {
101
+ this.startPromise = undefined;
102
+ }
103
+ }
104
+ /**
105
+ * Stops the runtime.
106
+ */
107
+ async stop() {
108
+ if (this._state === "stopped") {
109
+ return;
110
+ }
111
+ if (this.stopPromise) {
112
+ return this.stopPromise;
113
+ }
114
+ if (this._state === "created") {
115
+ this._state = "stopped";
116
+ this._stoppedAt = new Date();
117
+ return;
118
+ }
119
+ if (!canTransition(this._state, "stopping")) {
120
+ throw new RuntimeStateError(`Cannot stop runtime from state "${this._state}".`);
121
+ }
122
+ this.stopPromise = this.performStop();
123
+ try {
124
+ await this.stopPromise;
125
+ }
126
+ finally {
127
+ this.stopPromise = undefined;
128
+ }
129
+ }
130
+ /**
131
+ * Performs runtime startup.
132
+ */
133
+ async performStart() {
134
+ this.transitionTo("initializing");
135
+ if (this.options.emitEvents) {
136
+ this.emitEvent("runtime.initializing");
137
+ }
138
+ try {
139
+ await executeStartup(this.lifecycle, this.options.runtimeId, this._context.eventBus, this.logger, this.options.emitEvents);
140
+ this.transitionTo("running");
141
+ this._ready = true;
142
+ this._startedAt = new Date();
143
+ this.readinessTracker.markReady("Runtime started successfully.");
144
+ if (this.options.emitEvents) {
145
+ this.emitEvent("runtime.running");
146
+ this.emitEvent("runtime.readiness.changed", createReadinessEventPayload(this.options.runtimeId, "running", true, "Runtime started successfully."));
147
+ }
148
+ this.signalHandler.register(() => {
149
+ this.stop().catch((error) => {
150
+ this.logger.error("Shutdown failed.", {
151
+ errorMessage: error.message,
152
+ });
153
+ });
154
+ });
155
+ this.logger.info("Runtime is ready.", {
156
+ runtimeId: this.options.runtimeId,
157
+ environment: this.options.environment,
158
+ });
159
+ }
160
+ catch (error) {
161
+ const runtimeError = toRuntimeError(error, "startup");
162
+ this._error = runtimeError;
163
+ this._failedAt = new Date();
164
+ this.logger.error("Runtime failed to start.", {
165
+ errorMessage: runtimeError.message,
166
+ });
167
+ if (this.options.emitEvents) {
168
+ this.emitEvent("runtime.failed", createFailureEventPayload(this.options.runtimeId, "failed", runtimeError, "startup"));
169
+ }
170
+ try {
171
+ await rollbackStartup(this.lifecycle, this.logger);
172
+ }
173
+ catch (rollbackError) {
174
+ this.logger.error("Rollback failed.", {
175
+ errorMessage: rollbackError instanceof Error
176
+ ? rollbackError.message
177
+ : String(rollbackError),
178
+ });
179
+ }
180
+ this.transitionTo("failed");
181
+ throw runtimeError;
182
+ }
183
+ }
184
+ /**
185
+ * Performs runtime shutdown.
186
+ */
187
+ async performStop() {
188
+ this.transitionTo("stopping");
189
+ this._ready = false;
190
+ this.readinessTracker.markNotReady("Runtime is shutting down.");
191
+ if (this.options.emitEvents) {
192
+ this.emitEvent("runtime.stopping");
193
+ }
194
+ try {
195
+ await executeShutdown(this.lifecycle, this.options.runtimeId, this._context.eventBus, this.logger, this.options.shutdownTimeout, this.options.emitEvents);
196
+ this.transitionTo("stopped");
197
+ this._stoppedAt = new Date();
198
+ this.signalHandler.unregister();
199
+ if (this.options.emitEvents) {
200
+ this.emitEvent("runtime.stopped");
201
+ }
202
+ this.logger.info("Runtime stopped.", {
203
+ runtimeId: this.options.runtimeId,
204
+ });
205
+ }
206
+ catch (error) {
207
+ const runtimeError = toRuntimeError(error, "shutdown");
208
+ this._error = runtimeError;
209
+ this._failedAt = new Date();
210
+ this.logger.error("Runtime failed to stop.", {
211
+ errorMessage: runtimeError.message,
212
+ });
213
+ if (this.options.emitEvents) {
214
+ this.emitEvent("runtime.failed", createFailureEventPayload(this.options.runtimeId, "failed", runtimeError, "stop"));
215
+ }
216
+ this.transitionTo("failed");
217
+ throw runtimeError;
218
+ }
219
+ }
220
+ /**
221
+ * Transitions to a new state.
222
+ */
223
+ transitionTo(newState) {
224
+ const oldState = this._state;
225
+ if (!canTransition(oldState, newState)) {
226
+ throw new RuntimeStateError(`Invalid state transition from "${oldState}" to "${newState}".`);
227
+ }
228
+ this._state = newState;
229
+ this._status = createStatus(newState);
230
+ this.logger.debug(`Runtime state: ${oldState} -> ${newState}`);
231
+ }
232
+ /**
233
+ * Emits a runtime event.
234
+ */
235
+ emitEvent(eventType, payload) {
236
+ if (this.options.emitEvents && this._context.eventBus) {
237
+ const eventPayload = payload ??
238
+ createRuntimeEventPayload(this.options.runtimeId, this._state);
239
+ const event = createEvent({
240
+ type: eventType,
241
+ payload: eventPayload,
242
+ });
243
+ this._context.eventBus.publish(event);
244
+ }
245
+ }
246
+ }
247
+ /**
248
+ * Creates a runtime instance.
249
+ */
250
+ export function createRuntime(dependencies, options) {
251
+ return new DefaultRuntime(dependencies, options);
252
+ }
253
+ //# sourceMappingURL=runtime.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.core.js","sourceRoot":"","sources":["../../src/runtime/runtime.core.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,aAAa,EACb,SAAS,EACT,YAAY,GACb,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAIlE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,GACf,MAAM,0BAA0B,CAAC;AA4BlC;;GAEG;AACH,MAAM,OAAO,cAAc;IACjB,MAAM,GAAiB,SAAS,CAAC;IACjC,OAAO,CAAgB;IACvB,QAAQ,CAAiB;IACzB,MAAM,GAAG,KAAK,CAAC;IACf,UAAU,CAAQ;IAClB,UAAU,CAAQ;IAClB,SAAS,CAAQ;IACjB,MAAM,CAAS;IAEN,OAAO,CAAyB;IAChC,OAAO,CAA8B;IACrC,MAAM,CAAS;IACf,SAAS,CAAmB;IAC5B,aAAa,CAAgB;IAC7B,gB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,EAAE,CAAC;YACtD,MAAM,YAAY,GAChB,OAAO;gBACP,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACjE,MAAM,KAAK,GAAG,WAAW,CAAC;gBACxB,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,YAAY;aACtB,CAAC,CAAC;YACH,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,YAAiC,EACjC,OAAuB;IAEvB,OAAO,IAAI,cAAc,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Runtime context providing access to running application state.
3
+ */
4
+ export { createRuntimeContext, createRuntimeIdentity, } from "./runtimeContext.core.js";
5
+ export { createRuntimeId, createCorrelationId, createRequestId, } from "./runtimeContext.factory.js";
6
+ export type { RuntimeContext, RuntimeIdentity, RuntimeContextDependencies, RuntimeContextState, } from "./runtimeContext.type.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtimeContext/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,eAAe,GAChB,MAAM,6BAA6B,CAAC;AAErC,YAAY,EACV,cAAc,EACd,eAAe,EACf,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Runtime context providing access to running application state.
3
+ */
4
+ export { createRuntimeContext, createRuntimeIdentity, } from "./runtimeContext.core.js";
5
+ export { createRuntimeId, createCorrelationId, createRequestId, } from "./runtimeContext.factory.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtimeContext/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,eAAe,GAChB,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { Environment } from "@zudojs/constants";
2
+ import type { RuntimeContext, RuntimeContextDependencies, RuntimeIdentity } from "./runtimeContext.type.js";
3
+ /**
4
+ * Creates a runtime context.
5
+ */
6
+ export declare function createRuntimeContext(dependencies: RuntimeContextDependencies): RuntimeContext;
7
+ /**
8
+ * Creates runtime identity information.
9
+ */
10
+ export declare function createRuntimeIdentity(runtimeId: string, environment: Environment, applicationName: string, applicationVersion: string): RuntimeIdentity;
11
+ //# sourceMappingURL=runtimeContext.core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeContext.core.d.ts","sourceRoot":"","sources":["../../src/runtimeContext/runtimeContext.core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,OAAO,KAAK,EACV,cAAc,EACd,0BAA0B,EAC1B,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAMlC;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,0BAA0B,GACvC,cAAc,CAoBhB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,MAAM,EACvB,kBAAkB,EAAE,MAAM,GACzB,eAAe,CAYjB"}
@@ -0,0 +1,41 @@
1
+ import { createRuntimeId as generateRuntimeId } from "./runtimeContext.factory.js";
2
+ import { createStatus } from "../runtimeState/runtimeState.core.js";
3
+ /**
4
+ * Creates a runtime context.
5
+ */
6
+ export function createRuntimeContext(dependencies) {
7
+ const status = createStatus("created");
8
+ return Object.freeze({
9
+ runtimeId: dependencies.runtimeId,
10
+ environment: dependencies.environment,
11
+ applicationName: dependencies.applicationName,
12
+ applicationVersion: dependencies.applicationVersion,
13
+ state: "created",
14
+ status,
15
+ logger: dependencies.logger,
16
+ container: dependencies.container,
17
+ eventBus: dependencies.eventBus,
18
+ health: {
19
+ state: "unknown",
20
+ checks: [],
21
+ timestamp: new Date(),
22
+ },
23
+ ready: false,
24
+ });
25
+ }
26
+ /**
27
+ * Creates runtime identity information.
28
+ */
29
+ export function createRuntimeIdentity(runtimeId, environment, applicationName, applicationVersion) {
30
+ return Object.freeze({
31
+ runtimeId,
32
+ environment,
33
+ applicationName,
34
+ applicationVersion,
35
+ hostname: typeof process !== "undefined"
36
+ ? (process.env.HOSTNAME ?? "unknown")
37
+ : "unknown",
38
+ processId: typeof process !== "undefined" ? process.pid : 0,
39
+ });
40
+ }
41
+ //# sourceMappingURL=runtimeContext.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeContext.core.js","sourceRoot":"","sources":["../../src/runtimeContext/runtimeContext.core.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,IAAI,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAUnF,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEpE;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,YAAwC;IAExC,MAAM,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAEvC,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,SAAS,EAAE,YAAY,CAAC,SAAS;QACjC,WAAW,EAAE,YAAY,CAAC,WAAW;QACrC,eAAe,EAAE,YAAY,CAAC,eAAe;QAC7C,kBAAkB,EAAE,YAAY,CAAC,kBAAkB;QACnD,KAAK,EAAE,SAAS;QAChB,MAAM;QACN,MAAM,EAAE,YAAY,CAAC,MAAM;QAC3B,SAAS,EAAE,YAAY,CAAC,SAAS;QACjC,QAAQ,EAAE,YAAY,CAAC,QAAQ;QAC/B,MAAM,EAAE;YACN,KAAK,EAAE,SAAkB;YACzB,MAAM,EAAE,EAAE;YACV,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB;QACD,KAAK,EAAE,KAAK;KACb,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,SAAiB,EACjB,WAAwB,EACxB,eAAuB,EACvB,kBAA0B;IAE1B,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,SAAS;QACT,WAAW;QACX,eAAe;QACf,kBAAkB;QAClB,QAAQ,EACN,OAAO,OAAO,KAAK,WAAW;YAC5B,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,SAAS,CAAC;YACrC,CAAC,CAAC,SAAS;QACf,SAAS,EAAE,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAC5D,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { RuntimeId } from "../runtimeState/runtimeState.type.js";
2
+ /**
3
+ * Generates a unique runtime identifier.
4
+ */
5
+ export declare function createRuntimeId(): RuntimeId;
6
+ /**
7
+ * Generates a correlation ID for request tracking.
8
+ */
9
+ export declare function createCorrelationId(): string;
10
+ /**
11
+ * Generates a request ID.
12
+ */
13
+ export declare function createRequestId(): string;
14
+ //# sourceMappingURL=runtimeContext.factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeContext.factory.d.ts","sourceRoot":"","sources":["../../src/runtimeContext/runtimeContext.factory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAEtE;;GAEG;AACH,wBAAgB,eAAe,IAAI,SAAS,CAE3C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC"}
@@ -0,0 +1,20 @@
1
+ import { randomUUID } from "node:crypto";
2
+ /**
3
+ * Generates a unique runtime identifier.
4
+ */
5
+ export function createRuntimeId() {
6
+ return `rt_${randomUUID().replace(/-/g, "")}`;
7
+ }
8
+ /**
9
+ * Generates a correlation ID for request tracking.
10
+ */
11
+ export function createCorrelationId() {
12
+ return `corr_${randomUUID().replace(/-/g, "")}`;
13
+ }
14
+ /**
15
+ * Generates a request ID.
16
+ */
17
+ export function createRequestId() {
18
+ return `req_${randomUUID().replace(/-/g, "")}`;
19
+ }
20
+ //# sourceMappingURL=runtimeContext.factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeContext.factory.js","sourceRoot":"","sources":["../../src/runtimeContext/runtimeContext.factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,MAAM,UAAU,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAe,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,QAAQ,UAAU,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,OAAO,UAAU,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;AACjD,CAAC"}
@@ -0,0 +1,59 @@
1
+ import type { Environment } from "@zudojs/constants";
2
+ import type { Logger } from "@zudojs/logger";
3
+ import type { EventBus } from "@zudojs/events";
4
+ import type { Container } from "@zudojs/container";
5
+ import type { RuntimeId, RuntimeStatus, RuntimeState, RuntimeHealth } from "../runtimeState/runtimeState.type.js";
6
+ /**
7
+ * Runtime context providing access to the running application state.
8
+ */
9
+ export interface RuntimeContext {
10
+ readonly runtimeId: RuntimeId;
11
+ readonly environment: Environment;
12
+ readonly applicationName: string;
13
+ readonly applicationVersion: string;
14
+ readonly state: RuntimeState;
15
+ readonly status: RuntimeStatus;
16
+ readonly startedAt?: Date;
17
+ readonly logger: Logger;
18
+ readonly container: Container;
19
+ readonly eventBus: EventBus;
20
+ readonly health: RuntimeHealth;
21
+ readonly ready: boolean;
22
+ }
23
+ /**
24
+ * Runtime identity information.
25
+ */
26
+ export interface RuntimeIdentity {
27
+ readonly runtimeId: RuntimeId;
28
+ readonly applicationName: string;
29
+ readonly applicationVersion: string;
30
+ readonly environment: Environment;
31
+ readonly hostname: string;
32
+ readonly processId: number;
33
+ readonly startedAt?: Date;
34
+ }
35
+ /**
36
+ * Dependencies required to create the runtime context.
37
+ */
38
+ export interface RuntimeContextDependencies {
39
+ readonly runtimeId: RuntimeId;
40
+ readonly environment: Environment;
41
+ readonly applicationName: string;
42
+ readonly applicationVersion: string;
43
+ readonly logger: Logger;
44
+ readonly container: Container;
45
+ readonly eventBus: EventBus;
46
+ }
47
+ /**
48
+ * Mutable runtime context state (for internal use).
49
+ */
50
+ export interface RuntimeContextState {
51
+ status: RuntimeStatus;
52
+ health: RuntimeHealth;
53
+ ready: boolean;
54
+ startedAt?: Date;
55
+ stoppedAt?: Date;
56
+ failedAt?: Date;
57
+ error?: Error;
58
+ }
59
+ //# sourceMappingURL=runtimeContext.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeContext.type.d.ts","sourceRoot":"","sources":["../../src/runtimeContext/runtimeContext.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;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AE,MAAM,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=runtimeContext.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeContext.type.js","sourceRoot":"","sources":["../../src/runtimeContext/runtimeContext.type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Runtime error types.
3
+ */
4
+ export { RuntimeStateError, RuntimeStartError, RuntimeStopError, RuntimeInitializationError, RuntimeTimeoutError, RuntimeRollbackError, RuntimeCircularDependencyError, RuntimeDependencyError, RuntimeSignalError, toRuntimeError, } from "./runtimeError.base.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtimeError/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,oBAAoB,EACpB,8BAA8B,EAC9B,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,GACf,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Runtime error types.
3
+ */
4
+ export { RuntimeStateError, RuntimeStartError, RuntimeStopError, RuntimeInitializationError, RuntimeTimeoutError, RuntimeRollbackError, RuntimeCircularDependencyError, RuntimeDependencyError, RuntimeSignalError, toRuntimeError, } from "./runtimeError.base.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtimeError/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,oBAAoB,EACpB,8BAA8B,EAC9B,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,GACf,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,80 @@
1
+ import { RuntimeError, RuntimeStateError as BaseRuntimeStateError } from "@zudojs/errors";
2
+ /**
3
+ * Error thrown when an invalid runtime state is encountered.
4
+ */
5
+ export declare class RuntimeStateError extends BaseRuntimeStateError {
6
+ constructor(message: string);
7
+ }
8
+ /**
9
+ * Error thrown when runtime startup fails.
10
+ */
11
+ export declare class RuntimeStartError extends RuntimeError {
12
+ readonly phase: string;
13
+ readonly failedModuleId?: string;
14
+ constructor(message: string, options: {
15
+ readonly phase: string;
16
+ readonly failedModuleId?: string;
17
+ readonly cause?: Error;
18
+ });
19
+ }
20
+ /**
21
+ * Error thrown when runtime shutdown fails.
22
+ */
23
+ export declare class RuntimeStopError extends RuntimeError {
24
+ readonly phase: string;
25
+ constructor(message: string, options: {
26
+ readonly phase: string;
27
+ readonly cause?: Error;
28
+ });
29
+ }
30
+ /**
31
+ * Error thrown when runtime initialization fails.
32
+ */
33
+ export declare class RuntimeInitializationError extends RuntimeError {
34
+ constructor(message: string, options?: {
35
+ readonly cause?: Error;
36
+ });
37
+ }
38
+ /**
39
+ * Error thrown when a runtime timeout occurs.
40
+ */
41
+ export declare class RuntimeTimeoutError extends RuntimeError {
42
+ readonly operation: string;
43
+ readonly timeoutMs: number;
44
+ constructor(operation: string, timeoutMs: number);
45
+ }
46
+ /**
47
+ * Error thrown when runtime rollback fails.
48
+ */
49
+ export declare class RuntimeRollbackError extends RuntimeError {
50
+ readonly originalError: Error;
51
+ readonly rollbackError: Error;
52
+ constructor(originalError: Error, rollbackError: Error);
53
+ }
54
+ /**
55
+ * Error thrown when a circular dependency is detected.
56
+ */
57
+ export declare class RuntimeCircularDependencyError extends RuntimeError {
58
+ readonly cycle: readonly string[];
59
+ constructor(cycle: readonly string[]);
60
+ }
61
+ /**
62
+ * Error thrown when a module dependency cannot be resolved.
63
+ */
64
+ export declare class RuntimeDependencyError extends RuntimeError {
65
+ readonly moduleId: string;
66
+ readonly dependencyId: string;
67
+ constructor(moduleId: string, dependencyId: string);
68
+ }
69
+ /**
70
+ * Error thrown when runtime receives multiple signals.
71
+ */
72
+ export declare class RuntimeSignalError extends RuntimeError {
73
+ readonly signal: string;
74
+ constructor(signal: string);
75
+ }
76
+ /**
77
+ * Converts an unknown error to a RuntimeError.
78
+ */
79
+ export declare function toRuntimeError(error: unknown, phase?: string): RuntimeError;
80
+ //# sourceMappingURL=runtimeError.base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeError.base.d.ts","sourceRoot":"","sources":["../../src/runtimeError/runtimeError.base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,iBAAiB,IAAI,qBAAqB,EAE3C,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,qBAAqB;IAC1D,YAAmB,OAAO,EAAE,MAAM,EAEjC;CACF;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,YAAY;IACjD,SAAyB,KAAK,EAAE,MAAM,CAAC;IACvC,SAAgB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExC,YACE,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;QACP,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;QACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,KA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