@decohere/core 0.0.1-dev.20261123.408 → 0.0.1-dev.20261123.410

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.
@@ -41,8 +41,12 @@ _ts_decorate([
41
41
  _ts_metadata("design:returntype", void 0)
42
42
  ], InvalidateCacheDecorator.prototype, "decorator", null);
43
43
  const buildGetKey = (method, keyFn)=>{
44
- if (typeof method === "string") return ()=>method;
45
- if (keyFn) return (_instance, args)=>keyFn(...args);
44
+ if (typeof method === "string") {
45
+ return ()=>method;
46
+ }
47
+ if (keyFn) {
48
+ return (_instance, args)=>keyFn(...args);
49
+ }
46
50
  return (instance, args)=>Caching.generateCacheKey(instance, method.name, args);
47
51
  };
48
52
  export const invalidateCache = (method, options)=>{
@@ -77,7 +77,9 @@ export class App {
77
77
  this.hostedStarting = this.startHostedServices(retry);
78
78
  await this.hostedStarting;
79
79
  // The app was stopped while a hosted service was still starting.
80
- if (this.disposing != null) return undefined;
80
+ if (this.disposing != null) {
81
+ return undefined;
82
+ }
81
83
  return this.listen(options);
82
84
  }
83
85
  /**
@@ -92,7 +94,9 @@ export class App {
92
94
  async listen(options) {
93
95
  const hasHostedServices = this.hostedServices != null && !this.hostedServices.isEmpty;
94
96
  if (!this.server) {
95
- if (hasHostedServices) this.stopOnSignals(options);
97
+ if (hasHostedServices) {
98
+ this.stopOnSignals(options);
99
+ }
96
100
  return undefined;
97
101
  }
98
102
  const port = await this.getPort(options);
@@ -112,7 +116,9 @@ export class App {
112
116
  }
113
117
  async startHostedServices(retry) {
114
118
  const host = this.hostedServices;
115
- if (host == null || host.isEmpty) return [];
119
+ if (host == null || host.isEmpty) {
120
+ return [];
121
+ }
116
122
  const begun = performance.now();
117
123
  await host.start(this.container, retry);
118
124
  const timings = host.timings;
@@ -143,7 +149,9 @@ export class App {
143
149
  [Symbol.asyncDispose]() {
144
150
  // The container holds this App too; when stop() disposes the container it lands
145
151
  // here, and awaiting our own shutdown would deadlock.
146
- if (this.disposingContainer) return Promise.resolve();
152
+ if (this.disposingContainer) {
153
+ return Promise.resolve();
154
+ }
147
155
  return this.dispose();
148
156
  }
149
157
  /** Stop the app. Calling it again (or from a signal) returns the same shutdown. */ dispose() {
@@ -171,7 +179,9 @@ export class App {
171
179
  stopOnSignals(options) {
172
180
  const signals = options?.shutdownSignals ?? DEFAULT_SHUTDOWN_SIGNALS;
173
181
  const timeoutMs = options?.shutdownTimeoutMs ?? DEFAULT_SHUTDOWN_TIMEOUT_MS;
174
- if (signals === false || signals.length === 0) return;
182
+ if (signals === false || signals.length === 0) {
183
+ return;
184
+ }
175
185
  this.signalHandler = (signal)=>{
176
186
  this.logger.info(`Received ${signal}; finishing in-flight requests`);
177
187
  // console.error, not the logger: scribe may be the thing that's stuck.
@@ -187,11 +197,17 @@ export class App {
187
197
  });
188
198
  };
189
199
  this.shutdownSignals = signals;
190
- for (const signal of signals)process.on(signal, this.signalHandler);
200
+ for (const signal of signals){
201
+ process.on(signal, this.signalHandler);
202
+ }
191
203
  }
192
204
  removeSignalHandlers() {
193
- if (!this.signalHandler) return;
194
- for (const signal of this.shutdownSignals)process.off(signal, this.signalHandler);
205
+ if (!this.signalHandler) {
206
+ return;
207
+ }
208
+ for (const signal of this.shutdownSignals){
209
+ process.off(signal, this.signalHandler);
210
+ }
195
211
  }
196
212
  async getPort(options) {
197
213
  const port = options?.port ?? (await this.configurationService?.get(ApiConfiguration))?.port ?? DEFAULT_PORT;
@@ -34,7 +34,9 @@ export class Builder {
34
34
  * server listens, stopped in reverse when the app stops (including SIGTERM and Flux reboots).
35
35
  * Each is registered as a singleton, so other services can inject it by its class.
36
36
  */ withHostedService(...types) {
37
- for (const type of types)this.containerBuilder.registerSingleton(type);
37
+ for (const type of types){
38
+ this.containerBuilder.registerSingleton(type);
39
+ }
38
40
  this.hostedServices.add(...types);
39
41
  return this;
40
42
  }
@@ -82,7 +82,9 @@ const DEFAULT_RETRY_MAX_MS = 60_000;
82
82
  });
83
83
  }
84
84
  for (const service of this.started){
85
- if (typeof service.check !== "function") continue;
85
+ if (typeof service.check !== "function") {
86
+ continue;
87
+ }
86
88
  checks.push({
87
89
  name: service.constructor.name,
88
90
  check: ()=>service.check?.() ?? Promise.resolve()
@@ -101,7 +103,9 @@ const DEFAULT_RETRY_MAX_MS = 60_000;
101
103
  /** Run the steps from `stepIndex`, then start every service. */ async startFrom(container, retry, stepIndex) {
102
104
  const { signal } = this.controller;
103
105
  for(let index = stepIndex; index < this.steps.length; index++){
104
- if (signal.aborted) return;
106
+ if (signal.aborted) {
107
+ return;
108
+ }
105
109
  const step = this.steps[index];
106
110
  const begun = performance.now();
107
111
  try {
@@ -120,7 +124,9 @@ const DEFAULT_RETRY_MAX_MS = 60_000;
120
124
  this.record(step.name, begun, true);
121
125
  }
122
126
  for (const type of this.types){
123
- if (signal.aborted) return;
127
+ if (signal.aborted) {
128
+ return;
129
+ }
124
130
  const begun = performance.now();
125
131
  const service = container.resolve(type);
126
132
  try {
@@ -148,7 +154,9 @@ const DEFAULT_RETRY_MAX_MS = 60_000;
148
154
  ms,
149
155
  started
150
156
  });
151
- if (started) this.logger.debug(`${name} started in ${ms} ms`);
157
+ if (started) {
158
+ this.logger.debug(`${name} started in ${ms} ms`);
159
+ }
152
160
  }
153
161
  /** Stop what started, then throw the start's error (with the stop's, if that failed too). */ async failFast(startError) {
154
162
  // Not stop(): it waits for this start to settle.
@@ -197,7 +205,9 @@ const DEFAULT_RETRY_MAX_MS = 60_000;
197
205
  onStarted();
198
206
  };
199
207
  const schedule = ()=>{
200
- if (signal.aborted) return;
208
+ if (signal.aborted) {
209
+ return;
210
+ }
201
211
  const cancel = ()=>clearTimeout(timer);
202
212
  const timer = setTimeout(()=>{
203
213
  signal.removeEventListener("abort", cancel);
@@ -220,7 +230,9 @@ const DEFAULT_RETRY_MAX_MS = 60_000;
220
230
  this.starting
221
231
  ]);
222
232
  // A retry that finishes now may resume a start, which adds more work: wait until none is left.
223
- while(this.background.size > 0)await Promise.allSettled(this.background);
233
+ while(this.background.size > 0){
234
+ await Promise.allSettled(this.background);
235
+ }
224
236
  await this.stopStarted();
225
237
  }
226
238
  /** Stop what is started, newest first. Takes each service off the list, so it runs once. */ async stopStarted() {
@@ -233,7 +245,9 @@ const DEFAULT_RETRY_MAX_MS = 60_000;
233
245
  failures.push(error);
234
246
  }
235
247
  }
236
- if (failures.length === 1) throw failures[0];
248
+ if (failures.length === 1) {
249
+ throw failures[0];
250
+ }
237
251
  if (failures.length > 1) {
238
252
  throw new AggregateError(failures, `${failures.length} hosted services failed to stop`);
239
253
  }
@@ -12,7 +12,9 @@ export class FileEx {
12
12
  return this.relativePath;
13
13
  }
14
14
  async getContent() {
15
- if (this.#content != null) return this.#content;
15
+ if (this.#content != null) {
16
+ return this.#content;
17
+ }
16
18
  return readFile(this.fullPath);
17
19
  }
18
20
  }
@@ -23,8 +23,12 @@
23
23
  errors.push(error);
24
24
  }
25
25
  }
26
- if (errors.length === 1) throw errors[0];
27
- if (errors.length > 1) throw new AggregateError(errors, "Subject listeners threw");
26
+ if (errors.length === 1) {
27
+ throw errors[0];
28
+ }
29
+ if (errors.length > 1) {
30
+ throw new AggregateError(errors, "Subject listeners threw");
31
+ }
28
32
  }
29
33
  asObservable() {
30
34
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decohere/core",
3
- "version": "0.0.1-dev.20261123.408",
3
+ "version": "0.0.1-dev.20261123.410",
4
4
  "description": "The runtime base every Decohere package builds on: reflection, composition, configuration types, extensibility, collections, objects, caching on a Map, and basic file IO. No side effects on import.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -68,7 +68,7 @@
68
68
  "test": "echo \"Error: no test specified\" && exit 1"
69
69
  },
70
70
  "dependencies": {
71
- "@decohere/scribe": "0.0.1-dev.20261123.408",
71
+ "@decohere/scribe": "0.0.1-dev.20261123.410",
72
72
  "reflect-metadata": "^0.2.2"
73
73
  },
74
74
  "devDependencies": {}