@duvdu-v1/duvdu 1.1.211 → 1.1.213

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.
@@ -88,7 +88,7 @@ export interface ITeamContract {
88
88
  deadline: Date;
89
89
  details: string;
90
90
  attachments: string[];
91
- totalAmount: number;
91
+ totalPrice: number;
92
92
  actionAt: Date;
93
93
  rejectedBy?: 'customer' | 'sp';
94
94
  paymentLink: string;
@@ -84,7 +84,7 @@ exports.TeamContract = (0, mongoose_1.model)(model_names_1.MODELS.teamContract,
84
84
  hourPrice: { type: Number, default: 0 },
85
85
  deadline: Date,
86
86
  details: { type: String, default: null },
87
- totalAmount: { type: Number, default: 0 },
87
+ totalPrice: { type: Number, default: 0 },
88
88
  actionAt: Date,
89
89
  rejectedBy: { type: String, enum: ['customer', 'sp'] },
90
90
  paymentLink: { type: String, default: null },
@@ -39,8 +39,9 @@ class Bucket {
39
39
  }
40
40
  saveBucketFiles(folder, ...files) {
41
41
  return __awaiter(this, void 0, void 0, function* () {
42
- const CHUNK_SIZE = 20 * 1024 * 1024; // 20MB chunks for better performance
43
- const MAX_PARALLEL_CHUNKS = 4; // Control parallel uploads
42
+ const CHUNK_SIZE = 50 * 1024 * 1024; // 50MB chunks
43
+ const MAX_PARALLEL_CHUNKS = 8; // Increased parallel uploads
44
+ const MAX_RETRIES = 3;
44
45
  yield Promise.all(files.map((file) => __awaiter(this, void 0, void 0, function* () {
45
46
  var _a, e_1, _b, _c;
46
47
  const filePath = path_1.default.resolve(`media/${folder}/${file.filename}`);
@@ -68,20 +69,21 @@ class Bucket {
68
69
  });
69
70
  const uploadId = multipartUpload.UploadId;
70
71
  const parts = [];
71
- const fileStream = fs_1.default.createReadStream(filePath);
72
- // Prepare chunks for parallel upload
72
+ // Prepare chunks for upload
73
73
  const chunks = [];
74
- let currentChunk = Buffer.alloc(0);
74
+ let chunkIndex = 0;
75
+ const fileStream = fs_1.default.createReadStream(filePath, {
76
+ highWaterMark: CHUNK_SIZE // Optimize read buffer size
77
+ });
75
78
  try {
76
79
  for (var _d = true, fileStream_1 = __asyncValues(fileStream), fileStream_1_1; fileStream_1_1 = yield fileStream_1.next(), _a = fileStream_1_1.done, !_a; _d = true) {
77
80
  _c = fileStream_1_1.value;
78
81
  _d = false;
79
82
  const chunk = _c;
80
- currentChunk = Buffer.concat([currentChunk, chunk]);
81
- if (currentChunk.length >= CHUNK_SIZE) {
82
- chunks.push(Buffer.from(currentChunk));
83
- currentChunk = Buffer.alloc(0);
84
- }
83
+ chunks.push({
84
+ buffer: Buffer.from(chunk),
85
+ index: chunkIndex++
86
+ });
85
87
  }
86
88
  }
87
89
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -91,31 +93,41 @@ class Bucket {
91
93
  }
92
94
  finally { if (e_1) throw e_1.error; }
93
95
  }
94
- if (currentChunk.length > 0) {
95
- chunks.push(Buffer.from(currentChunk));
96
- }
97
- // Upload chunks in parallel batches
96
+ // Upload chunks in parallel batches with retry logic
98
97
  for (let i = 0; i < chunks.length; i += MAX_PARALLEL_CHUNKS) {
99
98
  const batch = chunks.slice(i, i + MAX_PARALLEL_CHUNKS);
100
- const partUploads = batch.map((chunkBuffer, index) => {
101
- const partNumber = i + index + 1;
102
- return new Promise((resolve, reject) => {
103
- this.s3.uploadPart({
104
- Bucket: this.bucketName,
105
- Key: `${folder}/${file.filename}`,
106
- PartNumber: partNumber,
107
- UploadId: uploadId,
108
- Body: chunkBuffer,
109
- }, (err, data) => {
110
- if (err)
111
- reject(err);
112
- else
113
- resolve({
99
+ const partUploads = batch.map(({ buffer, index }) => {
100
+ const partNumber = index + 1;
101
+ const uploadChunkWithRetry = (retryCount = 0) => __awaiter(this, void 0, void 0, function* () {
102
+ try {
103
+ return yield new Promise((resolve, reject) => {
104
+ this.s3.uploadPart({
105
+ Bucket: this.bucketName,
106
+ Key: `${folder}/${file.filename}`,
114
107
  PartNumber: partNumber,
115
- ETag: data.ETag
108
+ UploadId: uploadId,
109
+ Body: buffer,
110
+ }, (err, data) => {
111
+ if (err)
112
+ reject(err);
113
+ else
114
+ resolve({
115
+ PartNumber: partNumber,
116
+ ETag: data.ETag
117
+ });
116
118
  });
117
- });
119
+ });
120
+ }
121
+ catch (error) {
122
+ if (retryCount < MAX_RETRIES) {
123
+ // Exponential backoff
124
+ yield new Promise(resolve => setTimeout(resolve, Math.pow(2, retryCount) * 1000));
125
+ return uploadChunkWithRetry(retryCount + 1);
126
+ }
127
+ throw error;
128
+ }
118
129
  });
130
+ return uploadChunkWithRetry();
119
131
  });
120
132
  const completedParts = yield Promise.all(partUploads);
121
133
  parts.push(...completedParts.sort((a, b) => { var _a, _b; return ((_a = a.PartNumber) !== null && _a !== void 0 ? _a : 0) - ((_b = b.PartNumber) !== null && _b !== void 0 ? _b : 0); }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duvdu-v1/duvdu",
3
- "version": "1.1.211",
3
+ "version": "1.1.213",
4
4
  "main": "./build/index.js",
5
5
  "types": "./build/index.d.ts",
6
6
  "files": [