@bedelightful/upload-sdk 0.0.7

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 (239) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +132 -0
  3. package/dist/es/Exception/BaseException.js +14 -0
  4. package/dist/es/Exception/BaseException.js.map +1 -0
  5. package/dist/es/Exception/DownloadException.js +40 -0
  6. package/dist/es/Exception/DownloadException.js.map +1 -0
  7. package/dist/es/Exception/HttpException.js +50 -0
  8. package/dist/es/Exception/HttpException.js.map +1 -0
  9. package/dist/es/Exception/InitException.js +49 -0
  10. package/dist/es/Exception/InitException.js.map +1 -0
  11. package/dist/es/Exception/UploadException.js +50 -0
  12. package/dist/es/Exception/UploadException.js.map +1 -0
  13. package/dist/es/index.d.ts +867 -0
  14. package/dist/es/index.js +162 -0
  15. package/dist/es/index.js.map +1 -0
  16. package/dist/es/modules/Kodo/defaultUpload.js +38 -0
  17. package/dist/es/modules/Kodo/defaultUpload.js.map +1 -0
  18. package/dist/es/modules/Kodo/index.js +8 -0
  19. package/dist/es/modules/Kodo/index.js.map +1 -0
  20. package/dist/es/modules/Local/index.js +31 -0
  21. package/dist/es/modules/Local/index.js.map +1 -0
  22. package/dist/es/modules/MinIO/MultipartUpload.js +335 -0
  23. package/dist/es/modules/MinIO/MultipartUpload.js.map +1 -0
  24. package/dist/es/modules/MinIO/STSUpload.js +10 -0
  25. package/dist/es/modules/MinIO/STSUpload.js.map +1 -0
  26. package/dist/es/modules/MinIO/defaultUpload.js +124 -0
  27. package/dist/es/modules/MinIO/defaultUpload.js.map +1 -0
  28. package/dist/es/modules/MinIO/index.js +16 -0
  29. package/dist/es/modules/MinIO/index.js.map +1 -0
  30. package/dist/es/modules/OBS/MultipartUpload.js +269 -0
  31. package/dist/es/modules/OBS/MultipartUpload.js.map +1 -0
  32. package/dist/es/modules/OBS/STSUpload.js +71 -0
  33. package/dist/es/modules/OBS/STSUpload.js.map +1 -0
  34. package/dist/es/modules/OBS/defaultUpload.js +59 -0
  35. package/dist/es/modules/OBS/defaultUpload.js.map +1 -0
  36. package/dist/es/modules/OBS/index.js +16 -0
  37. package/dist/es/modules/OBS/index.js.map +1 -0
  38. package/dist/es/modules/OBS/utils/index.js +25 -0
  39. package/dist/es/modules/OBS/utils/index.js.map +1 -0
  40. package/dist/es/modules/OSS/MultipartUpload.js +232 -0
  41. package/dist/es/modules/OSS/MultipartUpload.js.map +1 -0
  42. package/dist/es/modules/OSS/STSUpload.js +48 -0
  43. package/dist/es/modules/OSS/STSUpload.js.map +1 -0
  44. package/dist/es/modules/OSS/defaultUpload.js +53 -0
  45. package/dist/es/modules/OSS/defaultUpload.js.map +1 -0
  46. package/dist/es/modules/OSS/index.js +16 -0
  47. package/dist/es/modules/OSS/index.js.map +1 -0
  48. package/dist/es/modules/OSS/utils/helper.js +137 -0
  49. package/dist/es/modules/OSS/utils/helper.js.map +1 -0
  50. package/dist/es/modules/OSS/utils/signature.js +96 -0
  51. package/dist/es/modules/OSS/utils/signature.js.map +1 -0
  52. package/dist/es/modules/TOS/MultipartUpload.js +288 -0
  53. package/dist/es/modules/TOS/MultipartUpload.js.map +1 -0
  54. package/dist/es/modules/TOS/STSUpload.js +92 -0
  55. package/dist/es/modules/TOS/STSUpload.js.map +1 -0
  56. package/dist/es/modules/TOS/defaultUpload.js +65 -0
  57. package/dist/es/modules/TOS/defaultUpload.js.map +1 -0
  58. package/dist/es/modules/TOS/index.js +16 -0
  59. package/dist/es/modules/TOS/index.js.map +1 -0
  60. package/dist/es/modules/TOS/utils/TosClientError.js +15 -0
  61. package/dist/es/modules/TOS/utils/TosClientError.js.map +1 -0
  62. package/dist/es/modules/TOS/utils/index.js +38 -0
  63. package/dist/es/modules/TOS/utils/index.js.map +1 -0
  64. package/dist/es/modules/TOS/utils/signatureV4.js +269 -0
  65. package/dist/es/modules/TOS/utils/signatureV4.js.map +1 -0
  66. package/dist/es/modules/TOS/utils/signatureV4Credentials.js +21 -0
  67. package/dist/es/modules/TOS/utils/signatureV4Credentials.js.map +1 -0
  68. package/dist/es/modules/TOS/utils/universal/crypto.browser.js +56 -0
  69. package/dist/es/modules/TOS/utils/universal/crypto.browser.js.map +1 -0
  70. package/dist/es/modules/TOS/utils/utils.js +18 -0
  71. package/dist/es/modules/TOS/utils/utils.js.map +1 -0
  72. package/dist/es/modules/index.js +20 -0
  73. package/dist/es/modules/index.js.map +1 -0
  74. package/dist/es/types/Kodo.js +1 -0
  75. package/dist/es/types/Kodo.js.map +1 -0
  76. package/dist/es/types/Local.js +1 -0
  77. package/dist/es/types/Local.js.map +1 -0
  78. package/dist/es/types/MinIO.js +1 -0
  79. package/dist/es/types/MinIO.js.map +1 -0
  80. package/dist/es/types/OBS.js +8 -0
  81. package/dist/es/types/OBS.js.map +1 -0
  82. package/dist/es/types/OSS.js +1 -0
  83. package/dist/es/types/OSS.js.map +1 -0
  84. package/dist/es/types/TOS.js +1 -0
  85. package/dist/es/types/TOS.js.map +1 -0
  86. package/dist/es/types/error.js +1 -0
  87. package/dist/es/types/error.js.map +1 -0
  88. package/dist/es/types/index.js +13 -0
  89. package/dist/es/types/index.js.map +1 -0
  90. package/dist/es/types/log.js +1 -0
  91. package/dist/es/types/log.js.map +1 -0
  92. package/dist/es/types/request.js +1 -0
  93. package/dist/es/types/request.js.map +1 -0
  94. package/dist/es/utils/EventEmitter.js +32 -0
  95. package/dist/es/utils/EventEmitter.js.map +1 -0
  96. package/dist/es/utils/UploadManger.js +276 -0
  97. package/dist/es/utils/UploadManger.js.map +1 -0
  98. package/dist/es/utils/UploadTask.js +13 -0
  99. package/dist/es/utils/UploadTask.js.map +1 -0
  100. package/dist/es/utils/checkDataFormat.js +41 -0
  101. package/dist/es/utils/checkDataFormat.js.map +1 -0
  102. package/dist/es/utils/global.js +83 -0
  103. package/dist/es/utils/global.js.map +1 -0
  104. package/dist/es/utils/index.js +20 -0
  105. package/dist/es/utils/index.js.map +1 -0
  106. package/dist/es/utils/logPubSub.js +59 -0
  107. package/dist/es/utils/logPubSub.js.map +1 -0
  108. package/dist/es/utils/multipart.js +159 -0
  109. package/dist/es/utils/multipart.js.map +1 -0
  110. package/dist/es/utils/nanoid.js +10 -0
  111. package/dist/es/utils/nanoid.js.map +1 -0
  112. package/dist/es/utils/regExpUtil.js +21 -0
  113. package/dist/es/utils/regExpUtil.js.map +1 -0
  114. package/dist/es/utils/request.js +234 -0
  115. package/dist/es/utils/request.js.map +1 -0
  116. package/dist/es/utils/response.js +20 -0
  117. package/dist/es/utils/response.js.map +1 -0
  118. package/dist/index.d.ts +867 -0
  119. package/dist/index.js +60913 -0
  120. package/dist/index.js.map +1 -0
  121. package/dist/index.min.js +130 -0
  122. package/dist/index.min.js.map +1 -0
  123. package/dist/lib/Exception/BaseException.js +37 -0
  124. package/dist/lib/Exception/BaseException.js.map +1 -0
  125. package/dist/lib/Exception/DownloadException.js +65 -0
  126. package/dist/lib/Exception/DownloadException.js.map +1 -0
  127. package/dist/lib/Exception/HttpException.js +75 -0
  128. package/dist/lib/Exception/HttpException.js.map +1 -0
  129. package/dist/lib/Exception/InitException.js +73 -0
  130. package/dist/lib/Exception/InitException.js.map +1 -0
  131. package/dist/lib/Exception/UploadException.js +75 -0
  132. package/dist/lib/Exception/UploadException.js.map +1 -0
  133. package/dist/lib/index.d.cts +867 -0
  134. package/dist/lib/index.js +203 -0
  135. package/dist/lib/index.js.map +1 -0
  136. package/dist/lib/modules/Kodo/defaultUpload.js +61 -0
  137. package/dist/lib/modules/Kodo/defaultUpload.js.map +1 -0
  138. package/dist/lib/modules/Kodo/index.js +28 -0
  139. package/dist/lib/modules/Kodo/index.js.map +1 -0
  140. package/dist/lib/modules/Local/index.js +50 -0
  141. package/dist/lib/modules/Local/index.js.map +1 -0
  142. package/dist/lib/modules/MinIO/MultipartUpload.js +357 -0
  143. package/dist/lib/modules/MinIO/MultipartUpload.js.map +1 -0
  144. package/dist/lib/modules/MinIO/STSUpload.js +33 -0
  145. package/dist/lib/modules/MinIO/STSUpload.js.map +1 -0
  146. package/dist/lib/modules/MinIO/defaultUpload.js +158 -0
  147. package/dist/lib/modules/MinIO/defaultUpload.js.map +1 -0
  148. package/dist/lib/modules/MinIO/index.js +35 -0
  149. package/dist/lib/modules/MinIO/index.js.map +1 -0
  150. package/dist/lib/modules/OBS/MultipartUpload.js +296 -0
  151. package/dist/lib/modules/OBS/MultipartUpload.js.map +1 -0
  152. package/dist/lib/modules/OBS/STSUpload.js +104 -0
  153. package/dist/lib/modules/OBS/STSUpload.js.map +1 -0
  154. package/dist/lib/modules/OBS/defaultUpload.js +88 -0
  155. package/dist/lib/modules/OBS/defaultUpload.js.map +1 -0
  156. package/dist/lib/modules/OBS/index.js +45 -0
  157. package/dist/lib/modules/OBS/index.js.map +1 -0
  158. package/dist/lib/modules/OBS/utils/index.js +49 -0
  159. package/dist/lib/modules/OBS/utils/index.js.map +1 -0
  160. package/dist/lib/modules/OSS/MultipartUpload.js +259 -0
  161. package/dist/lib/modules/OSS/MultipartUpload.js.map +1 -0
  162. package/dist/lib/modules/OSS/STSUpload.js +71 -0
  163. package/dist/lib/modules/OSS/STSUpload.js.map +1 -0
  164. package/dist/lib/modules/OSS/defaultUpload.js +76 -0
  165. package/dist/lib/modules/OSS/defaultUpload.js.map +1 -0
  166. package/dist/lib/modules/OSS/index.js +35 -0
  167. package/dist/lib/modules/OSS/index.js.map +1 -0
  168. package/dist/lib/modules/OSS/utils/helper.js +173 -0
  169. package/dist/lib/modules/OSS/utils/helper.js.map +1 -0
  170. package/dist/lib/modules/OSS/utils/signature.js +132 -0
  171. package/dist/lib/modules/OSS/utils/signature.js.map +1 -0
  172. package/dist/lib/modules/TOS/MultipartUpload.js +315 -0
  173. package/dist/lib/modules/TOS/MultipartUpload.js.map +1 -0
  174. package/dist/lib/modules/TOS/STSUpload.js +125 -0
  175. package/dist/lib/modules/TOS/STSUpload.js.map +1 -0
  176. package/dist/lib/modules/TOS/defaultUpload.js +94 -0
  177. package/dist/lib/modules/TOS/defaultUpload.js.map +1 -0
  178. package/dist/lib/modules/TOS/index.js +45 -0
  179. package/dist/lib/modules/TOS/index.js.map +1 -0
  180. package/dist/lib/modules/TOS/utils/TosClientError.js +34 -0
  181. package/dist/lib/modules/TOS/utils/TosClientError.js.map +1 -0
  182. package/dist/lib/modules/TOS/utils/index.js +64 -0
  183. package/dist/lib/modules/TOS/utils/index.js.map +1 -0
  184. package/dist/lib/modules/TOS/utils/signatureV4.js +294 -0
  185. package/dist/lib/modules/TOS/utils/signatureV4.js.map +1 -0
  186. package/dist/lib/modules/TOS/utils/signatureV4Credentials.js +44 -0
  187. package/dist/lib/modules/TOS/utils/signatureV4Credentials.js.map +1 -0
  188. package/dist/lib/modules/TOS/utils/universal/crypto.browser.js +93 -0
  189. package/dist/lib/modules/TOS/utils/universal/crypto.browser.js.map +1 -0
  190. package/dist/lib/modules/TOS/utils/utils.js +42 -0
  191. package/dist/lib/modules/TOS/utils/utils.js.map +1 -0
  192. package/dist/lib/modules/index.js +50 -0
  193. package/dist/lib/modules/index.js.map +1 -0
  194. package/dist/lib/types/Kodo.js +17 -0
  195. package/dist/lib/types/Kodo.js.map +1 -0
  196. package/dist/lib/types/Local.js +17 -0
  197. package/dist/lib/types/Local.js.map +1 -0
  198. package/dist/lib/types/MinIO.js +17 -0
  199. package/dist/lib/types/MinIO.js.map +1 -0
  200. package/dist/lib/types/OBS.js +32 -0
  201. package/dist/lib/types/OBS.js.map +1 -0
  202. package/dist/lib/types/OSS.js +17 -0
  203. package/dist/lib/types/OSS.js.map +1 -0
  204. package/dist/lib/types/TOS.js +17 -0
  205. package/dist/lib/types/TOS.js.map +1 -0
  206. package/dist/lib/types/error.js +17 -0
  207. package/dist/lib/types/error.js.map +1 -0
  208. package/dist/lib/types/index.js +37 -0
  209. package/dist/lib/types/index.js.map +1 -0
  210. package/dist/lib/types/log.js +17 -0
  211. package/dist/lib/types/log.js.map +1 -0
  212. package/dist/lib/types/request.js +17 -0
  213. package/dist/lib/types/request.js.map +1 -0
  214. package/dist/lib/utils/EventEmitter.js +51 -0
  215. package/dist/lib/utils/EventEmitter.js.map +1 -0
  216. package/dist/lib/utils/UploadManger.js +309 -0
  217. package/dist/lib/utils/UploadManger.js.map +1 -0
  218. package/dist/lib/utils/UploadTask.js +32 -0
  219. package/dist/lib/utils/UploadTask.js.map +1 -0
  220. package/dist/lib/utils/checkDataFormat.js +70 -0
  221. package/dist/lib/utils/checkDataFormat.js.map +1 -0
  222. package/dist/lib/utils/global.js +106 -0
  223. package/dist/lib/utils/global.js.map +1 -0
  224. package/dist/lib/utils/index.js +44 -0
  225. package/dist/lib/utils/index.js.map +1 -0
  226. package/dist/lib/utils/logPubSub.js +78 -0
  227. package/dist/lib/utils/logPubSub.js.map +1 -0
  228. package/dist/lib/utils/multipart.js +197 -0
  229. package/dist/lib/utils/multipart.js.map +1 -0
  230. package/dist/lib/utils/nanoid.js +33 -0
  231. package/dist/lib/utils/nanoid.js.map +1 -0
  232. package/dist/lib/utils/regExpUtil.js +44 -0
  233. package/dist/lib/utils/regExpUtil.js.map +1 -0
  234. package/dist/lib/utils/request.js +264 -0
  235. package/dist/lib/utils/request.js.map +1 -0
  236. package/dist/lib/utils/response.js +43 -0
  237. package/dist/lib/utils/response.js.map +1 -0
  238. package/dist/package.json +120 -0
  239. package/package.json +120 -0
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var MinIO_exports = {};
16
+ module.exports = __toCommonJS(MinIO_exports);
17
+ //# sourceMappingURL=MinIO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/types/MinIO.ts"],"sourcesContent":["import type { PlatformMultipartUploadOption, PlatformSimpleUploadOption, PlatformType } from \"./index\"\nimport type { DataWrapperWithHeaders, Result } from \"./request\"\n\n/**\n * AWS S3 / MinIO Object Storage\n */\nexport namespace MinIO {\n\t/** Simple upload using pre-signed URL */\n\texport interface AuthParams {\n url: string\n host: string\n method: string\n fields: Record<string, string>\n dir: string\n expires: number\n }\n\n\t/** Credentials for MinIO/S3 authentication */\n\texport interface Credentials {\n access_key_id: string\n secret_access_key: string\n session_token: string\n expiration: string\n }\n\n\t/** Upload using AccessKey/SecretKey with Signature V4 */\n\texport interface STSAuthParams {\n region: string\n endpoint: string\n bucket: string\n credentials: Credentials\n expires: number\n dir: string\n }\n\n\texport type Headers = Record<string, string>\n\n\texport interface DonePart {\n\t\tnumber: number\n\t\tetag: string\n\t}\n\n\texport interface Checkpoint {\n\t\t/** The file object selected by the user, if the browser is restarted, it needs the user to manually trigger the settings */\n\t\tfile: any\n\t\t/** object key */\n\t\tname: string\n\t\tfileSize: number\n\t\tpartSize: number\n\t\tUploadId: string\n\t\tdoneParts: DonePart[]\n\t}\n\n\texport interface InitMultipartUploadOption extends PlatformMultipartUploadOption {\n\t\theaders?: Headers\n\t\tmime?: string | null\n\t}\n\n\texport interface MultipartUploadOption extends PlatformMultipartUploadOption {\n\t\theaders?: Record<string, string>\n\t}\n\n\texport interface CompleteMultipartUploadOptions extends MultipartUploadOption {\n\t\tpartSize: number\n\t}\n\n\texport interface PartInfo {\n\t\tcontent: Buffer | Blob | ArrayBuffer\n\t\tsize: number\n\t}\n\n\texport interface InitMultipartUploadResponse {\n\t\tInitiateMultipartUploadResult: {\n\t\t\tBucket: string\n\t\t\tKey: string\n\t\t\tUploadId: string\n\t\t}\n\t}\n\n\texport interface CompleteMultipartUploadResponse {\n\t\tCompleteMultipartUploadResult: {\n\t\t\tLocation: string\n\t\t\tBucket: string\n\t\t\tKey: string\n\t\t\tETag: string\n\t\t}\n\t}\n\n\tinterface OriginResponseData {\n\t\tplatform: PlatformType.Minio\n\t\tfile_code?: string\n\t\tpath: string\n\t\turl?: string\n\t\texpires?: number\n\t}\n\n\texport type PostResponse = Result<OriginResponseData>\n\n\texport type PutResponse = DataWrapperWithHeaders<null>\n\n\texport type InitMultipartUploadResponseType = DataWrapperWithHeaders<InitMultipartUploadResponse>\n\n\texport type UploadPartResponse = DataWrapperWithHeaders<null>\n\n\texport type CompleteMultipartUploadResponseType = Result<OriginResponseData>\n}\n\n\n\n\n\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var OBS_exports = {};
20
+ __export(OBS_exports, {
21
+ OBSUploadFileEventType: () => OBSUploadFileEventType
22
+ });
23
+ module.exports = __toCommonJS(OBS_exports);
24
+ var OBSUploadFileEventType = /* @__PURE__ */ ((OBSUploadFileEventType2) => {
25
+ OBSUploadFileEventType2["initiateMultipartUploadSucceed"] = "initiateMultipartUploadSucceed";
26
+ return OBSUploadFileEventType2;
27
+ })(OBSUploadFileEventType || {});
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ OBSUploadFileEventType
31
+ });
32
+ //# sourceMappingURL=OBS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/types/OBS.ts"],"sourcesContent":["import type { DonePart, PlatformMultipartUploadOption } from \"./index\"\nimport type { DataWrapperWithHeaders } from \"./request\"\n\nexport const enum OBSUploadFileEventType {\n\tinitiateMultipartUploadSucceed = \"initiateMultipartUploadSucceed\",\n}\n\nexport namespace OBS {\n\texport interface UploadFileEventResponse {\n\t\t[OBSUploadFileEventType.initiateMultipartUploadSucceed]: InitMultipartUploadResponse\n\t}\n\n\texport interface AuthParams {\n\t\tAccessKeyId: string\n\t\thost: string\n\t\tpolicy: string\n\t\tsignature: string\n\t\tdir: string\n\t\t\"content-type\": string\n\t}\n\n\texport interface STSAuthParams {\n\t\thost: string\n\t\tregion: string\n\t\tendpoint: string\n\t\tcredentials: {\n\t\t\taccess: string\n\t\t\tsecret: string\n\t\t\tsecurity_token: string\n\t\t\texpires_at: string\n\t\t}\n\t\tbucket: string\n\t\tdir: string\n\t\texpires: number\n\t\tcallback: string\n\t}\n\n\texport interface PartInfo {\n\t\tcontent: Buffer\n\t\tsize: number\n\t}\n\n\texport interface InitMultipartUploadOption extends PlatformMultipartUploadOption {\n\t\tmime?: string | null\n\t}\n\n\texport interface CommonResponse<I> {\n\t\tCommonMsg: {\n\t\t\tStatus: number\n\t\t\tCode: string\n\t\t\tMessage: string\n\t\t\tHostId: string\n\t\t\tRequestId: string\n\t\t\tInterfaceResult: null\n\t\t\tId2: string\n\t\t}\n\t\tInterfaceResult: I\n\t}\n\n\texport interface InitMultipartUploadResponse {\n\t\tInitiateMultipartUploadResult: {\n\t\t\tBucket: string\n\t\t\tKey: string\n\t\t\tUploadId: string\n\t\t}\n\t}\n\n\texport interface InitMultipartUploadResult {\n\t\tres: unknown\n\t\tbucket: string\n\t\tname: string\n\t\tUploadId: string\n\t}\n\n\texport type UploadPartResponse = DataWrapperWithHeaders<null>\n\n\texport interface UploadPartResult {\n\t\tname: string\n\t\tetag: string\n\t\tres: UploadPartResponse\n\t}\n\n\texport type CompleteMultipartUploadResponse = CommonResponse<{\n\t\tContentLength: string\n\t\tDate: string\n\t\tRequestId: string\n\t\tId2: string\n\t\tLocation: string\n\t\tBucket: string\n\t\tKey: string\n\t\tETag: string\n\t}>\n\n\texport type UploadPart = DonePart\n\n\texport type PutResponseData = CommonResponse<{\n\t\tContentLength: \"0\"\n\t\tRequestId: \"0000018C63BA1641B01B419F482B8B1E\"\n\t\tETag: '\"e00ca89591de6668570981e97c9663ea\"'\n\t}>\n}\n\n\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,IAAW,yBAAX,kBAAWA,4BAAX;AACN,EAAAA,wBAAA,oCAAiC;AADhB,SAAAA;AAAA,GAAA;","names":["OBSUploadFileEventType"]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var OSS_exports = {};
16
+ module.exports = __toCommonJS(OSS_exports);
17
+ //# sourceMappingURL=OSS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/types/OSS.ts"],"sourcesContent":["import type { Progress, TaskId, PlatformType } from \".\"\nimport type { DataWrapperWithHeaders, Method, Result } from \"./request\"\n\n/**\n * Aliyun Object Storage\n */\nexport namespace OSS {\n\texport interface Option {\n\t\t/** access secret you create */\n\t\taccessKeyId: string\n\t\t/** access secret you create */\n\t\taccessKeySecret: string\n\t\t/** used by temporary authorization */\n\t\tstsToken?: string | undefined\n\t\t/** the default bucket you want to access If you don't have any bucket, please use putBucket() create one first. */\n\t\tbucket?: string | undefined\n\t\t/** oss region domain. It takes priority over region. */\n\t\tendpoint?: string | undefined\n\t\t/** the bucket data region location, please see Data Regions, default is oss-cn-hangzhou. */\n\t\tregion?: string | undefined\n\t\t/** access OSS with aliyun internal network or not, default is false. If your servers are running on aliyun too, you can set true to save lot of money. */\n\t\tinternal?: boolean | undefined\n\t\t/** instruct OSS client to use HTTPS (secure: true) or HTTP (secure: false) protocol. */\n\t\tsecure?: boolean | undefined\n\t\t/** instance level timeout for all operations, default is 60s */\n\t\ttimeout?: string | number | undefined\n\t\t/** use custom domain name */\n\t\tcname?: boolean | undefined\n\t\t/** use time (ms) of refresh STSToken interval it should be less than sts info expire interval, default is 300000ms(5min) when sts info expires. */\n\t\trefreshSTSTokenInterval?: number\n\t\t/** used by auto set stsToken、accessKeyId、accessKeySecret when sts info expires. return value must be object contains stsToken、accessKeyId、accessKeySecret */\n\t\trefreshSTSToken?: () => Promise<{\n\t\t\taccessKeyId: string\n\t\t\taccessKeySecret: string\n\t\t\tstsToken: string\n\t\t}>\n\t}\n\n\texport interface Headers {\n\t\t[propName: string]: any\n\n\t\t\"x-oss-date\": string\n\t\t\"x-oss-user-agent\"?: string\n\t}\n\n\t/** Credential fields returned by backend for Aliyun */\n\texport interface AuthParams {\n\t\tpolicy: string\n\t\taccessid: string\n\t\tsignature: string\n\t\thost: string\n\t\tdir: string\n\t\tcallback: string\n\t}\n\n\t/** Credential fields returned by backend when STS is enabled */\n\texport interface STSAuthParams {\n\t\tregion: string\n\t\tbucket: string\n\t\tdir: string\n\t\taccess_key_secret: string\n\t\taccess_key_id: string\n\t\tsts_token: string\n\t\tcallback: string\n\t}\n\n\texport interface DonePart {\n\t\tnumber: number\n\t\tetag: string\n\t}\n\n\texport interface Checkpoint {\n\t\t/** The file object selected by the user, if the browser is restarted, it needs the user to manually trigger the settings */\n\t\tfile: any\n\t\t/** object key */\n\t\tname: string\n\t\tfileSize: number\n\t\tpartSize: number\n\t\tUploadId: string\n\t\tdoneParts: DonePart[]\n\t}\n\n\texport interface InitMultipartUploadOption {\n\t\theaders?: Record<string, string>\n\t\tmime?: string | null\n\t}\n\n\texport interface MultipartUploadParams {\n\t\tbucket: string\n\t\tregion: string\n\t\tobject: string\n\t\taccessKeyId: string\n\t\taccessKeySecret: string\n\t\tstsToken: string\n\t\tcallback: string\n\t\ttaskId?: TaskId\n\t\txmlResponse?: boolean\n\t}\n\n\t/** Multipart upload interface */\n\texport interface MultipartUploadOption {\n\t\t/** the number of parts to be uploaded in parallel */\n\t\tparallel?: number\n\t\t/** the suggested size for each part */\n\t\tpartSize?: number\n\t\t/** the checkpoint to resume upload, if this is provided, it will continue the upload from where interrupted, otherwise a new multipart upload will be created. */\n\t\tcheckpoint?: Checkpoint\n\t\tmime?: string | null\n\t\theaders?: Record<string, string>\n\t}\n\n\texport interface CompleteMultipartUploadOptions {\n\t\tpartSize: number\n\t\tcallback?: string\n\t\theaders?: Record<string, string> | undefined\n\t\tprogress?: Progress\n\t}\n\n\texport interface ResumeMultipartOption extends MultipartUploadOption {\n\t\tprogress?: Progress\n\t}\n\n\texport interface CreateRequestParams extends MultipartUploadParams {\n\t\tmethod: Method\n\t\tsubRes: string | Record<string, any>\n\t\txmlResponse?: boolean | undefined\n\t\tquery?: Record<string, string>\n\t\tcontent?: File | Blob | string | ArrayBuffer | Buffer\n\t}\n\n\texport interface UploadPartError extends Error {\n\t\tname: string\n\t\tmessage: string\n\t\tstack: string\n\t\tpartNum: number\n\t}\n\n\texport interface PartInfo {\n\t\tcontent: string | ArrayBuffer | File | Blob | Buffer\n\t\tsize: number\n\t}\n\n\tinterface OriginResponseData {\n\t\tplatform: PlatformType.OSS\n\t\tfile_code: string\n\t\tpath: string\n\t\turl: string\n\t\texpires: number\n\t}\n\n\texport type PostResponse = Result<OriginResponseData>\n\n\texport type PutResponse = Result<OriginResponseData>\n\n\t/** Multipart upload init response */\n\texport type InitMultipartUploadResponse = DataWrapperWithHeaders<{\n\t\tInitiateMultipartUploadResult: {\n\t\t\tBucket: string\n\t\t\tKey: string\n\t\t\tUploadId: string\n\t\t}\n\t}>\n\n\texport type UploadPartResponse = DataWrapperWithHeaders<null>\n\n\texport type CompleteMultipartUploadResponse = Result<OriginResponseData>\n}\n\n\n\n\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var TOS_exports = {};
16
+ module.exports = __toCommonJS(TOS_exports);
17
+ //# sourceMappingURL=TOS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/types/TOS.ts"],"sourcesContent":["import type { SignersV4 } from \"../modules/TOS/utils/signatureV4\"\nimport type { PlatformMultipartUploadOption, PlatformSimpleUploadOption } from \"./index\"\nimport type { DataWrapperWithHeaders } from \"./request\"\n\nexport namespace TOS {\n\texport interface VolcEnginePlatformSimpleUploadOption extends PlatformSimpleUploadOption {\n\t\ttosCallbackParams: {\n\t\t\ttenant_id: string\n\t\t\torganization_code: string\n\t\t}\n\t}\n\n\texport interface VolcEnginePlatformMultipartUploadOption\n\t\textends PlatformMultipartUploadOption {}\n\n\texport interface CallbackResponse {\n\t\tplatform: \"tos\"\n\t\tfile_code: string\n\t\tpath: string\n\t\turl: string\n\t\texpires: number\n\t}\n\n\texport interface AuthParams {\n\t\thost: string\n\t\t\"x-tos-algorithm\": \"TOS4-HMAC-SHA256\"\n\t\t\"x-tos-date\": string\n\t\t\"x-tos-credential\": string\n\t\t\"x-tos-signature\": string\n\t\tpolicy: string\n\t\texpires: number\n\t\tcontent_type: string\n\t\tdir: string\n\t\t\"x-tos-callback\": string\n\t}\n\n\t// interface Headers extends Record<string, string> {\n\t// \t\"x-tos-date\": string\n\t// \t\"x-tos-content-sha256\": \"UNSIGNED-PAYLOAD\"\n\t// \t\"x-tos-security-token\": string\n\t// \tauthorization: string\n\t// }\n\n\texport type Headers = Record<string, string>\n\n\texport interface STSAuthParams {\n\t\tbucket: string\n\t\tcallback: string\n\t\tcredentials: {\n\t\t\tAccessKeyId: string\n\t\t\tCurrentTime: string\n\t\t\tExpiredTime: string\n\t\t\tSecretAccessKey: string\n\t\t\tSessionToken: string\n\t\t}\n\t\tdir: string\n\t\tendpoint: string\n\t\thost: string\n\t\texpires: number\n\t\tregion: string\n\t}\n\n\texport interface CreateRequestParams extends STSAuthParams {}\n\n\texport interface InitMultipartUploadOption extends MultipartUploadOption {\n\t\theaders: Headers\n\t\tmime?: string | null\n\t}\n\n\texport type DonePart = { number: number; etag: string }\n\n\texport interface Checkpoint {\n\t\t/** The file object selected by the user, if the browser is restarted, it needs the user to manually trigger the settings */\n\t\tfile: any\n\t\t/** object key */\n\t\tname: string\n\t\tfileSize: number\n\t\tpartSize: number\n\t\tUploadId: string\n\t\tdoneParts: DonePart[]\n\t}\n\n\texport interface PartInfo {\n\t\tcontent: Buffer\n\t\tsize: Number\n\t}\n\n\texport interface MultipartUploadOption extends PlatformMultipartUploadOption {\n\t\tsigners: SignersV4\n\t}\n\n\texport interface CompleteMultipartUploadOptions extends MultipartUploadOption {}\n\n\texport interface InitMultipartUploadResponse {\n\t\tBucket: string\n\t\tKey: string\n\t\tUploadId: string\n\t}\n\n\texport interface CompleteMultipartUploadResponse {\n\t\tLocation: string\n\t\tBucket: string\n\t\tKey: string\n\t\tETag: string\n\t\theaders: Record<string, string>\n\t}\n\n\texport type UploadPartResponse = DataWrapperWithHeaders<null>\n\n\texport type PostResponse = DataWrapperWithHeaders<null>\n\n\texport type PutResponse = DataWrapperWithHeaders<null>\n}\n\n\n\n\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var error_exports = {};
16
+ module.exports = __toCommonJS(error_exports);
17
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/types/error.ts"],"sourcesContent":["/**\n * Error type namespace\n * */\nexport namespace ErrorType {\n\texport interface BaseException {\n\t\t/** Error message */\n\t\tmessage: string\n\t}\n\n\texport interface BaseExceptionWithStatus extends BaseException {\n\t\t/** Error code */\n\t\tstatus: number\n\t}\n\n\texport interface UploadError extends Error {\n\t\tstatus?: number\n\t}\n\n\texport interface UploadPartException extends BaseExceptionWithStatus {\n\t\tname: string\n\t\tstack: string\n\t\tpartNum: number\n\t}\n}\n\n\n\n\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var types_exports = {};
20
+ __export(types_exports, {
21
+ PlatformType: () => PlatformType
22
+ });
23
+ module.exports = __toCommonJS(types_exports);
24
+ var PlatformType = /* @__PURE__ */ ((PlatformType2) => {
25
+ PlatformType2["OSS"] = "aliyun";
26
+ PlatformType2["Kodo"] = "qiniu";
27
+ PlatformType2["TOS"] = "tos";
28
+ PlatformType2["OBS"] = "obs";
29
+ PlatformType2["Local"] = "local";
30
+ PlatformType2["Minio"] = "minio";
31
+ return PlatformType2;
32
+ })(PlatformType || {});
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ PlatformType
36
+ });
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/types/index.ts"],"sourcesContent":["import type { OSS } from \"./OSS\"\nimport type { ErrorType } from \"./error\"\nimport type { Kodo } from \"./Kodo\"\nimport type { Local } from \"./Local\"\nimport type { Method } from \"./request\"\nimport type { TOS } from \"./TOS\"\nimport type { OBS } from \"./OBS\"\nimport type { MinIO } from \"./MinIO\"\n\n/** Request type */\nexport type MethodType = Method\n\n/**\n * @description Unified success response\n * @param code 1000 for successful request\n * @param message Request status information\n * @param data Return data payload\n */\nexport interface NormalSuccessResponse {\n\tcode: number\n\tmessage: string\n\theaders: Record<string, string>\n\tdata: {\n\t\tplatform: PlatformType\n\t\tpath: string\n\t}\n}\n\n/**\n * @param url Request URL\n * @param method Request method\n * @param headers Request headers\n * @param body Request body\n */\nexport interface Request {\n\turl: string\n\tmethod: Method\n\theaders?: Record<string, string>\n\tbody?: any\n}\n\n/**\n * @description: Image processing configuration\n * @param type // Image processing type, e.g.: resize, watermark\n * @param params Image processing parameters, refer to: https://help.aliyun.com/document_detail/144582.html\n */\nexport interface TransformImageConfig {\n\ttype:\n\t\t| \"resize\"\n\t\t| \"watermark\"\n\t\t| \"crop\"\n\t\t| \"quality\"\n\t\t| \"format\"\n\t\t| \"auto-orient\"\n\t\t| \"circle\"\n\t\t| \"indexcrop\"\n\t\t| \"rounded-corners\"\n\t\t| \"blur\"\n\t\t| \"rotate\"\n\t\t| \"interlace\"\n\t\t| \"bright\"\n\t\t| \"sharpen\"\n\t\t| \"contrast\"\n\tparams: Record<string, any>\n}\n\n/**\n * @description: Download configuration\n * @param url Request URL\n * @param method Request method\n * @param headers Request headers\n * @param body Request body\n */\nexport interface DownloadConfig extends Request {\n\toption?: {\n\t\timage?: TransformImageConfig[]\n\t}\n}\n\ntype UploadConfigOption = UploadCommonOption &\n\tPlatformSimpleUploadOption &\n\tPlatformMultipartUploadOption\n\n/**\n * @description: Common upload configuration\n * @param rewriteFileName Whether to rename the file\n */\nexport interface UploadCommonOption {\n\trewriteFileName?: boolean\n}\n\n/**\n * @description: Custom upload credential configuration\n * @param platform Platform type\n * @param credentials Credential information\n * @param expire Expiration timestamp (optional)\n */\nexport interface CustomCredentials {\n\tplatform: PlatformType\n\ttemporary_credential: PlatformParams\n\texpire?: number\n}\n\n/**\n * @description: Upload configuration, requires developers to configure upload credential request, SDK handles upload request internally\n * @param url Request upload credential - URL (optional when using custom credentials)\n * @param method Request upload credential - request method (optional when using custom credentials)\n * @param headers Request upload credential - request headers (optional when using custom credentials)\n * @param body Request upload credential - request body (optional when using custom credentials)\n * @param {File | Blob} file File to be uploaded\n * @param fileName File name\n * @param option Optional upload configuration\n * @param customCredentials Custom upload credentials (optional, will skip credential request when provided)\n */\nexport interface UploadConfig {\n\turl?: string\n\tmethod?: Method\n\theaders?: Record<string, string>\n\tbody?: any\n\tfile: File | Blob\n\tfileName: string\n\toption?: UploadConfigOption\n\tcustomCredentials?: CustomCredentials\n}\n\n/** Upload callback */\nexport interface UploadCallBack extends TaskCallBack {}\n\nexport type DonePart = { number: number; etag: string }\n\nexport interface Checkpoint {\n\t/** The file object selected by the user, if the browser is restarted, it needs the user to manually trigger the settings */\n\tfile: any\n\t/** object key */\n\tname: string\n\tfileSize: number\n\tpartSize: number\n\tUploadId: string\n\tdoneParts: DonePart[]\n}\n\n/** percent: percentage progress loaded: bytes uploaded total: total bytes checkpoint: upload checkpoint information */\nexport type Progress = (\n\tpercent: number,\n\tloaded: number,\n\ttotal: number,\n\tcheckpoint: Checkpoint | null,\n) => void\n\n/** PlatformType cloud storage provider enum type */\nexport enum PlatformType {\n\tOSS = \"aliyun\",\n\tKodo = \"qiniu\",\n\tTOS = \"tos\",\n\tOBS = \"obs\",\n\tLocal = \"local\",\n\tMinio = \"minio\",\n}\n\n/** Aggregated platform parameters */\nexport type PlatformParams =\n\t| OSS.AuthParams\n\t| OSS.STSAuthParams\n\t| Kodo.AuthParams\n\t| Local.AuthParams\n\t| TOS.AuthParams\n\t| TOS.STSAuthParams\n\t| OBS.AuthParams\n\t| OBS.STSAuthParams\n\t| MinIO.AuthParams\n\t| MinIO.STSAuthParams\n\n/** Request temporary credentials, return data template */\nexport interface UploadSource<T extends PlatformParams> {\n\tplatform: PlatformType\n\ttemporary_credential: T\n\texpire: number\n}\n\n/** Global variables */\nexport type GlobalCache<T extends PlatformParams> = Record<string, UploadSource<T>>\n\n/** Object storage platform base Option */\ninterface PlatformOption {\n\theaders?: Record<string, string>\n\ttaskId?: TaskId\n\tprogress?: Progress\n\treUploadedCount?: number\n}\n\n/** Multipart upload Option optional fields */\nexport interface PlatformMultipartUploadOption extends PlatformOption {\n\tparallel?: number\n\tpartSize?: number\n\tcheckpoint?: OSS.Checkpoint\n\tmime?: string | null\n}\n\n/** Simple upload Option optional fields */\nexport interface PlatformSimpleUploadOption extends PlatformOption {}\n\n/** Upload file implementation interface for different object storage platforms */\nexport type PlatformRequest<P, O> = (\n\tfile: File | Blob,\n\tkey: string,\n\tparams: P,\n\toption: O,\n) => Promise<NormalSuccessResponse>\n\n/** Object storage platform module */\nexport interface PlatformModule {\n\tupload: PlatformRequest<\n\t\tPlatformParams,\n\t\tPlatformSimpleUploadOption | PlatformMultipartUploadOption\n\t>\n}\n\n/** A TaskId is generated when a file upload starts */\nexport type TaskId = string\n\n/** Upload progress callback parameters */\nexport interface ProgressCallbackProps {\n\tpercent?: number\n\tloaded?: number\n\ttotal?: number\n\tcheckpoint?: OSS.Checkpoint | null\n}\n\n/** Success hook callback */\nexport type SuccessCallback = (response?: NormalSuccessResponse) => void\n\n/** Failure hook callback */\nexport type FailCallback = (err?: ErrorType.UploadError) => void\n\n/** Progress hook callback */\nexport type ProgressCallback = (\n\tpercent?: ProgressCallbackProps[\"percent\"],\n\tloaded?: ProgressCallbackProps[\"loaded\"],\n\ttotal?: ProgressCallbackProps[\"total\"],\n\tcheckpoint?: ProgressCallbackProps[\"checkpoint\"],\n) => void\n\n/** Upload task callbacks */\nexport interface TaskCallBack {\n\t// Upload succeeded\n\tsuccess?: (callback: SuccessCallback) => void\n\t// Upload errored\n\tfail?: (callback: FailCallback) => void\n\t// Progress\n\tprogress?: (callback: ProgressCallback) => void\n\t// Cancel\n\tcancel?: () => void\n\t// Pause\n\tpause?: () => void\n\t// Resume\n\tresume?: () => void\n}\n\n/** Task object */\nexport interface Task {\n\t// Upload succeeded\n\tsuccess?: SuccessCallback\n\t// Upload errored\n\tfail?: FailCallback\n\t// Progress\n\tprogress?: ProgressCallback\n\t// Cancel\n\tcancel?: () => void\n\t// Pause\n\tpause?: () => void\n\t// Resume\n\tresume?: () => void\n\t/** File progress info while paused */\n\tpauseInfo?: {\n\t\tisPause: boolean\n\t\tcheckpoint: OSS.Checkpoint\n\t}\n}\n\n\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsJO,IAAK,eAAL,kBAAKA,kBAAL;AACN,EAAAA,cAAA,SAAM;AACN,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,SAAM;AACN,EAAAA,cAAA,SAAM;AACN,EAAAA,cAAA,WAAQ;AACR,EAAAA,cAAA,WAAQ;AANG,SAAAA;AAAA,GAAA;","names":["PlatformType"]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var log_exports = {};
16
+ module.exports = __toCommonJS(log_exports);
17
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/types/log.ts"],"sourcesContent":["import type { ErrorType } from \"./error\"\n\n/**\n * Log module namespace\n * */\nexport namespace LogModule {\n\texport type LogType = \"SUCCESS\" | \"ERROR\" | \"WARN\" | \"DEBUG\"\n\n\texport type CallBack = (log: any) => void\n\n\texport type LogEventType = \"upload\" | \"download\"\n\n\texport type CreateLogConfig = {\n\t\ttype: LogType\n\t\t/** Event name */\n\t\teventName: LogEventType\n\t\t/** Event parameters */\n\t\teventParams?: any\n\t\t/** Event response */\n\t\teventResponse?: any\n\t\terror?: ErrorType.UploadError\n\t\t/** Additional content */\n\t\textra?: string\n\t}\n\n\t/**\n\t * Log data structure\n\t */\n\texport interface LogData {\n\t\t/** Status type */\n\t\ttype: LogType\n\t\t/** Event name */\n\t\tevent_name: LogEventType\n\t\t/** Event parameters */\n\t\tevent_params: any\n\t\t/** Event response */\n\t\tevent_response: any\n\t\t/** Exception type */\n\t\texception_type: string\n\t\t/** Exception message */\n\t\texception_message: string\n\t\t/** File where exception was triggered */\n\t\texception_file: string\n\t\t/** Line number where exception was triggered */\n\t\texception_line: string\n\t\t/** Column number where exception was triggered */\n\t\texception_row: string\n\t\t/** Additional content */\n\t\textra?: string\n\t\t/** Record time */\n\t\ttime: Date\n\t\t/** SDK name and version */\n\t\tversion: string\n\t}\n}\n\n\n\n\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var request_exports = {};
16
+ module.exports = __toCommonJS(request_exports);
17
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/types/request.ts"],"sourcesContent":["import type { ErrorType } from \"./error\"\nimport type { Progress, TaskId } from \"./index\"\n\nexport type Method =\n\t| \"get\"\n\t| \"GET\"\n\t| \"post\"\n\t| \"POST\"\n\t| \"delete\"\n\t| \"DELETE\"\n\t| \"head\"\n\t| \"HEAD\"\n\t| \"options\"\n\t| \"OPTIONS\"\n\t| \"put\"\n\t| \"PUT\"\n\t| \"patch\"\n\t| \"PATCH\"\n\nexport interface RequestConfig {\n\tmethod: Method\n\turl: string\n\tquery?: Record<string, string>\n\theaders?: Record<string, string>\n\tdata?: string | object\n\txmlResponse?: boolean\n\tsuccess?: (res: Object) => void\n\tfail?: (status: number, reject: (error: ErrorType.UploadError) => void) => void\n}\n\nexport interface UploadRequestConfig extends RequestConfig {\n\ttaskId?: TaskId\n\tonProgress?: Progress\n\twithoutWrapper?: boolean\n}\n\nexport interface Result<T> {\n\tcode?: number\n\tdata: T\n\tmessage?: string\n\theaders: Record<string, string>\n}\n\nexport interface RequestTask {\n\ttaskId: TaskId\n\tmakeCancel: () => void\n\tmakePause: () => void\n}\n\nexport interface DataWrapperWithHeaders<T> {\n\tdata: T\n\theaders: Record<string, string>\n}\n\n\n\n\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var EventEmitter_exports = {};
21
+ __export(EventEmitter_exports, {
22
+ default: () => EventEmitter
23
+ });
24
+ module.exports = __toCommonJS(EventEmitter_exports);
25
+ const _EventEmitter = class _EventEmitter {
26
+ constructor() {
27
+ this.observers = {};
28
+ }
29
+ // Register event listener
30
+ on(eventName, listener) {
31
+ if (!this.observers[eventName]) {
32
+ this.observers[eventName] = listener;
33
+ }
34
+ }
35
+ // Trigger event, callback all listeners
36
+ emit(eventName, ...args) {
37
+ const listener = this.observers[eventName];
38
+ if (listener) {
39
+ listener.apply(this, args);
40
+ }
41
+ }
42
+ // Remove specified listener for specified event
43
+ off(eventName) {
44
+ if (Object.keys(this.observers).includes(eventName)) {
45
+ delete this.observers[eventName];
46
+ }
47
+ }
48
+ };
49
+ __name(_EventEmitter, "EventEmitter");
50
+ let EventEmitter = _EventEmitter;
51
+ //# sourceMappingURL=EventEmitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/EventEmitter.ts"],"sourcesContent":["/** Event name */\ntype EventName = string\n\nexport default class EventEmitter<T extends (...args: any[]) => void> {\n\tobservers: Record<EventName, T>\n\n\tconstructor() {\n\t\t// Store event listener key-value pairs\n\t\tthis.observers = {}\n\t}\n\n\t// Register event listener\n\ton(eventName: EventName, listener: T) {\n\t\tif (!this.observers[eventName]) {\n\t\t\tthis.observers[eventName] = listener\n\t\t}\n\t}\n\n\t// Trigger event, callback all listeners\n\temit(eventName: EventName, ...args: Array<any>) {\n\t\tconst listener = this.observers[eventName]\n\t\tif (listener) {\n\t\t\tlistener.apply(this, args)\n\t\t}\n\t}\n\n\t// Remove specified listener for specified event\n\toff(eventName: EventName) {\n\t\tif (Object.keys(this.observers).includes(eventName)) {\n\t\t\tdelete this.observers[eventName]\n\t\t}\n\t}\n}\n\n\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,MAAqB,gBAArB,MAAqB,cAAiD;AAAA,EAGrE,cAAc;AAEb,SAAK,YAAY,CAAC;AAAA,EACnB;AAAA;AAAA,EAGA,GAAG,WAAsB,UAAa;AACrC,QAAI,CAAC,KAAK,UAAU,SAAS,GAAG;AAC/B,WAAK,UAAU,SAAS,IAAI;AAAA,IAC7B;AAAA,EACD;AAAA;AAAA,EAGA,KAAK,cAAyB,MAAkB;AAC/C,UAAM,WAAW,KAAK,UAAU,SAAS;AACzC,QAAI,UAAU;AACb,eAAS,MAAM,MAAM,IAAI;AAAA,IAC1B;AAAA,EACD;AAAA;AAAA,EAGA,IAAI,WAAsB;AACzB,QAAI,OAAO,KAAK,KAAK,SAAS,EAAE,SAAS,SAAS,GAAG;AACpD,aAAO,KAAK,UAAU,SAAS;AAAA,IAChC;AAAA,EACD;AACD;AA7BsE;AAAtE,IAAqB,eAArB;","names":[]}
@@ -0,0 +1,309 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var UploadManger_exports = {};
31
+ __export(UploadManger_exports, {
32
+ UploadManger: () => UploadManger
33
+ });
34
+ module.exports = __toCommonJS(UploadManger_exports);
35
+ var import_lodash_es = require("lodash-es");
36
+ var import_InitException = require("../Exception/InitException");
37
+ var import_UploadException = require("../Exception/UploadException");
38
+ var import_modules = __toESM(require("../modules"), 1);
39
+ var import_checkDataFormat = require("./checkDataFormat");
40
+ var import_EventEmitter = __toESM(require("./EventEmitter"), 1);
41
+ var import_global = require("./global");
42
+ var import_logPubSub = __toESM(require("./logPubSub"), 1);
43
+ var import_nanoid = require("./nanoid");
44
+ var import_request = require("./request");
45
+ const TaskEvent = new import_EventEmitter.default();
46
+ const _UploadManger = class _UploadManger {
47
+ constructor() {
48
+ this.tasks = {};
49
+ }
50
+ detach(taskId) {
51
+ delete this.tasks[taskId];
52
+ (0, import_request.completeRequest)(taskId);
53
+ }
54
+ notifySuccess(taskId, data) {
55
+ const { success } = this.tasks[taskId] || {};
56
+ if ((0, import_lodash_es.isFunction)(success)) {
57
+ success(data);
58
+ }
59
+ }
60
+ notifyError(taskId, err) {
61
+ const { fail } = this.tasks[taskId] || {};
62
+ if ((0, import_lodash_es.isFunction)(fail)) {
63
+ fail(err);
64
+ }
65
+ }
66
+ notifyProgress(taskId, percent, loaded, total, checkpoint) {
67
+ const { progress } = this.tasks[taskId] || {};
68
+ if ((0, import_lodash_es.isFunction)(progress)) {
69
+ progress(percent, loaded, total, checkpoint);
70
+ }
71
+ }
72
+ createTask(file, key, uploadConfig, option) {
73
+ let taskId = (0, import_nanoid.nanoid)();
74
+ if (this.tasks[taskId]) {
75
+ while (this.tasks[taskId]) {
76
+ taskId = (0, import_nanoid.nanoid)();
77
+ }
78
+ }
79
+ const output = {
80
+ success: (callback) => {
81
+ const taskEventCallback = /* @__PURE__ */ __name((response) => {
82
+ import_logPubSub.default.report({
83
+ type: "SUCCESS",
84
+ eventName: "upload",
85
+ eventParams: { ...uploadConfig },
86
+ eventResponse: response
87
+ });
88
+ TaskEvent.off(`${taskId}_success`);
89
+ TaskEvent.off(`${taskId}_fail`);
90
+ TaskEvent.off(`${taskId}_progress`);
91
+ callback(response);
92
+ }, "taskEventCallback");
93
+ TaskEvent.on(`${taskId}_success`, taskEventCallback);
94
+ },
95
+ fail: (callback) => {
96
+ const taskEventCallback = /* @__PURE__ */ __name((error) => {
97
+ import_logPubSub.default.report({
98
+ type: "ERROR",
99
+ eventName: "upload",
100
+ eventParams: { ...uploadConfig },
101
+ error
102
+ });
103
+ callback(error);
104
+ }, "taskEventCallback");
105
+ TaskEvent.on(`${taskId}_fail`, taskEventCallback);
106
+ },
107
+ progress: (callback) => {
108
+ const taskEventCallback = /* @__PURE__ */ __name((percent, loaded, total, checkpoint) => {
109
+ callback(percent, loaded, total, checkpoint);
110
+ }, "taskEventCallback");
111
+ TaskEvent.on(`${taskId}_progress`, taskEventCallback);
112
+ },
113
+ cancel: () => {
114
+ const task = this.tasks[taskId];
115
+ if (task) {
116
+ (0, import_request.cancelRequest)(taskId);
117
+ TaskEvent.off(`${taskId}_success`);
118
+ TaskEvent.off(`${taskId}_fail`);
119
+ TaskEvent.off(`${taskId}_progress`);
120
+ const { pauseInfo } = task;
121
+ if (pauseInfo) {
122
+ delete task.pauseInfo;
123
+ }
124
+ }
125
+ },
126
+ pause: () => {
127
+ const task = this.tasks[taskId];
128
+ if (task) {
129
+ const { pauseInfo } = task;
130
+ if (pauseInfo) {
131
+ task.pauseInfo = {
132
+ ...pauseInfo,
133
+ isPause: true
134
+ };
135
+ (0, import_request.pauseRequest)(taskId);
136
+ }
137
+ }
138
+ },
139
+ resume: () => {
140
+ const task = this.tasks[taskId];
141
+ if (task) {
142
+ const { pauseInfo } = task;
143
+ if (pauseInfo) {
144
+ const { isPause, checkpoint } = pauseInfo;
145
+ if (isPause) {
146
+ task.pauseInfo = {
147
+ isPause: false,
148
+ checkpoint
149
+ };
150
+ this.upload(file, key, taskId, uploadConfig, {
151
+ ...option,
152
+ checkpoint
153
+ });
154
+ }
155
+ }
156
+ }
157
+ }
158
+ };
159
+ this.tasks[taskId] = {
160
+ success: (response) => {
161
+ TaskEvent.emit(`${taskId}_success`, response);
162
+ },
163
+ fail: (error) => {
164
+ TaskEvent.emit(`${taskId}_fail`, error);
165
+ },
166
+ progress: (response) => {
167
+ TaskEvent.emit(`${taskId}_progress`, response);
168
+ },
169
+ cancel: output.cancel,
170
+ pause: output.pause,
171
+ resume: output.resume
172
+ };
173
+ this.upload(file, key, taskId, uploadConfig, option);
174
+ return {
175
+ success: output.success,
176
+ fail: output.fail,
177
+ progress: output.progress,
178
+ cancel: output.cancel,
179
+ pause: output.pause,
180
+ resume: output.resume
181
+ };
182
+ }
183
+ upload(file, key, taskId, uploadConfig, option) {
184
+ const onProgress = /* @__PURE__ */ __name((percent, loaded, total, checkpoint) => {
185
+ const task = this.tasks[taskId];
186
+ if (checkpoint && task) {
187
+ task.pauseInfo = {
188
+ isPause: false,
189
+ checkpoint
190
+ };
191
+ this.notifyProgress(taskId, percent, loaded, total, checkpoint);
192
+ } else {
193
+ this.notifyProgress(taskId, percent, loaded, total, null);
194
+ }
195
+ }, "onProgress");
196
+ const uploadPromise = uploadConfig.customCredentials ? Promise.resolve({
197
+ platform: uploadConfig.customCredentials.platform,
198
+ temporary_credential: uploadConfig.customCredentials.temporary_credential,
199
+ expire: uploadConfig.customCredentials.expire || 0
200
+ }) : (() => {
201
+ const { url, method, headers, body } = uploadConfig;
202
+ const uploadSourceRequest = {
203
+ url,
204
+ method,
205
+ headers,
206
+ body
207
+ };
208
+ const isNeedForceReFresh = !option?.reUploadedCount;
209
+ return (0, import_global.getUploadConfig)(uploadSourceRequest, isNeedForceReFresh);
210
+ })();
211
+ uploadPromise.then(async (uploadSource) => {
212
+ const platformType = uploadSource.platform;
213
+ const platformConfig = uploadSource.temporary_credential;
214
+ try {
215
+ const platform = import_modules.default[platformType];
216
+ if (!platform) {
217
+ throw new import_InitException.InitException(
218
+ import_InitException.InitExceptionCode.UPLOAD_IS_NO_SUPPORT_THIS_PLATFORM,
219
+ platformType
220
+ );
221
+ }
222
+ return { platform, platformConfig };
223
+ } catch (error) {
224
+ throw new import_InitException.InitException(
225
+ import_InitException.InitExceptionCode.UPLOAD_IS_NO_SUPPORT_THIS_PLATFORM,
226
+ platformType
227
+ );
228
+ }
229
+ }).then(({ platform, platformConfig }) => {
230
+ if (!file && !(0, import_checkDataFormat.isBlob)(file) && !(0, import_checkDataFormat.isFile)(file))
231
+ throw new import_InitException.InitException(import_InitException.InitExceptionCode.UPLOAD_IS_NO_SUPPORT_THIS_FILE_FORMAT);
232
+ if (!key)
233
+ throw new import_InitException.InitException(import_InitException.InitExceptionCode.MISSING_PARAMS_FOR_UPLOAD, "fileName");
234
+ if (!platform.upload) {
235
+ throw new import_InitException.InitException(
236
+ import_InitException.InitExceptionCode.UPLOAD_IS_NO_SUPPORT_THIS_PLATFORM,
237
+ "platform.upload is undefined"
238
+ );
239
+ }
240
+ return platform.upload(
241
+ file,
242
+ key,
243
+ platformConfig,
244
+ {
245
+ ...option,
246
+ progress: onProgress,
247
+ taskId
248
+ }
249
+ );
250
+ }).then((res) => {
251
+ this.notifySuccess(taskId, res);
252
+ this.detach(taskId);
253
+ }).catch((err) => {
254
+ let message = err;
255
+ if (err?.status === 1003) {
256
+ if (option?.reUploadedCount && option?.reUploadedCount >= 2) {
257
+ this.notifyError(
258
+ taskId,
259
+ new import_InitException.InitException(import_InitException.InitExceptionCode.REUPLOAD_IS_FAILED)
260
+ );
261
+ return;
262
+ }
263
+ this.upload(file, key, taskId, uploadConfig, {
264
+ ...option,
265
+ reUploadedCount: option?.reUploadedCount ? option.reUploadedCount + 1 : 1
266
+ });
267
+ return;
268
+ }
269
+ if (err?.status === 5002) {
270
+ message = new import_UploadException.UploadException(import_UploadException.UploadExceptionCode.UPLOAD_PAUSE);
271
+ }
272
+ if (err?.status === 5001) {
273
+ message = new import_UploadException.UploadException(import_UploadException.UploadExceptionCode.UPLOAD_CANCEL);
274
+ }
275
+ this.notifyError(taskId, message);
276
+ });
277
+ }
278
+ // Pause all uploads
279
+ pauseAllTask() {
280
+ Object.values(this.tasks).forEach((task) => {
281
+ if (task.pause) {
282
+ task.pause();
283
+ }
284
+ });
285
+ }
286
+ // Resume all uploads
287
+ resumeAllTask() {
288
+ Object.values(this.tasks).forEach((task) => {
289
+ if (task.resume) {
290
+ task.resume();
291
+ }
292
+ });
293
+ }
294
+ // Cancel all uploads
295
+ cancelAllTask() {
296
+ Object.values(this.tasks).forEach((task) => {
297
+ if (task.cancel) {
298
+ task.cancel();
299
+ }
300
+ });
301
+ }
302
+ };
303
+ __name(_UploadManger, "UploadManger");
304
+ let UploadManger = _UploadManger;
305
+ // Annotate the CommonJS export names for ESM import in node:
306
+ 0 && (module.exports = {
307
+ UploadManger
308
+ });
309
+ //# sourceMappingURL=UploadManger.js.map