@lemoncloud/clipbiz-backend-api 0.25.1019

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 ADDED
@@ -0,0 +1,4 @@
1
+ # @lemoncloud/clipbiz-backend-api
2
+
3
+ - 관리용 서비스 API
4
+
@@ -0,0 +1,217 @@
1
+ /**
2
+ * `types.ts`
3
+ * - common types used in `/cores`
4
+ *
5
+ * @author Steve <steve@lemoncloud.io>
6
+ * @date 2022-06-21 optimized w/ `abstract-services`
7
+ * @date 2022-06-28 added `Codable` interface for general types.
8
+ * @date 2023-01-18 optimized with `lemon-core@3.2.4`
9
+ * @date 2023-02-15 optimized with `lemon-core@3.2.5`
10
+ * @date 2024-11-14 optimized `IdentityToken`.
11
+ *
12
+ * @copyright (C) 2022 LemonCloud Co Ltd. - All Rights Reserved.
13
+ * @origin `@lemoncloud/codes-backend-api/cores`
14
+ */
15
+ import { NextIdentity, CoreModel, View, Body } from 'lemon-model';
16
+ export { CoreModel, View, Body };
17
+ /** type: `IdentityTokenSite` */
18
+ export interface IdentityTokenSite {
19
+ /** site-code (ex: kwonsun) */
20
+ code?: string;
21
+ /** name of site (ex: 권선) */
22
+ name?: string;
23
+ }
24
+ /** type: `IdentityTokenUser` */
25
+ export interface IdentityTokenUser {
26
+ /** name of user (ex: 홍길동) */
27
+ name?: string;
28
+ /** nick of user (ex: 홍사마) */
29
+ nick?: string;
30
+ /** (optional) login-id of user */
31
+ login?: string;
32
+ /** (optional) email of user */
33
+ email?: string;
34
+ }
35
+ /** type: `IdentityTokenGroup` */
36
+ export interface IdentityTokenGroup {
37
+ /** site-code (ex: kwonsun) */
38
+ code?: string;
39
+ /** name of site (ex: 권선) */
40
+ name?: string;
41
+ }
42
+ /**
43
+ * type: `IdentityToken` (named as `session`)
44
+ * - 계정토큰(= JWT(IdentityToken))으로, `/refresh`시 AWS Key와 함께 발급됨 (기본, 1일동안 유효함)
45
+ * - `backend-api`에서 조직/그룹/사용자에 맞게 재설정됨!
46
+ * - 세션토큰 검사는 `proxy.getCurrentSession()` 이용하기
47
+ */
48
+ export interface IdentityToken<T = any, U extends IdentityTokenUser = IdentityTokenUser, S extends IdentityTokenSite = IdentityTokenSite, G extends IdentityTokenGroup = IdentityTokenGroup> extends NextIdentity<T> {
49
+ /**
50
+ * site-id (= id in `SiteModel(사이트)`)
51
+ * - `#` 일경우, 특정 site에 엮이지 않음 (무시됨)
52
+ * - `0000` 일경우, 기본 site 정보로 환경설정에 따름
53
+ * - 메인 `backend-api` (see `.iss`)에서 관리되는 `site-model`의 id
54
+ *
55
+ * @see SiteModel
56
+ */
57
+ sid: string;
58
+ /**
59
+ * group-id (= id in `GroupModel(그룹)`)
60
+ * - `group`은 `user`를 물리적 구분으로 나눠서 생각해볼때 이용가능함.
61
+ *
62
+ * @see GroupModel
63
+ */
64
+ gid: string;
65
+ /**
66
+ * user-id (= id in `UserModel(유저)`)
67
+ * - 메인 `backend-api` (see `.iss`)에서 관리되는 `user-model`의 id.
68
+ *
69
+ * @see UserModel
70
+ */
71
+ uid: string;
72
+ /**
73
+ * auth-id (= id in `AuthModel(인정정보)`)
74
+ * - 메인 `backend-api` (see `.iss`)에서 관리되는 `auth-model`의 id.
75
+ * - 인증 정보를 통해서, 로그인의 추가 상세 정보를 알 수 있음.
76
+ *
77
+ * @see AuthModel
78
+ */
79
+ aid: string;
80
+ /**
81
+ * list of roles (like `user`, `admin`, `super`)
82
+ */
83
+ roles: string[];
84
+ /**
85
+ * (optional) internal `identity-id` (= delegated identity)
86
+ * - `.identityId` 는 aws cognito 인증을 통해서, 현재 인증된 `identity-id`를 알 수 있음
87
+ * - 다만, `delegated`된 경우에는 위임된 id 가 들어감.
88
+ *
89
+ * @deprecated 삭제될 예정! @241114
90
+ */
91
+ iid?: string;
92
+ /**
93
+ * service-name of issuer
94
+ * ex) `lemon-backend-api`
95
+ */
96
+ iss?: string;
97
+ /** Site Info */
98
+ Site: S;
99
+ /** User Info */
100
+ User: U;
101
+ /** (optional) Group Info */
102
+ Group?: G;
103
+ }
104
+ /**
105
+ * type `ListResult`
106
+ */
107
+ export interface ListResult<T, R = any> {
108
+ /**
109
+ * total searched count
110
+ */
111
+ total?: number;
112
+ /**
113
+ * max items count in the page
114
+ */
115
+ limit?: number;
116
+ /**
117
+ * current page number.
118
+ */
119
+ page?: number;
120
+ /**
121
+ * (optional) time took in sec
122
+ */
123
+ took?: number;
124
+ /**
125
+ * items searched
126
+ */
127
+ list: T[];
128
+ /**
129
+ * (optional) aggr list
130
+ */
131
+ aggr?: R[];
132
+ }
133
+ export interface AggrKeyCount {
134
+ /** name of key(or bucket name) */
135
+ key: string;
136
+ /** number of count */
137
+ val: number;
138
+ }
139
+ /**
140
+ * type `PaginatedListResult`
141
+ */
142
+ export interface PaginatedListResult<T, R = string> extends ListResult<T, R> {
143
+ /**
144
+ * current page
145
+ */
146
+ page: number;
147
+ }
148
+ /**
149
+ * type `ListParam`
150
+ */
151
+ export interface ListParam {
152
+ /**
153
+ * max items count to be fetched
154
+ */
155
+ limit?: number;
156
+ /**
157
+ * (optional) sorting order
158
+ * - 'asc': older first
159
+ * - 'desc': newer first
160
+ * - string: extended sorting features
161
+ */
162
+ sort?: 'asc' | 'desc' | string;
163
+ }
164
+ /**
165
+ * type `PaginateParam`
166
+ */
167
+ export interface PaginateParam extends ListParam {
168
+ /**
169
+ * page # to fetch (0-indexed)
170
+ */
171
+ page?: number;
172
+ /**
173
+ * (optional) offset # from start.
174
+ */
175
+ offset?: number;
176
+ /**
177
+ * (optional) flag to filter by uid
178
+ */
179
+ uid?: string;
180
+ /**
181
+ * (optional) flag to filter by sid (only for admin role)
182
+ */
183
+ sid?: string;
184
+ }
185
+ /**
186
+ * type `BulkUpdateBody`
187
+ */
188
+ export interface BulkUpdateBody<T> extends BulkBody<T> {
189
+ /**
190
+ * list bulk update model with id
191
+ */
192
+ list: T[];
193
+ }
194
+ /**
195
+ * body data for bulk
196
+ */
197
+ export interface BulkBody<T> {
198
+ list: T[];
199
+ }
200
+ /**
201
+ * list of the selected model-id
202
+ */
203
+ export interface BodyList<T extends {
204
+ id: string;
205
+ } = {
206
+ id: string;
207
+ }> {
208
+ list: T[];
209
+ }
210
+ /**
211
+ * type `BulkItemsResult`
212
+ */
213
+ export interface BulkItemsResult {
214
+ success: number;
215
+ failed: number;
216
+ failedItems: any[];
217
+ }
@@ -0,0 +1,285 @@
1
+ /**
2
+ * `auth/model.ts`
3
+ * - model definitions per account data
4
+ *
5
+ *
6
+ * @author Steve <steve@lemoncloud.io>
7
+ * @date 2022-08-29 initial version.
8
+ *
9
+ * @copyright (C) lemoncloud.io 2023 - All Rights Reserved.
10
+ * @origin `@lemoncloud/codes-backend-api/modules/auth`
11
+ */
12
+ import { CoreModel } from 'lemon-model';
13
+ import $LUT, { AccountStereo, Agreement, Alias, AuthStereo, GenderType, SiteStereo, UseAddressBasic, UserStereo, RoleStereo, InviteStereo } from './types';
14
+ import * as $oauth2 from './oauth2/oauth2-model';
15
+ /**
16
+ * type: `ModelType`
17
+ */
18
+ export declare type ModelType = keyof typeof $LUT.ModelType;
19
+ /**
20
+ * type: `Model`: common model
21
+ */
22
+ export declare type Model = CoreModel<ModelType>;
23
+ /**
24
+ * type: boolean style number.
25
+ */
26
+ export declare type BoolFlag = 0 | 1;
27
+ /**
28
+ * head of `account-model`
29
+ */
30
+ export interface AccountHead {
31
+ /** id of account */
32
+ id?: string;
33
+ /** name of account */
34
+ name?: string;
35
+ /** stereo of account */
36
+ stereo?: AccountStereo;
37
+ /** open-id */
38
+ openId?: string;
39
+ }
40
+ /**
41
+ * type: `AccountModel`
42
+ * - 가입(또는 인증/무인증) 처리된 회원 정보를 담음.
43
+ */
44
+ export interface AccountModel extends AccountHead, $oauth2.AccountModel<ModelType, AccountStereo> {
45
+ /** := identity-id */
46
+ id?: string;
47
+ /** flag of push notices */
48
+ isPushNotice?: number;
49
+ /** flag of push communities */
50
+ isPushCommunity?: number;
51
+ /** flag of push marketing */
52
+ isPushMarketing?: number;
53
+ }
54
+ /**
55
+ * 호스트(도메인) 모델
56
+ * - 호스트(도메인)으로부터 라우팅되는 타셋 사이트를 찾기 위함.
57
+ * - 라우트:사이트 = N:1 ()
58
+ */
59
+ export interface HostModel extends $oauth2.HostModel<ModelType> {
60
+ /** target host (or domain) */
61
+ id?: string;
62
+ }
63
+ /**
64
+ * head of `site-model`
65
+ */
66
+ export interface SiteHead {
67
+ /** id of site */
68
+ id?: string;
69
+ /** name of site */
70
+ name?: string;
71
+ }
72
+ /**
73
+ * 그룹 모델
74
+ * - CRUD (추가 생성) 가능한 모델임
75
+ */
76
+ export interface GroupModel extends $oauth2.GroupModel<ModelType> {
77
+ /** user-id (auto-seq) */
78
+ id?: string;
79
+ }
80
+ /**
81
+ * type: `SiteModel`
82
+ * - represent of site
83
+ */
84
+ export interface SiteModel<S extends string = SiteStereo> extends SiteHead, $oauth2.SiteModel<ModelType, S> {
85
+ /** id of site */
86
+ id?: string;
87
+ /** stereo of site */
88
+ stereo?: S;
89
+ /**
90
+ * flag of legacy system
91
+ */
92
+ legacy?: number;
93
+ /**
94
+ * (optional) extended alias infor if stereo == '#alias'
95
+ */
96
+ alias$?: Alias;
97
+ /** owner's user-id */
98
+ ownerId?: string;
99
+ /** (partial) owner-info */
100
+ owner$?: UserHead;
101
+ }
102
+ /**
103
+ * 역할 관리
104
+ * - 각 `User`와 `Site`별 설정된 권한/그룹 정보를 가짐
105
+ * - `*` 는 전체 사이트를 의미
106
+ */
107
+ export interface RoleModel<S extends string = RoleStereo> extends $oauth2.RoleModel<ModelType, S> {
108
+ /**
109
+ * role-name (must be lower-cased alphabets)
110
+ * or
111
+ * role-id := <userId>@<siteId>
112
+ */
113
+ id?: string;
114
+ /** stereo type of role */
115
+ stereo?: S;
116
+ /** (internal) linked user */
117
+ readonly $user?: UserModel;
118
+ }
119
+ /**
120
+ * head of `user-model`
121
+ */
122
+ export interface UserHead {
123
+ /** id of user */
124
+ id?: string;
125
+ /** name of user */
126
+ name?: string;
127
+ }
128
+ /**
129
+ * type: `UserModel`
130
+ * - represent of user login
131
+ */
132
+ export interface UserModel<S extends string = UserStereo> extends UserHead, $oauth2.UserModel<ModelType, S> {
133
+ /** stereo type of user */
134
+ stereo?: S;
135
+ /** user code (= encode(id)) */
136
+ code?: string;
137
+ /** name of model */
138
+ name?: string;
139
+ /** nick of model */
140
+ nick?: string;
141
+ /** (optional) photo of user */
142
+ photo?: string;
143
+ /** (optional) user phone */
144
+ phone?: string;
145
+ /** (optional) user infor text content. */
146
+ text?: string;
147
+ /** (optional) user gender */
148
+ gender?: GenderType;
149
+ /** (optional) birth of user */
150
+ birth?: string;
151
+ /** (optional) address of user */
152
+ address?: UseAddressBasic;
153
+ /** (optional) email of model */
154
+ email?: string;
155
+ /** (optional) the alias-id linked (valid only if stereo is alias) */
156
+ aliasId?: string;
157
+ /** (optional) the type of alias (default 'login') */
158
+ aliasType?: string;
159
+ /** (optional) the site-id (as default login) */
160
+ siteId?: string;
161
+ /** (partial) site-info of default */
162
+ site$?: SiteHead;
163
+ /** (optional) the login-id */
164
+ loginType?: string;
165
+ /** (optional) the login-id */
166
+ loginId?: string;
167
+ /** (optional) the login-pw (encoded) */
168
+ loginPw?: string;
169
+ /** (optional) the final iid from IAM */
170
+ identityId?: string;
171
+ /** (optional) the last auth-id */
172
+ lastAuthId?: string;
173
+ /**
174
+ * (optional) agreement detail in timestamp.
175
+ */
176
+ agree$?: Agreement;
177
+ /**
178
+ * (optional) extended alias infor if stereo == '#alias'
179
+ */
180
+ alias$?: Alias;
181
+ /** (internal) account linked */
182
+ readonly $account?: AccountModel;
183
+ }
184
+ /**
185
+ * head of `auth-model`
186
+ */
187
+ export interface AuthHead {
188
+ /** id of auth */
189
+ id?: string;
190
+ /** name of auth */
191
+ name?: string;
192
+ }
193
+ /**
194
+ * type: `AuthModel`
195
+ * - authorized token information.
196
+ */
197
+ export interface AuthModel extends AuthHead, $oauth2.AuthModel<ModelType, AuthStereo> {
198
+ /** uuid */
199
+ id?: string;
200
+ /** (optional) for internal */
201
+ name?: string;
202
+ /**
203
+ * stereo: same as provider.stereo.
204
+ */
205
+ stereo?: AuthStereo;
206
+ }
207
+ /**
208
+ * head of `invite-model`
209
+ */
210
+ export interface InviteHead {
211
+ /** id of invite */
212
+ id?: string;
213
+ /** name of invite */
214
+ name?: string;
215
+ }
216
+ /**
217
+ * type: `InviteModel`
218
+ * - inviteorized token information.
219
+ */
220
+ export interface InviteModel extends InviteHead, $oauth2.InviteModel<ModelType, InviteStereo> {
221
+ /**
222
+ * stereo-type
223
+ */
224
+ stereo?: InviteStereo;
225
+ /** code to verify (:= uuid) */
226
+ code?: string;
227
+ /** auth-id requested */
228
+ authId?: string;
229
+ /** auth-info requested */
230
+ auth$?: AuthHead;
231
+ /** user-id to invite */
232
+ userId?: string;
233
+ /** user-info to invite */
234
+ user$?: UserHead;
235
+ /** site-id requested */
236
+ siteId?: string;
237
+ /** site-info requested */
238
+ site$?: SiteHead;
239
+ /** (optional) location to open in browser */
240
+ readonly Location?: string;
241
+ }
242
+ /**
243
+ * extract field names from models
244
+ * - only fields start with lowercase, or all upper.
245
+ */
246
+ export declare const filterFields: (fields: string[], base?: string[]) => string[];
247
+ /** field names from head */
248
+ export declare const $HEAD: {
249
+ account: string[];
250
+ site: string[];
251
+ user: string[];
252
+ auth: string[];
253
+ invite: string[];
254
+ };
255
+ export declare const $FIELD: {
256
+ account: string[];
257
+ host: string[];
258
+ site: string[];
259
+ user: string[];
260
+ role: string[];
261
+ group: string[];
262
+ auth: string[];
263
+ invite: string[];
264
+ };
265
+ /** must export default as below */
266
+ declare const _default: {
267
+ $HEAD: {
268
+ account: string[];
269
+ site: string[];
270
+ user: string[];
271
+ auth: string[];
272
+ invite: string[];
273
+ };
274
+ $FIELD: {
275
+ account: string[];
276
+ host: string[];
277
+ site: string[];
278
+ user: string[];
279
+ role: string[];
280
+ group: string[];
281
+ auth: string[];
282
+ invite: string[];
283
+ };
284
+ };
285
+ export default _default;