@fluojs/config 1.0.3 → 1.0.4
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 +1 -1
- package/README.md +1 -1
- package/dist/load.js +1 -1
- package/dist/options.d.ts +2 -2
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +22 -4
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
package/README.ko.md
CHANGED
|
@@ -101,7 +101,7 @@ Root `@fluojs/config` 패키지를 import하는 것만으로는 Node filesystem,
|
|
|
101
101
|
|
|
102
102
|
`ConfigReloadManager.reload()`는 리로드 작업을 직렬화합니다. 현재 리로드가 listener 알림을 수행하는 동안 다른 리로드가 요청되면 후속 리로드는 큐에 들어가 활성 알림이 끝난 뒤 적용됩니다. 활성 알림이 실패하면 직전 snapshot을 복구하고 큐에 있던 리로드는 폐기합니다. 동일한 직렬화와 rollback 계약은 `createConfigReloader(...).reload()`에도 적용되며, watch로 시작된 알림 중 큐에 들어간 manual reload도 이 계약을 따릅니다.
|
|
103
103
|
|
|
104
|
-
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을 교체하지 않습니다.
|
|
104
|
+
Module registration과 reloader 생성은 `schema`로 전달한 nested Standard Schema validator object를 포함해 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을 교체하지 않습니다.
|
|
105
105
|
|
|
106
106
|
`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`을 사용합니다.
|
|
107
107
|
|
package/README.md
CHANGED
|
@@ -104,7 +104,7 @@ The `schema` option accepts a synchronous [Standard Schema](https://standardsche
|
|
|
104
104
|
|
|
105
105
|
`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.
|
|
106
106
|
|
|
107
|
-
Module registration and reloader creation snapshot caller-owned options before storing them
|
|
107
|
+
Module registration and reloader creation snapshot caller-owned options before storing them, including nested Standard Schema validator objects supplied through `schema`. 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.
|
|
108
108
|
|
|
109
109
|
`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.
|
|
110
110
|
|
package/dist/load.js
CHANGED
|
@@ -337,7 +337,7 @@ function readConfigSchemaResult(result) {
|
|
|
337
337
|
if (!isConfigSchemaSuccessResult(result)) {
|
|
338
338
|
throw createInvalidConfigError(new Error('Standard Schema config validator returned a malformed result.'));
|
|
339
339
|
}
|
|
340
|
-
return result.value;
|
|
340
|
+
return cloneConfigDictionary(result.value);
|
|
341
341
|
}
|
|
342
342
|
function validateConfig(options, merged) {
|
|
343
343
|
if (!options.schema) {
|
package/dist/options.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ import type { ConfigLoadOptions, ConfigModuleOptions } from './types.js';
|
|
|
3
3
|
* Creates a detached snapshot of config module registration options.
|
|
4
4
|
*
|
|
5
5
|
* @param options Caller-owned module options captured at registration time.
|
|
6
|
-
* @returns Options that cannot observe later caller mutations of config dictionaries.
|
|
6
|
+
* @returns Options that cannot observe later caller mutations of config dictionaries or schema objects.
|
|
7
7
|
*/
|
|
8
8
|
export declare function snapshotConfigModuleOptions(options?: ConfigModuleOptions): ConfigModuleOptions;
|
|
9
9
|
/**
|
|
10
10
|
* Creates a detached snapshot of config load and reload options.
|
|
11
11
|
*
|
|
12
12
|
* @param options Caller-owned load options captured by loaders or reload modules.
|
|
13
|
-
* @returns Options that preserve registration-time config dictionary inputs.
|
|
13
|
+
* @returns Options that preserve registration-time config dictionary and schema inputs.
|
|
14
14
|
*/
|
|
15
15
|
export declare function snapshotConfigLoadOptions(options?: ConfigLoadOptions): ConfigLoadOptions;
|
|
16
16
|
//# sourceMappingURL=options.d.ts.map
|
package/dist/options.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAoB,iBAAiB,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAoB,iBAAiB,EAAE,mBAAmB,EAAgB,MAAM,YAAY,CAAC;AAwCzG;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,mBAAmB,CAY9F;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,iBAAiB,CAYxF"}
|
package/dist/options.js
CHANGED
|
@@ -14,12 +14,27 @@ function snapshotProcessEnv(processEnv) {
|
|
|
14
14
|
}
|
|
15
15
|
return Object.freeze(snapshot);
|
|
16
16
|
}
|
|
17
|
+
function snapshotConfigSchema(schema) {
|
|
18
|
+
if (schema === undefined) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const standard = schema['~standard'];
|
|
22
|
+
const snapshot = {
|
|
23
|
+
'~standard': Object.freeze({
|
|
24
|
+
types: standard.types,
|
|
25
|
+
validate: standard.validate,
|
|
26
|
+
vendor: standard.vendor,
|
|
27
|
+
version: standard.version
|
|
28
|
+
})
|
|
29
|
+
};
|
|
30
|
+
return Object.freeze(snapshot);
|
|
31
|
+
}
|
|
17
32
|
|
|
18
33
|
/**
|
|
19
34
|
* Creates a detached snapshot of config module registration options.
|
|
20
35
|
*
|
|
21
36
|
* @param options Caller-owned module options captured at registration time.
|
|
22
|
-
* @returns Options that cannot observe later caller mutations of config dictionaries.
|
|
37
|
+
* @returns Options that cannot observe later caller mutations of config dictionaries or schema objects.
|
|
23
38
|
*/
|
|
24
39
|
export function snapshotConfigModuleOptions(options) {
|
|
25
40
|
if (options === undefined) {
|
|
@@ -28,7 +43,9 @@ export function snapshotConfigModuleOptions(options) {
|
|
|
28
43
|
return Object.freeze({
|
|
29
44
|
...options,
|
|
30
45
|
defaults: snapshotConfigDictionary(options.defaults),
|
|
31
|
-
processEnv: snapshotProcessEnv(options.processEnv)
|
|
46
|
+
processEnv: snapshotProcessEnv(options.processEnv),
|
|
47
|
+
runtimeOverrides: snapshotConfigDictionary(options.runtimeOverrides),
|
|
48
|
+
schema: snapshotConfigSchema(options.schema)
|
|
32
49
|
});
|
|
33
50
|
}
|
|
34
51
|
|
|
@@ -36,7 +53,7 @@ export function snapshotConfigModuleOptions(options) {
|
|
|
36
53
|
* Creates a detached snapshot of config load and reload options.
|
|
37
54
|
*
|
|
38
55
|
* @param options Caller-owned load options captured by loaders or reload modules.
|
|
39
|
-
* @returns Options that preserve registration-time config dictionary inputs.
|
|
56
|
+
* @returns Options that preserve registration-time config dictionary and schema inputs.
|
|
40
57
|
*/
|
|
41
58
|
export function snapshotConfigLoadOptions(options) {
|
|
42
59
|
if (options === undefined) {
|
|
@@ -46,6 +63,7 @@ export function snapshotConfigLoadOptions(options) {
|
|
|
46
63
|
...options,
|
|
47
64
|
defaults: snapshotConfigDictionary(options.defaults),
|
|
48
65
|
processEnv: snapshotProcessEnv(options.processEnv),
|
|
49
|
-
runtimeOverrides: snapshotConfigDictionary(options.runtimeOverrides)
|
|
66
|
+
runtimeOverrides: snapshotConfigDictionary(options.runtimeOverrides),
|
|
67
|
+
schema: snapshotConfigSchema(options.schema)
|
|
50
68
|
});
|
|
51
69
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ export interface ConfigModuleOptions {
|
|
|
30
30
|
processEnv?: NodeJS.ProcessEnv;
|
|
31
31
|
schema?: ConfigSchema;
|
|
32
32
|
defaults?: ConfigDictionary;
|
|
33
|
+
/** Highest-precedence values applied after defaults, env files, and `processEnv`. */
|
|
34
|
+
runtimeOverrides?: ConfigDictionary;
|
|
33
35
|
/** Supply a custom file parser (e.g. for YAML or TOML). Receives raw file content,
|
|
34
36
|
* returns a flat key-value record. Defaults to dotenv parsing. */
|
|
35
37
|
parse?: (content: string) => Record<string, string>;
|
|
@@ -44,7 +46,6 @@ export interface ConfigModuleOptions {
|
|
|
44
46
|
*/
|
|
45
47
|
export interface ConfigLoadOptions extends ConfigModuleOptions {
|
|
46
48
|
cwd?: string;
|
|
47
|
-
runtimeOverrides?: ConfigDictionary;
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
51
|
* Reason attached to config reload notifications.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB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,MAAM,IAAI,gBAAgB,CAAC;IAC3B,SAAS,CAAC,QAAQ,EAAE,oBAAoB,GAAG,wBAAwB,CAAC;IACpE,cAAc,CAAC,QAAQ,EAAE,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.
|
|
11
|
+
"version": "1.0.4",
|
|
12
12
|
"private": false,
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"repository": {
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@standard-schema/spec": "^1.1.0",
|
|
39
|
-
"@fluojs/core": "^1.0
|
|
39
|
+
"@fluojs/core": "^1.1.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"vitest": "^3.2.4",
|
|
43
|
-
"@fluojs/di": "^
|
|
43
|
+
"@fluojs/di": "^2.0.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"prebuild": "node ../../tooling/scripts/clean-dist.mjs",
|