@lemoncloud/growing-socials-api 0.24.1224 → 0.25.104

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,669 @@
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 } from 'lemon-model';
11
+ import $LUT, { ActivityStereo, CommentStereo, FeedStereo, TagStereo, TopicStereo, UserStereo } 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
+ * mapping of `.extra`
22
+ * - ONLY having string value. (indexing 유지위해서)
23
+ */
24
+ export interface ModelExtra {
25
+ [key: string]: string;
26
+ }
27
+ /**
28
+ * count of each `stereo` in child nodes
29
+ * - 자식글을 작성할경우, 부모에서 count를 저장함.
30
+ * - 검색을 최소화 하기 위해서, 정보를 저장함.
31
+ * - `delete`나 `hidden`시 카운트가 감소함.
32
+ */
33
+ export interface StereoCount {
34
+ [key: string]: number;
35
+ }
36
+ /**
37
+ * common `.text` content body.
38
+ */
39
+ export interface TextContent {
40
+ /**
41
+ * encoded html style with tag
42
+ * example:
43
+ * hello <t>world</t>
44
+ */
45
+ text?: string;
46
+ /**
47
+ * extracted tag text
48
+ * ex) `#some`
49
+ */
50
+ tags?: string[];
51
+ /** matched id of tag-model (not in order) */
52
+ tagIds?: string[];
53
+ /** (optional) partial tag-info by tagIds */
54
+ tag$$?: TagHead[];
55
+ /**
56
+ * extracted social-id text
57
+ * ex) `@who`
58
+ */
59
+ sids?: string[];
60
+ /** matched list of user-head by social-id */
61
+ sid$$?: UserHead[];
62
+ /** matched social-id (normalized, not in order, no duplicated) */
63
+ socialIds?: string[];
64
+ /** matched id of user-model by social-id (in order) */
65
+ userIds?: string[];
66
+ /** (optional) client-ip when created */
67
+ clientIp?: string;
68
+ /** (optional) user-agent when created */
69
+ userAgent?: string;
70
+ }
71
+ /**
72
+ * type: `UserHead`
73
+ * - common head of user-model.
74
+ */
75
+ export interface UserHead {
76
+ /** id of user */
77
+ id?: string;
78
+ /** nick of user */
79
+ nick?: string;
80
+ /** name of user */
81
+ name?: string;
82
+ /** profile image of user */
83
+ image?: string;
84
+ /** profile link of user */
85
+ link?: string;
86
+ /**
87
+ * social-id (unique) by alias.
88
+ */
89
+ socialId?: string;
90
+ }
91
+ /**
92
+ * social information
93
+ */
94
+ export interface SnsInfo {
95
+ /** facebook.com */
96
+ facebook?: string;
97
+ /** instagram.com */
98
+ instagram?: string;
99
+ /** tiktok.com */
100
+ tiktok?: string;
101
+ /** xiaohongshu.com */
102
+ xiaohongshu?: string;
103
+ /** lemon8-app.com */
104
+ lemon8?: string;
105
+ }
106
+ /**
107
+ * super class to support activity
108
+ */
109
+ export interface ActivitySupport {
110
+ /** target model-id */
111
+ id?: string;
112
+ /**
113
+ * total count of `like`
114
+ * - increased when other user has liked this target.
115
+ */
116
+ likeCount?: number;
117
+ /**
118
+ * total count of `dislike`
119
+ * - increased when other user has disliked this target.
120
+ */
121
+ dislikeCount?: number;
122
+ /**
123
+ * total count of `mark`
124
+ */
125
+ markCount?: number;
126
+ /**
127
+ * total count of `view`
128
+ */
129
+ viewCount?: number;
130
+ /**
131
+ * total count of `click`
132
+ */
133
+ clickCount?: number;
134
+ /**
135
+ * total count of `block`
136
+ */
137
+ blockCount?: number;
138
+ /**
139
+ * total count of `report`
140
+ */
141
+ reportCount?: number;
142
+ /** (optional) referenced activity */
143
+ readonly $activity?: ActivityModel;
144
+ }
145
+ /**
146
+ * type: `UserModel`
147
+ * - `backend-api`의 user-id와 매칭됨.
148
+ */
149
+ export interface UserModel<E = ModelExtra> extends UserHead, Model, ActivitySupport {
150
+ /** := backend-api/users/<id> */
151
+ id?: string;
152
+ /** stereo type */
153
+ stereo?: UserStereo;
154
+ /** target alias value */
155
+ alias?: string;
156
+ /**
157
+ * nick-name
158
+ */
159
+ nick?: string;
160
+ /**
161
+ * (optional) name of user
162
+ */
163
+ name?: string;
164
+ /**
165
+ * (optional) profile link of user.
166
+ */
167
+ link?: string;
168
+ /**
169
+ * user infor text content.
170
+ */
171
+ text?: string;
172
+ /**
173
+ * badge condition. (predefined in backend-api)
174
+ */
175
+ badge?: string;
176
+ /**
177
+ * social id (unique) by alias.
178
+ */
179
+ socialId?: string;
180
+ /**
181
+ * (alias) the matched identity-id
182
+ */
183
+ identityId?: string;
184
+ /**
185
+ * latest timestamp of feed.
186
+ */
187
+ lastFeedAt?: number;
188
+ /**
189
+ * latest id of feed.
190
+ */
191
+ lastFeedId?: string;
192
+ /**
193
+ * latest no of feed.
194
+ * - increased for every new feed content.
195
+ */
196
+ lastFeedNo?: number;
197
+ /**
198
+ * (optional) flag to have access to make ad-feed.
199
+ */
200
+ hasAdFeed?: number;
201
+ /**
202
+ * profile image of user.
203
+ */
204
+ image?: string;
205
+ /**
206
+ * background image (or color)
207
+ */
208
+ background?: string;
209
+ /**
210
+ * (optional) extra fields
211
+ * - custom extra object..
212
+ */
213
+ extra?: E;
214
+ /**
215
+ * (optional) sns infor
216
+ */
217
+ sns$?: SnsInfo;
218
+ /**
219
+ * (optional) count of followings
220
+ */
221
+ followings?: number;
222
+ /**
223
+ * (optional) count of followers
224
+ */
225
+ followers?: number;
226
+ /**
227
+ * (optional) count of ranking
228
+ */
229
+ ranking?: number;
230
+ /**
231
+ * (optional) the matched activity.
232
+ */
233
+ readonly $activity?: ActivityModel;
234
+ }
235
+ /**
236
+ * common head of goods
237
+ */
238
+ export interface GoodsHead {
239
+ /**
240
+ * goods-id
241
+ */
242
+ id?: string;
243
+ /**
244
+ * 제품명
245
+ */
246
+ name?: string;
247
+ nameEn?: string;
248
+ /**
249
+ * 브랜드명
250
+ */
251
+ brand?: string;
252
+ brandEn?: string;
253
+ /**
254
+ * 컬러명
255
+ */
256
+ color?: string;
257
+ colorEn?: string;
258
+ /**
259
+ * 대표 제품 이미지
260
+ */
261
+ image?: string;
262
+ imageEn?: string;
263
+ }
264
+ /**
265
+ * type: `FeedHead`
266
+ * - common head of feed-model.
267
+ */
268
+ export interface FeedHead {
269
+ /** id of feed */
270
+ id?: string;
271
+ /** name of feed */
272
+ name?: string;
273
+ }
274
+ /**
275
+ * type: `FeedModel`
276
+ * - modeling of feed
277
+ */
278
+ export interface FeedModel extends FeedHead, Model, ActivitySupport, TextContent {
279
+ /** := <auto-seq> */
280
+ id?: string;
281
+ /** stereo type */
282
+ stereo?: FeedStereo;
283
+ /** (internal) target alias value */
284
+ alias?: string;
285
+ /** sequenced number of feeds in same user */
286
+ feedNo?: number;
287
+ /** sequenced number of childs of this feed */
288
+ childNo?: number;
289
+ /** (internal) no of feed/child */
290
+ no?: number;
291
+ /**
292
+ * (internal) 각 자식의 stereo별 카운트
293
+ * NOTE - `POST /feeds/<id>/child stereo` 을 통한 자동 카운트
294
+ * TODO - 생성/표시 +1, 삭제/숨김 -1 (다만, aggr이 정확하지 않을 수 있으니 async 업데이트 필요함!)
295
+ */
296
+ stereo$?: StereoCount;
297
+ /** (optional) parent feed-id */
298
+ parentId?: string;
299
+ /** (optional) parent feed-info */
300
+ parent$?: FeedHead;
301
+ /** (optional) topic linked */
302
+ topicId?: string;
303
+ /** (optional) partial topic-info */
304
+ topic$?: TopicHead;
305
+ /** user-id of owner */
306
+ userId?: string;
307
+ /** (optional) partial user-info */
308
+ user$?: UserHead;
309
+ /** (optional) the current identity-id when created */
310
+ identityId?: string;
311
+ /** (optional) flag of ad-feed */
312
+ isAd?: number;
313
+ /**
314
+ * (optional) target language to be displayed
315
+ * @deprecated use `lang$` mapping
316
+ */
317
+ langs?: string[];
318
+ /** posted images */
319
+ imageIds?: string[];
320
+ /** (optional) partial image-info */
321
+ image$$?: ImageHead[];
322
+ /** sequence number of comments */
323
+ commentNo?: number;
324
+ /** count of hidden comments */
325
+ commentHidden?: number;
326
+ /**
327
+ * count of post comments
328
+ * - total comments := commentPosted - commentHidden
329
+ */
330
+ commentPosted?: number;
331
+ /**
332
+ * (optional) goods linked
333
+ */
334
+ goods$?: GoodsHead;
335
+ /**
336
+ * hidden condition.
337
+ * - 삭제대신 이용하는것
338
+ * - delete 할 경우 parent/child관계가 끈어지므로, 내부적으로 절대 지우진 않음.
339
+ */
340
+ hidden?: number;
341
+ /**
342
+ * 숨김처리 시간
343
+ */
344
+ hiddenAt?: number;
345
+ /**
346
+ * (optional) the single comment embedded.
347
+ */
348
+ readonly $comment?: CommentModel;
349
+ /**
350
+ * (optional) the single feed in child.
351
+ */
352
+ readonly $child?: FeedModel;
353
+ /**
354
+ * (optional) the matched activity.
355
+ */
356
+ readonly $activity?: ActivityModel;
357
+ /**
358
+ * (internal) score value.
359
+ */
360
+ readonly _score?: number;
361
+ }
362
+ /**
363
+ * type: `CommentHead`
364
+ * - common head of comment-model.
365
+ */
366
+ export interface CommentHead {
367
+ /** id of comment */
368
+ id?: string;
369
+ /** name of comment */
370
+ name?: string;
371
+ }
372
+ /**
373
+ * type: `CommentModel`
374
+ * - modeling of comment in feed
375
+ */
376
+ export interface CommentModel extends CommentHead, Model, ActivitySupport, TextContent {
377
+ /** := <feed-id>:<no> */
378
+ id?: string;
379
+ /** stereo type */
380
+ stereo?: CommentStereo;
381
+ /** target alias value */
382
+ alias?: string;
383
+ /** user-id of comment */
384
+ userId?: string;
385
+ /** (optional) partial user-info */
386
+ user$?: UserHead;
387
+ /** (optional) the current identity-id when created */
388
+ identityId?: string;
389
+ /** parent feed */
390
+ feedId?: string;
391
+ /** (optional) partial feed-info */
392
+ feed$?: FeedHead;
393
+ /**
394
+ * (optional) goods linked
395
+ */
396
+ goods$?: GoodsHead;
397
+ /**
398
+ * internal seq-number in feed
399
+ */
400
+ no?: number;
401
+ /**
402
+ * indent depth (0: default)
403
+ */
404
+ depth?: number;
405
+ /**
406
+ * parent-id of comment.
407
+ * - 대댓글일 경우 생김
408
+ */
409
+ parent?: string;
410
+ /**
411
+ * hidden condition.
412
+ * - 삭제대신 이용하는것
413
+ * - delete 할 경우 parent/child관계가 끈어지므로, 내부적으로 절대 지우진 않음.
414
+ */
415
+ hidden?: number;
416
+ /**
417
+ * 숨김처리 시간
418
+ */
419
+ hiddenAt?: number;
420
+ /**
421
+ * (optional) the matched activity.
422
+ */
423
+ readonly $activity?: ActivityModel;
424
+ }
425
+ /**
426
+ * type: `ImageHead`
427
+ * - common head of image-model.
428
+ */
429
+ export interface ImageHead {
430
+ /** id of image */
431
+ id?: string;
432
+ /** name of image */
433
+ name?: string;
434
+ }
435
+ /**
436
+ * type: `ImageModel`
437
+ * - modeling of image
438
+ */
439
+ export interface ImageModel extends ImageHead, Model {
440
+ /** := <auto-seq> */
441
+ id?: string;
442
+ /**
443
+ * (optional) name of image
444
+ */
445
+ name?: string;
446
+ /** user-id of owner */
447
+ userId?: string;
448
+ /** (optional) partial user-info */
449
+ user$?: UserHead;
450
+ /**
451
+ * image bucket uploaded
452
+ */
453
+ bucket?: string;
454
+ /**
455
+ * image key uploaded
456
+ */
457
+ key?: string;
458
+ /** size in pixel */
459
+ width?: number;
460
+ /** size in pixel */
461
+ height?: number;
462
+ /**
463
+ * Orientation of image
464
+ */
465
+ orientation?: number;
466
+ /**
467
+ * Content-Type
468
+ */
469
+ contentType?: string;
470
+ /**
471
+ * final url to serve
472
+ */
473
+ url?: string;
474
+ }
475
+ /**
476
+ * type: `TagHead`
477
+ * - common head of tag-model.
478
+ */
479
+ export interface TagHead {
480
+ /** id of tag */
481
+ id?: string;
482
+ /** name of tag */
483
+ name?: string;
484
+ }
485
+ /**
486
+ * type: `TagModel`
487
+ * - modeling of tag
488
+ */
489
+ export interface TagModel extends TagHead, Model, ActivitySupport {
490
+ /**
491
+ * id := <auto-seq>
492
+ * - 동음 이의어등 여러가지 상황을 고려해서, name 에 대한 여러가지 ID를 가지도록함
493
+ * - `alias`로 대표 모델을 지정하도록함.
494
+ */
495
+ id?: string;
496
+ /** stereo of tag */
497
+ stereo?: TagStereo;
498
+ /** target alias value */
499
+ alias?: string;
500
+ /**
501
+ * tag name
502
+ */
503
+ name?: string;
504
+ /** flag of censored condition (검열대상) */
505
+ censored?: number;
506
+ /**
507
+ * (optional) the matched activity.
508
+ */
509
+ readonly $activity?: ActivityModel;
510
+ }
511
+ /**
512
+ * type: `TopicHead` (토픽)
513
+ * - common head of topic-model.
514
+ */
515
+ export interface TopicHead {
516
+ /** id of topic */
517
+ id?: string;
518
+ /** name of topic */
519
+ name?: string;
520
+ /** parent-id of topic */
521
+ topicId?: string;
522
+ }
523
+ /**
524
+ * type: `TopicModel`
525
+ * - modeling of topic(토픽)
526
+ * - 토픽(주제)에 따른 피드(글)을 올릴 수 있다.
527
+ * - 특정 주제에 대한 내용 당음. (1피드에 1개의 토픽 매핑됨)
528
+ */
529
+ export interface TopicModel extends TopicHead, Model, ActivitySupport, TextContent {
530
+ /**
531
+ * id := <auto-seq>
532
+ */
533
+ id?: string;
534
+ /** stereo of topic */
535
+ stereo?: TopicStereo;
536
+ /** target alias value */
537
+ alias?: string;
538
+ /**
539
+ * topic name
540
+ */
541
+ name?: string;
542
+ /** ordering number */
543
+ order?: number;
544
+ /** flag of censored condition (검열대상) */
545
+ censored?: number;
546
+ /** parent topic to support */
547
+ topicId?: string;
548
+ /** partial parent */
549
+ topic$?: TopicHead;
550
+ /** user-id of owner */
551
+ userId?: string;
552
+ /** (optional) partial social-info */
553
+ social$?: UserHead;
554
+ /**
555
+ * (optional) the matched activity.
556
+ */
557
+ readonly $activity?: ActivityModel;
558
+ }
559
+ /**
560
+ * type: `ActivityHead`
561
+ * - common head of activity-model.
562
+ */
563
+ export interface ActivityHead {
564
+ /** id of activity */
565
+ id?: string;
566
+ /** name of activity */
567
+ name?: string;
568
+ }
569
+ /**
570
+ * type: `ActivityModel`
571
+ * - 사용자별 활동 정보 저장
572
+ * - 경주별 구매 여부, 읽기 카운트등..
573
+ */
574
+ export interface ActivityModel extends ActivityHead, Model {
575
+ /**
576
+ * id = <stereo>:md5(<custom-key>).len(<custom-key>)
577
+ */
578
+ id?: string;
579
+ /** stereo of model */
580
+ stereo?: ActivityStereo;
581
+ /** owner user-id */
582
+ userId?: string;
583
+ /** target resource-id */
584
+ targetId?: string;
585
+ /**
586
+ * liked count for transaction
587
+ * - 게시글: 좋아요 (like)
588
+ * - 사용자: 팔로잉 (follow)
589
+ *
590
+ * [좋아요] (0 -> 1)
591
+ * - 1를 증가시키고, 그 결과가 1이면 `likeCount` 증가시킴
592
+ * - 1를 증가시키고, 그 결과가 >1 이면, set `liked := 1` 적용
593
+ * 기대치) 항상 값을 `1`으로 유지시킴.
594
+ *
595
+ * [좋아요 해제] -> 좋아도 반대 (1 -> 0)
596
+ * - 1를 감소키고, 그 결과가 0이면 `likeCount` 감소시킴
597
+ * 기대치) 항상 값을 0으로 유지시킴.
598
+ */
599
+ liked?: number;
600
+ /** 좋아요 설정 시간 (없으면 null) */
601
+ likedAt?: number;
602
+ /** disliked count for transaction */
603
+ disliked?: number;
604
+ /** 싫어요 설정 시간 (없으면 null) */
605
+ dislikedAt?: number;
606
+ /** 북마크: marked count for transaction */
607
+ marked?: number;
608
+ /** 북마크 설정 시간 (없으면 null) */
609
+ markedAt?: number;
610
+ /**
611
+ * 구독: 피드/유저의 구독 상태에 따른 여부
612
+ * - 피드 수신 상태를 나타낼때, 구독에 따른 피드인지 확인하기 위함
613
+ */
614
+ subscribed?: number;
615
+ /**
616
+ * 구독시간: 구독으로 수신된 시간
617
+ */
618
+ subscribedAt?: number;
619
+ /**
620
+ * 읽은 개수 처리
621
+ */
622
+ viewed?: number;
623
+ /** 읽기한 설정 시간 (없으면 null) */
624
+ viewedAt?: number;
625
+ /** (optional) the accumulated viewMilliSecond */
626
+ viewMilliSecond?: number;
627
+ /**
628
+ * 클릭 개수 처리
629
+ */
630
+ clicked?: number;
631
+ /** 클릭한 설정 시간 (없으면 null) */
632
+ clickedAt?: number;
633
+ /** 신고: reported count for transaction */
634
+ reported?: number;
635
+ /** 신고 시간 (if applicable) */
636
+ reportedAt?: number;
637
+ /** 신고 내용 */
638
+ reportedReason?: string;
639
+ /** 차단: blocked count for transaction */
640
+ blocked?: number;
641
+ /** 차단 시간 (if applicable) */
642
+ blockedAt?: number;
643
+ /** 차단 내용 */
644
+ blockedReason?: string;
645
+ }
646
+ /**
647
+ * extract field names from models
648
+ * - only fields start with lowercase, or all upper.
649
+ */
650
+ export declare const filterFields: (fields: string[], base?: string[]) => string[];
651
+ /** field names from head */
652
+ export declare const $HEAD: {
653
+ user: string[];
654
+ feed: string[];
655
+ comment: string[];
656
+ tag: string[];
657
+ topic: string[];
658
+ image: string[];
659
+ activity: string[];
660
+ };
661
+ export declare const $FIELD: {
662
+ user: string[];
663
+ feed: string[];
664
+ comment: string[];
665
+ tag: string[];
666
+ topic: string[];
667
+ image: string[];
668
+ activity: string[];
669
+ };