@wlindabla/file_uploader 1.0.0 → 2.0.1

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 (110) hide show
  1. package/README.md +54 -28
  2. package/dist/cjs/cache/index.d.ts +198 -0
  3. package/dist/cjs/cache/index.js +318 -0
  4. package/dist/cjs/cache/index.js.map +1 -0
  5. package/dist/cjs/core/index.d.ts +271 -0
  6. package/dist/cjs/core/index.js +762 -0
  7. package/dist/cjs/core/index.js.map +1 -0
  8. package/dist/cjs/events/chunk/index.d.ts +27 -0
  9. package/dist/cjs/events/chunk/index.js +70 -0
  10. package/dist/cjs/events/chunk/index.js.map +1 -0
  11. package/dist/cjs/events/complete/index.d.ts +64 -0
  12. package/dist/cjs/events/complete/index.js +152 -0
  13. package/dist/cjs/events/complete/index.js.map +1 -0
  14. package/dist/cjs/events/index.d.ts +95 -0
  15. package/dist/cjs/events/index.js +85 -0
  16. package/dist/cjs/events/index.js.map +1 -0
  17. package/dist/cjs/events/initialize/index.d.ts +45 -0
  18. package/dist/cjs/events/initialize/index.js +105 -0
  19. package/dist/cjs/events/initialize/index.js.map +1 -0
  20. package/dist/cjs/events/state/index.d.ts +67 -0
  21. package/dist/cjs/events/state/index.js +145 -0
  22. package/dist/cjs/events/state/index.js.map +1 -0
  23. package/dist/cjs/exceptions/index.d.ts +84 -0
  24. package/dist/{exceptions → cjs/exceptions}/index.js +38 -18
  25. package/dist/cjs/exceptions/index.js.map +1 -0
  26. package/dist/cjs/index.d.ts +14 -0
  27. package/dist/cjs/index.js +33 -0
  28. package/dist/cjs/index.js.map +1 -0
  29. package/dist/cjs/subscribers/index.d.ts +34 -0
  30. package/dist/cjs/subscribers/index.js +187 -0
  31. package/dist/cjs/subscribers/index.js.map +1 -0
  32. package/dist/cjs/types/index.d.ts +110 -0
  33. package/dist/cjs/types/index.js +53 -0
  34. package/dist/cjs/types/index.js.map +1 -0
  35. package/dist/cjs/utils/index.d.ts +72 -0
  36. package/dist/cjs/utils/index.js +208 -0
  37. package/dist/cjs/utils/index.js.map +1 -0
  38. package/dist/esm/cache/index.d.mts +198 -0
  39. package/dist/esm/cache/index.js +4 -0
  40. package/dist/{index.js.map → esm/cache/index.js.map} +1 -1
  41. package/dist/{events/initialize/index.js → esm/chunk-3JTTZCSQ.js} +25 -19
  42. package/dist/esm/chunk-3JTTZCSQ.js.map +1 -0
  43. package/dist/{events/state/index.js → esm/chunk-6225YMFE.js} +38 -20
  44. package/dist/esm/chunk-6225YMFE.js.map +1 -0
  45. package/dist/esm/chunk-7QVYU63E.js +6 -0
  46. package/dist/esm/chunk-7QVYU63E.js.map +1 -0
  47. package/dist/{events/complete/index.js → esm/chunk-BNMI7DW3.js} +25 -19
  48. package/dist/esm/chunk-BNMI7DW3.js.map +1 -0
  49. package/dist/{subscribers/index.js → esm/chunk-HYNJBWW5.js} +36 -34
  50. package/dist/esm/chunk-HYNJBWW5.js.map +1 -0
  51. package/dist/{events/index.js → esm/chunk-JDL3U4OX.js} +7 -37
  52. package/dist/esm/chunk-JDL3U4OX.js.map +1 -0
  53. package/dist/{events/chunk/index.js → esm/chunk-LD2DWZRJ.js} +14 -11
  54. package/dist/esm/chunk-LD2DWZRJ.js.map +1 -0
  55. package/dist/{utils/index.js → esm/chunk-MFYC4PBP.js} +15 -22
  56. package/dist/esm/chunk-MFYC4PBP.js.map +1 -0
  57. package/dist/esm/chunk-NXYS73I4.js +125 -0
  58. package/dist/esm/chunk-NXYS73I4.js.map +1 -0
  59. package/dist/{cache/index.js → esm/chunk-PFALORWQ.js} +10 -11
  60. package/dist/esm/chunk-PFALORWQ.js.map +1 -0
  61. package/dist/{core/index.js → esm/chunk-TONVXBLH.js} +239 -231
  62. package/dist/esm/chunk-TONVXBLH.js.map +1 -0
  63. package/dist/{types/index.js → esm/chunk-X757PBC5.js} +5 -7
  64. package/dist/esm/chunk-X757PBC5.js.map +1 -0
  65. package/dist/esm/core/index.d.mts +271 -0
  66. package/dist/esm/core/index.js +12 -0
  67. package/dist/esm/core/index.js.map +1 -0
  68. package/dist/esm/events/chunk/index.d.mts +27 -0
  69. package/dist/esm/events/chunk/index.js +4 -0
  70. package/dist/esm/events/chunk/index.js.map +1 -0
  71. package/dist/esm/events/complete/index.d.mts +64 -0
  72. package/dist/esm/events/complete/index.js +4 -0
  73. package/dist/esm/events/complete/index.js.map +1 -0
  74. package/dist/esm/events/index.d.mts +95 -0
  75. package/dist/esm/events/index.js +8 -0
  76. package/dist/esm/events/index.js.map +1 -0
  77. package/dist/esm/events/initialize/index.d.mts +45 -0
  78. package/dist/esm/events/initialize/index.js +4 -0
  79. package/dist/esm/events/initialize/index.js.map +1 -0
  80. package/dist/esm/events/state/index.d.mts +67 -0
  81. package/dist/esm/events/state/index.js +4 -0
  82. package/dist/esm/events/state/index.js.map +1 -0
  83. package/dist/esm/exceptions/index.d.mts +84 -0
  84. package/dist/esm/exceptions/index.js +4 -0
  85. package/dist/esm/exceptions/index.js.map +1 -0
  86. package/dist/esm/index.d.mts +14 -0
  87. package/dist/esm/index.js +14 -0
  88. package/dist/esm/index.js.map +1 -0
  89. package/dist/esm/subscribers/index.d.mts +34 -0
  90. package/dist/esm/subscribers/index.js +10 -0
  91. package/dist/esm/subscribers/index.js.map +1 -0
  92. package/dist/esm/types/index.d.mts +110 -0
  93. package/dist/esm/types/index.js +4 -0
  94. package/dist/esm/types/index.js.map +1 -0
  95. package/dist/esm/utils/index.d.mts +72 -0
  96. package/dist/esm/utils/index.js +5 -0
  97. package/dist/esm/utils/index.js.map +1 -0
  98. package/package.json +165 -14
  99. package/dist/cache/index.js.map +0 -1
  100. package/dist/core/index.js.map +0 -1
  101. package/dist/events/chunk/index.js.map +0 -1
  102. package/dist/events/complete/index.js.map +0 -1
  103. package/dist/events/index.js.map +0 -1
  104. package/dist/events/initialize/index.js.map +0 -1
  105. package/dist/events/state/index.js.map +0 -1
  106. package/dist/exceptions/index.js.map +0 -1
  107. package/dist/index.js +0 -49
  108. package/dist/subscribers/index.js.map +0 -1
  109. package/dist/types/index.js.map +0 -1
  110. package/dist/utils/index.js.map +0 -1
@@ -0,0 +1,45 @@
1
+ import { InitializeUploadOptions, InitializeUploadResponse } from '../../types/index.js';
2
+ import { BaseEvent } from '@wlindabla/event_dispatcher';
3
+ import '@wlindabla/http_client';
4
+
5
+ /**
6
+ * Event data for Upload State INITIALIZE
7
+ */
8
+ declare class InitializingUploadEvent extends BaseEvent {
9
+ readonly initUploadOptions: InitializeUploadOptions;
10
+ private _mediaId;
11
+ constructor(initUploadOptions: InitializeUploadOptions);
12
+ setMediaId(_mediaUploadId: string): void;
13
+ get mediaId(): string;
14
+ }
15
+ /**
16
+ * Event data for INITIALIZE_UPLOAD_STARTED
17
+ */
18
+ declare class InitializeUploadStartedEvent extends BaseEvent {
19
+ readonly fileName: string;
20
+ readonly fileSize: number;
21
+ readonly fileHash: string;
22
+ constructor(fileName: string, fileSize: number, fileHash: string);
23
+ }
24
+ /**
25
+ * Event data for INITIALIZE_UPLOAD_SUCCESS
26
+ */
27
+ declare class InitializeUploadSuccessEvent extends BaseEvent {
28
+ readonly status: number;
29
+ readonly sessionId: string;
30
+ readonly responseData: InitializeUploadResponse;
31
+ constructor(status: number, sessionId: string, responseData: InitializeUploadResponse);
32
+ }
33
+ /**
34
+ * Event data for INITIALIZE_UPLOAD_FAILURE
35
+ */
36
+ declare class InitializeUploadFailureEvent extends BaseEvent {
37
+ readonly error: Error;
38
+ readonly status?: number | undefined;
39
+ readonly errorData?: any | undefined;
40
+ readonly responseData?: any | undefined;
41
+ readonly isNetworkError?: boolean | undefined;
42
+ constructor(error: Error, status?: number | undefined, errorData?: any | undefined, responseData?: any | undefined, isNetworkError?: boolean | undefined);
43
+ }
44
+
45
+ export { InitializeUploadFailureEvent, InitializeUploadStartedEvent, InitializeUploadSuccessEvent, InitializingUploadEvent };
@@ -0,0 +1,105 @@
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 initialize_exports = {};
21
+ __export(initialize_exports, {
22
+ InitializeUploadFailureEvent: () => InitializeUploadFailureEvent,
23
+ InitializeUploadStartedEvent: () => InitializeUploadStartedEvent,
24
+ InitializeUploadSuccessEvent: () => InitializeUploadSuccessEvent,
25
+ InitializingUploadEvent: () => InitializingUploadEvent
26
+ });
27
+ module.exports = __toCommonJS(initialize_exports);
28
+ var import_event_dispatcher = require("@wlindabla/event_dispatcher");
29
+ class InitializingUploadEvent extends import_event_dispatcher.BaseEvent {
30
+ constructor(initUploadOptions) {
31
+ super();
32
+ this.initUploadOptions = initUploadOptions;
33
+ this._mediaId = null;
34
+ }
35
+ initUploadOptions;
36
+ static {
37
+ __name(this, "InitializingUploadEvent");
38
+ }
39
+ _mediaId;
40
+ setMediaId(_mediaUploadId) {
41
+ this._mediaId = _mediaUploadId;
42
+ }
43
+ get mediaId() {
44
+ if (this._mediaId === null) {
45
+ throw new Error(
46
+ "MediaId has not been set. This likely means the InitializeUploadSubscriber failed. Check that INITIALIZE_UPLOAD event was properly handled."
47
+ );
48
+ }
49
+ return this._mediaId;
50
+ }
51
+ }
52
+ class InitializeUploadStartedEvent extends import_event_dispatcher.BaseEvent {
53
+ constructor(fileName, fileSize, fileHash) {
54
+ super();
55
+ this.fileName = fileName;
56
+ this.fileSize = fileSize;
57
+ this.fileHash = fileHash;
58
+ }
59
+ fileName;
60
+ fileSize;
61
+ fileHash;
62
+ static {
63
+ __name(this, "InitializeUploadStartedEvent");
64
+ }
65
+ }
66
+ class InitializeUploadSuccessEvent extends import_event_dispatcher.BaseEvent {
67
+ constructor(status, sessionId, responseData) {
68
+ super();
69
+ this.status = status;
70
+ this.sessionId = sessionId;
71
+ this.responseData = responseData;
72
+ }
73
+ status;
74
+ sessionId;
75
+ responseData;
76
+ static {
77
+ __name(this, "InitializeUploadSuccessEvent");
78
+ }
79
+ }
80
+ class InitializeUploadFailureEvent extends import_event_dispatcher.BaseEvent {
81
+ constructor(error, status, errorData, responseData, isNetworkError) {
82
+ super();
83
+ this.error = error;
84
+ this.status = status;
85
+ this.errorData = errorData;
86
+ this.responseData = responseData;
87
+ this.isNetworkError = isNetworkError;
88
+ }
89
+ error;
90
+ status;
91
+ errorData;
92
+ responseData;
93
+ isNetworkError;
94
+ static {
95
+ __name(this, "InitializeUploadFailureEvent");
96
+ }
97
+ }
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ InitializeUploadFailureEvent,
101
+ InitializeUploadStartedEvent,
102
+ InitializeUploadSuccessEvent,
103
+ InitializingUploadEvent
104
+ });
105
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/events/initialize/index.ts"],"sourcesContent":["/*\n * This file is part of the project by AGBOKOUDJO Franck.\n *\n * (c) AGBOKOUDJO Franck <internationaleswebservices@gmail.com>\n * Phone: +229 0167 25 18 86\n * LinkedIn: https://www.linkedin.com/in/internationales-web-apps-services-120520193/\n * Company: INTERNATIONALES WEB APPS & SERVICES\n *\n * For more information, please feel free to contact the author.\n */\n\nimport {\n InitializeUploadOptions,\n InitializeUploadResponse\n} from \"../../types\";\n\nimport { BaseEvent } from \"@wlindabla/event_dispatcher\";\n\n/**\n * Event data for Upload State INITIALIZE\n */\nexport class InitializingUploadEvent extends BaseEvent{\n private _mediaId: string | null;\n constructor(\n public readonly initUploadOptions: InitializeUploadOptions\n ) {\n super();\n this._mediaId = null;\n } \n\n public setMediaId(_mediaUploadId: string) {\n this._mediaId = _mediaUploadId;\n }\n\n public get mediaId(): string {\n if (this._mediaId === null) {\n throw new Error(\n 'MediaId has not been set. ' +\n 'This likely means the InitializeUploadSubscriber failed. ' +\n 'Check that INITIALIZE_UPLOAD event was properly handled.'\n );\n }\n return this._mediaId;\n }\n}\n\n/**\n * Event data for INITIALIZE_UPLOAD_STARTED\n */\nexport class InitializeUploadStartedEvent extends BaseEvent {\n constructor(\n public readonly fileName: string,\n public readonly fileSize: number,\n public readonly fileHash: string\n ) { super(); }\n}\n\n/**\n * Event data for INITIALIZE_UPLOAD_SUCCESS\n */\nexport class InitializeUploadSuccessEvent extends BaseEvent{\n constructor(\n public readonly status: number,\n public readonly sessionId: string,\n public readonly responseData: InitializeUploadResponse\n ) { super(); }\n}\n\n/**\n * Event data for INITIALIZE_UPLOAD_FAILURE\n */\nexport class InitializeUploadFailureEvent extends BaseEvent {\n constructor(\n public readonly error: Error,\n public readonly status?: number,\n public readonly errorData?: any,\n public readonly responseData?: any,\n public readonly isNetworkError?: boolean\n ) { super(); }\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,8BAA0B;AAKnB,MAAM,gCAAgC,kCAAS;AAAA,EAElD,YACoB,mBAClB;AACE,UAAM;AAFU;AAGhB,SAAK,WAAW;AAAA,EACpB;AAAA,EAJoB;AAAA,EAxBxB,OAqBsD;AAAA;AAAA;AAAA,EAC1C;AAAA,EAQD,WAAW,gBAAwB;AACtC,SAAK,WAAW;AAAA,EACpB;AAAA,EAEA,IAAW,UAAkB;AACzB,QAAI,KAAK,aAAa,MAAM;AACxB,YAAM,IAAI;AAAA,QACN;AAAA,MAGJ;AAAA,IACJ;AACA,WAAO,KAAK;AAAA,EAChB;AACJ;AAKO,MAAM,qCAAqC,kCAAU;AAAA,EACxD,YACoB,UACA,UACA,UAClB;AAAE,UAAM;AAHU;AACA;AACA;AAAA,EACP;AAAA,EAHO;AAAA,EACA;AAAA,EACA;AAAA,EArDxB,OAiD4D;AAAA;AAAA;AAM5D;AAKO,MAAM,qCAAqC,kCAAS;AAAA,EACvD,YACoB,QACA,WACA,cAClB;AAAE,UAAM;AAHU;AACA;AACA;AAAA,EACP;AAAA,EAHO;AAAA,EACA;AAAA,EACA;AAAA,EAhExB,OA4D2D;AAAA;AAAA;AAM3D;AAKO,MAAM,qCAAqC,kCAAU;AAAA,EACxD,YACoB,OACA,QACA,WACA,cACA,gBAClB;AAAE,UAAM;AALU;AACA;AACA;AACA;AACA;AAAA,EACP;AAAA,EALO;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EA7ExB,OAuE4D;AAAA;AAAA;AAQ5D;","names":[]}
@@ -0,0 +1,67 @@
1
+ import { UploadProgress, UploadState } from '../../types/index.js';
2
+ import '@wlindabla/http_client';
3
+
4
+ /**
5
+ * Event data for UPLOAD_STATE_CHANGED
6
+ */
7
+ declare class UploadStateChangedEvent {
8
+ readonly oldState: UploadState;
9
+ readonly newState: UploadState;
10
+ readonly changedAt: number;
11
+ constructor(oldState: UploadState, newState: UploadState, changedAt?: number);
12
+ }
13
+ /**
14
+ * Event data for UPLOAD_CANCELLED
15
+ */
16
+ declare class UploadCancelledEvent {
17
+ readonly mediaName: string;
18
+ readonly totalChunks: number;
19
+ readonly uploadedBytes: number;
20
+ readonly percentage: number;
21
+ readonly currentChunkIndex: number;
22
+ readonly message: string;
23
+ readonly cancelledAt: number;
24
+ constructor(mediaName: string, totalChunks: number, uploadedBytes: number, percentage: number, currentChunkIndex: number, message?: string, cancelledAt?: number);
25
+ }
26
+ /**
27
+ * Event data for UPLOAD_RESUMED
28
+ */
29
+ declare class UploadResumedEvent {
30
+ readonly mediaName: string;
31
+ readonly totalChunks: number;
32
+ readonly uploadedBytes: number;
33
+ readonly percentage: number;
34
+ readonly resumedAt: number;
35
+ constructor(mediaName: string, totalChunks: number, uploadedBytes: number, percentage: number, resumedAt?: number);
36
+ }
37
+ /**
38
+ * Event data for UPLOAD_PAUSED
39
+ */
40
+ declare class UploadPausedEvent {
41
+ readonly mediaName: string;
42
+ readonly totalChunks: number;
43
+ readonly uploadedBytes: number;
44
+ readonly percentage: number;
45
+ readonly pausedAt: number;
46
+ constructor(mediaName: string, totalChunks: number, uploadedBytes: number, percentage: number, pausedAt?: number);
47
+ }
48
+ /**
49
+ * Event data for MEDIA_CHUNK_UPLOAD_SUCCESS
50
+ */
51
+ declare class UploadProgressEvent {
52
+ private readonly uploadProgress;
53
+ readonly responseData: string | Record<string, string | any> | unknown;
54
+ readonly httpStatus: number;
55
+ constructor(uploadProgress: UploadProgress, responseData: string | Record<string, string | any> | unknown, httpStatus: number);
56
+ get uploadedChunks(): number;
57
+ get totalChunks(): number;
58
+ get percentage(): number;
59
+ get uploadedBytes(): number;
60
+ get totalBytes(): number;
61
+ get currentChunk(): number;
62
+ get speed(): number | undefined;
63
+ get estimatedTimeRemaining(): number | undefined | null;
64
+ get elapsed(): number;
65
+ }
66
+
67
+ export { UploadCancelledEvent, UploadPausedEvent, UploadProgressEvent, UploadResumedEvent, UploadStateChangedEvent };
@@ -0,0 +1,145 @@
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 state_exports = {};
21
+ __export(state_exports, {
22
+ UploadCancelledEvent: () => UploadCancelledEvent,
23
+ UploadPausedEvent: () => UploadPausedEvent,
24
+ UploadProgressEvent: () => UploadProgressEvent,
25
+ UploadResumedEvent: () => UploadResumedEvent,
26
+ UploadStateChangedEvent: () => UploadStateChangedEvent
27
+ });
28
+ module.exports = __toCommonJS(state_exports);
29
+ class UploadStateChangedEvent {
30
+ constructor(oldState, newState, changedAt = Date.now()) {
31
+ this.oldState = oldState;
32
+ this.newState = newState;
33
+ this.changedAt = changedAt;
34
+ }
35
+ oldState;
36
+ newState;
37
+ changedAt;
38
+ static {
39
+ __name(this, "UploadStateChangedEvent");
40
+ }
41
+ }
42
+ class UploadCancelledEvent {
43
+ constructor(mediaName, totalChunks, uploadedBytes, percentage, currentChunkIndex, message = "Upload cancelled by user", cancelledAt = Date.now()) {
44
+ this.mediaName = mediaName;
45
+ this.totalChunks = totalChunks;
46
+ this.uploadedBytes = uploadedBytes;
47
+ this.percentage = percentage;
48
+ this.currentChunkIndex = currentChunkIndex;
49
+ this.message = message;
50
+ this.cancelledAt = cancelledAt;
51
+ }
52
+ mediaName;
53
+ totalChunks;
54
+ uploadedBytes;
55
+ percentage;
56
+ currentChunkIndex;
57
+ message;
58
+ cancelledAt;
59
+ static {
60
+ __name(this, "UploadCancelledEvent");
61
+ }
62
+ }
63
+ class UploadResumedEvent {
64
+ constructor(mediaName, totalChunks, uploadedBytes, percentage, resumedAt = Date.now()) {
65
+ this.mediaName = mediaName;
66
+ this.totalChunks = totalChunks;
67
+ this.uploadedBytes = uploadedBytes;
68
+ this.percentage = percentage;
69
+ this.resumedAt = resumedAt;
70
+ }
71
+ mediaName;
72
+ totalChunks;
73
+ uploadedBytes;
74
+ percentage;
75
+ resumedAt;
76
+ static {
77
+ __name(this, "UploadResumedEvent");
78
+ }
79
+ }
80
+ class UploadPausedEvent {
81
+ constructor(mediaName, totalChunks, uploadedBytes, percentage, pausedAt = Date.now()) {
82
+ this.mediaName = mediaName;
83
+ this.totalChunks = totalChunks;
84
+ this.uploadedBytes = uploadedBytes;
85
+ this.percentage = percentage;
86
+ this.pausedAt = pausedAt;
87
+ }
88
+ mediaName;
89
+ totalChunks;
90
+ uploadedBytes;
91
+ percentage;
92
+ pausedAt;
93
+ static {
94
+ __name(this, "UploadPausedEvent");
95
+ }
96
+ }
97
+ class UploadProgressEvent {
98
+ constructor(uploadProgress, responseData, httpStatus) {
99
+ this.uploadProgress = uploadProgress;
100
+ this.responseData = responseData;
101
+ this.httpStatus = httpStatus;
102
+ }
103
+ uploadProgress;
104
+ responseData;
105
+ httpStatus;
106
+ static {
107
+ __name(this, "UploadProgressEvent");
108
+ }
109
+ get uploadedChunks() {
110
+ return this.uploadProgress.uploadedChunks;
111
+ }
112
+ get totalChunks() {
113
+ return this.uploadProgress.totalChunks;
114
+ }
115
+ get percentage() {
116
+ return this.uploadProgress.percentage;
117
+ }
118
+ get uploadedBytes() {
119
+ return this.uploadProgress.uploadedBytes;
120
+ }
121
+ get totalBytes() {
122
+ return this.uploadProgress.totalBytes;
123
+ }
124
+ get currentChunk() {
125
+ return this.uploadProgress.currentChunk;
126
+ }
127
+ get speed() {
128
+ return this.uploadProgress.speed;
129
+ }
130
+ get estimatedTimeRemaining() {
131
+ return this.uploadProgress.estimatedTimeRemaining;
132
+ }
133
+ get elapsed() {
134
+ return this.uploadProgress.elapsed;
135
+ }
136
+ }
137
+ // Annotate the CommonJS export names for ESM import in node:
138
+ 0 && (module.exports = {
139
+ UploadCancelledEvent,
140
+ UploadPausedEvent,
141
+ UploadProgressEvent,
142
+ UploadResumedEvent,
143
+ UploadStateChangedEvent
144
+ });
145
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/events/state/index.ts"],"sourcesContent":["/*\n * This file is part of the project by AGBOKOUDJO Franck.\n *\n * (c) AGBOKOUDJO Franck <internationaleswebservices@gmail.com>\n * Phone: +229 0167 25 18 86\n * LinkedIn: https://www.linkedin.com/in/internationales-web-apps-services-120520193/\n * Company: INTERNATIONALES WEB APPS & SERVICES\n *\n * For more information, please feel free to contact the author.\n */\n\nimport {\n UploadState,\n UploadProgress\n} from \"../../types\";\n\n/**\n * Event data for UPLOAD_STATE_CHANGED\n */\nexport class UploadStateChangedEvent {\n constructor(\n public readonly oldState: UploadState,\n public readonly newState: UploadState,\n public readonly changedAt: number = Date.now()\n ) { }\n}\n\n\n/**\n * Event data for UPLOAD_CANCELLED\n */\nexport class UploadCancelledEvent {\n constructor(\n public readonly mediaName: string,\n public readonly totalChunks: number,\n public readonly uploadedBytes: number,\n public readonly percentage: number,\n public readonly currentChunkIndex:number,\n public readonly message: string =\"Upload cancelled by user\",\n public readonly cancelledAt: number = Date.now()\n ) { }\n}\n\n\n/**\n * Event data for UPLOAD_RESUMED\n */\nexport class UploadResumedEvent {\n constructor(\n public readonly mediaName: string,\n public readonly totalChunks: number,\n public readonly uploadedBytes: number,\n public readonly percentage: number,\n public readonly resumedAt: number = Date.now()\n ) { }\n}\n\n/**\n * Event data for UPLOAD_PAUSED\n */\nexport class UploadPausedEvent {\n constructor(\n public readonly mediaName: string,\n public readonly totalChunks: number,\n public readonly uploadedBytes: number,\n public readonly percentage: number,\n public readonly pausedAt: number = Date.now()\n ) { }\n}\n\n/**\n * Event data for MEDIA_CHUNK_UPLOAD_SUCCESS\n */\nexport class UploadProgressEvent {\n constructor(\n private readonly uploadProgress: UploadProgress,\n public readonly responseData: string | Record<string, string | any> | unknown,\n public readonly httpStatus: number\n ) { }\n\n public get uploadedChunks(): number { return this.uploadProgress.uploadedChunks; }\n\n public get totalChunks(): number { return this.uploadProgress.totalChunks; }\n\n public get percentage(): number { return this.uploadProgress.percentage; }\n\n public get uploadedBytes(): number { return this.uploadProgress.uploadedBytes; }\n\n public get totalBytes(): number { return this.uploadProgress.totalBytes; }\n\n public get currentChunk(): number { return this.uploadProgress.currentChunk; }\n\n public get speed(): number | undefined { return this.uploadProgress.speed; }\n\n public get estimatedTimeRemaining(): number | undefined | null { return this.uploadProgress.estimatedTimeRemaining; }\n\n public get elapsed(): number { return this.uploadProgress.elapsed; }\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBO,MAAM,wBAAwB;AAAA,EACjC,YACoB,UACA,UACA,YAAoB,KAAK,IAAI,GAC/C;AAHkB;AACA;AACA;AAAA,EAChB;AAAA,EAHgB;AAAA,EACA;AAAA,EACA;AAAA,EAvBxB,OAmBqC;AAAA;AAAA;AAMrC;AAMO,MAAM,qBAAqB;AAAA,EAC9B,YACoB,WACA,aACA,eACA,YACA,mBACA,UAAiB,4BACjB,cAAsB,KAAK,IAAI,GACjD;AAPkB;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EAChB;AAAA,EAPgB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAvCxB,OA+BkC;AAAA;AAAA;AAUlC;AAMO,MAAM,mBAAmB;AAAA,EAC5B,YACoB,WACA,aACA,eACA,YACA,YAAoB,KAAK,IAAI,GAC/C;AALkB;AACA;AACA;AACA;AACA;AAAA,EAChB;AAAA,EALgB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EArDxB,OA+CgC;AAAA;AAAA;AAQhC;AAKO,MAAM,kBAAkB;AAAA,EAC3B,YACoB,WACA,aACA,eACA,YACA,WAAmB,KAAK,IAAI,GAC9C;AALkB;AACA;AACA;AACA;AACA;AAAA,EAChB;AAAA,EALgB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAlExB,OA4D+B;AAAA;AAAA;AAQ/B;AAKO,MAAM,oBAAoB;AAAA,EAC7B,YACqB,gBACD,cACA,YAClB;AAHmB;AACD;AACA;AAAA,EAChB;AAAA,EAHiB;AAAA,EACD;AAAA,EACA;AAAA,EA7ExB,OAyEiC;AAAA;AAAA;AAAA,EAO7B,IAAW,iBAAyB;AAAE,WAAO,KAAK,eAAe;AAAA,EAAgB;AAAA,EAEjF,IAAW,cAAsB;AAAE,WAAO,KAAK,eAAe;AAAA,EAAa;AAAA,EAE3E,IAAW,aAAqB;AAAE,WAAO,KAAK,eAAe;AAAA,EAAY;AAAA,EAEzE,IAAW,gBAAwB;AAAE,WAAO,KAAK,eAAe;AAAA,EAAe;AAAA,EAE/E,IAAW,aAAqB;AAAE,WAAO,KAAK,eAAe;AAAA,EAAY;AAAA,EAEzE,IAAW,eAAuB;AAAE,WAAO,KAAK,eAAe;AAAA,EAAc;AAAA,EAE7E,IAAW,QAA4B;AAAE,WAAO,KAAK,eAAe;AAAA,EAAO;AAAA,EAE3E,IAAW,yBAAoD;AAAE,WAAO,KAAK,eAAe;AAAA,EAAwB;AAAA,EAEpH,IAAW,UAAkB;AAAE,WAAO,KAAK,eAAe;AAAA,EAAS;AACvE;","names":[]}
@@ -0,0 +1,84 @@
1
+ import { ChunkError, ChunkInfo } from '../types/index.js';
2
+ import '@wlindabla/http_client';
3
+
4
+ declare class InitializeUploadFailureException extends Error {
5
+ readonly responseData: any;
6
+ constructor(responseData: any, message: string);
7
+ }
8
+ /**
9
+ * Exception data for MEDIA_CHUNK_UPLOAD_HTTP_ERROR_RESPONSE
10
+ */
11
+ declare class ChunkUploadHttpErrorException extends Error {
12
+ readonly errorPayload: string | Record<string, string | unknown> | unknown;
13
+ readonly statusResponse: number;
14
+ constructor(errorPayload: string | Record<string, string | unknown> | unknown, statusResponse: number);
15
+ }
16
+ /**
17
+ * Custom error thrown during chunked file upload operations.
18
+ *
19
+ * This error provides detailed information about which chunk failed,
20
+ * the underlying error, and whether a retry will be attempted.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * try {
25
+ * await uploadChunk(chunk);
26
+ * } catch (error) {
27
+ * throw new FileUploadChunkError(
28
+ * `Failed to upload chunk ${chunkIndex}`,
29
+ * chunkError
30
+ * );
31
+ * }
32
+ *
33
+ * // Later in error handler
34
+ * if (error instanceof FileUploadChunkError) {
35
+ * console.log(`Chunk ${error.chunkIndex} failed`);
36
+ * console.log(`Will retry: ${error.willRetry}`);
37
+ * }
38
+ * ```
39
+ */
40
+ declare class FileUploadChunkError extends Error {
41
+ /**
42
+ * The detailed chunk error information
43
+ */
44
+ readonly chunkError: ChunkError;
45
+ /**
46
+ * Creates a new FileUploadChunkError
47
+ *
48
+ * @param message - Human-readable error message
49
+ * @param chunkError - Detailed information about the chunk failure
50
+ */
51
+ constructor(message: string, chunkError: ChunkError);
52
+ /**
53
+ * Gets the index of the chunk that failed
54
+ */
55
+ get chunkIndex(): number;
56
+ /**
57
+ * Gets the attempt number when the chunk failed
58
+ */
59
+ get attemptNumber(): number;
60
+ /**
61
+ * Indicates whether a retry will be attempted
62
+ */
63
+ get willRetry(): boolean;
64
+ /**
65
+ * Gets the underlying error that caused the chunk upload to fail
66
+ */
67
+ get underlyingError(): Error;
68
+ /**
69
+ * Gets the full chunk information
70
+ */
71
+ get chunk(): ChunkInfo;
72
+ /**
73
+ * Returns a JSON representation of the error
74
+ */
75
+ toJSON(): object;
76
+ }
77
+ declare class UploadCancelledException extends Error {
78
+ readonly chunkIndex: number;
79
+ readonly totalChunks: number;
80
+ readonly uploadedBytes: number;
81
+ constructor(chunkIndex: number, totalChunks: number, uploadedBytes: number, message: string);
82
+ }
83
+
84
+ export { ChunkUploadHttpErrorException, FileUploadChunkError, InitializeUploadFailureException, UploadCancelledException };
@@ -1,7 +1,30 @@
1
- 'use strict';
2
-
1
+ "use strict";
3
2
  var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
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 exceptions_exports = {};
21
+ __export(exceptions_exports, {
22
+ ChunkUploadHttpErrorException: () => ChunkUploadHttpErrorException,
23
+ FileUploadChunkError: () => FileUploadChunkError,
24
+ InitializeUploadFailureException: () => InitializeUploadFailureException,
25
+ UploadCancelledException: () => UploadCancelledException
26
+ });
27
+ module.exports = __toCommonJS(exceptions_exports);
5
28
  class InitializeUploadFailureException extends Error {
6
29
  constructor(responseData, message) {
7
30
  super(message);
@@ -11,6 +34,7 @@ class InitializeUploadFailureException extends Error {
11
34
  Error.captureStackTrace(this, InitializeUploadFailureException);
12
35
  }
13
36
  }
37
+ responseData;
14
38
  static {
15
39
  __name(this, "InitializeUploadFailureException");
16
40
  }
@@ -25,6 +49,8 @@ class ChunkUploadHttpErrorException extends Error {
25
49
  Error.captureStackTrace(this, ChunkUploadHttpErrorException);
26
50
  }
27
51
  }
52
+ errorPayload;
53
+ statusResponse;
28
54
  static {
29
55
  __name(this, "ChunkUploadHttpErrorException");
30
56
  }
@@ -81,16 +107,6 @@ class FileUploadChunkError extends Error {
81
107
  get chunk() {
82
108
  return this.chunkError.chunk;
83
109
  }
84
- /**
85
- * Returns a detailed string representation of the error
86
- */
87
- toString() {
88
- return `${this.name}: ${this.message}
89
- Chunk: ${this.chunkIndex + 1}/${this.chunk.size} bytes
90
- Attempt: ${this.attemptNumber}
91
- Will Retry: ${this.willRetry}
92
- Cause: ${this.underlyingError.message}`;
93
- }
94
110
  /**
95
111
  * Returns a JSON representation of the error
96
112
  */
@@ -120,14 +136,18 @@ class UploadCancelledException extends Error {
120
136
  Error.captureStackTrace(this, UploadCancelledException);
121
137
  }
122
138
  }
139
+ chunkIndex;
140
+ totalChunks;
141
+ uploadedBytes;
123
142
  static {
124
143
  __name(this, "UploadCancelledException");
125
144
  }
126
145
  }
127
-
128
- exports.ChunkUploadHttpErrorException = ChunkUploadHttpErrorException;
129
- exports.FileUploadChunkError = FileUploadChunkError;
130
- exports.InitializeUploadFailureException = InitializeUploadFailureException;
131
- exports.UploadCancelledException = UploadCancelledException;
132
- //# sourceMappingURL=index.js.map
146
+ // Annotate the CommonJS export names for ESM import in node:
147
+ 0 && (module.exports = {
148
+ ChunkUploadHttpErrorException,
149
+ FileUploadChunkError,
150
+ InitializeUploadFailureException,
151
+ UploadCancelledException
152
+ });
133
153
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/exceptions/index.ts"],"sourcesContent":["/*\n * This file is part of the project by AGBOKOUDJO Franck.\n *\n * (c) AGBOKOUDJO Franck <internationaleswebservices@gmail.com>\n * Phone: +229 0167 25 18 86\n * LinkedIn: https://www.linkedin.com/in/internationales-web-apps-services-120520193/\n * Company: INTERNATIONALES WEB APPS & SERVICES\n *\n * For more information, please feel free to contact the author.\n */\n\nimport { ChunkInfo, ChunkError } from \"../types\";\n\nexport class InitializeUploadFailureException extends Error {\n constructor(public readonly responseData: any, message: string) {\n super(message);\n this.name = \"InitializeUploadFailureException\";\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, InitializeUploadFailureException);\n }\n }\n}\n\n/**\n * Exception data for MEDIA_CHUNK_UPLOAD_HTTP_ERROR_RESPONSE\n */\nexport class ChunkUploadHttpErrorException extends Error {\n constructor(\n public readonly errorPayload: string | Record<string, string | unknown> | unknown,\n public readonly statusResponse: number\n ) {\n super();\n\n this.name = \"ChunkUploadHttpErrorException\";\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, ChunkUploadHttpErrorException);\n }\n }\n}\n\n/**\n * Custom error thrown during chunked file upload operations.\n * \n * This error provides detailed information about which chunk failed,\n * the underlying error, and whether a retry will be attempted.\n * \n * @example\n * ```typescript\n * try {\n * await uploadChunk(chunk);\n * } catch (error) {\n * throw new FileUploadChunkError(\n * `Failed to upload chunk ${chunkIndex}`,\n * chunkError\n * );\n * }\n * \n * // Later in error handler\n * if (error instanceof FileUploadChunkError) {\n * console.log(`Chunk ${error.chunkIndex} failed`);\n * console.log(`Will retry: ${error.willRetry}`);\n * }\n * ```\n */\nexport class FileUploadChunkError extends Error {\n\n /**\n * The detailed chunk error information\n */\n public readonly chunkError: ChunkError;\n\n /**\n * Creates a new FileUploadChunkError\n * \n * @param message - Human-readable error message\n * @param chunkError - Detailed information about the chunk failure\n */\n constructor(message: string, chunkError: ChunkError) {\n super(message, { cause: chunkError.error });\n\n this.name = \"FileUploadChunkError\";\n this.chunkError = chunkError;\n\n // Maintain proper stack trace in V8 engines (Chrome, Node.js)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, FileUploadChunkError);\n }\n }\n\n /**\n * Gets the index of the chunk that failed\n */\n get chunkIndex(): number {\n return this.chunkError.chunk.index;\n }\n\n /**\n * Gets the attempt number when the chunk failed\n */\n get attemptNumber(): number {\n return this.chunkError.attempt;\n }\n\n /**\n * Indicates whether a retry will be attempted\n */\n get willRetry(): boolean {\n return this.chunkError.willRetry;\n }\n\n /**\n * Gets the underlying error that caused the chunk upload to fail\n */\n get underlyingError(): Error {\n return this.chunkError.error;\n }\n\n /**\n * Gets the full chunk information\n */\n get chunk(): ChunkInfo {\n return this.chunkError.chunk;\n }\n \n /**\n * Returns a JSON representation of the error\n */\n toJSON(): object {\n return {\n name: this.name,\n message: this.message,\n chunkIndex: this.chunkIndex,\n attempt: this.attemptNumber,\n willRetry: this.willRetry,\n underlyingError: {\n name: this.underlyingError.name,\n message: this.underlyingError.message\n },\n stack: this.stack\n };\n }\n}\n\n\nexport class UploadCancelledException extends Error {\n constructor(\n public readonly chunkIndex: number,\n public readonly totalChunks: number,\n public readonly uploadedBytes: number,\n message: string\n ) {\n super(message);\n this.name = \"UploadCancelledException\";\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, UploadCancelledException);\n }\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,MAAM,yCAAyC,MAAM;AAAA,EACxD,YAA4B,cAAmB,SAAiB;AAC5D,UAAM,OAAO;AADW;AAExB,SAAK,OAAO;AAEZ,QAAI,MAAM,mBAAmB;AACzB,YAAM,kBAAkB,MAAM,gCAAgC;AAAA,IAClE;AAAA,EACJ;AAAA,EAP4B;AAAA,EAdhC,OAa4D;AAAA;AAAA;AAS5D;AAKO,MAAM,sCAAsC,MAAM;AAAA,EACrD,YACoB,cACA,gBAClB;AACE,UAAM;AAHU;AACA;AAIhB,SAAK,OAAO;AAEZ,QAAI,MAAM,mBAAmB;AACzB,YAAM,kBAAkB,MAAM,6BAA6B;AAAA,IAC/D;AAAA,EACJ;AAAA,EAVoB;AAAA,EACA;AAAA,EA9BxB,OA2ByD;AAAA;AAAA;AAazD;AA0BO,MAAM,6BAA6B,MAAM;AAAA,EAlEhD,OAkEgD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAK5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhB,YAAY,SAAiB,YAAwB;AACjD,UAAM,SAAS,EAAE,OAAO,WAAW,MAAM,CAAC;AAE1C,SAAK,OAAO;AACZ,SAAK,aAAa;AAGlB,QAAI,MAAM,mBAAmB;AACzB,YAAM,kBAAkB,MAAM,oBAAoB;AAAA,IACtD;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,aAAqB;AACrB,WAAO,KAAK,WAAW,MAAM;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,gBAAwB;AACxB,WAAO,KAAK,WAAW;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,YAAqB;AACrB,WAAO,KAAK,WAAW;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,kBAAyB;AACzB,WAAO,KAAK,WAAW;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,QAAmB;AACnB,WAAO,KAAK,WAAW;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKA,SAAiB;AACb,WAAO;AAAA,MACH,MAAM,KAAK;AAAA,MACX,SAAS,KAAK;AAAA,MACd,YAAY,KAAK;AAAA,MACjB,SAAS,KAAK;AAAA,MACd,WAAW,KAAK;AAAA,MAChB,iBAAiB;AAAA,QACb,MAAM,KAAK,gBAAgB;AAAA,QAC3B,SAAS,KAAK,gBAAgB;AAAA,MAClC;AAAA,MACA,OAAO,KAAK;AAAA,IAChB;AAAA,EACJ;AACJ;AAGO,MAAM,iCAAiC,MAAM;AAAA,EAChD,YACoB,YACA,aACA,eAChB,SACF;AACE,UAAM,OAAO;AALG;AACA;AACA;AAIhB,SAAK,OAAO;AAEZ,QAAI,MAAM,mBAAmB;AACzB,YAAM,kBAAkB,MAAM,wBAAwB;AAAA,IAC1D;AAAA,EACJ;AAAA,EAXoB;AAAA,EACA;AAAA,EACA;AAAA,EAtJxB,OAkJoD;AAAA;AAAA;AAcpD;","names":[]}
@@ -0,0 +1,14 @@
1
+ export { ChunkError, ChunkInfo, ChunkSizeConfig, DEFAULT_CONFIG, InitializeUploadOptions, InitializeUploadResponse, ResumeData, UploadEndpoints, UploadOptions, UploadProgress, UploadResult, UploadState, UploadStatus } from './types/index.js';
2
+ export { ChunkFormDataBuilder, ChunkFormDataOptions, ExponentialBackoffStrategy, FileUtils, LinearBackoffStrategy, createChunkFormData, updateProgressBarHTMLNotified } from './utils/index.js';
3
+ export { ChunkUploadHttpErrorException, FileUploadChunkError, InitializeUploadFailureException, UploadCancelledException } from './exceptions/index.js';
4
+ export { HttpFileUploaderEvents } from './events/index.js';
5
+ export { FinalizeUploadSubscriber, InitializeUploadSubscriber } from './subscribers/index.js';
6
+ export { DefaultUploadResumeCacheAdapter, UploadCacheError, UploadResumeCacheInterface } from './cache/index.js';
7
+ export { ChunkedFileUploader } from './core/index.js';
8
+ export { ChunkUploadHttpErrorResponseEvent, UploadChunkStartedEvent } from './events/chunk/index.js';
9
+ export { FinalizeUploadEvent, FinalizeUploadFailureEvent, ResumeUploadEvent, UploadMediaCompleteEvent } from './events/complete/index.js';
10
+ export { InitializeUploadFailureEvent, InitializeUploadStartedEvent, InitializeUploadSuccessEvent, InitializingUploadEvent } from './events/initialize/index.js';
11
+ export { UploadCancelledEvent, UploadPausedEvent, UploadProgressEvent, UploadResumedEvent, UploadStateChangedEvent } from './events/state/index.js';
12
+ import '@wlindabla/http_client';
13
+ import '@wlindabla/event_dispatcher';
14
+ import '@wlindabla/http_client/events';
@@ -0,0 +1,33 @@
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./utils"), module.exports);
19
+ __reExport(src_exports, require("./exceptions"), module.exports);
20
+ __reExport(src_exports, require("./events"), module.exports);
21
+ __reExport(src_exports, require("./subscribers"), module.exports);
22
+ __reExport(src_exports, require("./cache"), module.exports);
23
+ __reExport(src_exports, require("./core"), module.exports);
24
+ // Annotate the CommonJS export names for ESM import in node:
25
+ 0 && (module.exports = {
26
+ ...require("./utils"),
27
+ ...require("./exceptions"),
28
+ ...require("./events"),
29
+ ...require("./subscribers"),
30
+ ...require("./cache"),
31
+ ...require("./core")
32
+ });
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./exceptions\";\nexport * from \"./events\";\nexport * from \"./subscribers\";\nexport * from \"./cache\";\nexport * from \"./core\";"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AACA,wBAAc,oBADd;AAEA,wBAAc,yBAFd;AAGA,wBAAc,qBAHd;AAIA,wBAAc,0BAJd;AAKA,wBAAc,oBALd;AAMA,wBAAc,mBANd;","names":[]}
@@ -0,0 +1,34 @@
1
+ import { EventSubscriberInterface, EventDispatcherInterface } from '@wlindabla/event_dispatcher';
2
+ import { InitializingUploadEvent } from '../events/initialize/index.js';
3
+ import { FinalizeUploadEvent } from '../events/complete/index.js';
4
+ import '../types/index.js';
5
+ import '@wlindabla/http_client';
6
+ import '@wlindabla/http_client/events';
7
+
8
+ declare class InitializeUploadSubscriber implements EventSubscriberInterface {
9
+ private readonly eventDispatcher;
10
+ constructor(eventDispatcher: EventDispatcherInterface);
11
+ getSubscribedEvents(): Record<string, string | {
12
+ listener: string;
13
+ priority?: number | undefined;
14
+ }>;
15
+ /**
16
+ * Initializes upload session with the server.
17
+ *
18
+ * @param fileHash - SHA-256 hash of the file (first 1MB)
19
+ * @returns Session ID from server, or null if initialization failed
20
+ * @throws {FileUploadInitializationError} If server returns error or network fails
21
+ */
22
+ onInitializeUpload(event: InitializingUploadEvent): Promise<void>;
23
+ }
24
+ declare class FinalizeUploadSubscriber implements EventSubscriberInterface {
25
+ private readonly eventDispatcher;
26
+ constructor(eventDispatcher: EventDispatcherInterface);
27
+ getSubscribedEvents(): Record<string, string | {
28
+ listener: string;
29
+ priority?: number | undefined;
30
+ }>;
31
+ onFinalizeUpload(event: FinalizeUploadEvent): Promise<void>;
32
+ }
33
+
34
+ export { FinalizeUploadSubscriber, InitializeUploadSubscriber };