sonamu 0.7.19 → 0.7.20
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/api/config.d.ts +2 -1
- package/dist/api/config.d.ts.map +1 -1
- package/dist/api/config.js +1 -1
- package/dist/bin/cli.js +3 -3
- package/dist/database/db.d.ts +2 -2
- package/dist/database/db.d.ts.map +1 -1
- package/dist/database/db.js +23 -30
- package/dist/template/implementations/services.template.d.ts.map +1 -1
- package/dist/template/implementations/services.template.js +4 -1
- package/dist/testing/fixture-manager.d.ts.map +1 -1
- package/dist/testing/fixture-manager.js +4 -4
- package/dist/ui-web/assets/{index-DFqVuxOB.js → index-B87IyofX.js} +1 -1
- package/dist/ui-web/index.html +1 -1
- package/package.json +2 -2
- package/src/api/config.ts +2 -1
- package/src/bin/cli.ts +2 -2
- package/src/database/db.ts +40 -43
- package/src/template/implementations/services.template.ts +3 -0
- package/src/testing/fixture-manager.ts +3 -4
package/src/database/db.ts
CHANGED
|
@@ -6,15 +6,23 @@ import { Sonamu } from "../api";
|
|
|
6
6
|
import type { DatabaseConfig, SonamuConfig } from "../api/config";
|
|
7
7
|
import { TransactionContext } from "./transaction-context";
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* 여러 설정 객체를 순차적으로 deep merge합니다.
|
|
11
|
+
* undefined/null인 인자는 무시됩니다.
|
|
12
|
+
*/
|
|
13
|
+
function mergeConfigs<T extends object>(...configs: (Partial<T> | undefined | null)[]): T {
|
|
14
|
+
return configs.reduce<T>((acc, config) => (config ? assign(acc, config as T) : acc), {} as T);
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
export type DBPreset = "w" | "r";
|
|
10
18
|
|
|
11
19
|
export type SonamuDBConfig = {
|
|
12
20
|
development_master: Knex.Config;
|
|
13
21
|
development_slave: Knex.Config;
|
|
14
|
-
test: Knex.Config;
|
|
15
|
-
fixture_remote: Knex.Config;
|
|
16
22
|
production_master: Knex.Config;
|
|
17
23
|
production_slave: Knex.Config;
|
|
24
|
+
fixture: Knex.Config;
|
|
25
|
+
test: Knex.Config;
|
|
18
26
|
};
|
|
19
27
|
|
|
20
28
|
export class DBClass {
|
|
@@ -120,48 +128,37 @@ export class DBClass {
|
|
|
120
128
|
config.defaultOptions,
|
|
121
129
|
);
|
|
122
130
|
|
|
123
|
-
//
|
|
124
|
-
const test: DatabaseConfig = assign(defaultKnexConfig, {
|
|
125
|
-
connection: {
|
|
126
|
-
database: `${config.name}_test`,
|
|
127
|
-
...config.defaultOptions?.connection,
|
|
128
|
-
},
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
// 개발 환경 설정
|
|
132
|
-
const devMasterOptions = config.environments?.development;
|
|
133
|
-
const devSlaveOptions = config.environments?.development_slave;
|
|
134
|
-
const development_master = assign(defaultKnexConfig, devMasterOptions ?? {});
|
|
135
|
-
const development_slave = assign(
|
|
136
|
-
assign(defaultKnexConfig, devMasterOptions ?? {}),
|
|
137
|
-
devSlaveOptions ?? {},
|
|
138
|
-
);
|
|
139
|
-
// NOTE: fixture remote는 default connection의 DB를 override해선 안됨.
|
|
140
|
-
const fixture_remote = assign(
|
|
141
|
-
assign(assign(defaultKnexConfig, devMasterOptions ?? {}), {
|
|
142
|
-
connection: {
|
|
143
|
-
database: `${config.name}_fixture_remote`,
|
|
144
|
-
},
|
|
145
|
-
}),
|
|
146
|
-
config.environments?.remote_fixture ?? {},
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
// 프로덕션 환경 설정
|
|
150
|
-
const prodMasterOptions = config.environments?.production ?? {};
|
|
151
|
-
const prodSlaveOptions = config.environments?.production_slave ?? {};
|
|
152
|
-
const production_master = assign(defaultKnexConfig, prodMasterOptions);
|
|
153
|
-
const production_slave = assign(
|
|
154
|
-
assign(defaultKnexConfig, prodMasterOptions),
|
|
155
|
-
prodSlaveOptions ?? {},
|
|
156
|
-
);
|
|
157
|
-
|
|
131
|
+
// biome-ignore format: 설정 구조 가독성을 위해 여러 줄로 유지
|
|
158
132
|
return {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
133
|
+
// 여기에 나열한 순서대로 Sonamu UI의 DB Migration 탭에 표시됩니다.
|
|
134
|
+
test: mergeConfigs(
|
|
135
|
+
defaultKnexConfig,
|
|
136
|
+
{ connection: { database: `${config.name}_test` } },
|
|
137
|
+
config.environments?.test
|
|
138
|
+
),
|
|
139
|
+
fixture: mergeConfigs(
|
|
140
|
+
defaultKnexConfig,
|
|
141
|
+
{ connection: { database: `${config.name}_fixture` } },
|
|
142
|
+
config.environments?.fixture,
|
|
143
|
+
),
|
|
144
|
+
development_master: mergeConfigs(
|
|
145
|
+
defaultKnexConfig,
|
|
146
|
+
config.environments?.development
|
|
147
|
+
),
|
|
148
|
+
development_slave: mergeConfigs(
|
|
149
|
+
defaultKnexConfig,
|
|
150
|
+
config.environments?.development,
|
|
151
|
+
config.environments?.development_slave,
|
|
152
|
+
),
|
|
153
|
+
production_master: mergeConfigs(
|
|
154
|
+
defaultKnexConfig,
|
|
155
|
+
config.environments?.production
|
|
156
|
+
),
|
|
157
|
+
production_slave: mergeConfigs(
|
|
158
|
+
defaultKnexConfig,
|
|
159
|
+
config.environments?.production,
|
|
160
|
+
config.environments?.production_slave,
|
|
161
|
+
),
|
|
165
162
|
};
|
|
166
163
|
}
|
|
167
164
|
|
|
@@ -255,6 +255,9 @@ ${functions.join("\n\n")}
|
|
|
255
255
|
body: namespaces.join("\n\n"),
|
|
256
256
|
importKeys: diff(unique(importKeys), [...typeParamNames, "ListResult"]),
|
|
257
257
|
customHeaders: [
|
|
258
|
+
"/** biome-ignore-all lint: generated는 무시 */",
|
|
259
|
+
"/** biome-ignore-all assist: generated는 무시 */",
|
|
260
|
+
"",
|
|
258
261
|
`import { queryOptions, useQuery, useMutation } from '@tanstack/react-query';`,
|
|
259
262
|
`import type { AxiosProgressEvent } from 'axios';`,
|
|
260
263
|
`import qs from 'qs';`,
|
|
@@ -87,7 +87,7 @@ export class FixtureManagerClass {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
this.tdb = knex(Sonamu.dbConfig.test);
|
|
90
|
-
this.fdb = knex(Sonamu.dbConfig.
|
|
90
|
+
this.fdb = knex(Sonamu.dbConfig.fixture);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
async getChecksum(db: Knex, tableName: string) {
|
|
@@ -100,7 +100,7 @@ export class FixtureManagerClass {
|
|
|
100
100
|
pg_dump로 원격 DB를 덤프하고, pg_restore로 로컬에 복원합니다.
|
|
101
101
|
*/
|
|
102
102
|
async sync() {
|
|
103
|
-
const fixtureConn = Sonamu.dbConfig.
|
|
103
|
+
const fixtureConn = Sonamu.dbConfig.fixture.connection as Knex.PgConnectionConfig;
|
|
104
104
|
const testConn = Sonamu.dbConfig.test.connection as Knex.PgConnectionConfig;
|
|
105
105
|
|
|
106
106
|
// 1. 로컬 test DB 연결 종료 및 재생성
|
|
@@ -182,8 +182,7 @@ export class FixtureManagerClass {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
// 픽스쳐DB, 실DB
|
|
185
|
-
const fixtureDatabase = (Sonamu.dbConfig.
|
|
186
|
-
.database;
|
|
185
|
+
const fixtureDatabase = (Sonamu.dbConfig.fixture.connection as Knex.ConnectionConfig).database;
|
|
187
186
|
const realDatabase = (Sonamu.dbConfig.production_master.connection as Knex.ConnectionConfig)
|
|
188
187
|
.database;
|
|
189
188
|
|