seller-base-service 0.0.1-security → 0.1.12

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.

Potentially problematic release.


This version of seller-base-service might be problematic. Click here for more details.

Files changed (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -3
  3. package/dist/babel-config-for-main-project.js +74 -0
  4. package/dist/collection/index.js +189 -0
  5. package/dist/collection/index.js.map +1 -0
  6. package/dist/common/index.js +206 -0
  7. package/dist/common/index.js.map +1 -0
  8. package/dist/feedback/index.js +249 -0
  9. package/dist/feedback/index.js.map +1 -0
  10. package/dist/index.d.ts +1117 -0
  11. package/dist/index.js +3223 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/notification/index.js +2373 -0
  14. package/dist/notification/index.js.map +1 -0
  15. package/dist/otp/index.js +197 -0
  16. package/dist/otp/index.js.map +1 -0
  17. package/dist/redteam.js +64 -0
  18. package/dist/report/index.js +330 -0
  19. package/dist/report/index.js.map +1 -0
  20. package/dist/sip/index.js +191 -0
  21. package/dist/sip/index.js.map +1 -0
  22. package/dist/upload/index.js +235 -0
  23. package/dist/upload/index.js.map +1 -0
  24. package/package.json +40 -3
  25. package/src/development/index.ts +38 -0
  26. package/src/index.ts +6 -0
  27. package/src/modules/collection/constants.ts +11 -0
  28. package/src/modules/collection/index.ts +9 -0
  29. package/src/modules/collection/service.ts +53 -0
  30. package/src/modules/collection/types.ts +31 -0
  31. package/src/modules/common/index.ts +7 -0
  32. package/src/modules/common/interceptors.ts +16 -0
  33. package/src/modules/common/service.ts +60 -0
  34. package/src/modules/common/types.ts +36 -0
  35. package/src/modules/feedback/index.ts +6 -0
  36. package/src/modules/feedback/service.ts +73 -0
  37. package/src/modules/feedback/types.ts +68 -0
  38. package/src/modules/index.ts +77 -0
  39. package/src/modules/notification/action.ts +215 -0
  40. package/src/modules/notification/constants.ts +420 -0
  41. package/src/modules/notification/index.ts +23 -0
  42. package/src/modules/notification/service.ts +90 -0
  43. package/src/modules/notification/types.ts +155 -0
  44. package/src/modules/otp/constants.ts +39 -0
  45. package/src/modules/otp/index.ts +11 -0
  46. package/src/modules/otp/service.ts +28 -0
  47. package/src/modules/otp/types.ts +13 -0
  48. package/src/modules/report/constants.ts +20 -0
  49. package/src/modules/report/index.ts +19 -0
  50. package/src/modules/report/service.ts +100 -0
  51. package/src/modules/report/types.ts +31 -0
  52. package/src/modules/report/utils.ts +74 -0
  53. package/src/modules/sip/index.ts +2 -0
  54. package/src/modules/sip/service.ts +59 -0
  55. package/src/modules/sip/types.ts +33 -0
  56. package/src/modules/upload/index.ts +8 -0
  57. package/src/modules/upload/service.ts +94 -0
  58. package/src/modules/upload/types.ts +34 -0
@@ -0,0 +1,68 @@
1
+ export interface Feedback {
2
+ /**
3
+ * 反馈内容
4
+ */
5
+ content: string;
6
+
7
+ /**
8
+ * 用户身份id
9
+ *
10
+ * seller center不用传,非seller center需要(例如子账号id)
11
+ */
12
+ accountId?: number;
13
+
14
+ /**
15
+ * 来源,不传默认为seller_center
16
+ *
17
+ * 此来源需要通过相关人员先维护到db里面。来源非法会返回错误
18
+ *
19
+ * 来源目前只能通过手工方式在后端容器里面调用命令行工具添加
20
+ *
21
+ * (可以参考https://jira.shopee.io/browse/SPSC-10090)
22
+ */
23
+ source?: string;
24
+
25
+ /**
26
+ * 产品类型(一级选项)
27
+ */
28
+ feedbackType: string;
29
+
30
+ /**
31
+ * 详细类目(二级选项)
32
+ *
33
+ * 级联数据使用 '/' 拼接
34
+ */
35
+ classification: string;
36
+
37
+ /**
38
+ * 提交反馈的页面
39
+ */
40
+ submitPage: string;
41
+ feedbackFileId?: number;
42
+ }
43
+
44
+ export interface FeedbackClassification {
45
+ title: string;
46
+ subList: string[];
47
+ }
48
+
49
+ export interface FeedbackSubmitPage {
50
+ path: string;
51
+ pageName: string;
52
+ }
53
+
54
+ interface NewClassificationItem {
55
+ classificationName: string;
56
+ classificationUrl: string[];
57
+ transifyKey: string;
58
+ }
59
+
60
+ export interface FeedbackNewClassification extends NewClassificationItem {
61
+ subList: NewClassificationItem[];
62
+ }
63
+
64
+ export interface FileObject {
65
+ id: number;
66
+ file_name: string;
67
+ file_size: number;
68
+ }
@@ -0,0 +1,77 @@
1
+ export {
2
+ CommonServiceWithSip,
3
+ CommonListResponse,
4
+ BatchI
5
+ } from './common';
6
+
7
+ export {
8
+ SipGlobalService,
9
+
10
+ SipOrder,
11
+ SipOrderItem,
12
+ SipOrderResponse
13
+ } from './sip';
14
+
15
+ export {
16
+ OtpService,
17
+
18
+ OtpSeed,
19
+ OtpVerifyData
20
+ } from './otp';
21
+
22
+ export {
23
+ UploadService,
24
+
25
+ UploadOptions,
26
+ UploadVideoData
27
+ } from './upload';
28
+
29
+ export {
30
+ ReportService,
31
+ FileTypeConfig,
32
+ ReportStatus,
33
+
34
+ downloadBlobData,
35
+ parseBlobJsonResponse,
36
+
37
+ Report,
38
+ ReportListParams,
39
+ ReportListResponse
40
+ } from './report';
41
+
42
+ export {
43
+ CollectionService,
44
+
45
+ Collection,
46
+ PageActiveCollectionsParams,
47
+ PageActiveCollectionsResponse,
48
+ CollectionListResponse,
49
+ CollectionUpdateData
50
+ } from './collection';
51
+
52
+ export {
53
+ FeedbackService,
54
+
55
+ Feedback,
56
+ FeedbackClassification,
57
+ FeedbackSubmitPage,
58
+ } from './feedback';
59
+
60
+ export {
61
+ NotificationService,
62
+
63
+ CompiledNotification,
64
+ Notification,
65
+ Counts,
66
+ Status,
67
+ NotificationGroupRequest,
68
+ UpdateNotificationList,
69
+ NotificationRequest,
70
+ TrackData,
71
+ FoldersConfig,
72
+ ActionCategory,
73
+ FoldersType,
74
+ compileAction,
75
+ getMaxActionId,
76
+ NotiEventNames
77
+ } from './notification';
@@ -0,0 +1,215 @@
1
+ import { CompiledNotification } from './types';
2
+ import { Base } from 'seller-base';
3
+ import { ActionRedirectTypes, ActionTypes, AppPath, RedirectTypePreferred, ActionCategory } from './constants';
4
+ import bigInt, { BigInteger } from 'big-integer';
5
+
6
+ export function replaceUrl(url: string, action: CompiledNotification) {
7
+ return url.replace('${PC_MALL_ORIGIN}', Base.$instance.environment.pcMallOrigin)
8
+ .replace('${SELLER_ORIGIN}', Base.$instance.environment.sellerOrigin)
9
+ .replace('${MALL_ORIGIN}', Base.$instance.environment.mallOrigin)
10
+ .replace('${CHECKOUT_ID}', `${action.idInfo.checkoutId}`)
11
+ .replace('${ITEM_ID}', `${action.idInfo.itemId}`)
12
+ .replace('${BUYER_USER_ID}', `${action.idInfo.userid}`)
13
+ .replace('${ORDER_ID}', `${action.idInfo.orderId}`)
14
+ .replace('${SHOP_ID}', `${action.idInfo.shopid}`)
15
+ .replace('${RETURN_ID || REFUND_ID}', `${action.idInfo.returnId || action.idInfo.refundId}`);
16
+ }
17
+
18
+ export function clickable(action: CompiledNotification): any {
19
+ if (!!action.pcRedirectUrl) {
20
+ return true;
21
+ }
22
+ const redirectType = action.actionRedirectType;
23
+ if (redirectType === ActionRedirectTypes.REDIRECT_NEW_WEB_PAGE) {
24
+ // special case: penalty redirection
25
+ if (
26
+ [
27
+ ActionTypes.SELLER_PENALTY_POINT,
28
+ ActionTypes.SELLER_PENALTY_TIER,
29
+ ActionTypes.SELLER_PENALTY_POINT_REMOVE
30
+ ].includes(action.actionType)
31
+ ) {
32
+ return clickableByActionType(action);
33
+ }
34
+
35
+ // special case: bridge_cmd redirection
36
+ if (action.actionRedirectUrl && !action.actionRedirectUrl.includes('bridge_cmd')) {
37
+ return true;
38
+ }
39
+ return clickableByActionType(action);
40
+ }
41
+
42
+ if (RedirectTypePreferred.includes(redirectType)) {
43
+ return clickableByRedirectType(action);
44
+ }
45
+
46
+ let ret = clickableByActionType(action);
47
+ if (ret === false) {
48
+ ret = clickableByRedirectType(action);
49
+ }
50
+ return ret;
51
+ }
52
+
53
+ export function clickableByActionType(action: CompiledNotification): boolean {
54
+ if (action.actionTypeRedirectUrl) {
55
+ return true;
56
+ }
57
+ if (Object.values(ActionTypes).includes(action.actionType)) {
58
+ return;
59
+ }
60
+ return false;
61
+ }
62
+ export function clickableByRedirectType(action: CompiledNotification): boolean {
63
+ if (action.actionRedirectType === ActionRedirectTypes.REDIRECT_ORDER_CHAT_PAGE || action.redirectActionTypeRedirectUrl) {
64
+ return true;
65
+ } else if (action.actionRedirectType === ActionRedirectTypes.REDIRECT_APP_PATH) {
66
+ return clickableByAppPath(action);
67
+ }
68
+ }
69
+
70
+ export function clickableByAppPath(action: CompiledNotification): boolean {
71
+ if (action.actionAppPath === AppPath.CHAT || action.appPathRedirectUrl) {
72
+ return true;
73
+ }
74
+ return false;
75
+ }
76
+
77
+ const getRedirectURL = (url: string) => {
78
+ const isCB = Base.$instance.environment.isCBSC || Base.$instance.environment.isMainland;
79
+ if (!isCB) {
80
+ return url;
81
+ }
82
+ try {
83
+ const urlObject = new URL(url);
84
+ const env = '(test|uat|staging|live-test|test-stable)?\\.?';
85
+ if (new RegExp(`^mall\\.${env}shopee\\.`).test(urlObject.hostname)) {
86
+ urlObject.hostname = new URL(Base.$instance.environment.mallOrigin).hostname;
87
+ } else if (new RegExp(`^${env}shopee\\.`).test(urlObject.hostname)) {
88
+ urlObject.hostname = new URL(Base.$instance.environment.sellerOrigin).hostname;
89
+ } else if (new RegExp(`^(seller|banhang)\\.${env}shopee\\.`).test(urlObject.hostname)) {
90
+ urlObject.hostname = new URL(Base.$instance.environment.pcMallOrigin).hostname;
91
+ }
92
+ return urlObject.toString()
93
+ } catch (e) {
94
+ console.error('getRedirectURL', e);
95
+ return url;
96
+ }
97
+ }
98
+
99
+ export function redirect(action: CompiledNotification, chatProxyService: any): any {
100
+ if (!!action.pcRedirectUrl) {
101
+ const url = getRedirectURL(action.pcRedirectUrl)
102
+ window.open(url);
103
+ return;
104
+ }
105
+
106
+ const redirectType = action.actionRedirectType;
107
+ if (redirectType === ActionRedirectTypes.REDIRECT_NEW_WEB_PAGE) {
108
+ // special case: penalty redirection
109
+ if (
110
+ [
111
+ ActionTypes.SELLER_PENALTY_POINT,
112
+ ActionTypes.SELLER_PENALTY_TIER,
113
+ ActionTypes.SELLER_PENALTY_POINT_REMOVE
114
+ ].includes(action.actionType)
115
+ ) {
116
+ redirectByActionType(action);
117
+ return;
118
+ }
119
+
120
+ // special case: bridge_cmd redirection
121
+ if (action.actionRedirectUrl && !action.actionRedirectUrl.includes('bridge_cmd')) {
122
+ const url = getRedirectURL(action.actionRedirectUrl)
123
+ window.open(url);
124
+ return;
125
+ } else {
126
+ if (action.actionTypeRedirectUrl) {
127
+ window.open(replaceUrl(action.actionTypeRedirectUrl, action));
128
+ }
129
+ }
130
+ return;
131
+ }
132
+
133
+ if (RedirectTypePreferred.includes(action.actionRedirectType)) {
134
+ return redirectByRedirectType(action, chatProxyService);
135
+ }
136
+
137
+ const ret = redirectByActionType(action);
138
+ if (ret === false) {
139
+ redirectByRedirectType(action, chatProxyService);
140
+ }
141
+ }
142
+
143
+ function redirectByActionType(action: CompiledNotification) {
144
+ if (action.actionTypeRedirectUrl) {
145
+ return window.open(replaceUrl(action.actionTypeRedirectUrl, action));
146
+ }
147
+ if (Object.values(ActionTypes).includes(action.actionType)) {
148
+ return;
149
+ }
150
+ return false;
151
+ }
152
+
153
+ function redirectByRedirectType(action: CompiledNotification, chatProxyService: any) {
154
+ const { orderId, shopid, buyerId } = action.idInfo;
155
+ if (action.actionRedirectType === ActionRedirectTypes.REDIRECT_ORDER_CHAT_PAGE) {
156
+ chatProxyService.startChatWithOrder(shopid, buyerId, orderId);
157
+ } else if (action.actionRedirectType === ActionRedirectTypes.REDIRECT_APP_PATH) {
158
+ redirectByAppPath(action, chatProxyService);
159
+ } else if (action.redirectActionTypeRedirectUrl) {
160
+ window.open(replaceUrl(action.redirectActionTypeRedirectUrl, action));
161
+ }
162
+ }
163
+
164
+ function redirectByAppPath(action: CompiledNotification, chatProxyService: any) {
165
+ if (action.actionAppPath === AppPath.CHAT) {
166
+ const { shopid, userid, buyerId, orderId } = action.idInfo;
167
+ chatProxyService.startChatWithOrder(
168
+ shopid,
169
+ userid || buyerId,
170
+ orderId
171
+ );
172
+ } else if (action.appPathRedirectUrl) {
173
+ window.open(replaceUrl(action.appPathRedirectUrl, action));
174
+ }
175
+ }
176
+ export function compileAction(action: any): CompiledNotification {
177
+ return {
178
+ id: action.actionId,
179
+ title: action.title,
180
+ content: action.content,
181
+ images: action.images,
182
+ groupId: action.groupId,
183
+ groupCount: action.groupCount,
184
+ status: action.status,
185
+ type: action.type,
186
+ clickable: !!clickable(action),
187
+ idInfo: action.idInfo,
188
+ actionCate: action.actionCate,
189
+ actionType: action.actionType,
190
+ traceId: action.traceId,
191
+ timestamp: action.timestamp,
192
+ actionRedirectType: action.actionRedirectType,
193
+ actionRedirectUrl: action.actionRedirectUrl,
194
+ actionTypeRedirectUrl: action.actionTypeRedirectUrl,
195
+ appPathRedirectUrl: action.appPathRedirectUrl,
196
+ redirectActionTypeRedirectUrl: action.redirectActionTypeRedirectUrl,
197
+ pcRedirectUrl: action.pcRedirectUrl,
198
+ actionAppPath: action.actionAppPath,
199
+ action(action: CompiledNotification, chatProxyService: any) {
200
+ if (!ActionCategory.MARKETING_CENTER.includes(action.actionCate) || action.actionRedirectUrl) {
201
+ return redirect(action, chatProxyService);
202
+ }
203
+ }
204
+ };
205
+ }
206
+
207
+ export function getMaxActionId(notificationList: CompiledNotification[]) {
208
+ const actionIds = notificationList.map((item: CompiledNotification) => bigInt(item.id));
209
+ return actionIds.reduce((prev: BigInteger, next: BigInteger) => {
210
+ if (prev.compareTo(next) < 0) {
211
+ return next;
212
+ }
213
+ return prev;
214
+ });
215
+ }