@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.
@@ -0,0 +1,318 @@
1
+ /**
2
+ * `auth/types.ts`
3
+ * - 기본 types used in `backed-proxy`
4
+ *
5
+ * **[중요! exports 순서]**
6
+ * 1. define data type in `types.ts` w/ internal types.
7
+ * 2. define Model in `model.ts`
8
+ * 3. define View/Body in `view.ts`, and external types.
9
+ *
10
+ * @author Steve <steve@lemoncloud.io>
11
+ * @date 2022-08-29 initial version.
12
+ *
13
+ * @copyright (C) lemoncloud.io 2023 - All Rights Reserved.
14
+ * @origin `@lemoncloud/codes-backend-api/modules/auth`
15
+ */
16
+ import { OAuthAPITokenResult } from './oauth2/oauth2-types';
17
+ import { AuthModel, RoleModel, SiteModel, UserModel } from './model';
18
+ /**
19
+ * Lookup Table
20
+ *
21
+ * WARN! DO NOT EXPORT AS `$LUT`. use default export instead.
22
+ */
23
+ declare const $LUT: {
24
+ /**
25
+ * Possible type of model.
26
+ */
27
+ ModelType: {
28
+ /** host model */
29
+ host: string;
30
+ /** site model */
31
+ site: string;
32
+ /** account model */
33
+ account: string;
34
+ /** user model */
35
+ user: string;
36
+ /** group model */
37
+ group: string;
38
+ /** role model */
39
+ role: string;
40
+ /** auth model */
41
+ auth: string;
42
+ /** invite model */
43
+ invite: string;
44
+ };
45
+ /**
46
+ * HostStereo.
47
+ */
48
+ HostStereo: {
49
+ '': string;
50
+ '#alias': string;
51
+ };
52
+ /**
53
+ * SiteStereo.
54
+ */
55
+ SiteStereo: {
56
+ /** created per user automatically */
57
+ mine: string;
58
+ /** created for `workspace` manually */
59
+ work: string;
60
+ '': string;
61
+ '#alias': string;
62
+ domain: string;
63
+ session: string;
64
+ };
65
+ /**
66
+ * AccountStereo.
67
+ */
68
+ AccountStereo: {
69
+ business: string;
70
+ code: string;
71
+ '': string;
72
+ '#alias': string;
73
+ iid: string;
74
+ login: string;
75
+ phone: string; /**
76
+ * SiteStereo.
77
+ */
78
+ email: string;
79
+ social: string;
80
+ session: string;
81
+ };
82
+ /**
83
+ * UserStereo.
84
+ */
85
+ UserStereo: {
86
+ '': string;
87
+ /** (internal) alias by code */
88
+ '#code': string;
89
+ /** admin user */
90
+ admin: string;
91
+ /** normal user */
92
+ user: string;
93
+ /** dummy user */
94
+ dummy: string;
95
+ '#alias': string;
96
+ session: string;
97
+ };
98
+ /**
99
+ * UserRole
100
+ */
101
+ UserRole: {
102
+ '': string;
103
+ /** self user */
104
+ self: string;
105
+ /** Guest user */
106
+ guest: string;
107
+ /** normal user */
108
+ user: string;
109
+ /** owner */
110
+ owner: string;
111
+ /** member */
112
+ member: string;
113
+ /** session: authed by session remotely */
114
+ session: string;
115
+ /** admin user (normal) */
116
+ admin: string;
117
+ };
118
+ /**
119
+ * GroupStereo.
120
+ */
121
+ GroupStereo: {
122
+ '': string;
123
+ '#alias': string;
124
+ };
125
+ /**
126
+ * RoleStereo.
127
+ */
128
+ RoleStereo: {
129
+ /** owner */
130
+ owner: string;
131
+ /** member */
132
+ member: string;
133
+ '': string;
134
+ '#alias': string;
135
+ };
136
+ /**
137
+ * AuthStereo.
138
+ */
139
+ AuthStereo: {
140
+ '#': string;
141
+ '': string;
142
+ '#alias': string; /** member */
143
+ session: string; /** admin user (normal) */
144
+ phone: string;
145
+ email: string;
146
+ };
147
+ /**
148
+ * InviteStereo
149
+ */
150
+ InviteStereo: {
151
+ /** empty */
152
+ '': string;
153
+ /** (internal) alias type */
154
+ '#alias': string;
155
+ };
156
+ /**
157
+ * GenderType
158
+ */
159
+ GenderType: {
160
+ '': string;
161
+ male: string;
162
+ female: string;
163
+ };
164
+ };
165
+ /**
166
+ * type: `HostStereo`
167
+ */
168
+ export declare type HostStereo = keyof typeof $LUT.HostStereo;
169
+ /**
170
+ * type: `SiteStereo`
171
+ */
172
+ export declare type SiteStereo = keyof typeof $LUT.SiteStereo;
173
+ /**
174
+ * type: `AccountStereo`
175
+ */
176
+ export declare type AccountStereo = keyof typeof $LUT.AccountStereo;
177
+ /**
178
+ * type: `UserStereo`
179
+ */
180
+ export declare type UserStereo = keyof typeof $LUT.UserStereo;
181
+ /**
182
+ * type: `UserRole`
183
+ */
184
+ export declare type UserRole = keyof typeof $LUT.UserRole;
185
+ /**
186
+ * type: `GroupStereo`
187
+ */
188
+ export declare type GroupStereo = keyof typeof $LUT.GroupStereo;
189
+ /**
190
+ * type: `RoleStereo`
191
+ */
192
+ export declare type RoleStereo = keyof typeof $LUT.RoleStereo;
193
+ /**
194
+ * type: `AuthStereo`
195
+ */
196
+ export declare type AuthStereo = keyof typeof $LUT.AuthStereo;
197
+ /**
198
+ * type: `InviteStereo`
199
+ */
200
+ export declare type InviteStereo = keyof typeof $LUT.InviteStereo;
201
+ /**
202
+ * type: `GenderType`
203
+ */
204
+ export declare type GenderType = keyof typeof $LUT.GenderType;
205
+ /**
206
+ * general form of agreement.
207
+ */
208
+ export interface Agreement {
209
+ /** 서비스 이용 약관 */
210
+ service?: number;
211
+ /** 개인정보 처리방침 */
212
+ privacy?: number;
213
+ /** 개인정보 제3자 제공 동의 */
214
+ privacy3rd?: number;
215
+ /**
216
+ * save timestamp of agreed
217
+ */
218
+ [key: string]: number;
219
+ }
220
+ /**
221
+ * extended alias infor
222
+ */
223
+ export interface Alias {
224
+ /**
225
+ * type of alias
226
+ */
227
+ type?: string;
228
+ /**
229
+ * alias value
230
+ * - can be different by `type`
231
+ */
232
+ alias?: string;
233
+ }
234
+ /**
235
+ * common jwt properties
236
+ */
237
+ export interface JwtCommon {
238
+ /**
239
+ * expired at (sec)
240
+ */
241
+ exp?: number;
242
+ /**
243
+ * issued at (sec)
244
+ * = Math.floor(current_ms / 1000)
245
+ */
246
+ iat?: number;
247
+ /**
248
+ * issuer name.
249
+ */
250
+ iss?: string;
251
+ }
252
+ /**
253
+ * 주소입력 지원
254
+ */
255
+ export interface UseAddressBasic {
256
+ /** 주소(우편번호) */
257
+ addrPost?: string;
258
+ /** 주소(거리=우편번호매칭) */
259
+ addrStreet?: string;
260
+ /** 주소(상세) */
261
+ addrDetail?: string;
262
+ /** 주소(추가) */
263
+ addrExtra?: string;
264
+ }
265
+ /**
266
+ * type: `UserTokenModel`
267
+ * - user model with final Token and information.
268
+ * - 내부 로직에서 쓰이는 모델로, 사용자에게는 `UserTokenView`로 전달됨
269
+ *
270
+ * @see UserTransformer.asUserTokenView()
271
+ */
272
+ export interface UserTokenModel extends UserModel {
273
+ /**
274
+ * token result.
275
+ */
276
+ readonly $token: OAuthAPITokenResult<undefined, undefined>;
277
+ /** (optional) site linked */
278
+ readonly $site?: SiteModel;
279
+ /** (optional) auth linked */
280
+ readonly $auth?: AuthModel;
281
+ /** (optional) role linked */
282
+ readonly $role?: RoleModel;
283
+ }
284
+ /**
285
+ * contain id + text
286
+ */
287
+ export interface TextPair {
288
+ /** id of text (see text-model) */
289
+ id: string;
290
+ /** text in string */
291
+ text: string;
292
+ }
293
+ /**
294
+ * type: `UserAliasUpdateBody`
295
+ * - 로그인 계정 수정을 위한 Request Body
296
+ */
297
+ export interface UserAliasUpdateBody {
298
+ /** type of alias */
299
+ type: AccountStereo;
300
+ /** alias before the change */
301
+ alias1: string;
302
+ /** alias after change */
303
+ alias2: string;
304
+ }
305
+ /**
306
+ * params of `/invite`
307
+ * - 사용자 초대하기 (email or userId)
308
+ */
309
+ export interface UserInviteParams {
310
+ /** email address */
311
+ email?: string;
312
+ /** or user-id to invite */
313
+ userId?: string;
314
+ /** role to assign */
315
+ role?: 'guest' | 'member';
316
+ }
317
+ /** must export $LUT as default */
318
+ export default $LUT;
@@ -0,0 +1,266 @@
1
+ /**
2
+ * `auth/views.ts`
3
+ * - types used in `backed-proxy`
4
+ *
5
+ * @author Steve <steve@lemoncloud.io>
6
+ * @date 2022-08-29 initial version.
7
+ *
8
+ * @copyright (C) lemoncloud.io 2023 - All Rights Reserved.
9
+ * @origin `@lemoncloud/codes-backend-api/modules/auth`
10
+ */
11
+ import { View, Body } from 'lemon-model';
12
+ import { AccountModel, AuthModel, GroupModel, HostModel, InviteModel, RoleModel, SiteModel, UserModel } from './model';
13
+ import { OAuthAPITokenResult, OAuthLoginUserBody, OAuthLoginUserParam } from './oauth2/oauth2-types';
14
+ import { IdentityToken } from '../../cores/types';
15
+ import $LUT, { Agreement } from './types';
16
+ export * from './types';
17
+ export default $LUT;
18
+ /**
19
+ * type: `SiteView`
20
+ * - usually same as post's body.
21
+ */
22
+ export interface SiteView extends View, Omit<Partial<SiteModel>, 'id' | 'legacy' | 'isPublic' | 'owner$'> {
23
+ /**
24
+ * unique id of this type
25
+ */
26
+ id: string;
27
+ /** flag of legacy site */
28
+ legacy?: boolean;
29
+ /** flag if domain is in public */
30
+ isPublic?: boolean;
31
+ /** (optional) owner info */
32
+ readonly owner$?: UserView;
33
+ }
34
+ /**
35
+ * Type `SiteBody`
36
+ */
37
+ export interface SiteBody extends Body, Partial<SiteView> {
38
+ }
39
+ /** type: `AccountView` */
40
+ export interface AccountView extends View, Omit<Partial<AccountModel>, 'id' | 'isPushNotice' | 'isPushCommunity' | 'isPushMarketing'> {
41
+ id?: string;
42
+ isPushNotice?: boolean;
43
+ isPushCommunity?: boolean;
44
+ isPushMarketing?: boolean;
45
+ }
46
+ /**
47
+ * Type `AccountBody`
48
+ */
49
+ export interface AccountBody extends Body, Partial<AccountView> {
50
+ }
51
+ /**
52
+ * type: `UserView`
53
+ * - usually same as post's body.
54
+ */
55
+ export interface UserView extends View, Omit<Partial<UserModel>, 'id' | '$account'> {
56
+ /**
57
+ * unique id of this type
58
+ */
59
+ id: string;
60
+ /** (optional) account linked */
61
+ readonly $account?: AccountView;
62
+ }
63
+ /**
64
+ * Type `UserBody`
65
+ */
66
+ export interface UserBody extends Body, Partial<UserView> {
67
+ }
68
+ /** type: `HostView` */
69
+ export interface HostView extends View, Omit<Partial<HostModel>, 'id'> {
70
+ /**
71
+ * unique id of this type
72
+ */
73
+ id: string;
74
+ }
75
+ /** Type `HostBody` */
76
+ export interface HostBody extends Body, Partial<HostView> {
77
+ }
78
+ /** type: `GroupView` */
79
+ export interface GroupView extends View, Omit<Partial<GroupModel>, 'id'> {
80
+ /**
81
+ * auto-seq id of this model.
82
+ */
83
+ id: string;
84
+ }
85
+ /** Type `GroupBody` */
86
+ export interface GroupBody extends Body, Partial<GroupView> {
87
+ }
88
+ /** type: `RoleView` */
89
+ export interface RoleView extends View, Omit<Partial<RoleModel>, 'id' | '$user'> {
90
+ /**
91
+ * auto-seq id of this model.
92
+ */
93
+ id: string;
94
+ /** (optional) linked user */
95
+ readonly $user?: UserView;
96
+ }
97
+ /** Type `RoleBody` */
98
+ export interface RoleBody extends Body, Partial<RoleView> {
99
+ }
100
+ /** type: `AuthView` */
101
+ export interface AuthView extends View, Omit<Partial<AuthModel>, 'id'> {
102
+ /**
103
+ * auto-seq id of this model.
104
+ */
105
+ id: string;
106
+ }
107
+ /** Type `AuthBody` */
108
+ export interface AuthBody extends Body, Partial<AuthView> {
109
+ }
110
+ /** type: `InviteView` */
111
+ export interface InviteView extends View, Omit<Partial<InviteModel>, 'id'> {
112
+ /**
113
+ * auto-seq id of this model.
114
+ */
115
+ id: string;
116
+ }
117
+ /** Type `InviteBody` */
118
+ export interface InviteBody extends Body, Partial<InviteView> {
119
+ }
120
+ /**
121
+ * param of `/login-user`.
122
+ */
123
+ export interface LoginUserParam extends OAuthLoginUserParam {
124
+ /**
125
+ * flag to issue token (default 1)
126
+ */
127
+ token: any;
128
+ }
129
+ /**
130
+ * body of `/login-user`.
131
+ */
132
+ export interface LoginUserBody extends OAuthLoginUserBody {
133
+ /**
134
+ * user-id to login
135
+ */
136
+ uid: string;
137
+ }
138
+ export interface RegisterEmailUserBody extends Body {
139
+ /**
140
+ * email address
141
+ */
142
+ email: string;
143
+ /**
144
+ * (optional) check if email is verified
145
+ */
146
+ emailVerified?: boolean;
147
+ /**
148
+ * name
149
+ */
150
+ name: string;
151
+ /**
152
+ * access password-1
153
+ */
154
+ password1: string;
155
+ /**
156
+ * access password-2
157
+ */
158
+ password2: string;
159
+ /** agreeds */
160
+ agree$: Agreement;
161
+ /** (optional) 추천인 ID */
162
+ referrerId?: string;
163
+ /**
164
+ * phone verified.
165
+ * - 연결할 전화번호 (나중에 이걸로 로그인 가능함)
166
+ */
167
+ phone?: string;
168
+ }
169
+ /**
170
+ * detailed user-info
171
+ */
172
+ export interface UserInfo$ {
173
+ /**
174
+ * the final identity-id in linked.
175
+ *
176
+ * @see AccountModel.delegatedId
177
+ */
178
+ iid: string;
179
+ /**
180
+ * the current account-model along with `context.identity`
181
+ *
182
+ * @see AccountView
183
+ */
184
+ $account: AccountView;
185
+ }
186
+ /**
187
+ * user-profile
188
+ */
189
+ export interface UserProfile$<T = any> {
190
+ /** site-id */
191
+ sid: string;
192
+ /** group-id */
193
+ gid: string;
194
+ /** user-id */
195
+ uid: string;
196
+ /** roles */
197
+ roles: string[];
198
+ /** the current(or delegated) identity-id */
199
+ identityId: string;
200
+ /** site in detail */
201
+ $site: SiteView;
202
+ /** user in detail */
203
+ $user: UserView;
204
+ /** user in detail */
205
+ $role: RoleView;
206
+ /** auth in detail */
207
+ $auth: AuthView;
208
+ /** (optional) the detailed user-info */
209
+ $info?: UserInfo$;
210
+ /** (optional) the detailed user-info */
211
+ $token?: T;
212
+ }
213
+ /**
214
+ * type: `UserTokenView`
215
+ * - result view of user with token
216
+ */
217
+ export interface UserTokenView extends UserView {
218
+ /**
219
+ * token result.
220
+ */
221
+ readonly Token: OAuthAPITokenResult<SiteView, UserView>;
222
+ /** (optional) site linked */
223
+ readonly $site?: SiteView;
224
+ /** (optional) auth linked */
225
+ readonly $auth?: AuthView;
226
+ /** (optional) role linked */
227
+ readonly $role?: RoleView;
228
+ }
229
+ /**
230
+ * type: `UserDuplicateCheckResult`
231
+ * - result view of exist user with alias
232
+ */
233
+ export interface UserDuplicateCheckResult {
234
+ /** 로그인 ID (input) */
235
+ loginId: string;
236
+ /** 유저등록여부 */
237
+ hasUser: boolean;
238
+ /** (optinal) 업체 ID */
239
+ siteId?: string;
240
+ }
241
+ /**
242
+ * type: `MyUserSiteLink`
243
+ * - 회사 가입 요청 정보를 담음
244
+ */
245
+ export interface MyUserSiteLinkElement$ {
246
+ /** 승인 요청 시각 */
247
+ requestedAt?: number;
248
+ /** 가입 승인 시각 */
249
+ allowedAt?: number;
250
+ /** 가입 거절 시각 */
251
+ rejectedAt?: number;
252
+ /** 탈퇴 시각 */
253
+ leavedAt?: number;
254
+ }
255
+ /**
256
+ * type: `UserDelegateBody`
257
+ * - body of `/users/0/delegate`
258
+ */
259
+ export interface UserDelegateBody<T = any> {
260
+ /**
261
+ * session(identity-token) to delegate
262
+ *
263
+ * - (default) use `x-lemon-identity` if not defined.
264
+ */
265
+ $token?: IdentityToken<T>;
266
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * `model.ts`
3
+ * - model definitions per account data
4
+ *
5
+ * @author Steve <steve@lemoncloud.io>
6
+ * @date 2022-08-29 initial version.
7
+ *
8
+ * Copyright (C) 2020 LemonCloud Co Ltd. - All Rights Reserved.
9
+ */
10
+ import { CoreModel, NextIdentityAccess, SimpleSet } from 'lemon-model';
11
+ import $LUT from './types';
12
+ /**
13
+ * type: `ModelType`
14
+ */
15
+ export declare type ModelType = keyof typeof $LUT.ModelType;
16
+ /**
17
+ * type: `Model`: common model
18
+ */
19
+ export declare type Model = CoreModel<ModelType>;
20
+ /**
21
+ * type: `MockHead`
22
+ * - common head of mock-model.
23
+ */
24
+ export interface MockHead {
25
+ /** id of mock */
26
+ id?: string;
27
+ /** name of mock */
28
+ name?: string;
29
+ }
30
+ /**
31
+ * `mock`: internal mock model.
32
+ * - provice mocks data
33
+ */
34
+ export interface MockModel<T = string> extends MockHead, Model {
35
+ /** name of this model */
36
+ name?: string;
37
+ /** alias-id when stereo='#alias' */
38
+ aliasId?: string;
39
+ /** json encoding all data */
40
+ meta?: T;
41
+ }
42
+ export interface MockModelExt<T = string> extends MockModel<T> {
43
+ /** extended data with any type */
44
+ [key: string]: any;
45
+ }
46
+ /**
47
+ * type: `TestHead`
48
+ * - common head of test-model.
49
+ */
50
+ export interface TestHead {
51
+ /** internal reference */
52
+ _idx?: number;
53
+ /** internal date(YYYY-MM-DD) */
54
+ _date?: string;
55
+ }
56
+ /**
57
+ * `test`: internal test model.
58
+ */
59
+ export interface TestModel extends Model, TestHead {
60
+ /** name of model */
61
+ name?: string;
62
+ /** test count */
63
+ count?: number;
64
+ /** (optional) extra */
65
+ extra?: SimpleSet;
66
+ /**
67
+ * inner Object.
68
+ */
69
+ readonly Model?: Model;
70
+ /**
71
+ * (view) Access Infor.
72
+ */
73
+ readonly $identity?: NextIdentityAccess;
74
+ }
75
+ /**
76
+ * extract field names from models
77
+ * - only fields start with lowercase, or all upper.
78
+ */
79
+ export declare const filterFields: (fields: string[], base?: string[]) => string[];
80
+ /** field names from head */
81
+ export declare const $HEAD: {
82
+ mock: string[];
83
+ test: string[];
84
+ };
85
+ export declare const $FIELD: {
86
+ mock: string[];
87
+ test: string[];
88
+ };
89
+ /** must export default as below */
90
+ declare const _default: {
91
+ $HEAD: {
92
+ mock: string[];
93
+ test: string[];
94
+ };
95
+ $FIELD: {
96
+ mock: string[];
97
+ test: string[];
98
+ };
99
+ };
100
+ export default _default;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * `types.ts`
3
+ * - 기본 types used in `backend-proxy`
4
+ *
5
+ * **[중요! exports 순서]**
6
+ * 1. define data type in `types.ts` w/ internal types.
7
+ * 2. define Model in `model.ts`
8
+ * 3. define View/Body in `view.ts`, and external types.
9
+ *
10
+ * @author Steve <steve@lemoncloud.io>
11
+ * @date 2022-08-29 initial version.
12
+ *
13
+ * Copyright (C) 2022 LemonCloud Co Ltd. - All Rights Reserved.
14
+ */
15
+ /**
16
+ * Lookup Table
17
+ *
18
+ * WARN! DO NOT EXPORT AS `$LUT`. use default export instead.
19
+ */
20
+ declare const $LUT: {
21
+ /**
22
+ * Possible type of model.
23
+ */
24
+ ModelType: {
25
+ /** mock model */
26
+ mock: string;
27
+ /** test model */
28
+ test: string;
29
+ };
30
+ /** type: MockStereo */
31
+ MockStereo: {
32
+ '': string;
33
+ '#': string;
34
+ '#alias': string;
35
+ };
36
+ };
37
+ /**
38
+ * type: `MockStereo`
39
+ */
40
+ export declare type MockStereo = keyof typeof $LUT.MockStereo;
41
+ /** must export $LUT as default */
42
+ export default $LUT;