@simplysm/sd-claude 14.0.46 → 14.0.48
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/{claude/references/sd-simplysm14/sd-claude/usage.md → README.md} +2 -2
- package/claude/rules/sd-claude-rules.md +27 -9
- package/claude/rules/sd-options.md +11 -6
- package/claude/sd-subagent-start.sh +6 -0
- package/claude/settings.json +1 -12
- package/claude/skills/sd-check/SKILL.md +18 -9
- package/claude/skills/sd-claude-docs/SKILL.md +29 -58
- package/claude/skills/sd-claude-docs/references/package-claudemd.md +12 -0
- package/claude/skills/sd-claude-docs/references/package-doc-gen.md +22 -12
- package/claude/skills/sd-debug/SKILL.md +5 -3
- package/claude/skills/sd-deliverable/SKILL.md +0 -1
- package/claude/skills/sd-dev/SKILL.md +14 -9
- package/claude/skills/sd-doc-extract/SKILL.md +7 -9
- package/claude/skills/sd-doc-extract/_common.py +8 -1
- package/claude/skills/sd-doc-extract/_extract_docx.py +74 -34
- package/claude/skills/sd-doc-extract/_extract_pdf.py +12 -1
- package/claude/skills/sd-doc-extract/_extract_pptx.py +103 -23
- package/claude/skills/sd-doc-extract/_extract_xlsb.py +93 -4
- package/claude/skills/sd-doc-extract/_extract_xlsx.py +98 -36
- package/claude/skills/sd-doc-extract/extract.py +22 -3
- package/claude/skills/sd-inner-clarify/SKILL.md +78 -0
- package/claude/skills/sd-inner-debug/SKILL.md +1 -1
- package/claude/skills/sd-inner-review/SKILL.md +13 -0
- package/claude/skills/sd-plan/SKILL.md +50 -17
- package/claude/skills/sd-prompt/SKILL.md +180 -178
- package/claude/skills/sd-prompt/references/eval-runner.md +5 -31
- package/claude/skills/sd-prompt/references/sd-eval-env-template.md +23 -0
- package/claude/skills/sd-refactor/SKILL.md +2 -2
- package/claude/skills/sd-tdd/SKILL.md +46 -10
- package/claude/skills/sd-use/SKILL.md +84 -80
- package/claude/skills/sd-wbs/SKILL.md +85 -27
- package/{claude/references/sd-simplysm14/sd-claude/docs → docs}/assets.md +2 -3
- package/{claude/references/sd-simplysm14/sd-claude/docs → docs}/hooks.md +7 -6
- package/{claude/references/sd-simplysm14/sd-claude/docs → docs}/scripts.md +1 -9
- package/package.json +3 -2
- package/scripts/sync.mjs +4 -2
- package/claude/references/sd-simplysm14/angular/docs/bootstrap.md +0 -48
- package/claude/references/sd-simplysm14/angular/docs/directives.md +0 -236
- package/claude/references/sd-simplysm14/angular/docs/features.md +0 -379
- package/claude/references/sd-simplysm14/angular/docs/pipes.md +0 -32
- package/claude/references/sd-simplysm14/angular/docs/plugins.md +0 -37
- package/claude/references/sd-simplysm14/angular/docs/provider-types.md +0 -283
- package/claude/references/sd-simplysm14/angular/docs/providers.md +0 -370
- package/claude/references/sd-simplysm14/angular/docs/styling.md +0 -222
- package/claude/references/sd-simplysm14/angular/docs/type-utilities.md +0 -250
- package/claude/references/sd-simplysm14/angular/docs/ui-data.md +0 -275
- package/claude/references/sd-simplysm14/angular/docs/ui-form.md +0 -490
- package/claude/references/sd-simplysm14/angular/docs/ui-layout.md +0 -140
- package/claude/references/sd-simplysm14/angular/docs/ui-navigation.md +0 -241
- package/claude/references/sd-simplysm14/angular/docs/ui-overlay.md +0 -157
- package/claude/references/sd-simplysm14/angular/docs/ui-visual.md +0 -127
- package/claude/references/sd-simplysm14/angular/docs/utils.md +0 -295
- package/claude/references/sd-simplysm14/angular/usage.md +0 -489
- package/claude/references/sd-simplysm14/capacitor-plugin-auto-update/usage.md +0 -182
- package/claude/references/sd-simplysm14/capacitor-plugin-file-system/docs/file-operations.md +0 -154
- package/claude/references/sd-simplysm14/capacitor-plugin-file-system/docs/permissions.md +0 -84
- package/claude/references/sd-simplysm14/capacitor-plugin-file-system/docs/storage-paths.md +0 -107
- package/claude/references/sd-simplysm14/capacitor-plugin-file-system/docs/types.md +0 -83
- package/claude/references/sd-simplysm14/capacitor-plugin-file-system/usage.md +0 -133
- package/claude/references/sd-simplysm14/capacitor-plugin-intent/usage.md +0 -203
- package/claude/references/sd-simplysm14/capacitor-plugin-usb-storage/usage.md +0 -258
- package/claude/references/sd-simplysm14/core-browser/usage.md +0 -306
- package/claude/references/sd-simplysm14/core-common/docs/errors.md +0 -82
- package/claude/references/sd-simplysm14/core-common/docs/extensions.md +0 -167
- package/claude/references/sd-simplysm14/core-common/docs/features.md +0 -136
- package/claude/references/sd-simplysm14/core-common/docs/types.md +0 -245
- package/claude/references/sd-simplysm14/core-common/docs/utils.md +0 -591
- package/claude/references/sd-simplysm14/core-common/usage.md +0 -255
- package/claude/references/sd-simplysm14/core-node/docs/child-process.md +0 -182
- package/claude/references/sd-simplysm14/core-node/docs/features.md +0 -214
- package/claude/references/sd-simplysm14/core-node/docs/file-system.md +0 -509
- package/claude/references/sd-simplysm14/core-node/docs/file-watching.md +0 -139
- package/claude/references/sd-simplysm14/core-node/docs/logging.md +0 -180
- package/claude/references/sd-simplysm14/core-node/docs/path.md +0 -176
- package/claude/references/sd-simplysm14/core-node/docs/utilities-cpx.md +0 -194
- package/claude/references/sd-simplysm14/core-node/docs/utilities-fsx.md +0 -469
- package/claude/references/sd-simplysm14/core-node/docs/utilities-pathx.md +0 -151
- package/claude/references/sd-simplysm14/core-node/docs/worker-threads.md +0 -334
- package/claude/references/sd-simplysm14/core-node/docs/worker.md +0 -205
- package/claude/references/sd-simplysm14/core-node/usage.md +0 -259
- package/claude/references/sd-simplysm14/excel/docs/core-classes.md +0 -443
- package/claude/references/sd-simplysm14/excel/docs/types.md +0 -455
- package/claude/references/sd-simplysm14/excel/docs/utilities.md +0 -194
- package/claude/references/sd-simplysm14/excel/docs/wrapper.md +0 -73
- package/claude/references/sd-simplysm14/excel/usage.md +0 -134
- package/claude/references/sd-simplysm14/lint/usage.md +0 -130
- package/claude/references/sd-simplysm14/orm-common/docs/core.md +0 -188
- package/claude/references/sd-simplysm14/orm-common/docs/expression.md +0 -190
- package/claude/references/sd-simplysm14/orm-common/docs/models.md +0 -17
- package/claude/references/sd-simplysm14/orm-common/docs/query-builder.md +0 -97
- package/claude/references/sd-simplysm14/orm-common/docs/queryable-executable.md +0 -250
- package/claude/references/sd-simplysm14/orm-common/docs/schema-builders.md +0 -364
- package/claude/references/sd-simplysm14/orm-common/docs/types.md +0 -522
- package/claude/references/sd-simplysm14/orm-common/usage.md +0 -229
- package/claude/references/sd-simplysm14/orm-node/docs/connections.md +0 -137
- package/claude/references/sd-simplysm14/orm-node/docs/core.md +0 -131
- package/claude/references/sd-simplysm14/orm-node/docs/types.md +0 -173
- package/claude/references/sd-simplysm14/orm-node/usage.md +0 -143
- package/claude/references/sd-simplysm14/sd-cli/usage.md +0 -782
- package/claude/references/sd-simplysm14/service-client/docs/features.md +0 -217
- package/claude/references/sd-simplysm14/service-client/docs/main.md +0 -148
- package/claude/references/sd-simplysm14/service-client/docs/protocol.md +0 -53
- package/claude/references/sd-simplysm14/service-client/docs/transport.md +0 -131
- package/claude/references/sd-simplysm14/service-client/docs/types.md +0 -129
- package/claude/references/sd-simplysm14/service-client/usage.md +0 -202
- package/claude/references/sd-simplysm14/service-common/docs/app-structure.md +0 -175
- package/claude/references/sd-simplysm14/service-common/docs/events.md +0 -64
- package/claude/references/sd-simplysm14/service-common/docs/protocol.md +0 -331
- package/claude/references/sd-simplysm14/service-common/docs/service-types.md +0 -90
- package/claude/references/sd-simplysm14/service-common/docs/types.md +0 -19
- package/claude/references/sd-simplysm14/service-common/usage.md +0 -154
- package/claude/references/sd-simplysm14/service-server/docs/auth.md +0 -64
- package/claude/references/sd-simplysm14/service-server/docs/core.md +0 -174
- package/claude/references/sd-simplysm14/service-server/docs/legacy.md +0 -25
- package/claude/references/sd-simplysm14/service-server/docs/main.md +0 -88
- package/claude/references/sd-simplysm14/service-server/docs/protocol.md +0 -33
- package/claude/references/sd-simplysm14/service-server/docs/services.md +0 -94
- package/claude/references/sd-simplysm14/service-server/docs/transport-http.md +0 -93
- package/claude/references/sd-simplysm14/service-server/docs/transport-socket.md +0 -119
- package/claude/references/sd-simplysm14/service-server/docs/types.md +0 -36
- package/claude/references/sd-simplysm14/service-server/docs/utils.md +0 -22
- package/claude/references/sd-simplysm14/service-server/usage.md +0 -171
- package/claude/references/sd-simplysm14/storage/usage.md +0 -301
- package/claude/references/sd-simplysm14.md +0 -35
- package/claude/rules/sd-clarify.md +0 -23
- package/claude/sd-session-start.sh +0 -10
- /package/{claude/references/sd-simplysm14/sd-claude/docs → docs}/cli.md +0 -0
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
# @simplysm/orm-common
|
|
2
|
-
|
|
3
|
-
DBMS 독립적인 ORM 코어 라이브러리. TypeScript Fluent API로 스키마를 정의하고, SQL AST(QueryDef)를 경유하여 MySQL/MSSQL/PostgreSQL 세 방언(dialect)의 SQL을 생성한다.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @simplysm/orm-common
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## API Overview
|
|
12
|
-
|
|
13
|
-
### Core
|
|
14
|
-
|
|
15
|
-
| API | Type | Description |
|
|
16
|
-
|-----|------|-------------|
|
|
17
|
-
| `DbContext` | class | DB 연결/트랜잭션/DDL/초기화를 제공하는 추상 클래스. `queryable()`/`executable()`로 테이블/프로시저 등록 |
|
|
18
|
-
| `SD_BUILDER` | const | DbContext 프로퍼티에 부착된 builder 참조용 Symbol |
|
|
19
|
-
| `DbContextBase` | interface | Queryable/Executable에서 사용하는 DbContext 내부 인터페이스 |
|
|
20
|
-
| `DbContextStatus` | type | DbContext 상태: `"ready" \| "connect" \| "transact"` |
|
|
21
|
-
| `DbContextDdlMethods` | interface | DDL 실행 메서드 인터페이스 (createTable, dropTable 등) |
|
|
22
|
-
| `DbErrorCode` | enum | 트랜잭션 에러 코드 (NO_ACTIVE_TRANSACTION, DEADLOCK 등) |
|
|
23
|
-
| `DbTransactionError` | class | DBMS 네이티브 에러를 표준 에러 코드로 래핑하는 에러 클래스 |
|
|
24
|
-
|
|
25
|
-
See [docs/core.md](./docs/core.md) for detailed API documentation.
|
|
26
|
-
|
|
27
|
-
### Queryable / Executable
|
|
28
|
-
|
|
29
|
-
| API | Type | Description |
|
|
30
|
-
|-----|------|-------------|
|
|
31
|
-
| `Queryable` | class | SELECT/INSERT/UPDATE/DELETE/UPSERT 체인 빌더. 메서드 체이닝으로 쿼리 구성 |
|
|
32
|
-
| `queryable` | function | Queryable 생성 팩토리 함수 |
|
|
33
|
-
| `getMatchedPrimaryKeys` | function | FK column 배열과 대상 테이블 PK를 매칭하여 PK column 이름 반환 |
|
|
34
|
-
| `QueryableRecord` | type | Queryable column 프록시 레코드 타입 |
|
|
35
|
-
| `QueryableWriteRecord` | type | UPDATE/INSERT용 column 레코드 타입 |
|
|
36
|
-
| `UnwrapQueryableRecord` | type | QueryableRecord에서 실제 데이터 타입 추출 |
|
|
37
|
-
| `PathProxy` | type | include()에서 관계 경로를 타입 안전하게 지정하기 위한 프록시 타입 |
|
|
38
|
-
| `Executable` | class | Stored Procedure 실행 래퍼 클래스 |
|
|
39
|
-
| `executable` | function | Executable 생성 팩토리 함수 |
|
|
40
|
-
| `parseSearchQuery` | function | 검색 쿼리 문자열을 SQL LIKE 패턴으로 파싱 |
|
|
41
|
-
| `ParsedSearchQuery` | interface | parseSearchQuery 결과 타입 (or, must, not 배열) |
|
|
42
|
-
|
|
43
|
-
See [docs/queryable-executable.md](./docs/queryable-executable.md) for detailed API documentation.
|
|
44
|
-
|
|
45
|
-
### Expression
|
|
46
|
-
|
|
47
|
-
| API | Type | Description |
|
|
48
|
-
|-----|------|-------------|
|
|
49
|
-
| `expr` | const | SQL 표현식 AST 빌더 네임스페이스 (60+ 함수) |
|
|
50
|
-
| `SwitchExprBuilder` | interface | CASE WHEN 표현식 체이닝 빌더 인터페이스 |
|
|
51
|
-
| `ExprUnit` | class | 타입 안전 표현식 래퍼 |
|
|
52
|
-
| `WhereExprUnit` | class | WHERE 절용 표현식 래퍼 |
|
|
53
|
-
| `ExprInput` | type | ExprUnit 또는 리터럴 값을 받는 입력 타입 |
|
|
54
|
-
| `toExpr` | function | ExprInput을 Expr AST로 변환하는 내부 헬퍼 (커스텀 빌더 작성 시 사용) |
|
|
55
|
-
|
|
56
|
-
See [docs/expression.md](./docs/expression.md) for detailed API documentation.
|
|
57
|
-
|
|
58
|
-
### Schema Builders
|
|
59
|
-
|
|
60
|
-
| API | Type | Description |
|
|
61
|
-
|-----|------|-------------|
|
|
62
|
-
| `Table` | function | TableBuilder 팩토리 함수 |
|
|
63
|
-
| `TableBuilder` | class | Fluent API로 테이블 스키마 정의 |
|
|
64
|
-
| `View` | function | ViewBuilder 팩토리 함수 |
|
|
65
|
-
| `ViewBuilder` | class | Fluent API로 뷰 스키마 정의 |
|
|
66
|
-
| `Procedure` | function | ProcedureBuilder 팩토리 함수 |
|
|
67
|
-
| `ProcedureBuilder` | class | Fluent API로 Stored Procedure 정의 |
|
|
68
|
-
| `ColumnBuilder` | class | Column 정의 빌더 (타입, nullable, autoIncrement, default) |
|
|
69
|
-
| `createColumnFactory` | function | Column 타입 팩토리 생성 (int, varchar, datetime 등) |
|
|
70
|
-
| `ColumnBuilderRecord` | type | Column builder 레코드 타입 |
|
|
71
|
-
| `InferColumns` | type | Column builder에서 실제 값 타입 추론 |
|
|
72
|
-
| `InferColumnExprs` | type | Column builder에서 expression 입력 타입 추론 |
|
|
73
|
-
| `RequiredInsertKeys` | type | INSERT용 필수 column key 추출 |
|
|
74
|
-
| `OptionalInsertKeys` | type | INSERT용 선택적 column key 추출 |
|
|
75
|
-
| `InferInsertColumns` | type | INSERT 타입 추론 |
|
|
76
|
-
| `InferUpdateColumns` | type | UPDATE 타입 추론 (모든 필드 optional) |
|
|
77
|
-
| `DataToColumnBuilderRecord` | type | 데이터 레코드를 Column builder 레코드로 변환 |
|
|
78
|
-
| `IndexBuilder` | class | Index 정의 빌더 (unique, orderBy) |
|
|
79
|
-
| `createIndexFactory` | function | Index 팩토리 생성 |
|
|
80
|
-
| `ForeignKeyBuilder` | class | FK 관계 빌더 (N:1, DB FK 생성) |
|
|
81
|
-
| `ForeignKeyTargetBuilder` | class | FK 역참조 빌더 (1:N, single 옵션) |
|
|
82
|
-
| `RelationKeyBuilder` | class | 논리적 관계 빌더 (N:1, DB FK 미생성) |
|
|
83
|
-
| `RelationKeyTargetBuilder` | class | 논리적 역참조 빌더 (1:N, DB FK 미생성) |
|
|
84
|
-
| `createRelationFactory` | function | 관계 빌더 팩토리 생성 |
|
|
85
|
-
| `RelationBuilderRecord` | type | 관계 builder 레코드 타입 |
|
|
86
|
-
| `ExtractRelationTarget` | type | FK에서 대상 타입 추출 (단일 객체) |
|
|
87
|
-
| `ExtractRelationTargetResult` | type | FKTarget에서 대상 타입 추출 (배열/단일) |
|
|
88
|
-
| `InferDeepRelations` | type | 관계 정의에서 심층 타입 추론 |
|
|
89
|
-
|
|
90
|
-
See [docs/schema-builders.md](./docs/schema-builders.md) for detailed API documentation.
|
|
91
|
-
|
|
92
|
-
### Models
|
|
93
|
-
|
|
94
|
-
| API | Type | Description |
|
|
95
|
-
|-----|------|-------------|
|
|
96
|
-
| `_Migration` | const | 시스템 마이그레이션 테이블 정의 (TableBuilder 인스턴스) |
|
|
97
|
-
|
|
98
|
-
See [docs/models.md](./docs/models.md) for detailed API documentation.
|
|
99
|
-
|
|
100
|
-
### Query Builder
|
|
101
|
-
|
|
102
|
-
| API | Type | Description |
|
|
103
|
-
|-----|------|-------------|
|
|
104
|
-
| `createQueryBuilder` | function | Dialect에 맞는 QueryBuilder 인스턴스 생성 |
|
|
105
|
-
| `QueryBuilderBase` | class | QueryDef -> SQL 문자열 변환 추상 클래스 |
|
|
106
|
-
| `ExprRendererBase` | class | Expr -> SQL 표현식 변환 추상 클래스 |
|
|
107
|
-
| `MysqlQueryBuilder` | class | MySQL용 QueryBuilder |
|
|
108
|
-
| `MysqlExprRenderer` | class | MySQL용 ExprRenderer |
|
|
109
|
-
| `MssqlQueryBuilder` | class | MSSQL용 QueryBuilder |
|
|
110
|
-
| `MssqlExprRenderer` | class | MSSQL용 ExprRenderer |
|
|
111
|
-
| `PostgresqlQueryBuilder` | class | PostgreSQL용 QueryBuilder |
|
|
112
|
-
| `PostgresqlExprRenderer` | class | PostgreSQL용 ExprRenderer |
|
|
113
|
-
|
|
114
|
-
See [docs/query-builder.md](./docs/query-builder.md) for detailed API documentation.
|
|
115
|
-
|
|
116
|
-
### Types
|
|
117
|
-
|
|
118
|
-
| API | Type | Description |
|
|
119
|
-
|-----|------|-------------|
|
|
120
|
-
| `Dialect` | type | 지원 DB 방언: `"mysql" \| "mssql" \| "postgresql"` |
|
|
121
|
-
| `dialects` | const | 모든 Dialect 목록 배열 |
|
|
122
|
-
| `IsolationLevel` | type | 트랜잭션 격리 수준 |
|
|
123
|
-
| `DataRecord` | type | 쿼리 결과 데이터 레코드 타입 (재귀적) |
|
|
124
|
-
| `DbContextExecutor` | interface | DB 연결/쿼리 실행 인터페이스 |
|
|
125
|
-
| `QueryBuildResult` | interface | QueryBuilder.build() 반환 타입 |
|
|
126
|
-
| `ResultMeta` | interface | SELECT 결과 변환용 메타데이터 |
|
|
127
|
-
| `Migration` | interface | DB 마이그레이션 정의 |
|
|
128
|
-
| `parseQueryResult` | function | DB 쿼리 결과를 TypeScript 객체로 변환 (타입 파싱 + JOIN 중첩) |
|
|
129
|
-
| `DataType` | type | SQL 데이터 타입 정의 (int, varchar, datetime 등) |
|
|
130
|
-
| `ColumnPrimitiveMap` | type | TypeScript 타입 이름 -> 실제 타입 매핑 |
|
|
131
|
-
| `ColumnPrimitiveStr` | type | Column 원시 타입 이름 문자열 |
|
|
132
|
-
| `ColumnPrimitive` | type | Column에 저장 가능한 모든 원시 타입 |
|
|
133
|
-
| `dataTypeStrToColumnPrimitiveStr` | const | SQL DataType -> TypeScript 타입 이름 매핑 |
|
|
134
|
-
| `InferColumnPrimitiveFromDataType` | type | DataType에서 TypeScript 타입 추론 |
|
|
135
|
-
| `inferColumnPrimitiveStr` | function | 런타임 값에서 ColumnPrimitiveStr 추론 |
|
|
136
|
-
| `ColumnMeta` | interface | Column 메타데이터 |
|
|
137
|
-
| `DateUnit` | type | 날짜 단위: `"year" \| "month" \| "day" \| "hour" \| "minute" \| "second"` |
|
|
138
|
-
| `Expr` | type | 모든 표현식 AST의 유니온 타입 |
|
|
139
|
-
| `WhereExpr` | type | WHERE 절 표현식 AST 유니온 타입 |
|
|
140
|
-
| `WinSpec` | interface | Window 함수 스펙 (partitionBy, orderBy) |
|
|
141
|
-
| `WinFn` | type | Window 함수 유니온 타입 |
|
|
142
|
-
| `QueryDef` | type | 모든 쿼리 정의의 유니온 타입 |
|
|
143
|
-
| `SelectQueryDef` | interface | SELECT 쿼리 정의 |
|
|
144
|
-
| `SelectQueryDefJoin` | interface | SELECT 쿼리 JOIN 정의 (SelectQueryDef 확장) |
|
|
145
|
-
| `InsertQueryDef` | interface | INSERT 쿼리 정의 |
|
|
146
|
-
| `UpdateQueryDef` | interface | UPDATE 쿼리 정의 |
|
|
147
|
-
| `DeleteQueryDef` | interface | DELETE 쿼리 정의 |
|
|
148
|
-
| `UpsertQueryDef` | interface | UPSERT 쿼리 정의 |
|
|
149
|
-
| `QueryDefObjectName` | interface | 테이블/뷰 이름 정의 (database, schema, name) |
|
|
150
|
-
| `CudOutputDef` | interface | INSERT/UPDATE/DELETE output 정의 (columns, pkColNames, aiColName) |
|
|
151
|
-
| `DDL_TYPES` | const | DDL 타입 문자열 목록 |
|
|
152
|
-
| `DdlType` | type | DDL 타입 유니온 |
|
|
153
|
-
| 60+ `Expr*` interfaces | interface | 각 표현식 AST 인터페이스 (ExprColumn, ExprValue, ExprEq, ...) |
|
|
154
|
-
| 13+ `WinFn*` interfaces | interface | Window 함수 AST 인터페이스 |
|
|
155
|
-
| DDL QueryDef interfaces | interface | DDL 쿼리 정의 인터페이스 (CreateTable, DropTable, ...) |
|
|
156
|
-
|
|
157
|
-
See [docs/types.md](./docs/types.md) for detailed API documentation.
|
|
158
|
-
|
|
159
|
-
## Usage Examples
|
|
160
|
-
|
|
161
|
-
### 스키마 정의 및 DbContext 설정
|
|
162
|
-
|
|
163
|
-
```typescript
|
|
164
|
-
import { Table, View, Procedure, DbContext, expr } from "@simplysm/orm-common";
|
|
165
|
-
|
|
166
|
-
// 테이블 정의
|
|
167
|
-
const User = Table("User")
|
|
168
|
-
.columns((c) => ({
|
|
169
|
-
id: c.bigint().autoIncrement(),
|
|
170
|
-
name: c.varchar(100),
|
|
171
|
-
email: c.varchar(200).nullable(),
|
|
172
|
-
companyId: c.bigint().nullable(),
|
|
173
|
-
createdAt: c.datetime(),
|
|
174
|
-
}))
|
|
175
|
-
.primaryKey("id")
|
|
176
|
-
.indexes((i) => [i.index("email").unique()])
|
|
177
|
-
.relations((r) => ({
|
|
178
|
-
company: r.foreignKey(["companyId"], () => Company),
|
|
179
|
-
posts: r.foreignKeyTarget(() => Post, "author"),
|
|
180
|
-
}));
|
|
181
|
-
|
|
182
|
-
// DbContext 정의
|
|
183
|
-
class MainDb extends DbContext {
|
|
184
|
-
user = this.queryable(User);
|
|
185
|
-
post = this.queryable(Post);
|
|
186
|
-
|
|
187
|
-
migrations = [
|
|
188
|
-
{ name: "001_init", up: async (db) => { await db.createTable(User); } },
|
|
189
|
-
];
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const db = new MainDb(executor, { database: "mydb" });
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### SELECT 쿼리
|
|
196
|
-
|
|
197
|
-
```typescript
|
|
198
|
-
await db.connect(async () => {
|
|
199
|
-
// 기본 조회
|
|
200
|
-
const users = await db.user()
|
|
201
|
-
.where((u) => [expr.eq(u.isActive, true)])
|
|
202
|
-
.orderBy((u) => u.name)
|
|
203
|
-
.limit(0, 20)
|
|
204
|
-
.execute();
|
|
205
|
-
|
|
206
|
-
// JOIN + include
|
|
207
|
-
const posts = await db.post()
|
|
208
|
-
.include((p) => p.author)
|
|
209
|
-
.include((p) => p.author.company)
|
|
210
|
-
.execute();
|
|
211
|
-
|
|
212
|
-
// 집계
|
|
213
|
-
const count = await db.user()
|
|
214
|
-
.where((u) => [expr.eq(u.isActive, true)])
|
|
215
|
-
.count();
|
|
216
|
-
});
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
### 검색 파서
|
|
220
|
-
|
|
221
|
-
```typescript
|
|
222
|
-
import { parseSearchQuery } from "@simplysm/orm-common";
|
|
223
|
-
|
|
224
|
-
const parsed = parseSearchQuery('+apple -banana "exact phrase"');
|
|
225
|
-
// { must: ["%apple%", "%exact phrase%"], not: ["%banana%"], or: [] }
|
|
226
|
-
|
|
227
|
-
// Queryable.search()로 직접 사용
|
|
228
|
-
db.user().search((u) => [u.name, u.email], "John +admin -deleted");
|
|
229
|
-
```
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
# Connections
|
|
2
|
-
|
|
3
|
-
세 연결 클래스(`MssqlDbConn`, `MysqlDbConn`, `PostgresqlDbConn`)는 모두 `EventEmitter<{ close: void }>`를 상속하고 `DbConn` 인터페이스를 구현한다.
|
|
4
|
-
|
|
5
|
-
일반적으로 직접 생성하지 않고 `createDbConn()`을 통해 인스턴스를 얻는다. 직접 생성은 테스트 코드에서 네이티브 라이브러리를 주입할 때 사용한다.
|
|
6
|
-
|
|
7
|
-
## `MssqlDbConn`
|
|
8
|
-
|
|
9
|
-
tedious 라이브러리를 사용하여 MSSQL/Azure SQL 연결을 관리하는 클래스.
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
class MssqlDbConn extends EventEmitter<{ close: void }> implements DbConn {
|
|
13
|
-
isConnected: boolean;
|
|
14
|
-
isInTransaction: boolean;
|
|
15
|
-
readonly config: MssqlDbConnConfig;
|
|
16
|
-
|
|
17
|
-
constructor(
|
|
18
|
-
tedious: typeof import("tedious"),
|
|
19
|
-
config: MssqlDbConnConfig,
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
connect(): Promise<void>;
|
|
23
|
-
close(): Promise<void>;
|
|
24
|
-
beginTransaction(isolationLevel?: IsolationLevel): Promise<void>;
|
|
25
|
-
commitTransaction(): Promise<void>;
|
|
26
|
-
rollbackTransaction(): Promise<void>;
|
|
27
|
-
execute(queries: string[]): Promise<Record<string, unknown>[][]>;
|
|
28
|
-
executeParametrized(query: string, params?: unknown[]): Promise<Record<string, unknown>[][]>;
|
|
29
|
-
bulkInsert(
|
|
30
|
-
tableName: string,
|
|
31
|
-
columnMetas: Record<string, ColumnMeta>,
|
|
32
|
-
records: Record<string, unknown>[],
|
|
33
|
-
): Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
**생성자**: tedious 라이브러리 모듈을 첫 번째 인수로 직접 주입받는다. `createDbConn()`이 동적 import 후 전달한다.
|
|
38
|
-
|
|
39
|
-
**`connect()`**: `config.dialect === "mssql-azure"`인 경우 `encrypt: true`로 연결한다. 연결 성공 시 유휴 타임아웃 타이머(`DB_CONN_DEFAULT_TIMEOUT * 2`)를 시작한다.
|
|
40
|
-
|
|
41
|
-
**`close()`**: 진행 중인 요청을 취소(`cancel()`)하고 30초 내에 완료될 때까지 대기한 뒤 연결을 종료한다.
|
|
42
|
-
|
|
43
|
-
**`bulkInsert()`**: tedious `BulkLoad` API를 사용한다. 값 변환 규칙:
|
|
44
|
-
- `Uuid` → `toString()`
|
|
45
|
-
- `Uint8Array` → `Buffer.from(val)` (tedious 라이브러리 요구사항으로 인한 예외적 허용)
|
|
46
|
-
- `DateTime` / `DateOnly` → `.date` (native Date 객체)
|
|
47
|
-
- `Time` → `"HH:mm:ss"` 포맷 문자열
|
|
48
|
-
|
|
49
|
-
**`executeParametrized()`**: 파라미터가 있으면 `conn.execSql()`, 없으면 `conn.execSqlBatch()`를 사용한다. 쿼리 오류 시 오류 발생 줄을 `==> ` 접두사로 표시하여 에러 메시지에 포함한다.
|
|
50
|
-
|
|
51
|
-
## `MysqlDbConn`
|
|
52
|
-
|
|
53
|
-
mysql2/promise 라이브러리를 사용하여 MySQL 연결을 관리하는 클래스.
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
class MysqlDbConn extends EventEmitter<{ close: void }> implements DbConn {
|
|
57
|
-
isConnected: boolean;
|
|
58
|
-
isInTransaction: boolean;
|
|
59
|
-
readonly config: MysqlDbConnConfig;
|
|
60
|
-
|
|
61
|
-
constructor(
|
|
62
|
-
mysql2: typeof import("mysql2/promise"),
|
|
63
|
-
config: MysqlDbConnConfig,
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
connect(): Promise<void>;
|
|
67
|
-
close(): Promise<void>;
|
|
68
|
-
beginTransaction(isolationLevel?: IsolationLevel): Promise<void>;
|
|
69
|
-
commitTransaction(): Promise<void>;
|
|
70
|
-
rollbackTransaction(): Promise<void>;
|
|
71
|
-
execute(queries: string[]): Promise<Record<string, unknown>[][]>;
|
|
72
|
-
executeParametrized(query: string, params?: unknown[]): Promise<Record<string, unknown>[][]>;
|
|
73
|
-
bulkInsert(
|
|
74
|
-
tableName: string,
|
|
75
|
-
columnMetas: Record<string, ColumnMeta>,
|
|
76
|
-
records: Record<string, unknown>[],
|
|
77
|
-
): Promise<void>;
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
**생성자**: mysql2/promise 라이브러리 모듈을 첫 번째 인수로 직접 주입받는다.
|
|
82
|
-
|
|
83
|
-
**`connect()`**: `username === "root"`인 경우 `database` 옵션을 전달하지 않는다 (모든 데이터베이스에 접근 가능하도록 관리 작업용). `multipleStatements: true`, `charset: "utf8mb4"`로 연결한다.
|
|
84
|
-
|
|
85
|
-
**`beginTransaction()`**: `SET SESSION TRANSACTION ISOLATION LEVEL {level}` 후 `BEGIN`을 실행한다. MySQL은 트랜잭션 시작 전에 격리 수준을 설정해야 한다.
|
|
86
|
-
|
|
87
|
-
**`bulkInsert()`**: `LOAD DATA LOCAL INFILE`을 사용한다. 처리 흐름:
|
|
88
|
-
1. `os.tmpdir()`에 UUID 기반 임시 CSV 파일 생성 (TAB 구분)
|
|
89
|
-
2. UUID/binary 컬럼은 hex 문자열로 기록, `SET` 절에서 `UNHEX()` 변환
|
|
90
|
-
3. `LOAD DATA LOCAL INFILE` 실행
|
|
91
|
-
4. `finally` 블록에서 임시 파일 삭제
|
|
92
|
-
|
|
93
|
-
**`executeParametrized()`**: 결과 형식에 따라 처리:
|
|
94
|
-
- single SELECT → flat `RowDataPacket[]`를 단일 결과 집합으로 반환
|
|
95
|
-
- single INSERT/UPDATE/DELETE → `ResultSetHeader`이므로 빈 결과 집합 반환
|
|
96
|
-
- multi-statement → 각 statement의 결과를 별도 결과 집합으로 분리
|
|
97
|
-
|
|
98
|
-
## `PostgresqlDbConn`
|
|
99
|
-
|
|
100
|
-
pg + pg-copy-streams 라이브러리를 사용하여 PostgreSQL 연결을 관리하는 클래스.
|
|
101
|
-
|
|
102
|
-
```typescript
|
|
103
|
-
class PostgresqlDbConn extends EventEmitter<{ close: void }> implements DbConn {
|
|
104
|
-
isConnected: boolean;
|
|
105
|
-
isInTransaction: boolean;
|
|
106
|
-
readonly config: PostgresqlDbConnConfig;
|
|
107
|
-
|
|
108
|
-
constructor(
|
|
109
|
-
pg: typeof import("pg"),
|
|
110
|
-
pgCopyStreams: typeof import("pg-copy-streams"),
|
|
111
|
-
config: PostgresqlDbConnConfig,
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
connect(): Promise<void>;
|
|
115
|
-
close(): Promise<void>;
|
|
116
|
-
beginTransaction(isolationLevel?: IsolationLevel): Promise<void>;
|
|
117
|
-
commitTransaction(): Promise<void>;
|
|
118
|
-
rollbackTransaction(): Promise<void>;
|
|
119
|
-
execute(queries: string[]): Promise<Record<string, unknown>[][]>;
|
|
120
|
-
executeParametrized(query: string, params?: unknown[]): Promise<Record<string, unknown>[][]>;
|
|
121
|
-
bulkInsert(
|
|
122
|
-
tableName: string,
|
|
123
|
-
columnMetas: Record<string, ColumnMeta>,
|
|
124
|
-
records: Record<string, unknown>[],
|
|
125
|
-
): Promise<void>;
|
|
126
|
-
}
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
**생성자**: pg와 pg-copy-streams 라이브러리 모듈을 첫 번째, 두 번째 인수로 직접 주입받는다.
|
|
130
|
-
|
|
131
|
-
**`connect()`**: 기본 포트는 `5432`. `connectionTimeoutMillis: DB_CONN_CONNECT_TIMEOUT`, `query_timeout: DB_CONN_DEFAULT_TIMEOUT`으로 연결한다.
|
|
132
|
-
|
|
133
|
-
**`beginTransaction()`**: `BEGIN` 후 `SET TRANSACTION ISOLATION LEVEL {level}`을 실행한다.
|
|
134
|
-
|
|
135
|
-
**`bulkInsert()`**: `COPY FROM STDIN`(CSV 형식)을 사용한다. `pg-copy-streams`의 `from()` 함수로 스트림을 생성하고, `Readable.from(csvContent)`를 파이프한다. binary 컬럼은 PostgreSQL bytea hex 형식(`\x{hex}`)으로 변환한다.
|
|
136
|
-
|
|
137
|
-
**`executeParametrized()`**: PostgreSQL은 단일 결과 집합을 반환하므로 `[result.rows]`로 래핑하여 반환한다.
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
# Core
|
|
2
|
-
|
|
3
|
-
## `createDbConn`
|
|
4
|
-
|
|
5
|
-
dialect 기반 DbConn 팩토리. 네이티브 드라이버를 지연 로딩하여 DbConn 인스턴스를 생성한다.
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
async function createDbConn(config: DbConnConfig): Promise<DbConn>;
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
`config.dialect`에 따라 적절한 DbConn 구현체를 생성한다:
|
|
12
|
-
|
|
13
|
-
| dialect | 반환 타입 | 로드하는 패키지 |
|
|
14
|
-
|---------|-----------|----------------|
|
|
15
|
-
| `"mysql"` | `MysqlDbConn` | `mysql2/promise` |
|
|
16
|
-
| `"postgresql"` | `PostgresqlDbConn` | `pg`, `pg-copy-streams` |
|
|
17
|
-
| `"mssql"` / `"mssql-azure"` | `MssqlDbConn` | `tedious` |
|
|
18
|
-
|
|
19
|
-
네이티브 드라이버 패키지는 최초 호출 시에만 동적 import로 로드하고 모듈 수준 캐시에 보관한다. 이후 호출에서는 캐시된 모듈을 재사용한다.
|
|
20
|
-
|
|
21
|
-
반환된 `DbConn`은 아직 연결되지 않은 상태이므로 `connect()`를 별도로 호출해야 한다.
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
const conn = await createDbConn({ dialect: "mysql", host: "...", username: "...", password: "..." });
|
|
25
|
-
await conn.connect(); // 연결 수립
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## `NodeDbContextExecutor`
|
|
29
|
-
|
|
30
|
-
`orm-common`의 `DbContextExecutor` 인터페이스를 구현하는 Node.js 환경용 실행자. `DbContext`에서 내부적으로 사용한다.
|
|
31
|
-
|
|
32
|
-
```typescript
|
|
33
|
-
class NodeDbContextExecutor implements DbContextExecutor {
|
|
34
|
-
constructor(config: DbConnConfig);
|
|
35
|
-
|
|
36
|
-
connect(): Promise<void>;
|
|
37
|
-
close(): Promise<void>;
|
|
38
|
-
beginTransaction(isolationLevel?: IsolationLevel): Promise<void>;
|
|
39
|
-
commitTransaction(): Promise<void>;
|
|
40
|
-
rollbackTransaction(): Promise<void>;
|
|
41
|
-
executeParametrized(query: string, params?: unknown[]): Promise<Record<string, unknown>[][]>;
|
|
42
|
-
bulkInsert(
|
|
43
|
-
tableName: string,
|
|
44
|
-
columnMetas: Record<string, ColumnMeta>,
|
|
45
|
-
records: DataRecord[],
|
|
46
|
-
): Promise<void>;
|
|
47
|
-
executeDefs<T = DataRecord>(
|
|
48
|
-
defs: QueryDef[],
|
|
49
|
-
resultMetas?: (ResultMeta | undefined)[],
|
|
50
|
-
): Promise<T[][]>;
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
내부적으로 `createDbConn()`으로 DB 연결을 생성하고 관리한다.
|
|
55
|
-
|
|
56
|
-
**`executeDefs()`**: `QueryDef` 배열을 SQL로 변환하여 실행한다. 처리 방식:
|
|
57
|
-
- `resultMetas`가 모두 `undefined`이면 쿼리를 단일 문자열로 결합하여 한 번의 요청으로 실행한다 (결과 불필요 최적화).
|
|
58
|
-
- 그 외에는 각 def를 개별 실행하고 `ResultMeta`가 있으면 `parseQueryResult()`로 결과를 파싱한다.
|
|
59
|
-
- `buildResult.resultSetIndex`가 지정된 경우 해당 인덱스의 결과 집합을 사용한다.
|
|
60
|
-
|
|
61
|
-
일반적으로 직접 사용하지 않는다. `createOrm()`이 내부적으로 이 클래스를 생성하여 `DbContext`에 전달한다.
|
|
62
|
-
|
|
63
|
-
## `createOrm`
|
|
64
|
-
|
|
65
|
-
Node.js ORM 팩토리 함수. `DbContext` 서브클래스와 DB 연결 설정을 받아 트랜잭션을 관리하는 `Orm<T>` 인스턴스를 반환한다.
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
function createOrm<T extends DbContext>(
|
|
69
|
-
DbClass: new (executor: DbContextExecutor, opt: { database: string; schema?: string }) => T,
|
|
70
|
-
config: DbConnConfig,
|
|
71
|
-
options?: OrmOptions,
|
|
72
|
-
): Orm<T>;
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
`options.database` / `options.schema`는 `config`의 동일 필드보다 우선 적용된다. `database`는 필수이며, `config`와 `options` 양쪽 모두 `database`가 없으면 에러를 throw한다.
|
|
76
|
-
|
|
77
|
-
```typescript
|
|
78
|
-
class MyDb extends DbContext {
|
|
79
|
-
user = this.queryable(User);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const orm = createOrm(MyDb, {
|
|
83
|
-
dialect: "mysql",
|
|
84
|
-
host: "localhost",
|
|
85
|
-
username: "root",
|
|
86
|
-
password: "password",
|
|
87
|
-
database: "mydb",
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
await orm.connect(async (db) => {
|
|
91
|
-
return db.user().execute();
|
|
92
|
-
});
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## `Orm`
|
|
96
|
-
|
|
97
|
-
`createOrm()`에서 반환하는 객체의 타입.
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
interface Orm<T extends DbContext> {
|
|
101
|
-
readonly DbClass: new (executor: DbContextExecutor, opt: { database: string; schema?: string }) => T;
|
|
102
|
-
readonly config: DbConnConfig;
|
|
103
|
-
readonly options?: OrmOptions;
|
|
104
|
-
connect<R>(callback: (conn: T) => Promise<R>, isolationLevel?: IsolationLevel): Promise<R>;
|
|
105
|
-
connectWithoutTransaction<R>(callback: (conn: T) => Promise<R>): Promise<R>;
|
|
106
|
-
}
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
| Field | Type | Description |
|
|
110
|
-
|-------|------|-------------|
|
|
111
|
-
| `DbClass` | constructor | DbContext 서브클래스 생성자 |
|
|
112
|
-
| `config` | `DbConnConfig` | DB 연결 설정 |
|
|
113
|
-
| `options` | `OrmOptions?` | ORM 옵션 |
|
|
114
|
-
| `connect(callback, isolationLevel?)` | `Promise<R>` | 트랜잭션 내에서 콜백을 실행한다. 콜백 완료 후 자동 커밋, 예외 발생 시 자동 롤백 |
|
|
115
|
-
| `connectWithoutTransaction(callback)` | `Promise<R>` | 트랜잭션 없이 콜백을 실행한다 |
|
|
116
|
-
|
|
117
|
-
## `OrmOptions`
|
|
118
|
-
|
|
119
|
-
`createOrm()`의 세 번째 인수로 전달하는 옵션. `DbConnConfig`의 동일 필드보다 우선 적용된다.
|
|
120
|
-
|
|
121
|
-
```typescript
|
|
122
|
-
interface OrmOptions {
|
|
123
|
-
database?: string;
|
|
124
|
-
schema?: string;
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
| Field | Type | Description |
|
|
129
|
-
|-------|------|-------------|
|
|
130
|
-
| `database` | `string?` | 데이터베이스 이름. `DbConnConfig`의 `database` 대신 사용된다 |
|
|
131
|
-
| `schema` | `string?` | 스키마 이름 (MSSQL: `dbo`, PostgreSQL: `public`). `DbConnConfig`의 `schema` 대신 사용된다 |
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
# Types
|
|
2
|
-
|
|
3
|
-
## `DbConn`
|
|
4
|
-
|
|
5
|
-
저수준 DB 연결 인터페이스. 각 DBMS 구현체(`MssqlDbConn`, `MysqlDbConn`, `PostgresqlDbConn`)가 이 인터페이스를 구현한다.
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
interface DbConn extends EventEmitter<{ close: void }> {
|
|
9
|
-
config: DbConnConfig;
|
|
10
|
-
isConnected: boolean;
|
|
11
|
-
isInTransaction: boolean;
|
|
12
|
-
connect(): Promise<void>;
|
|
13
|
-
close(): Promise<void>;
|
|
14
|
-
beginTransaction(isolationLevel?: IsolationLevel): Promise<void>;
|
|
15
|
-
commitTransaction(): Promise<void>;
|
|
16
|
-
rollbackTransaction(): Promise<void>;
|
|
17
|
-
execute(queries: string[]): Promise<Record<string, unknown>[][]>;
|
|
18
|
-
executeParametrized(query: string, params?: unknown[]): Promise<Record<string, unknown>[][]>;
|
|
19
|
-
bulkInsert(
|
|
20
|
-
tableName: string,
|
|
21
|
-
columnMetas: Record<string, ColumnMeta>,
|
|
22
|
-
records: Record<string, unknown>[],
|
|
23
|
-
): Promise<void>;
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
| Field | Type | Description |
|
|
28
|
-
|-------|------|-------------|
|
|
29
|
-
| `config` | `DbConnConfig` | 연결 설정 |
|
|
30
|
-
| `isConnected` | `boolean` | 연결 여부 |
|
|
31
|
-
| `isInTransaction` | `boolean` | 트랜잭션 진행 여부 |
|
|
32
|
-
| `connect()` | `Promise<void>` | DB 연결을 수립한다 |
|
|
33
|
-
| `close()` | `Promise<void>` | DB 연결을 종료한다 |
|
|
34
|
-
| `beginTransaction(isolationLevel?)` | `Promise<void>` | 트랜잭션을 시작한다 |
|
|
35
|
-
| `commitTransaction()` | `Promise<void>` | 트랜잭션을 커밋한다 |
|
|
36
|
-
| `rollbackTransaction()` | `Promise<void>` | 트랜잭션을 롤백한다 |
|
|
37
|
-
| `execute(queries)` | `Promise<Record<string, unknown>[][]>` | SQL 쿼리 배열을 실행한다 |
|
|
38
|
-
| `executeParametrized(query, params?)` | `Promise<Record<string, unknown>[][]>` | 파라미터화된 쿼리를 실행한다 |
|
|
39
|
-
| `bulkInsert(tableName, columnMetas, records)` | `Promise<void>` | 네이티브 bulk API를 사용하여 대량 삽입한다 |
|
|
40
|
-
|
|
41
|
-
`EventEmitter<{ close: void }>`를 상속하므로 연결 종료 시 `'close'` 이벤트를 수신할 수 있다.
|
|
42
|
-
|
|
43
|
-
## `DbConnConfig`
|
|
44
|
-
|
|
45
|
-
DB 연결 설정 discriminated union. `dialect` 필드로 구현체를 분기한다.
|
|
46
|
-
|
|
47
|
-
```typescript
|
|
48
|
-
type DbConnConfig = MysqlDbConnConfig | MssqlDbConnConfig | PostgresqlDbConnConfig;
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## `MysqlDbConnConfig`
|
|
52
|
-
|
|
53
|
-
MySQL 연결 설정.
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
interface MysqlDbConnConfig {
|
|
57
|
-
dialect: "mysql";
|
|
58
|
-
host: string;
|
|
59
|
-
port?: number;
|
|
60
|
-
username: string;
|
|
61
|
-
password: string;
|
|
62
|
-
database?: string;
|
|
63
|
-
defaultIsolationLevel?: IsolationLevel;
|
|
64
|
-
}
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
| Field | Type | Description |
|
|
68
|
-
|-------|------|-------------|
|
|
69
|
-
| `dialect` | `"mysql"` | Discriminant. 항상 `"mysql"` |
|
|
70
|
-
| `host` | `string` | 호스트 주소 |
|
|
71
|
-
| `port` | `number?` | 포트 (생략 시 mysql2 기본값 사용) |
|
|
72
|
-
| `username` | `string` | 사용자 이름 |
|
|
73
|
-
| `password` | `string` | 비밀번호 |
|
|
74
|
-
| `database` | `string?` | 데이터베이스 이름 |
|
|
75
|
-
| `defaultIsolationLevel` | `IsolationLevel?` | 기본 격리 수준 (미지정 시 `READ_UNCOMMITTED`) |
|
|
76
|
-
|
|
77
|
-
## `MssqlDbConnConfig`
|
|
78
|
-
|
|
79
|
-
MSSQL/Azure SQL 연결 설정.
|
|
80
|
-
|
|
81
|
-
```typescript
|
|
82
|
-
interface MssqlDbConnConfig {
|
|
83
|
-
dialect: "mssql" | "mssql-azure";
|
|
84
|
-
host: string;
|
|
85
|
-
port?: number;
|
|
86
|
-
username: string;
|
|
87
|
-
password: string;
|
|
88
|
-
database?: string;
|
|
89
|
-
schema?: string;
|
|
90
|
-
defaultIsolationLevel?: IsolationLevel;
|
|
91
|
-
}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
| Field | Type | Description |
|
|
95
|
-
|-------|------|-------------|
|
|
96
|
-
| `dialect` | `"mssql" \| "mssql-azure"` | Discriminant. `"mssql-azure"`인 경우 암호화 연결(encrypt)을 사용한다 |
|
|
97
|
-
| `host` | `string` | 호스트 주소 |
|
|
98
|
-
| `port` | `number?` | 포트 |
|
|
99
|
-
| `username` | `string` | 사용자 이름 |
|
|
100
|
-
| `password` | `string` | 비밀번호 |
|
|
101
|
-
| `database` | `string?` | 데이터베이스 이름 |
|
|
102
|
-
| `schema` | `string?` | 스키마 이름 |
|
|
103
|
-
| `defaultIsolationLevel` | `IsolationLevel?` | 기본 격리 수준 (미지정 시 `READ_UNCOMMITTED`) |
|
|
104
|
-
|
|
105
|
-
## `PostgresqlDbConnConfig`
|
|
106
|
-
|
|
107
|
-
PostgreSQL 연결 설정.
|
|
108
|
-
|
|
109
|
-
```typescript
|
|
110
|
-
interface PostgresqlDbConnConfig {
|
|
111
|
-
dialect: "postgresql";
|
|
112
|
-
host: string;
|
|
113
|
-
port?: number;
|
|
114
|
-
username: string;
|
|
115
|
-
password: string;
|
|
116
|
-
database?: string;
|
|
117
|
-
schema?: string;
|
|
118
|
-
defaultIsolationLevel?: IsolationLevel;
|
|
119
|
-
}
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
| Field | Type | Description |
|
|
123
|
-
|-------|------|-------------|
|
|
124
|
-
| `dialect` | `"postgresql"` | Discriminant. 항상 `"postgresql"` |
|
|
125
|
-
| `host` | `string` | 호스트 주소 |
|
|
126
|
-
| `port` | `number?` | 포트 (미지정 시 `5432`) |
|
|
127
|
-
| `username` | `string` | 사용자 이름 |
|
|
128
|
-
| `password` | `string` | 비밀번호 |
|
|
129
|
-
| `database` | `string?` | 데이터베이스 이름 |
|
|
130
|
-
| `schema` | `string?` | 스키마 이름 |
|
|
131
|
-
| `defaultIsolationLevel` | `IsolationLevel?` | 기본 격리 수준 (미지정 시 `READ_UNCOMMITTED`) |
|
|
132
|
-
|
|
133
|
-
## `DB_CONN_CONNECT_TIMEOUT`
|
|
134
|
-
|
|
135
|
-
DB 연결 수립 타임아웃 (10초).
|
|
136
|
-
|
|
137
|
-
```typescript
|
|
138
|
-
const DB_CONN_CONNECT_TIMEOUT = 10 * 1000; // 10_000ms
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
## `DB_CONN_DEFAULT_TIMEOUT`
|
|
142
|
-
|
|
143
|
-
DB 쿼리 기본 타임아웃 (10분). 유휴 연결 자동 종료 타이머는 이 값의 2배 후 `close()`를 호출한다.
|
|
144
|
-
|
|
145
|
-
```typescript
|
|
146
|
-
const DB_CONN_DEFAULT_TIMEOUT = 10 * 60 * 1000; // 600_000ms
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
## `DB_CONN_ERRORS`
|
|
150
|
-
|
|
151
|
-
DB 연결 관련 오류 메시지 상수.
|
|
152
|
-
|
|
153
|
-
```typescript
|
|
154
|
-
const DB_CONN_ERRORS = {
|
|
155
|
-
NOT_CONNECTED: "'Connection'이 연결되어 있지 않습니다.",
|
|
156
|
-
ALREADY_CONNECTED: "'Connection'이 이미 연결되어 있습니다.",
|
|
157
|
-
} as const;
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
| Key | Value |
|
|
161
|
-
|-----|-------|
|
|
162
|
-
| `NOT_CONNECTED` | `"'Connection'이 연결되어 있지 않습니다."` |
|
|
163
|
-
| `ALREADY_CONNECTED` | `"'Connection'이 이미 연결되어 있습니다."` |
|
|
164
|
-
|
|
165
|
-
## `getDialectFromConfig`
|
|
166
|
-
|
|
167
|
-
`DbConnConfig`에서 정규화된 `Dialect`를 추출한다.
|
|
168
|
-
|
|
169
|
-
```typescript
|
|
170
|
-
function getDialectFromConfig(config: DbConnConfig): Dialect;
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
`"mssql-azure"` → `"mssql"`로 변환하고, 나머지(`"mysql"`, `"mssql"`, `"postgresql"`)는 `config.dialect`를 그대로 반환한다.
|