@gaonjs/config 0.5.3 → 0.6.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.
package/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export { defineConfig, defineAppConfig, type GaonConfig, type AppConfig, type Ap
2
2
  export { loadGaonConfig, findConfigPath } from './load.js';
3
3
  export { resolveApps, toAppSpec, type DiscoveredApp, } from './apps.js';
4
4
  export { wireGaon, type WiredGaon } from './wire.js';
5
+ export { connectTestDatabase, type TestDbHandle } from './testkit.js';
package/dist/index.js CHANGED
@@ -10,3 +10,5 @@ export { defineConfig, defineAppConfig, } from './types.js';
10
10
  export { loadGaonConfig, findConfigPath } from './load.js';
11
11
  export { resolveApps, toAppSpec, } from './apps.js';
12
12
  export { wireGaon } from './wire.js';
13
+ // 테스트 DB 배선 (결정 111 · gaon test 격리)
14
+ export { connectTestDatabase } from './testkit.js';
@@ -0,0 +1,9 @@
1
+ export interface TestDbHandle {
2
+ /** 등록한 모든 커넥션을 종료한다(afterAll 에서 호출). */
3
+ close(): Promise<void>;
4
+ }
5
+ /**
6
+ * 테스트용 DB 커넥션을 등록한다(결정 111). 각 커넥션을 `<db>_test` 로 파생해
7
+ * poolMax:1 로 붙인다. 반환값의 close() 를 afterAll 에서 호출해 정리한다.
8
+ */
9
+ export declare function connectTestDatabase(cwd?: string): Promise<TestDbHandle>;
@@ -0,0 +1,28 @@
1
+ // @gaonjs/config · 테스트 DB 커넥션 배선 (결정 111)
2
+ //
3
+ // gaon.config 의 각 커넥션을 `<db>_test` 로 파생해 등록한다 — `gaon test` 가 미리
4
+ // 만들어 마이그레이션한 그 DB 다. 스캐폴드 `test/setup.ts` 가 부트스트랩으로 쓰고,
5
+ // 매 테스트 뒤 `truncateAll()` 로 격리한다(§9 실 인프라 · 근거는 결정 111).
6
+ //
7
+ // wireGaon 과 달리 Redis·NATS·mail 은 배선하지 않는다 — DB 격리만 담당한다.
8
+ import { loadGaonConfig } from './load.js';
9
+ import { createDb, registerConnection, deriveTestDatabaseConfig, destroyAllConnections, } from '@gaonjs/data';
10
+ /**
11
+ * 테스트용 DB 커넥션을 등록한다(결정 111). 각 커넥션을 `<db>_test` 로 파생해
12
+ * poolMax:1 로 붙인다. 반환값의 close() 를 afterAll 에서 호출해 정리한다.
13
+ */
14
+ export async function connectTestDatabase(cwd = process.cwd()) {
15
+ const config = await loadGaonConfig(cwd);
16
+ if (config.db) {
17
+ for (const [key, cfg] of Object.entries(config.db)) {
18
+ const base = cfg;
19
+ const testCfg = deriveTestDatabaseConfig({ ...base, poolMax: 1 });
20
+ registerConnection(key, createDb(testCfg), base.adapter);
21
+ }
22
+ }
23
+ return {
24
+ close: async () => {
25
+ await destroyAllConnections();
26
+ },
27
+ };
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gaonjs/config",
3
- "version": "0.5.3",
3
+ "version": "0.6.0",
4
4
  "description": "Gaon 루트 설정 로더·자동 배선 (gaon.config.ts · §3.3 · M9-A)",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,12 +26,12 @@
26
26
  "dependencies": {
27
27
  "ioredis": "^5.4.1",
28
28
  "@gaonjs/async": "0.6.1",
29
- "@gaonjs/core": "0.2.1",
30
- "@gaonjs/data": "0.9.2",
31
29
  "@gaonjs/mail": "0.1.3",
32
- "@gaonjs/i18n": "0.1.2",
30
+ "@gaonjs/core": "0.2.1",
31
+ "@gaonjs/data": "0.11.0",
33
32
  "@gaonjs/storage": "0.1.2",
34
- "@gaonjs/web": "0.7.2"
33
+ "@gaonjs/i18n": "0.1.2",
34
+ "@gaonjs/web": "0.8.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "fastify": "^5.0.0"