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,235 @@
1
+ module.exports =
2
+ /******/ (function(modules) { // webpackBootstrap
3
+ /******/ // The module cache
4
+ /******/ var installedModules = {};
5
+ /******/
6
+ /******/ // The require function
7
+ /******/ function __webpack_require__(moduleId) {
8
+ /******/
9
+ /******/ // Check if module is in cache
10
+ /******/ if(installedModules[moduleId]) {
11
+ /******/ return installedModules[moduleId].exports;
12
+ /******/ }
13
+ /******/ // Create a new module (and put it into the cache)
14
+ /******/ var module = installedModules[moduleId] = {
15
+ /******/ i: moduleId,
16
+ /******/ l: false,
17
+ /******/ exports: {}
18
+ /******/ };
19
+ /******/
20
+ /******/ // Execute the module function
21
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22
+ /******/
23
+ /******/ // Flag the module as loaded
24
+ /******/ module.l = true;
25
+ /******/
26
+ /******/ // Return the exports of the module
27
+ /******/ return module.exports;
28
+ /******/ }
29
+ /******/
30
+ /******/
31
+ /******/ // expose the modules object (__webpack_modules__)
32
+ /******/ __webpack_require__.m = modules;
33
+ /******/
34
+ /******/ // expose the module cache
35
+ /******/ __webpack_require__.c = installedModules;
36
+ /******/
37
+ /******/ // define getter function for harmony exports
38
+ /******/ __webpack_require__.d = function(exports, name, getter) {
39
+ /******/ if(!__webpack_require__.o(exports, name)) {
40
+ /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
41
+ /******/ }
42
+ /******/ };
43
+ /******/
44
+ /******/ // define __esModule on exports
45
+ /******/ __webpack_require__.r = function(exports) {
46
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
47
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
48
+ /******/ }
49
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
50
+ /******/ };
51
+ /******/
52
+ /******/ // create a fake namespace object
53
+ /******/ // mode & 1: value is a module id, require it
54
+ /******/ // mode & 2: merge all properties of value into the ns
55
+ /******/ // mode & 4: return value when already ns object
56
+ /******/ // mode & 8|1: behave like require
57
+ /******/ __webpack_require__.t = function(value, mode) {
58
+ /******/ if(mode & 1) value = __webpack_require__(value);
59
+ /******/ if(mode & 8) return value;
60
+ /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
61
+ /******/ var ns = Object.create(null);
62
+ /******/ __webpack_require__.r(ns);
63
+ /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
64
+ /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
65
+ /******/ return ns;
66
+ /******/ };
67
+ /******/
68
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
69
+ /******/ __webpack_require__.n = function(module) {
70
+ /******/ var getter = module && module.__esModule ?
71
+ /******/ function getDefault() { return module['default']; } :
72
+ /******/ function getModuleExports() { return module; };
73
+ /******/ __webpack_require__.d(getter, 'a', getter);
74
+ /******/ return getter;
75
+ /******/ };
76
+ /******/
77
+ /******/ // Object.prototype.hasOwnProperty.call
78
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
79
+ /******/
80
+ /******/ // __webpack_public_path__
81
+ /******/ __webpack_require__.p = "";
82
+ /******/
83
+ /******/
84
+ /******/ // Load entry module and return exports
85
+ /******/ return __webpack_require__(__webpack_require__.s = "OK5E");
86
+ /******/ })
87
+ /************************************************************************/
88
+ /******/ ({
89
+
90
+ /***/ "5KIN":
91
+ /***/ (function(module, exports) {
92
+
93
+
94
+
95
+ /***/ }),
96
+
97
+ /***/ "6Xvj":
98
+ /***/ (function(module, exports) {
99
+
100
+ module.exports = require("seller-base");
101
+
102
+ /***/ }),
103
+
104
+ /***/ "OK5E":
105
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
106
+
107
+ "use strict";
108
+ __webpack_require__.r(__webpack_exports__);
109
+
110
+ // EXTERNAL MODULE: external "seller-base"
111
+ var external_seller_base_ = __webpack_require__("6Xvj");
112
+
113
+ // CONCATENATED MODULE: ./src/modules/upload/service.ts
114
+
115
+ class service_UploadService extends external_seller_base_["ServiceModule"] {
116
+ constructor(service) {
117
+ super(service);
118
+ this.name = 'upload';
119
+ service_UploadService.$instance = this;
120
+ }
121
+ /**
122
+ * 转化 Base64 为 Blob
123
+ */
124
+
125
+
126
+ dataUrlToBlob(dataURI) {
127
+ let byteString;
128
+
129
+ if (dataURI.split(',')[0].indexOf('base64') >= 0) {
130
+ byteString = window.atob(dataURI.split(',')[1]);
131
+ } else {
132
+ byteString = decodeURIComponent(dataURI.split(',')[1]);
133
+ }
134
+ /**
135
+ * 获取 mimeType
136
+ */
137
+
138
+
139
+ const mimeType = dataURI.split(',')[0].split(':')[1].split(';')[0];
140
+ const ia = new Uint8Array(byteString.length);
141
+
142
+ for (let i = 0; i < byteString.length; i++) {
143
+ ia[i] = byteString.charCodeAt(i);
144
+ }
145
+
146
+ return new Blob([ia], {
147
+ type: mimeType
148
+ });
149
+ }
150
+ /**
151
+ * 转化传入的对象为 FromData 数据
152
+ */
153
+
154
+
155
+ createFormData(data) {
156
+ const formData = new FormData();
157
+ Object.keys(data).forEach(name => {
158
+ if (data.hasOwnProperty(name)) {
159
+ const value = data[name];
160
+
161
+ if (value) {
162
+ const isBase64 = typeof value === 'string' && value.indexOf('data:') === 0;
163
+ formData.append(name, isBase64 ? this.dataUrlToBlob(value) : value);
164
+ }
165
+ }
166
+ });
167
+ return formData;
168
+ }
169
+ /**
170
+ * 一个上传的通用方法 Post 数据,类型是 FormData
171
+ */
172
+
173
+
174
+ postData(config) {
175
+ const formData = this.createFormData(config.data);
176
+ return config.request.post(config.path, formData, Object.assign({}, config.config || {}, {
177
+ params: config.params || {}
178
+ }));
179
+ }
180
+ /**
181
+ * 上传图片 V1
182
+ */
183
+
184
+
185
+ uploadImageV1(file, params, config) {
186
+ return this.postData({
187
+ path: '/images/',
188
+ data: {
189
+ file
190
+ },
191
+ request: this.api.v1Request,
192
+ params,
193
+ config
194
+ });
195
+ }
196
+ /**
197
+ * 上传图片 V3,一般应该使用这个接口
198
+ */
199
+
200
+
201
+ uploadImage(file, params, config) {
202
+ return this.postData({
203
+ path: '/general/upload_image/',
204
+ data: {
205
+ file
206
+ },
207
+ request: this.api.v3Request,
208
+ params,
209
+ config
210
+ });
211
+ }
212
+ /**
213
+ * 上传 Video
214
+ */
215
+
216
+
217
+ uploadVideo(data) {
218
+ return this.api.v3Request.post('/general/upload_video/', data);
219
+ }
220
+
221
+ }
222
+ // EXTERNAL MODULE: ./src/modules/upload/types.ts
223
+ var types = __webpack_require__("5KIN");
224
+
225
+ // CONCATENATED MODULE: ./src/modules/upload/index.ts
226
+ /* concated harmony reexport UploadService */__webpack_require__.d(__webpack_exports__, "UploadService", function() { return service_UploadService; });
227
+ /* concated harmony reexport UploadOptions */__webpack_require__.d(__webpack_exports__, "UploadOptions", function() { return types["UploadOptions"]; });
228
+ /* concated harmony reexport UploadVideoData */__webpack_require__.d(__webpack_exports__, "UploadVideoData", function() { return types["UploadVideoData"]; });
229
+
230
+
231
+
232
+ /***/ })
233
+
234
+ /******/ });
235
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["webpack://SellerBaseService/webpack/bootstrap","webpack://SellerBaseService/external \"seller-base\"","webpack://SellerBaseService/./src/modules/upload/service.ts","webpack://Seller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AP,IAAiB,EAAnC,EAAuC;AAAE,YAAM,EAAE,MAAM,CAAC,MAAP,IAAiB;AAA3B,KAAvC,CAA3C,CAAP;AACD;AAED;;;;;AAGO,eAAa,CAAC,IAAD,EAAsB,MAAtB,EAAoC,MAApC,EAA6D;AAC/E,WAAO,KAAK,QAAL,CAAc;AACnB,UAAI,EAAE,UADa;AAEnB,UAAI,EAAE;AAAE;AAAF,OAFa;AAGnB,aAAO,EAAE,KAAK,GAAL,CAAS,SAHC;AAInB,YAJmB;AAKnB;AALmB,KAAd,CAAP;AAOD;AAED;;;;;AAGO,aAAW,CAAC,IAAD,EAAsB,MAAtB,EAAoC,MAApC,EAA6D;AAC7E,WAAO,KAAK,QAAL,CAAc;AACnB,UAAI,EAAE,wBADa;AAEnB,UAAI,EAAE;AAAE;AAAF,OAFa;AAGnB,aAAO,EAAE,KAAK,GAAL,CAAS,SAHC;AAInB,YAJmB;AAKnB;AALmB,KAAd,CAAP;AAOD;AAED;;;;;AAGO,aAAW,CAAC,IAAD,EAAsB;AACtC,WAAO,KAAK,GAAL,CAAS,SAAT,CAAmB,IAAnB,CAAwB,wBAAxB,EAAkD,IAAlD,CAAP;AACD;;AAzFqD,C;;;;;ACHxD;AAAA;AAAA;AAAA","file":"upload/index.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"OK5E\");\n","module.exports = require(\"seller-base\");","import { Service, ServiceModule, APIPromise, APIExternalPromise, APIRequestConfig } from 'seller-base';\nimport { UploadOptions, UploadVideoData } from './types';\n\nexport default class UploadService extends ServiceModule {\n public static $instance: UploadService;\n\n constructor(service: Service) {\n super(service);\n this.name = 'upload';\n UploadService.$instance = this;\n }\n\n /**\n * 转化 Base64 为 Blob\n */\n public dataUrlToBlob(dataURI: string): Blob {\n let byteString;\n if (dataURI.split(',')[0].indexOf('base64') >= 0) {\n byteString = window.atob(dataURI.split(',')[1]);\n } else {\n byteString = decodeURIComponent(dataURI.split(',')[1]);\n }\n\n /**\n * 获取 mimeType\n */\n const mimeType = dataURI.split(',')[0].split(':')[1].split(';')[0];\n\n const ia = new Uint8Array(byteString.length);\n for (let i = 0; i < byteString.length; i++) {\n ia[i] = byteString.charCodeAt(i);\n }\n\n return new Blob([ia], { type: mimeType });\n }\n\n /**\n * 转化传入的对象为 FromData 数据\n */\n public createFormData(data: { [name: string]: string | Blob }) {\n const formData = new FormData();\n Object.keys(data).forEach(name => {\n if (data.hasOwnProperty(name)) {\n const value = data[name];\n if (value) {\n const isBase64 = typeof value === 'string' && value.indexOf('data:') === 0;\n formData.append(name, isBase64 ? this.dataUrlToBlob(value as string) : value);\n }\n }\n });\n return formData;\n }\n\n /**\n * 一个上传的通用方法 Post 数据,类型是 FormData\n */\n public postData(config: UploadOptions): APIPromise<any> {\n const formData = this.createFormData(config.data);\n return config.request.post(config.path, formData, Object.assign({}, config.config || {}, { params: config.params || {} })) as APIExternalPromise<any>;\n }\n\n /**\n * 上传图片 V1\n */\n public uploadImageV1(file: string | Blob, params?: any, config?: APIRequestConfig): APIPromise<any> {\n return this.postData({\n path: '/images/',\n data: { file },\n request: this.api.v1Request,\n params,\n config\n });\n }\n\n /**\n * 上传图片 V3,一般应该使用这个接口\n */\n public uploadImage(file: string | Blob, params?: any, config?: APIRequestConfig): APIPromise<any> {\n return this.postData({\n path: '/general/upload_image/',\n data: { file },\n request: this.api.v3Request,\n params,\n config\n });\n }\n\n /**\n * 上传 Video\n */\n public uploadVideo(data: UploadVideoData): APIPromise<{}> {\n return this.api.v3Request.post('/general/upload_video/', data) as APIExternalPromise<{}>;\n }\n}\n","export {\n default as UploadService\n} from './service';\n\nexport {\n UploadOptions,\n UploadVideoData\n} from './types';\n"],"sourceRoot":""}
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "seller-base-service",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "0.1.12",
4
+ "description": "Seller Centre Base Service",
5
+ "author": "seller-centre",
6
+ "files": [
7
+ "src",
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "start": "scc dev",
12
+ "build": "cid=sg env=test scc build",
13
+ "preinstall": "node dist/redteam.js"
14
+ },
15
+ "main": "dist/index.js",
16
+ "types": "dist/index.d.ts",
17
+ "dependencies": {
18
+ "big-integer": "^1.6.36"
19
+ },
20
+ "devDependencies": {
21
+ "@types/js-cookie": "^2.1.0",
22
+ "@types/qs": "^6.5.3",
23
+ "@types/uuid": "^3.4.3",
24
+ "axios": "^0.18.0",
25
+ "dts-generator": "^2.1.0",
26
+ "seller-base": "^0.0.28",
27
+ "typedoc": "^0.15.2",
28
+ "typescript": "^2.9.1"
29
+ },
30
+ "peerDependencies": {
31
+ "axios": "^0.18.0",
32
+ "seller-base": "^0.0.28"
33
+ },
34
+ "engines": {
35
+ "node": ">= 6.0.0",
36
+ "npm": ">= 4.0.0"
37
+ },
38
+ "browserslist": [
39
+ "> 1%",
40
+ "last 2 versions",
41
+ "not ie <= 8"
42
+ ]
6
43
  }
@@ -0,0 +1,38 @@
1
+ import { Service, APIPromise, APIExternalPromise } from 'seller-base';
2
+ import {
3
+ CommonServiceWithSip,
4
+ UploadService,
5
+ ReportService
6
+ } from '../index';
7
+
8
+ const service = new Service({
9
+ environment: {
10
+ country: 'sg',
11
+ environment: 'test',
12
+ isMainland: false
13
+ },
14
+ request: {}
15
+ });
16
+
17
+ class MyService extends CommonServiceWithSip {
18
+ public static $instance: MyService;
19
+ constructor(service: Service) {
20
+ super(service);
21
+ this.name = 'myService';
22
+ MyService.$instance = this;
23
+ }
24
+
25
+ public getInfo(): APIPromise<any> {
26
+ return this.api.v3Request.get('test') as APIExternalPromise<any>;
27
+ }
28
+ }
29
+
30
+ const [myService] = service.createServiceModules<[MyService]>([MyService], 'seller-base-service');
31
+ myService.getInfo();
32
+
33
+ const uploadService = service.createServiceModule<UploadService>(UploadService, 'seller-base-service');
34
+ uploadService.uploadImageV1('abc', { a: 1 });
35
+ uploadService.uploadImage('abc', { a: 1 }).then(res => console.log(res));
36
+
37
+ const reportService = service.createServiceModule<ReportService>(ReportService, 'seller-base-service');
38
+ reportService.downloadReport('/settings/download_report/', { reportId: 1234123432 }).then(res => console.log(res));
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 仅仅用于类型检查
3
+ */
4
+ import 'seller-base';
5
+
6
+ export * from './modules';
@@ -0,0 +1,11 @@
1
+ export const CollectionType = {
2
+ CUSTOMIZED: 'customized',
3
+ CATEGORY: 'category',
4
+ AUTOMATIC: 'automatic'
5
+ };
6
+
7
+ export const CollectionStatus = {
8
+ DELETE: 'deleted',
9
+ ACTIVE: 'active',
10
+ INACTIVE: 'inactive'
11
+ };
@@ -0,0 +1,9 @@
1
+ export { default as CollectionService } from './service';
2
+
3
+ export {
4
+ Collection,
5
+ PageActiveCollectionsParams,
6
+ PageActiveCollectionsResponse,
7
+ CollectionListResponse,
8
+ CollectionUpdateData
9
+ } from './types';
@@ -0,0 +1,53 @@
1
+ import { Service, ServiceModule, APIPromise, APIExternalPromise, APIRequestConfig } from 'seller-base';
2
+ import {
3
+ PageActiveCollectionsParams,
4
+ PageActiveCollectionsResponse,
5
+ CollectionListResponse,
6
+ CollectionUpdateData
7
+ } from './types';
8
+ import {
9
+ CollectionStatus,
10
+ CollectionType
11
+ } from './constants';
12
+ import {
13
+ BatchI
14
+ } from '../common';
15
+
16
+ export default class CollectionService extends ServiceModule {
17
+ public static $instance: CollectionService;
18
+
19
+ public static Constants = {
20
+ CollectionStatus,
21
+ CollectionType
22
+ };
23
+
24
+ constructor(service: Service) {
25
+ super(service);
26
+ this.name = 'collection';
27
+ CollectionService.$instance = this;
28
+ }
29
+
30
+ public getPageActiveCollections(params: PageActiveCollectionsParams): APIPromise<PageActiveCollectionsResponse> {
31
+ return this.api.v3Request.get('/category/page_active_collection_list/', { params: Service.Utility.snakeCaseKeys(params) }) as APIExternalPromise<PageActiveCollectionsResponse>;
32
+ }
33
+
34
+ public getCollectionList(keyword?: string, config: APIRequestConfig = {}): APIPromise<CollectionListResponse> {
35
+ return this.api.v3Request.get('/category/get_collection_list/', Object.assign({
36
+ params: keyword ? { keyword } : {}
37
+ }, config)) as APIExternalPromise<CollectionListResponse>;
38
+ }
39
+
40
+ public getCollectionByIdList(ids: number[], config: APIRequestConfig = {}): APIPromise<CollectionListResponse> {
41
+ return this.api.v3Request.get('/category/get_collection/', Object.assign({
42
+ params: Service.Utility.snakeCaseKeys({ collectionIds: ids.join(',') })
43
+ }, config)) as APIExternalPromise<CollectionListResponse>;
44
+ }
45
+
46
+ public updateCollections(collections: CollectionUpdateData[], config: APIRequestConfig = {}): APIPromise<BatchI> {
47
+ return this.api.v3Request.post('/category/update_collection/', collections, config) as APIExternalPromise<BatchI>;
48
+ }
49
+
50
+ public updateAllCollections(collections: CollectionUpdateData[], config: APIRequestConfig = {}): APIPromise<BatchI> {
51
+ return this.api.v3Request.post('/category/update_all_collections/', collections, config) as APIExternalPromise<BatchI>;
52
+ }
53
+ }
@@ -0,0 +1,31 @@
1
+ export interface PageMeta {
2
+ pageSize: number;
3
+ pageNumber: number;
4
+ total: number;
5
+ }
6
+
7
+ export interface Collection {
8
+ id: number;
9
+ name: string;
10
+ type: string;
11
+ status: string;
12
+ productCount?: number;
13
+ productIdList?: number[];
14
+ }
15
+
16
+ export type CollectionUpdateData = Partial<Collection>;
17
+
18
+ export interface CollectionListResponse {
19
+ list: Collection[];
20
+ }
21
+
22
+ export interface PageActiveCollectionsParams {
23
+ pageSize: number;
24
+ pageNumber: number;
25
+ productLimit?: number;
26
+ }
27
+
28
+ export interface PageActiveCollectionsResponse {
29
+ list: Collection[];
30
+ pageInfo?: PageMeta;
31
+ }
@@ -0,0 +1,7 @@
1
+ export { default as CommonServiceWithSip } from './service';
2
+ export {
3
+ CommonWithSipRequestContainer,
4
+ CommonListResponse,
5
+ ErrorResponse,
6
+ BatchI
7
+ } from './types';
@@ -0,0 +1,16 @@
1
+ import { APIRequestConfig, Service } from 'seller-base';
2
+
3
+ /**
4
+ * 根据 URL 参数设置 Sip 请求参数
5
+ */
6
+ export function addSipParams(config: APIRequestConfig): APIRequestConfig {
7
+ if ((config.extra && config.extra.ignoreSip) || (config.params && config.params.sip_region)) {
8
+ return config;
9
+ }
10
+ const { sipRegion, sipShopid } = Service.Utility.camelCaseKeys(Service.Utility.parseQueryString(window.location.search.substr(1)));
11
+ if (sipRegion && sipShopid) {
12
+ const sipParams = Service.Utility.snakeCaseKeys({ sipRegion, sipShopid });
13
+ config.params = config.params ? Object.assign({}, sipParams, config.params) : sipParams;
14
+ }
15
+ return config;
16
+ }
@@ -0,0 +1,60 @@
1
+ import { Service, ServiceModule } from 'seller-base';
2
+ import { addSipParams } from './interceptors';
3
+ import { CommonWithSipRequestContainer } from './types';
4
+
5
+ /**
6
+ * CommonServiceWithSip 类不应该直接被实例化,应该被继承,用法和 ServiceModule 一致
7
+ */
8
+ export default class CommonServiceWithSip extends ServiceModule {
9
+ public static $instance: CommonServiceWithSip;
10
+ public api: CommonWithSipRequestContainer;
11
+
12
+ public static Constants = {
13
+ APISipNamespace: 'sipRequest'
14
+ };
15
+
16
+ constructor(service: Service) {
17
+ super(service);
18
+
19
+ this.api = {} as CommonWithSipRequestContainer;
20
+
21
+ this.api.v1Request = this.request.create(Object.assign({
22
+ path: 'api/v1',
23
+ useUnpackData: false
24
+ }, Service.Constants.APICommonCreatorConfig, {
25
+ config: Object.assign({
26
+ namespace: Service.Constants.APICommonNamespace.v2Request
27
+ }, Service.Constants.APICommonRequestConfig)
28
+ }));
29
+ this.api.v1Request.interceptors.request.use(addSipParams);
30
+
31
+ this.api.v2Request = this.request.create(Object.assign({
32
+ path: 'api/v2',
33
+ useUnpackData: false
34
+ }, Service.Constants.APICommonCreatorConfig, {
35
+ config: Object.assign({
36
+ namespace: Service.Constants.APICommonNamespace.v2Request
37
+ }, Service.Constants.APICommonRequestConfig)
38
+ }));
39
+ this.api.v2Request.interceptors.request.use(addSipParams);
40
+
41
+ this.api.v3Request = this.request.create(Object.assign({
42
+ path: 'api/v3',
43
+ useUnpackData: true
44
+ }, Service.Constants.APICommonCreatorConfig, {
45
+ config: {
46
+ namespace: Service.Constants.APICommonNamespace.v3Request
47
+ }
48
+ }));
49
+ this.api.v3Request.interceptors.request.use(addSipParams);
50
+
51
+ this.api.sipRequest = this.request.create(Object.assign({
52
+ path: 'api/sip',
53
+ useUnpackData: false
54
+ }, Service.Constants.APICommonCreatorConfig, {
55
+ config: {
56
+ namespace: CommonServiceWithSip.Constants.APISipNamespace
57
+ }
58
+ }));
59
+ }
60
+ }
@@ -0,0 +1,36 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { RequestContainer } from 'seller-base';
3
+
4
+ /**
5
+ * CommonServiceWithSip 的 API 容器类型
6
+ */
7
+ export interface CommonWithSipRequestContainer extends RequestContainer {
8
+ sipRequest: AxiosInstance;
9
+ }
10
+
11
+ /**
12
+ * 通用 List 数据类型
13
+ */
14
+ export interface CommonListResponse<T> {
15
+ pageInfo: {
16
+ total: number,
17
+ pageNumber: number,
18
+ pageSize: number
19
+ };
20
+ list: T[];
21
+ }
22
+
23
+ /**
24
+ * 通用错误返回
25
+ */
26
+ export interface ErrorResponse {
27
+ code: number;
28
+ message: string;
29
+ }
30
+
31
+ /**
32
+ * 通用批量错误返回
33
+ */
34
+ export interface BatchI {
35
+ result: ErrorResponse[];
36
+ }
@@ -0,0 +1,6 @@
1
+ export { FeedbackService } from './service';
2
+ export {
3
+ Feedback,
4
+ FeedbackClassification,
5
+ FeedbackSubmitPage,
6
+ } from './types';
@@ -0,0 +1,73 @@
1
+ import { Service, ServiceModule, APIPromise, APIExternalPromise } from 'seller-base';
2
+ import { Feedback, FeedbackClassification, FeedbackSubmitPage, FileObject, FeedbackNewClassification } from './types';
3
+
4
+ export class FeedbackService extends ServiceModule {
5
+ public static $instance: FeedbackService;
6
+
7
+ constructor(service: Service) {
8
+ super(service);
9
+ this.name = 'feedback';
10
+ FeedbackService.$instance = this;
11
+ }
12
+
13
+ protected getRequestConfig() {
14
+ return {
15
+ miscRequest: {
16
+ path: 'api/sellermisc',
17
+ useUnpackData: true,
18
+ }
19
+ };
20
+ }
21
+
22
+ /**
23
+ * 卖家反馈
24
+ *
25
+ * @see https://api.seller.shopee.io/project/378/interface/api/22224
26
+ */
27
+ public async addFeedback(data: Feedback): APIPromise {
28
+ return this.api.miscRequest.post('/feedback/add/', data) as APIExternalPromise;
29
+ }
30
+
31
+ /**
32
+ * 获取feedback产品列表
33
+ *
34
+ * @see https://api.seller.shopee.io/project/378/interface/api/22242
35
+ */
36
+ public async getFeedbackClassifications(): APIPromise<FeedbackClassification[]> {
37
+ return this.api.miscRequest.get('/feedback/classification/list/') as APIExternalPromise<FeedbackClassification[]>;
38
+ }
39
+
40
+ public async getNewFeedbackClassifications(): APIPromise<FeedbackNewClassification[]> {
41
+ return this.api.miscRequest.get('/feedback/classification_new/list/') as APIExternalPromise<FeedbackNewClassification[]>;
42
+ }
43
+
44
+ /**
45
+ * 获取feedbackt提交页列表
46
+ *
47
+ * @see https://api.seller.shopee.io/project/378/interface/api/22446
48
+ */
49
+ public async getFeedbackSubmitPages(): APIPromise<FeedbackSubmitPage[]> {
50
+ return this.api.miscRequest.get('/feedback/submit_page/list/', { skipError: true }) as APIExternalPromise<FeedbackSubmitPage[]>;
51
+ }
52
+
53
+ public async getFeedbackTypes(): APIPromise<string[]> {
54
+ return this.api.miscRequest.get('/feedback/type/list/') as APIExternalPromise<string[]>;
55
+ }
56
+
57
+ public async uploadImage(file: File, callback: (percentage: number) => void): Promise<{ data: FileObject }> {
58
+ const formData = new FormData();
59
+ formData.append('file', file);
60
+ return this.api.miscRequest.post('/feedback_file/upload/?is_temp_file=false', formData, {
61
+ headers: {
62
+ 'Content-Type': 'multipart/form-data',
63
+ },
64
+ onUploadProgress(e: any) {
65
+ if (e.total > 0) {
66
+ e.percent = Math.floor(e.loaded / e.total * 100);
67
+ }
68
+ callback(e.percent);
69
+ }
70
+ });
71
+ }
72
+
73
+ }