@congminh1254/shopee-sdk 0.10.0 → 1.0.0

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.
Files changed (133) hide show
  1. package/README.md +172 -36
  2. package/lib/fetch.js +13 -0
  3. package/lib/fetch.js.map +1 -1
  4. package/lib/managers/add-on-deal.manager.d.ts +140 -0
  5. package/lib/managers/add-on-deal.manager.js +240 -0
  6. package/lib/managers/add-on-deal.manager.js.map +1 -0
  7. package/lib/managers/ads.manager.d.ts +217 -1
  8. package/lib/managers/ads.manager.js +312 -0
  9. package/lib/managers/ads.manager.js.map +1 -1
  10. package/lib/managers/bundle-deal.manager.d.ts +106 -0
  11. package/lib/managers/bundle-deal.manager.js +178 -0
  12. package/lib/managers/bundle-deal.manager.js.map +1 -0
  13. package/lib/managers/discount.manager.d.ts +102 -0
  14. package/lib/managers/discount.manager.js +167 -0
  15. package/lib/managers/discount.manager.js.map +1 -0
  16. package/lib/managers/fbs.manager.d.ts +115 -0
  17. package/lib/managers/fbs.manager.js +145 -0
  18. package/lib/managers/fbs.manager.js.map +1 -0
  19. package/lib/managers/first-mile.manager.d.ts +150 -0
  20. package/lib/managers/first-mile.manager.js +264 -0
  21. package/lib/managers/first-mile.manager.js.map +1 -0
  22. package/lib/managers/follow-prize.manager.d.ts +108 -0
  23. package/lib/managers/follow-prize.manager.js +152 -0
  24. package/lib/managers/follow-prize.manager.js.map +1 -0
  25. package/lib/managers/global-product.manager.d.ts +664 -0
  26. package/lib/managers/global-product.manager.js +904 -0
  27. package/lib/managers/global-product.manager.js.map +1 -0
  28. package/lib/managers/index.d.ts +17 -1
  29. package/lib/managers/index.js +17 -1
  30. package/lib/managers/index.js.map +1 -1
  31. package/lib/managers/livestream.manager.d.ts +377 -0
  32. package/lib/managers/livestream.manager.js +529 -0
  33. package/lib/managers/livestream.manager.js.map +1 -0
  34. package/lib/managers/logistics.manager.d.ts +267 -1
  35. package/lib/managers/logistics.manager.js +544 -0
  36. package/lib/managers/logistics.manager.js.map +1 -1
  37. package/lib/managers/media-space.manager.d.ts +179 -0
  38. package/lib/managers/media-space.manager.js +220 -0
  39. package/lib/managers/media-space.manager.js.map +1 -0
  40. package/lib/managers/media.manager.d.ts +226 -0
  41. package/lib/managers/media.manager.js +274 -0
  42. package/lib/managers/media.manager.js.map +1 -0
  43. package/lib/managers/merchant.manager.d.ts +100 -0
  44. package/lib/managers/merchant.manager.js +144 -0
  45. package/lib/managers/merchant.manager.js.map +1 -0
  46. package/lib/managers/order.manager.d.ts +213 -1
  47. package/lib/managers/order.manager.js +305 -0
  48. package/lib/managers/order.manager.js.map +1 -1
  49. package/lib/managers/payment.manager.d.ts +186 -1
  50. package/lib/managers/payment.manager.js +288 -0
  51. package/lib/managers/payment.manager.js.map +1 -1
  52. package/lib/managers/returns.manager.d.ts +200 -0
  53. package/lib/managers/returns.manager.js +300 -0
  54. package/lib/managers/returns.manager.js.map +1 -0
  55. package/lib/managers/sbs.manager.d.ts +112 -0
  56. package/lib/managers/sbs.manager.js +149 -0
  57. package/lib/managers/sbs.manager.js.map +1 -0
  58. package/lib/managers/shop-category.manager.d.ts +207 -0
  59. package/lib/managers/shop-category.manager.js +258 -0
  60. package/lib/managers/shop-category.manager.js.map +1 -0
  61. package/lib/managers/shop-flash-sale.manager.d.ts +242 -0
  62. package/lib/managers/shop-flash-sale.manager.js +321 -0
  63. package/lib/managers/shop-flash-sale.manager.js.map +1 -0
  64. package/lib/managers/shop.manager.d.ts +173 -0
  65. package/lib/managers/shop.manager.js +217 -0
  66. package/lib/managers/shop.manager.js.map +1 -0
  67. package/lib/managers/top-picks.manager.d.ts +62 -0
  68. package/lib/managers/top-picks.manager.js +91 -0
  69. package/lib/managers/top-picks.manager.js.map +1 -0
  70. package/lib/schemas/add-on-deal.d.ts +390 -0
  71. package/lib/schemas/add-on-deal.js +45 -0
  72. package/lib/schemas/add-on-deal.js.map +1 -0
  73. package/lib/schemas/ads.d.ts +437 -0
  74. package/lib/schemas/bundle-deal.d.ts +300 -0
  75. package/lib/schemas/bundle-deal.js +27 -0
  76. package/lib/schemas/bundle-deal.js.map +1 -0
  77. package/lib/schemas/discount.d.ts +334 -0
  78. package/lib/schemas/discount.js +15 -0
  79. package/lib/schemas/discount.js.map +1 -0
  80. package/lib/schemas/fbs.d.ts +117 -0
  81. package/lib/schemas/fbs.js +2 -0
  82. package/lib/schemas/fbs.js.map +1 -0
  83. package/lib/schemas/first-mile.d.ts +551 -0
  84. package/lib/schemas/first-mile.js +2 -0
  85. package/lib/schemas/first-mile.js.map +1 -0
  86. package/lib/schemas/follow-prize.d.ts +198 -0
  87. package/lib/schemas/follow-prize.js +27 -0
  88. package/lib/schemas/follow-prize.js.map +1 -0
  89. package/lib/schemas/global-product.d.ts +1127 -0
  90. package/lib/schemas/global-product.js +2 -0
  91. package/lib/schemas/global-product.js.map +1 -0
  92. package/lib/schemas/index.d.ts +13 -0
  93. package/lib/schemas/index.js +17 -0
  94. package/lib/schemas/index.js.map +1 -1
  95. package/lib/schemas/livestream.d.ts +649 -0
  96. package/lib/schemas/livestream.js +2 -0
  97. package/lib/schemas/livestream.js.map +1 -0
  98. package/lib/schemas/logistics.d.ts +979 -0
  99. package/lib/schemas/logistics.js +13 -0
  100. package/lib/schemas/logistics.js.map +1 -1
  101. package/lib/schemas/media-space.d.ts +189 -0
  102. package/lib/schemas/media-space.js +2 -0
  103. package/lib/schemas/media-space.js.map +1 -0
  104. package/lib/schemas/media.d.ts +230 -0
  105. package/lib/schemas/media.js +2 -0
  106. package/lib/schemas/media.js.map +1 -0
  107. package/lib/schemas/merchant.d.ts +236 -0
  108. package/lib/schemas/merchant.js +2 -0
  109. package/lib/schemas/merchant.js.map +1 -0
  110. package/lib/schemas/order.d.ts +431 -0
  111. package/lib/schemas/payment.d.ts +397 -0
  112. package/lib/schemas/returns.d.ts +632 -0
  113. package/lib/schemas/returns.js +63 -0
  114. package/lib/schemas/returns.js.map +1 -0
  115. package/lib/schemas/sbs.d.ts +484 -0
  116. package/lib/schemas/sbs.js +2 -0
  117. package/lib/schemas/sbs.js.map +1 -0
  118. package/lib/schemas/shop-category.d.ts +176 -0
  119. package/lib/schemas/shop-category.js +2 -0
  120. package/lib/schemas/shop-category.js.map +1 -0
  121. package/lib/schemas/shop-flash-sale.d.ts +473 -0
  122. package/lib/schemas/shop-flash-sale.js +43 -0
  123. package/lib/schemas/shop-flash-sale.js.map +1 -0
  124. package/lib/schemas/shop.d.ts +250 -0
  125. package/lib/schemas/shop.js +2 -0
  126. package/lib/schemas/shop.js.map +1 -0
  127. package/lib/schemas/top-picks.d.ts +99 -0
  128. package/lib/schemas/top-picks.js +2 -0
  129. package/lib/schemas/top-picks.js.map +1 -0
  130. package/lib/sdk.d.ts +34 -0
  131. package/lib/sdk.js +34 -0
  132. package/lib/sdk.js.map +1 -1
  133. package/package.json +2 -4
@@ -0,0 +1,179 @@
1
+ import { ShopeeConfig } from "../sdk.js";
2
+ import { UploadImageParams, UploadImageResponse, InitVideoUploadParams, InitVideoUploadResponse, UploadVideoPartParams, UploadVideoPartResponse, CompleteVideoUploadParams, CompleteVideoUploadResponse, CancelVideoUploadParams, CancelVideoUploadResponse, GetVideoUploadResultParams, GetVideoUploadResultResponse } from "../schemas/media-space.js";
3
+ import { BaseManager } from "./base.manager.js";
4
+ /**
5
+ * MediaSpaceManager handles media file uploads (images and videos) to Shopee's media space.
6
+ *
7
+ * This manager provides functionality for:
8
+ * - Uploading images with different scenes and aspect ratios
9
+ * - Multi-part video upload with session management
10
+ * - Video transcoding status tracking
11
+ * - Video upload cancellation
12
+ */
13
+ export declare class MediaSpaceManager extends BaseManager {
14
+ constructor(config: ShopeeConfig);
15
+ /**
16
+ * Upload multiple image files to MediaSpace (less than 9 images).
17
+ *
18
+ * @param params - Parameters for image upload
19
+ * @param params.scene - The scene where the picture is used ('normal' for item images, 'desc' for descriptions)
20
+ * @param params.ratio - Image aspect ratio ('1:1' or '3:4', only for whitelisted sellers)
21
+ * @param params.image - Image files (Max 10.0 MB each, formats: JPG, JPEG, PNG)
22
+ * @returns Promise with uploaded image information including image IDs and URLs
23
+ *
24
+ * @remarks
25
+ * This API requires multipart/form-data content type.
26
+ * - normal scene: Images will be processed as square images (recommended for item images)
27
+ * - desc scene: Images will not be processed (recommended for extend_description)
28
+ *
29
+ * @throws {Error} When the API request fails or returns an error
30
+ * - error_tier_img_partial: Internal error, please contact openapi team
31
+ * - error_tier_img_old_app: Internal error, please contact openapi team
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const result = await sdk.mediaSpace.uploadImage({
36
+ * scene: 'normal',
37
+ * ratio: '1:1',
38
+ * image: imageFile
39
+ * });
40
+ * console.log('Uploaded image ID:', result.response.image_info_list[0].image_info.image_id);
41
+ * ```
42
+ */
43
+ uploadImage(params: UploadImageParams): Promise<UploadImageResponse>;
44
+ /**
45
+ * Initiate video upload session.
46
+ *
47
+ * @param params - Parameters for initializing video upload
48
+ * @param params.file_md5 - MD5 hash of the video file
49
+ * @param params.file_size - Size of video file in bytes (maximum 30MB)
50
+ * @returns Promise with video_upload_id for subsequent upload operations
51
+ *
52
+ * @remarks
53
+ * Video duration should be between 10s and 60s (inclusive).
54
+ * Use the returned video_upload_id for uploading video parts and completing the upload.
55
+ *
56
+ * @throws {Error} When the API request fails or returns an error
57
+ * - error_file_size: File size is too large. Video size should be less than 30M
58
+ * - error_param: Invalid parameter
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const result = await sdk.mediaSpace.initVideoUpload({
63
+ * file_md5: '2abf0b6e5ff90ff24437a0808f171a93',
64
+ * file_size: 1261876
65
+ * });
66
+ * const uploadId = result.response.video_upload_id;
67
+ * ```
68
+ */
69
+ initVideoUpload(params: InitVideoUploadParams): Promise<InitVideoUploadResponse>;
70
+ /**
71
+ * Upload video file by part using the upload_id from initVideoUpload.
72
+ *
73
+ * @param params - Parameters for uploading video part
74
+ * @param params.video_upload_id - The video_upload_id from init_video_upload response
75
+ * @param params.part_seq - Sequence of the current part, starts from 0
76
+ * @param params.content_md5 - MD5 hash of this part
77
+ * @param params.part_content - The content of this part of file
78
+ * @returns Promise indicating success or failure of the part upload
79
+ *
80
+ * @remarks
81
+ * The request Content-Type should be multipart/form-data.
82
+ * Part size should be exactly 4MB, except for the last part of file.
83
+ *
84
+ * @throws {Error} When the API request fails or returns an error
85
+ * - error_invalid_upload_id: Invalid upload_id
86
+ * - error_invalid_part_seq: Invalid part_seq
87
+ * - error_invalid_part_size: Invalid part_size
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * await sdk.mediaSpace.uploadVideoPart({
92
+ * video_upload_id: 'sg_90ce045e-fd92-4f0b-97a4-eda40546cd9f_000000',
93
+ * part_seq: 0,
94
+ * content_md5: '3bb08579fffbfc13ed9d23cda8bbb46d',
95
+ * part_content: videoPart
96
+ * });
97
+ * ```
98
+ */
99
+ uploadVideoPart(params: UploadVideoPartParams): Promise<UploadVideoPartResponse>;
100
+ /**
101
+ * Complete the video upload and start the transcoding process when all parts are uploaded successfully.
102
+ *
103
+ * @param params - Parameters for completing video upload
104
+ * @param params.video_upload_id - The ID of this upload session from init_video_upload
105
+ * @param params.part_seq_list - All uploaded sequence numbers
106
+ * @param params.report_data - Upload performance tracking data
107
+ * @returns Promise indicating completion status
108
+ *
109
+ * @remarks
110
+ * Call this API after all video parts have been successfully uploaded.
111
+ * The video will be transcoded and ready for use in item operations once transcoding completes.
112
+ *
113
+ * @throws {Error} When the API request fails or returns an error
114
+ * - error_invalid_upload_id: Invalid upload_id
115
+ * - error_already_completed: Upload already completed
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * await sdk.mediaSpace.completeVideoUpload({
120
+ * video_upload_id: 'sg_90ce045e-fd92-4f0b-97a4-eda40546cd9f_000000',
121
+ * part_seq_list: [0, 1, 2, 3],
122
+ * report_data: { upload_cost: 11832 }
123
+ * });
124
+ * ```
125
+ */
126
+ completeVideoUpload(params: CompleteVideoUploadParams): Promise<CompleteVideoUploadResponse>;
127
+ /**
128
+ * Query the upload status and result of video upload.
129
+ *
130
+ * @param params - Parameters for getting video upload result
131
+ * @param params.video_upload_id - The video_upload_id from init_video_upload response
132
+ * @returns Promise with upload status and video information (if transcoding is complete)
133
+ *
134
+ * @remarks
135
+ * Possible status values:
136
+ * - INITIATED: Waiting for part uploading and/or complete_video_upload call
137
+ * - TRANSCODING: Transcoding the video file
138
+ * - SUCCEEDED: Transcoding completed, ready for use
139
+ * - FAILED: Upload failed, check message field for details
140
+ * - CANCELLED: Upload was cancelled
141
+ *
142
+ * @throws {Error} When the API request fails or returns an error
143
+ * - error_invalid_upload_id: Invalid upload_id
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * const result = await sdk.mediaSpace.getVideoUploadResult({
148
+ * video_upload_id: 'sg_90ce045e-fd92-4f0b-97a4-eda40546cd9f_000000'
149
+ * });
150
+ * if (result.response.status === 'SUCCEEDED') {
151
+ * console.log('Video URL:', result.response.video_info.video_url_list[0].video_url);
152
+ * }
153
+ * ```
154
+ */
155
+ getVideoUploadResult(params: GetVideoUploadResultParams): Promise<GetVideoUploadResultResponse>;
156
+ /**
157
+ * Cancel a video upload session.
158
+ *
159
+ * @param params - Parameters for canceling video upload
160
+ * @param params.video_upload_id - The ID of this upload session from init_video_upload
161
+ * @returns Promise indicating cancellation status
162
+ *
163
+ * @remarks
164
+ * Use this API to cancel an ongoing video upload session if needed.
165
+ * After cancellation, the video_upload_id cannot be used for further operations.
166
+ *
167
+ * @throws {Error} When the API request fails or returns an error
168
+ * - error_invalid_upload_id: Invalid upload_id
169
+ * - error_already_completed: Upload already completed
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * await sdk.mediaSpace.cancelVideoUpload({
174
+ * video_upload_id: 'sg_90ce045e-fd92-4f0b-97a4-eda40546cd9f_000000'
175
+ * });
176
+ * ```
177
+ */
178
+ cancelVideoUpload(params: CancelVideoUploadParams): Promise<CancelVideoUploadResponse>;
179
+ }
@@ -0,0 +1,220 @@
1
+ import { ShopeeFetch } from "../fetch.js";
2
+ import { BaseManager } from "./base.manager.js";
3
+ /**
4
+ * MediaSpaceManager handles media file uploads (images and videos) to Shopee's media space.
5
+ *
6
+ * This manager provides functionality for:
7
+ * - Uploading images with different scenes and aspect ratios
8
+ * - Multi-part video upload with session management
9
+ * - Video transcoding status tracking
10
+ * - Video upload cancellation
11
+ */
12
+ export class MediaSpaceManager extends BaseManager {
13
+ constructor(config) {
14
+ super(config);
15
+ }
16
+ /**
17
+ * Upload multiple image files to MediaSpace (less than 9 images).
18
+ *
19
+ * @param params - Parameters for image upload
20
+ * @param params.scene - The scene where the picture is used ('normal' for item images, 'desc' for descriptions)
21
+ * @param params.ratio - Image aspect ratio ('1:1' or '3:4', only for whitelisted sellers)
22
+ * @param params.image - Image files (Max 10.0 MB each, formats: JPG, JPEG, PNG)
23
+ * @returns Promise with uploaded image information including image IDs and URLs
24
+ *
25
+ * @remarks
26
+ * This API requires multipart/form-data content type.
27
+ * - normal scene: Images will be processed as square images (recommended for item images)
28
+ * - desc scene: Images will not be processed (recommended for extend_description)
29
+ *
30
+ * @throws {Error} When the API request fails or returns an error
31
+ * - error_tier_img_partial: Internal error, please contact openapi team
32
+ * - error_tier_img_old_app: Internal error, please contact openapi team
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const result = await sdk.mediaSpace.uploadImage({
37
+ * scene: 'normal',
38
+ * ratio: '1:1',
39
+ * image: imageFile
40
+ * });
41
+ * console.log('Uploaded image ID:', result.response.image_info_list[0].image_info.image_id);
42
+ * ```
43
+ */
44
+ async uploadImage(params) {
45
+ const response = await ShopeeFetch.fetch(this.config, "/media_space/upload_image", {
46
+ method: "POST",
47
+ body: params,
48
+ });
49
+ return response;
50
+ }
51
+ /**
52
+ * Initiate video upload session.
53
+ *
54
+ * @param params - Parameters for initializing video upload
55
+ * @param params.file_md5 - MD5 hash of the video file
56
+ * @param params.file_size - Size of video file in bytes (maximum 30MB)
57
+ * @returns Promise with video_upload_id for subsequent upload operations
58
+ *
59
+ * @remarks
60
+ * Video duration should be between 10s and 60s (inclusive).
61
+ * Use the returned video_upload_id for uploading video parts and completing the upload.
62
+ *
63
+ * @throws {Error} When the API request fails or returns an error
64
+ * - error_file_size: File size is too large. Video size should be less than 30M
65
+ * - error_param: Invalid parameter
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * const result = await sdk.mediaSpace.initVideoUpload({
70
+ * file_md5: '2abf0b6e5ff90ff24437a0808f171a93',
71
+ * file_size: 1261876
72
+ * });
73
+ * const uploadId = result.response.video_upload_id;
74
+ * ```
75
+ */
76
+ async initVideoUpload(params) {
77
+ const response = await ShopeeFetch.fetch(this.config, "/media_space/init_video_upload", {
78
+ method: "POST",
79
+ auth: true,
80
+ body: params,
81
+ });
82
+ return response;
83
+ }
84
+ /**
85
+ * Upload video file by part using the upload_id from initVideoUpload.
86
+ *
87
+ * @param params - Parameters for uploading video part
88
+ * @param params.video_upload_id - The video_upload_id from init_video_upload response
89
+ * @param params.part_seq - Sequence of the current part, starts from 0
90
+ * @param params.content_md5 - MD5 hash of this part
91
+ * @param params.part_content - The content of this part of file
92
+ * @returns Promise indicating success or failure of the part upload
93
+ *
94
+ * @remarks
95
+ * The request Content-Type should be multipart/form-data.
96
+ * Part size should be exactly 4MB, except for the last part of file.
97
+ *
98
+ * @throws {Error} When the API request fails or returns an error
99
+ * - error_invalid_upload_id: Invalid upload_id
100
+ * - error_invalid_part_seq: Invalid part_seq
101
+ * - error_invalid_part_size: Invalid part_size
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * await sdk.mediaSpace.uploadVideoPart({
106
+ * video_upload_id: 'sg_90ce045e-fd92-4f0b-97a4-eda40546cd9f_000000',
107
+ * part_seq: 0,
108
+ * content_md5: '3bb08579fffbfc13ed9d23cda8bbb46d',
109
+ * part_content: videoPart
110
+ * });
111
+ * ```
112
+ */
113
+ async uploadVideoPart(params) {
114
+ const response = await ShopeeFetch.fetch(this.config, "/media_space/upload_video_part", {
115
+ method: "POST",
116
+ body: params,
117
+ });
118
+ return response;
119
+ }
120
+ /**
121
+ * Complete the video upload and start the transcoding process when all parts are uploaded successfully.
122
+ *
123
+ * @param params - Parameters for completing video upload
124
+ * @param params.video_upload_id - The ID of this upload session from init_video_upload
125
+ * @param params.part_seq_list - All uploaded sequence numbers
126
+ * @param params.report_data - Upload performance tracking data
127
+ * @returns Promise indicating completion status
128
+ *
129
+ * @remarks
130
+ * Call this API after all video parts have been successfully uploaded.
131
+ * The video will be transcoded and ready for use in item operations once transcoding completes.
132
+ *
133
+ * @throws {Error} When the API request fails or returns an error
134
+ * - error_invalid_upload_id: Invalid upload_id
135
+ * - error_already_completed: Upload already completed
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * await sdk.mediaSpace.completeVideoUpload({
140
+ * video_upload_id: 'sg_90ce045e-fd92-4f0b-97a4-eda40546cd9f_000000',
141
+ * part_seq_list: [0, 1, 2, 3],
142
+ * report_data: { upload_cost: 11832 }
143
+ * });
144
+ * ```
145
+ */
146
+ async completeVideoUpload(params) {
147
+ const response = await ShopeeFetch.fetch(this.config, "/media_space/complete_video_upload", {
148
+ method: "POST",
149
+ body: params,
150
+ });
151
+ return response;
152
+ }
153
+ /**
154
+ * Query the upload status and result of video upload.
155
+ *
156
+ * @param params - Parameters for getting video upload result
157
+ * @param params.video_upload_id - The video_upload_id from init_video_upload response
158
+ * @returns Promise with upload status and video information (if transcoding is complete)
159
+ *
160
+ * @remarks
161
+ * Possible status values:
162
+ * - INITIATED: Waiting for part uploading and/or complete_video_upload call
163
+ * - TRANSCODING: Transcoding the video file
164
+ * - SUCCEEDED: Transcoding completed, ready for use
165
+ * - FAILED: Upload failed, check message field for details
166
+ * - CANCELLED: Upload was cancelled
167
+ *
168
+ * @throws {Error} When the API request fails or returns an error
169
+ * - error_invalid_upload_id: Invalid upload_id
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * const result = await sdk.mediaSpace.getVideoUploadResult({
174
+ * video_upload_id: 'sg_90ce045e-fd92-4f0b-97a4-eda40546cd9f_000000'
175
+ * });
176
+ * if (result.response.status === 'SUCCEEDED') {
177
+ * console.log('Video URL:', result.response.video_info.video_url_list[0].video_url);
178
+ * }
179
+ * ```
180
+ */
181
+ async getVideoUploadResult(params) {
182
+ const response = await ShopeeFetch.fetch(this.config, "/media_space/get_video_upload_result", {
183
+ method: "GET",
184
+ auth: true,
185
+ params,
186
+ });
187
+ return response;
188
+ }
189
+ /**
190
+ * Cancel a video upload session.
191
+ *
192
+ * @param params - Parameters for canceling video upload
193
+ * @param params.video_upload_id - The ID of this upload session from init_video_upload
194
+ * @returns Promise indicating cancellation status
195
+ *
196
+ * @remarks
197
+ * Use this API to cancel an ongoing video upload session if needed.
198
+ * After cancellation, the video_upload_id cannot be used for further operations.
199
+ *
200
+ * @throws {Error} When the API request fails or returns an error
201
+ * - error_invalid_upload_id: Invalid upload_id
202
+ * - error_already_completed: Upload already completed
203
+ *
204
+ * @example
205
+ * ```typescript
206
+ * await sdk.mediaSpace.cancelVideoUpload({
207
+ * video_upload_id: 'sg_90ce045e-fd92-4f0b-97a4-eda40546cd9f_000000'
208
+ * });
209
+ * ```
210
+ */
211
+ async cancelVideoUpload(params) {
212
+ const response = await ShopeeFetch.fetch(this.config, "/media_space/cancel_video_upload", {
213
+ method: "POST",
214
+ auth: true,
215
+ body: params,
216
+ });
217
+ return response;
218
+ }
219
+ }
220
+ //# sourceMappingURL=media-space.manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-space.manager.js","sourceRoot":"","sources":["../../src/managers/media-space.manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAe1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAChD,YAAY,MAAoB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,KAAK,CAAC,WAAW,CAAC,MAAyB;QACzC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,2BAA2B,EAC3B;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,KAAK,CAAC,eAAe,CAAC,MAA6B;QACjD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,gCAAgC,EAChC;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,KAAK,CAAC,eAAe,CAAC,MAA6B;QACjD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,gCAAgC,EAChC;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,KAAK,CAAC,mBAAmB,CACvB,MAAiC;QAEjC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,oCAAoC,EACpC;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,KAAK,CAAC,oBAAoB,CACxB,MAAkC;QAElC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,sCAAsC,EACtC;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI;YACV,MAAM;SACP,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,KAAK,CAAC,iBAAiB,CAAC,MAA+B;QACrD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,kCAAkC,EAClC;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
@@ -0,0 +1,226 @@
1
+ import { ShopeeConfig } from "../sdk.js";
2
+ import { BaseManager } from "./base.manager.js";
3
+ import { UploadMediaImageParams, UploadMediaImageResponse, UploadImageParams, UploadImageResponse, InitVideoUploadParams, InitVideoUploadResponse, UploadVideoPartParams, UploadVideoPartResponse, CompleteVideoUploadParams, CompleteVideoUploadResponse, GetVideoUploadResultParams, GetVideoUploadResultResponse, CancelVideoUploadParams, CancelVideoUploadResponse } from "../schemas/media.js";
4
+ /**
5
+ * MediaManager handles media upload operations for the Shopee API
6
+ *
7
+ * Provides methods for:
8
+ * - Image upload for various business scenarios
9
+ * - Video upload with multi-part upload support
10
+ * - Video upload status tracking
11
+ */
12
+ export declare class MediaManager extends BaseManager {
13
+ constructor(config: ShopeeConfig);
14
+ /**
15
+ * Upload images for specific business scenarios (e.g., returns)
16
+ *
17
+ * @param {UploadMediaImageParams} params - Parameters for uploading images
18
+ * @param {number} params.business - Business type (2 = Returns)
19
+ * @param {number} params.scene - Scene type (1 = Return Seller Self Arrange Pickup Proof)
20
+ * @param {string | Buffer | Array<string | Buffer>} params.images - Image files to upload
21
+ * @returns {Promise<UploadMediaImageResponse>} Response containing uploaded image information
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const result = await sdk.media.uploadMediaImage({
26
+ * business: 2,
27
+ * scene: 1,
28
+ * images: '/path/to/image.jpg'
29
+ * });
30
+ * console.log('Uploaded images:', result.response.image_list);
31
+ * ```
32
+ *
33
+ * **Restrictions:**
34
+ * - business = 2, scene = 1: Up to 3 images, max 10MB each, formats: JPG, JPEG, PNG
35
+ *
36
+ * @throws {Error} When the API request fails
37
+ */
38
+ uploadMediaImage(params: UploadMediaImageParams): Promise<UploadMediaImageResponse>;
39
+ /**
40
+ * Upload multiple image files for general use
41
+ *
42
+ * @param {UploadImageParams} params - Parameters for uploading images
43
+ * @param {string | Buffer | Array<string | Buffer>} params.image - Image files (up to 9 images)
44
+ * @param {string} [params.scene] - Scene type ("normal" or "desc")
45
+ * @param {string} [params.ratio] - Image ratio ("1:1" or "3:4", whitelisted sellers only)
46
+ * @returns {Promise<UploadImageResponse>} Response containing uploaded image information
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * // Upload product images (square processing)
51
+ * const result = await sdk.media.uploadImage({
52
+ * image: ['/path/to/image1.jpg', '/path/to/image2.jpg'],
53
+ * scene: 'normal',
54
+ * ratio: '1:1'
55
+ * });
56
+ *
57
+ * // Upload description images (no processing)
58
+ * const descResult = await sdk.media.uploadImage({
59
+ * image: '/path/to/desc-image.jpg',
60
+ * scene: 'desc'
61
+ * });
62
+ * ```
63
+ *
64
+ * **Image Requirements:**
65
+ * - Maximum: 9 images per request
66
+ * - Maximum size: 10MB per image
67
+ * - Formats: JPG, JPEG, PNG
68
+ * - Scene "normal": Image processed as square (recommended for item images)
69
+ * - Scene "desc": No processing (recommended for extended descriptions)
70
+ *
71
+ * @throws {Error} When the API request fails
72
+ */
73
+ uploadImage(params: UploadImageParams): Promise<UploadImageResponse>;
74
+ /**
75
+ * Initiate a video upload session
76
+ *
77
+ * @param {InitVideoUploadParams} params - Parameters for initiating video upload
78
+ * @param {string} params.file_md5 - MD5 hash of the video file
79
+ * @param {number} params.file_size - Size of video file in bytes (max 30MB)
80
+ * @returns {Promise<InitVideoUploadResponse>} Response containing video_upload_id
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * const result = await sdk.media.initVideoUpload({
85
+ * file_md5: '2abf0b6e5ff90ff24437a0808f171a93',
86
+ * file_size: 1261876
87
+ * });
88
+ * const videoUploadId = result.response.video_upload_id;
89
+ * ```
90
+ *
91
+ * **Video Requirements:**
92
+ * - Duration: 10-60 seconds (inclusive)
93
+ * - Maximum size: 30MB
94
+ * - Must upload by parts after initialization
95
+ *
96
+ * @throws {Error} When the API request fails
97
+ * - error_file_size: File size is too large (max 30MB)
98
+ */
99
+ initVideoUpload(params: InitVideoUploadParams): Promise<InitVideoUploadResponse>;
100
+ /**
101
+ * Upload a video file by parts
102
+ *
103
+ * @param {UploadVideoPartParams} params - Parameters for uploading video part
104
+ * @param {string} params.video_upload_id - Upload ID from initVideoUpload
105
+ * @param {number} params.part_seq - Sequence number starting from 0
106
+ * @param {string} params.content_md5 - MD5 hash of this part
107
+ * @param {string | Buffer} params.part_content - Content of this part
108
+ * @returns {Promise<UploadVideoPartResponse>} Response indicating upload success
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * // Upload video parts sequentially
113
+ * for (let i = 0; i < partCount; i++) {
114
+ * await sdk.media.uploadVideoPart({
115
+ * video_upload_id: videoUploadId,
116
+ * part_seq: i,
117
+ * content_md5: partMd5,
118
+ * part_content: partBuffer
119
+ * });
120
+ * }
121
+ * ```
122
+ *
123
+ * **Part Requirements:**
124
+ * - Part size: Exactly 4MB except for the last part
125
+ * - Must provide MD5 hash for each part
126
+ * - Upload parts sequentially starting from 0
127
+ *
128
+ * @throws {Error} When the API request fails
129
+ * - error_invalid_upload_id: Invalid upload_id
130
+ * - error_invalid_part_seq: Invalid part_seq
131
+ * - error_invalid_part_size: Invalid part_size
132
+ */
133
+ uploadVideoPart(params: UploadVideoPartParams): Promise<UploadVideoPartResponse>;
134
+ /**
135
+ * Complete the video upload and start transcoding
136
+ *
137
+ * @param {CompleteVideoUploadParams} params - Parameters for completing video upload
138
+ * @param {string} params.video_upload_id - Upload ID from initVideoUpload
139
+ * @param {number[]} params.part_seq_list - List of all uploaded part sequences
140
+ * @param {object} params.report_data - Upload performance tracking data
141
+ * @param {number} params.report_data.upload_cost - Upload time in milliseconds
142
+ * @returns {Promise<CompleteVideoUploadResponse>} Response indicating completion
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * const startTime = Date.now();
147
+ * // ... upload all parts ...
148
+ * const uploadCost = Date.now() - startTime;
149
+ *
150
+ * await sdk.media.completeVideoUpload({
151
+ * video_upload_id: videoUploadId,
152
+ * part_seq_list: [0, 1, 2, 3],
153
+ * report_data: {
154
+ * upload_cost: uploadCost
155
+ * }
156
+ * });
157
+ * ```
158
+ *
159
+ * **Notes:**
160
+ * - Call this after all parts are uploaded successfully
161
+ * - Transcoding process begins after this call
162
+ * - Use getVideoUploadResult to check transcoding status
163
+ *
164
+ * @throws {Error} When the API request fails
165
+ * - error_invalid_upload_id: Invalid upload_id
166
+ * - error_already_completed: Upload already completed
167
+ */
168
+ completeVideoUpload(params: CompleteVideoUploadParams): Promise<CompleteVideoUploadResponse>;
169
+ /**
170
+ * Query the upload status and result of a video upload
171
+ *
172
+ * @param {GetVideoUploadResultParams} params - Parameters for querying video status
173
+ * @param {string} params.video_upload_id - Upload ID from initVideoUpload
174
+ * @returns {Promise<GetVideoUploadResultResponse>} Response containing upload status and video info
175
+ *
176
+ * @example
177
+ * ```typescript
178
+ * const result = await sdk.media.getVideoUploadResult({
179
+ * video_upload_id: videoUploadId
180
+ * });
181
+ *
182
+ * if (result.response.status === 'SUCCEEDED') {
183
+ * console.log('Video URL:', result.response.video_info.video_url_list);
184
+ * console.log('Duration:', result.response.video_info.duration);
185
+ * } else if (result.response.status === 'FAILED') {
186
+ * console.error('Upload failed:', result.response.message);
187
+ * }
188
+ * ```
189
+ *
190
+ * **Upload Status:**
191
+ * - INITIATED: Waiting for parts or complete_video_upload call
192
+ * - TRANSCODING: Transcoding the video file
193
+ * - SUCCEEDED: Transcoding completed, video ready to use
194
+ * - FAILED: Upload failed, check message for details
195
+ * - CANCELLED: Upload was cancelled
196
+ *
197
+ * @throws {Error} When the API request fails
198
+ * - error_invalid_upload_id: Invalid upload_id
199
+ */
200
+ getVideoUploadResult(params: GetVideoUploadResultParams): Promise<GetVideoUploadResultResponse>;
201
+ /**
202
+ * Cancel a video upload session
203
+ *
204
+ * @param {CancelVideoUploadParams} params - Parameters for cancelling video upload
205
+ * @param {string} params.video_upload_id - Upload ID from initVideoUpload
206
+ * @returns {Promise<CancelVideoUploadResponse>} Response indicating cancellation
207
+ *
208
+ * @example
209
+ * ```typescript
210
+ * await sdk.media.cancelVideoUpload({
211
+ * video_upload_id: videoUploadId
212
+ * });
213
+ * console.log('Video upload cancelled');
214
+ * ```
215
+ *
216
+ * **Use Cases:**
217
+ * - Cancel upload on user request
218
+ * - Cancel failed upload to free resources
219
+ * - Cancel when upload takes too long
220
+ *
221
+ * @throws {Error} When the API request fails
222
+ * - error_invalid_upload_id: Invalid upload_id
223
+ * - error_already_completed: Upload already completed (cannot cancel)
224
+ */
225
+ cancelVideoUpload(params: CancelVideoUploadParams): Promise<CancelVideoUploadResponse>;
226
+ }