@deplois/api 0.0.1 → 0.0.3
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.md +44 -0
- package/dist/database/user.entity.d.ts +3 -3
- package/dist/identity/interface.d.ts +8 -6
- package/package.json +27 -9
package/README.md
CHANGED
|
@@ -175,3 +175,47 @@ npm run publish -- 1.2.3 "릴리스 내용" --deploy
|
|
|
175
175
|
`fetch`는 세 번째 버전을 1 올립니다. minor/major를 올리면 하위 버전은 0으로 초기화합니다. 테스트·빌드 후 버전을 변경하고 변경 파일 전체를 commit → push → npmjs 공개 배포합니다. `--deploy`를 빼면 commit·push까지만 진행합니다. `npm run deploy`는 현재 버전을 테스트·빌드해서 npm에만 배포합니다.
|
|
176
176
|
|
|
177
177
|
각 패키지 폴더에 별도 Git 저장소와 origin이 설정되어 있어야 합니다. 상위 저장소를 대신 commit하지 않습니다. npm 배포 시에는 npmjs 로그인 및 배포 권한이 필요합니다. 스크립트 자체는 template과 동일하게 Git 및 npm 패키지에서 제외하는 로컬 파일입니다.
|
|
178
|
+
|
|
179
|
+
### 서비스별 사용자 필드
|
|
180
|
+
|
|
181
|
+
`profile`은 기본 항목 외에도 서비스별 키, 배열, 중첩 객체를 받습니다. 기본 항목은 선택 사항이며 `null`도 저장할 수 있습니다. 추가 키는 `userPlugin.create`, `get`, `update`와 JSONB 저장에서 유지됩니다. 수정할 때 생략한 키는 유지하고 `undefined`로 전달한 키만 삭제합니다.
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
await userPlugin.create({
|
|
185
|
+
profile: {
|
|
186
|
+
fullName: '민재', nickname: 'minjae',
|
|
187
|
+
preferences: { language: 'ko' }
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
프로젝트 전체에서 추가 필드의 타입을 정하려면 공개 `UserProfile` 인터페이스를 확장합니다.
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
import '@deplois/api'
|
|
196
|
+
|
|
197
|
+
declare module '@deplois/api' {
|
|
198
|
+
interface UserProfile {
|
|
199
|
+
nickname?: string
|
|
200
|
+
preferences?: { language?: string }
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
프로필 타입을 지정하거나 별도 DB 컬럼/관계가 필요하면 공통 Entity를 상속합니다.
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
import { Column, Entity } from 'typeorm'
|
|
209
|
+
import { UserEntity } from '@deplois/api/database'
|
|
210
|
+
import type { UserProfile } from '@deplois/api'
|
|
211
|
+
|
|
212
|
+
@Entity('user')
|
|
213
|
+
export class User extends UserEntity<UserProfile & { nickname?: string }> {
|
|
214
|
+
@Column({ name: 'customer_number', type: 'varchar', nullable: true })
|
|
215
|
+
customerNumber: string | null
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
DataSource에는 앱의 `User`를 등록하고 해당 Repository로 추가 컬럼을 저장합니다. 기본 `TypeORMIdentityStore`와 `SessionEntity`는 기본 `UserEntity`를 대상으로 하므로, 커스텀 테이블에는 앱의 관계 Entity와 `IdentityStore`도 같은 대상을 사용해야 합니다. 공통 `userPlugin.create/update`는 `profile`, `metadata`만 입력받으며 임의 입력으로 ID나 활성 상태를 덮어쓰지 않습니다.
|
|
220
|
+
|
|
221
|
+
기본 `/session/users`는 공개용 기본 프로필 항목만 응답합니다. 추가 필드 공개 여부는 앱 컨트롤러에서 정합니다. 새로운 DB 컬럼은 앱의 migration으로 추가하세요.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare class UserEntity {
|
|
1
|
+
import type { UserProfile } from '../identity/interface';
|
|
2
|
+
export declare class UserEntity<Profile extends UserProfile = UserProfile> {
|
|
3
3
|
readonly id: string;
|
|
4
|
-
profile:
|
|
4
|
+
profile: Profile;
|
|
5
5
|
metadata: Record<string, unknown>;
|
|
6
6
|
isActive: boolean;
|
|
7
7
|
readonly createdDate: Date;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
export interface UserProfile {
|
|
2
|
+
fullName?: string | null;
|
|
3
|
+
emailAddress?: string | null;
|
|
4
|
+
phoneNumber?: string | null;
|
|
5
|
+
imageUrl?: string | null;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
1
8
|
export interface User {
|
|
2
9
|
id: string;
|
|
3
|
-
profile:
|
|
4
|
-
fullName?: string;
|
|
5
|
-
emailAddress?: string;
|
|
6
|
-
phoneNumber?: string;
|
|
7
|
-
imageUrl?: string;
|
|
8
|
-
};
|
|
10
|
+
profile: UserProfile;
|
|
9
11
|
metadata: Record<string, unknown>;
|
|
10
12
|
isActive: boolean;
|
|
11
13
|
createdDate: Date;
|
package/package.json
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deplois/api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Shared NestJS API infrastructure for deplois",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./database": {
|
|
14
|
+
"types": "./dist/database/index.d.ts",
|
|
15
|
+
"default": "./dist/database/index.js"
|
|
16
|
+
}
|
|
11
17
|
},
|
|
12
|
-
"files": [
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
13
22
|
"scripts": {
|
|
14
23
|
"build": "tsc -p tsconfig.json",
|
|
15
24
|
"check": "tsc -p tsconfig.json --noEmit",
|
|
@@ -18,17 +27,23 @@
|
|
|
18
27
|
"publish": "node scripts/publish.mjs",
|
|
19
28
|
"deploy": "node scripts/publish.mjs"
|
|
20
29
|
},
|
|
21
|
-
"engines": {
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=22"
|
|
32
|
+
},
|
|
22
33
|
"peerDependencies": {
|
|
23
|
-
"@nestjs/common": "^11.0.0",
|
|
24
|
-
"@nestjs/core": "^11.0.0",
|
|
34
|
+
"@nestjs/common": "^11.0.0 || ^12.0.0",
|
|
35
|
+
"@nestjs/core": "^11.0.0 || ^12.0.0",
|
|
25
36
|
"class-transformer": "^0.5.1",
|
|
26
37
|
"class-validator": "^0.15.0",
|
|
27
38
|
"reflect-metadata": "^0.2.2",
|
|
28
39
|
"rxjs": "^7.8.1",
|
|
29
40
|
"typeorm": "^1.1.0"
|
|
30
41
|
},
|
|
31
|
-
"peerDependenciesMeta": {
|
|
42
|
+
"peerDependenciesMeta": {
|
|
43
|
+
"typeorm": {
|
|
44
|
+
"optional": true
|
|
45
|
+
}
|
|
46
|
+
},
|
|
32
47
|
"devDependencies": {
|
|
33
48
|
"@nestjs/common": "^11.0.1",
|
|
34
49
|
"@nestjs/core": "^11.0.1",
|
|
@@ -42,6 +57,9 @@
|
|
|
42
57
|
"typeorm": "^1.1.0",
|
|
43
58
|
"typescript": "^5.7.3"
|
|
44
59
|
},
|
|
45
|
-
"publishConfig": {
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public",
|
|
62
|
+
"registry": "https://registry.npmjs.org/"
|
|
63
|
+
},
|
|
46
64
|
"license": "UNLICENSED"
|
|
47
65
|
}
|