@fluojs/config 1.0.0-beta.8 → 1.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.
package/README.ko.md CHANGED
@@ -97,7 +97,7 @@ class MyService {
97
97
 
98
98
  `ConfigReloadManager.reload()`는 리로드 작업을 직렬화합니다. 현재 리로드가 listener 알림을 수행하는 동안 다른 리로드가 요청되면 후속 리로드는 큐에 들어가 활성 알림이 끝난 뒤 적용됩니다. 활성 알림이 실패하면 직전 snapshot을 복구하고 큐에 있던 리로드는 폐기합니다. 동일한 직렬화와 rollback 계약은 `createConfigReloader(...).reload()`에도 적용되며, watch로 시작된 알림 중 큐에 들어간 manual reload도 이 계약을 따릅니다.
99
99
 
100
- Module registration과 reloader 생성은 caller-owned options를 저장하기 전에 snapshot으로 분리합니다. `ConfigModule.forRoot(...)`, `ConfigReloadModule.forRoot(...)`, `createConfigReloader(...)`에 넘긴 객체를 나중에 변경해도 bootstrap, manual reload, watch reload 입력은 바뀌지 않습니다. `ConfigModule.forRoot({ watch: true, ... })`를 사용하면 module은 application bootstrap 중 env-file watcher를 시작하고, watch reload가 성공한 뒤 같은 injected `ConfigService` instance를 갱신합니다. Watch mode에서 시작 시점에 env file 없으면 file snapshot처럼 취급하고 parent directory를 watch하므로, 나중에 env file을 생성해도 reload가 트리거될 수 있습니다. Watch reload는 reload 전에 최종 env file content를 마지막으로 commit된 watch baseline과 비교하므로, 내용이 바뀌지 않은 저장이나 변경 후 debounce 안에서 원래 내용으로 되돌린 burst는 인프로세스 config snapshot을 교체하지 않습니다.
100
+ Module registration과 reloader 생성은 caller-owned options를 저장하기 전에 snapshot으로 분리합니다. `ConfigModule.forRoot(...)`, `ConfigReloadModule.forRoot(...)`, `createConfigReloader(...)`에 넘긴 객체를 나중에 변경해도 bootstrap, manual reload, watch reload 입력은 바뀌지 않습니다. `ConfigModule.forRoot({ watch: true, ... })`를 사용하면 module은 application bootstrap 중 env-file watcher를 시작하고, 먼저 injected `ConfigService`를 watch reloader baseline과 맞춘 다음 watch reload가 성공한 뒤 같은 injected `ConfigService` instance를 갱신합니다. `ConfigModule`의 automatic watch reload 실패를 애플리케이션이 소유해야 한다면 `onReloadError`를 전달하세요. Watch mode에서는 기존 env file 누락된 env file 모두에 대해 parent directory를 watch하므로, 나중에 env file을 생성하거나 atomic replacement로 교체해도 reload가 트리거될 수 있습니다. Watch reload는 reload 전에 최종 env file content를 마지막으로 commit된 watch baseline과 비교하므로, 내용이 바뀌지 않은 저장이나 변경 후 debounce 안에서 원래 내용으로 되돌린 burst는 인프로세스 config snapshot을 교체하지 않습니다.
101
101
 
102
102
  `ConfigReloadModule`은 명시적으로 주입 가능한 reload layer이며 standalone config source가 아닙니다. manual reload나 subscription을 위해 `CONFIG_RELOADER`가 필요한 caller는 `ConfigModule` 또는 다른 `ConfigService` provider와 함께 사용하세요. `ConfigModule` 또는 `ConfigReloadModule`이 만든 watcher는 `watch: true`일 때만 생성되며 module shutdown 중에 닫힙니다. 같은 env file에 대해서는 한 layer에서만 `watch: true`를 활성화하세요. 자동 `ConfigService` 갱신만 필요하면 `ConfigModule`을 사용하고, subscription/manual reload를 위한 injected reloader 계약이 필요하면 `ConfigReloadModule`을 사용합니다.
103
103
 
package/README.md CHANGED
@@ -100,7 +100,7 @@ The `schema` option accepts a synchronous [Standard Schema](https://standardsche
100
100
 
101
101
  `ConfigReloadManager.reload()` serializes reload work. If another reload is requested while the current reload is notifying listeners, the follow-up reload is queued and applied after the active notification finishes; if the active notification fails, the previous snapshot is restored and the queued reload is discarded. The same serialization and rollback contract applies to `createConfigReloader(...).reload()`, including manual reloads queued during watch-triggered notifications.
102
102
 
103
- Module registration and reloader creation snapshot caller-owned options before storing them. Later mutations to objects passed to `ConfigModule.forRoot(...)`, `ConfigReloadModule.forRoot(...)`, or `createConfigReloader(...)` do not affect bootstrap, manual reloads, or watch reloads. When `ConfigModule.forRoot({ watch: true, ... })` is used, the module starts an env-file watcher during application bootstrap and updates the same injected `ConfigService` instance after successful watch reloads. In watch mode, a missing env file at startup is treated as an empty file snapshot while the parent directory is watched so creating the env file later can still trigger reload. Watch reloads compare the final env file content with the last committed watch baseline before reloading, so unchanged saves and change-then-revert bursts do not replace the in-process config snapshot.
103
+ Module registration and reloader creation snapshot caller-owned options before storing them. Later mutations to objects passed to `ConfigModule.forRoot(...)`, `ConfigReloadModule.forRoot(...)`, or `createConfigReloader(...)` do not affect bootstrap, manual reloads, or watch reloads. When `ConfigModule.forRoot({ watch: true, ... })` is used, the module starts an env-file watcher during application bootstrap, first aligns the injected `ConfigService` with the watch reloader baseline, and then updates the same injected `ConfigService` instance after successful watch reloads. Pass `onReloadError` when the application needs ownership of automatic watch reload failures from `ConfigModule`. In watch mode, the parent directory is watched for both existing and missing env files, so creating or atomically replacing the env file can trigger reload. Watch reloads compare the final env file content with the last committed watch baseline before reloading, so unchanged saves and change-then-revert bursts do not replace the in-process config snapshot.
104
104
 
105
105
  `ConfigReloadModule` is the explicit injectable reload layer, not a standalone config source. Pair it with `ConfigModule` or another `ConfigService` provider when callers need `CONFIG_RELOADER` for manual reloads or subscriptions. Watchers created by `ConfigModule` or `ConfigReloadModule` are created only when `watch: true`, and they are closed during module shutdown. Enable `watch: true` on one layer for a given env file: use `ConfigModule` for automatic `ConfigService` updates, or `ConfigReloadModule` when callers need the injected reloader contract for subscriptions/manual reloads.
106
106
 
package/dist/load.js CHANGED
@@ -241,7 +241,7 @@ function startReloaderWatcher(normalized, options, state, listeners, errorListen
241
241
  if (!options.watch) {
242
242
  return undefined;
243
243
  }
244
- const watchTarget = existsSync(normalized.envFile) ? normalized.envFile : dirname(normalized.envFile);
244
+ const watchTarget = dirname(normalized.envFile);
245
245
  const watchedEnvFileName = basename(normalized.envFile);
246
246
  if (!existsSync(watchTarget)) {
247
247
  return undefined;
@@ -249,7 +249,7 @@ function startReloaderWatcher(normalized, options, state, listeners, errorListen
249
249
  return watch(watchTarget, {
250
250
  persistent: false
251
251
  }, (_eventType, filename) => {
252
- if (watchTarget !== normalized.envFile && filename !== null && filename.toString() !== watchedEnvFileName) {
252
+ if (filename !== null && filename.toString() !== watchedEnvFileName) {
253
253
  return;
254
254
  }
255
255
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,mBAAmB,EAA4C,MAAM,YAAY,CAAC;AA4ChG;;GAEG;AACH,qBAAa,YAAY;IACvB;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,UAAU,YAAY;CA4BtE"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,mBAAmB,EAA4C,MAAM,YAAY,CAAC;AAmDhG;;GAEG;AACH,qBAAa,YAAY;IACvB;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,UAAU,YAAY;CA4BtE"}
package/dist/module.js CHANGED
@@ -17,6 +17,7 @@ class ConfigModuleWatchManager {
17
17
  }
18
18
  reloader;
19
19
  reloadForwarder;
20
+ errorForwarder;
20
21
  constructor(config, options) {
21
22
  this.config = config;
22
23
  this.options = options;
@@ -29,6 +30,7 @@ class ConfigModuleWatchManager {
29
30
  return;
30
31
  }
31
32
  this.reloader = createConfigReloader(this.options);
33
+ replaceConfigServiceSnapshotUnchecked(this.config, this.reloader.current());
32
34
  this.reloadForwarder = this.reloader.subscribe(snapshot => {
33
35
  const previousConfig = this.config.snapshot();
34
36
  try {
@@ -38,10 +40,15 @@ class ConfigModuleWatchManager {
38
40
  throw error;
39
41
  }
40
42
  });
43
+ if (this.options.onReloadError) {
44
+ this.errorForwarder = this.reloader.subscribeError(this.options.onReloadError);
45
+ }
41
46
  }
42
47
  onModuleDestroy() {
43
48
  this.reloadForwarder?.unsubscribe();
44
49
  this.reloadForwarder = undefined;
50
+ this.errorForwarder?.unsubscribe();
51
+ this.errorForwarder = undefined;
45
52
  this.reloader?.close();
46
53
  this.reloader = undefined;
47
54
  }
package/dist/types.d.ts CHANGED
@@ -34,6 +34,8 @@ export interface ConfigModuleOptions {
34
34
  * returns a flat key-value record. Defaults to dotenv parsing. */
35
35
  parse?: (content: string) => Record<string, string>;
36
36
  watch?: boolean;
37
+ /** Receives automatic watch reload failures owned by `ConfigModule`. */
38
+ onReloadError?: ConfigReloadErrorListener;
37
39
  /** Whether the module should expose `ConfigService` globally. Defaults to `true`. */
38
40
  global?: boolean;
39
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,MAAM,YAAY,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEhI;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,MAAM,SAAS,MAAM,GAAG,EAAE,IAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnF;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,GAClB,GAAG,MAAM,GAAG,CAAC,EAAE,GACf,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC;CACrC,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,GACnB,KAAK,CAAC;AAEV;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CA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AAE,yBAAyB,GAAG,wBAAwB,CAAC;IAC9E,KAAK,IAAI,IAAI,CAAC;CACf"}
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "environment",
9
9
  "typed-config"
10
10
  ],
11
- "version": "1.0.0-beta.8",
11
+ "version": "1.0.1",
12
12
  "private": false,
13
13
  "license": "MIT",
14
14
  "repository": {
@@ -38,11 +38,11 @@
38
38
  "@standard-schema/spec": "^1.1.0",
39
39
  "dotenv": "^16.0.0",
40
40
  "dotenv-expand": "^11.0.0",
41
- "@fluojs/core": "^1.0.0-beta.5"
41
+ "@fluojs/core": "^1.0.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "vitest": "^3.2.4",
45
- "@fluojs/di": "^1.0.0-beta.7"
45
+ "@fluojs/di": "^1.0.1"
46
46
  },
47
47
  "scripts": {
48
48
  "prebuild": "node ../../tooling/scripts/clean-dist.mjs",