@momentumcms/server-analog 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/index.cjs +34 -43
- package/index.js +34 -43
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 0.5.0 (2026-02-23)
|
|
2
|
+
|
|
3
|
+
This was a version bump only for server-analog to align it with other projects, there were no code changes.
|
|
4
|
+
|
|
5
|
+
## 0.4.1 (2026-02-22)
|
|
6
|
+
|
|
7
|
+
This was a version bump only for server-analog to align it with other projects, there were no code changes.
|
|
8
|
+
|
|
1
9
|
## 0.4.0 (2026-02-22)
|
|
2
10
|
|
|
3
11
|
### 🚀 Features
|
package/index.cjs
CHANGED
|
@@ -37,6 +37,35 @@ var init_storage_types = __esm({
|
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
+
// libs/storage/src/lib/storage-utils.ts
|
|
41
|
+
function getExtensionFromMimeType(mimeType) {
|
|
42
|
+
return MIME_TO_EXT[mimeType] ?? "";
|
|
43
|
+
}
|
|
44
|
+
var MIME_TO_EXT;
|
|
45
|
+
var init_storage_utils = __esm({
|
|
46
|
+
"libs/storage/src/lib/storage-utils.ts"() {
|
|
47
|
+
"use strict";
|
|
48
|
+
MIME_TO_EXT = {
|
|
49
|
+
"image/jpeg": ".jpg",
|
|
50
|
+
"image/png": ".png",
|
|
51
|
+
"image/gif": ".gif",
|
|
52
|
+
"image/webp": ".webp",
|
|
53
|
+
"image/svg+xml": ".svg",
|
|
54
|
+
"application/pdf": ".pdf",
|
|
55
|
+
"application/json": ".json",
|
|
56
|
+
"text/plain": ".txt",
|
|
57
|
+
"text/html": ".html",
|
|
58
|
+
"text/css": ".css",
|
|
59
|
+
"application/javascript": ".js",
|
|
60
|
+
"video/mp4": ".mp4",
|
|
61
|
+
"video/webm": ".webm",
|
|
62
|
+
"audio/mpeg": ".mp3",
|
|
63
|
+
"audio/wav": ".wav",
|
|
64
|
+
"application/zip": ".zip"
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
40
69
|
// libs/storage/src/lib/storage-local.ts
|
|
41
70
|
function localStorageAdapter(options) {
|
|
42
71
|
const { directory, baseUrl } = options;
|
|
@@ -103,27 +132,6 @@ function localStorageAdapter(options) {
|
|
|
103
132
|
}
|
|
104
133
|
};
|
|
105
134
|
}
|
|
106
|
-
function getExtensionFromMimeType(mimeType) {
|
|
107
|
-
const mimeToExt = {
|
|
108
|
-
"image/jpeg": ".jpg",
|
|
109
|
-
"image/png": ".png",
|
|
110
|
-
"image/gif": ".gif",
|
|
111
|
-
"image/webp": ".webp",
|
|
112
|
-
"image/svg+xml": ".svg",
|
|
113
|
-
"application/pdf": ".pdf",
|
|
114
|
-
"application/json": ".json",
|
|
115
|
-
"text/plain": ".txt",
|
|
116
|
-
"text/html": ".html",
|
|
117
|
-
"text/css": ".css",
|
|
118
|
-
"application/javascript": ".js",
|
|
119
|
-
"video/mp4": ".mp4",
|
|
120
|
-
"video/webm": ".webm",
|
|
121
|
-
"audio/mpeg": ".mp3",
|
|
122
|
-
"audio/wav": ".wav",
|
|
123
|
-
"application/zip": ".zip"
|
|
124
|
-
};
|
|
125
|
-
return mimeToExt[mimeType] ?? "";
|
|
126
|
-
}
|
|
127
135
|
var import_node_fs, import_node_path, import_node_crypto2;
|
|
128
136
|
var init_storage_local = __esm({
|
|
129
137
|
"libs/storage/src/lib/storage-local.ts"() {
|
|
@@ -131,6 +139,7 @@ var init_storage_local = __esm({
|
|
|
131
139
|
import_node_fs = require("node:fs");
|
|
132
140
|
import_node_path = require("node:path");
|
|
133
141
|
import_node_crypto2 = require("node:crypto");
|
|
142
|
+
init_storage_utils();
|
|
134
143
|
}
|
|
135
144
|
});
|
|
136
145
|
|
|
@@ -192,7 +201,7 @@ function s3StorageAdapter(options) {
|
|
|
192
201
|
return {
|
|
193
202
|
async upload(file, uploadOptions) {
|
|
194
203
|
const s3 = await getClient();
|
|
195
|
-
const ext = (0, import_node_path2.extname)(file.originalName) ||
|
|
204
|
+
const ext = (0, import_node_path2.extname)(file.originalName) || getExtensionFromMimeType(file.mimeType);
|
|
196
205
|
const filename = uploadOptions?.filename ? `${uploadOptions.filename}${ext}` : `${(0, import_node_crypto3.randomUUID)()}${ext}`;
|
|
197
206
|
const key = uploadOptions?.directory ? `${uploadOptions.directory}/${filename}` : filename;
|
|
198
207
|
await s3.send(
|
|
@@ -281,33 +290,13 @@ function s3StorageAdapter(options) {
|
|
|
281
290
|
}
|
|
282
291
|
};
|
|
283
292
|
}
|
|
284
|
-
function getExtensionFromMimeType2(mimeType) {
|
|
285
|
-
const mimeToExt = {
|
|
286
|
-
"image/jpeg": ".jpg",
|
|
287
|
-
"image/png": ".png",
|
|
288
|
-
"image/gif": ".gif",
|
|
289
|
-
"image/webp": ".webp",
|
|
290
|
-
"image/svg+xml": ".svg",
|
|
291
|
-
"application/pdf": ".pdf",
|
|
292
|
-
"application/json": ".json",
|
|
293
|
-
"text/plain": ".txt",
|
|
294
|
-
"text/html": ".html",
|
|
295
|
-
"text/css": ".css",
|
|
296
|
-
"application/javascript": ".js",
|
|
297
|
-
"video/mp4": ".mp4",
|
|
298
|
-
"video/webm": ".webm",
|
|
299
|
-
"audio/mpeg": ".mp3",
|
|
300
|
-
"audio/wav": ".wav",
|
|
301
|
-
"application/zip": ".zip"
|
|
302
|
-
};
|
|
303
|
-
return mimeToExt[mimeType] ?? "";
|
|
304
|
-
}
|
|
305
293
|
var import_node_crypto3, import_node_path2, S3Client, PutObjectCommand, DeleteObjectCommand, HeadObjectCommand, GetObjectCommand, getSignedUrl;
|
|
306
294
|
var init_storage_s3 = __esm({
|
|
307
295
|
"libs/storage/src/lib/storage-s3.ts"() {
|
|
308
296
|
"use strict";
|
|
309
297
|
import_node_crypto3 = require("node:crypto");
|
|
310
298
|
import_node_path2 = require("node:path");
|
|
299
|
+
init_storage_utils();
|
|
311
300
|
}
|
|
312
301
|
});
|
|
313
302
|
|
|
@@ -524,6 +513,7 @@ var init_mime_validator = __esm({
|
|
|
524
513
|
var src_exports = {};
|
|
525
514
|
__export(src_exports, {
|
|
526
515
|
detectMimeType: () => detectMimeType,
|
|
516
|
+
getExtensionFromMimeType: () => getExtensionFromMimeType,
|
|
527
517
|
isMimeTypeAllowed: () => isMimeTypeAllowed,
|
|
528
518
|
localStorageAdapter: () => localStorageAdapter,
|
|
529
519
|
mimeTypeMatches: () => mimeTypeMatches,
|
|
@@ -536,6 +526,7 @@ var init_src = __esm({
|
|
|
536
526
|
init_storage_types();
|
|
537
527
|
init_storage_local();
|
|
538
528
|
init_storage_s3();
|
|
529
|
+
init_storage_utils();
|
|
539
530
|
init_mime_validator();
|
|
540
531
|
}
|
|
541
532
|
});
|
package/index.js
CHANGED
|
@@ -15,6 +15,35 @@ var init_storage_types = __esm({
|
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
// libs/storage/src/lib/storage-utils.ts
|
|
19
|
+
function getExtensionFromMimeType(mimeType) {
|
|
20
|
+
return MIME_TO_EXT[mimeType] ?? "";
|
|
21
|
+
}
|
|
22
|
+
var MIME_TO_EXT;
|
|
23
|
+
var init_storage_utils = __esm({
|
|
24
|
+
"libs/storage/src/lib/storage-utils.ts"() {
|
|
25
|
+
"use strict";
|
|
26
|
+
MIME_TO_EXT = {
|
|
27
|
+
"image/jpeg": ".jpg",
|
|
28
|
+
"image/png": ".png",
|
|
29
|
+
"image/gif": ".gif",
|
|
30
|
+
"image/webp": ".webp",
|
|
31
|
+
"image/svg+xml": ".svg",
|
|
32
|
+
"application/pdf": ".pdf",
|
|
33
|
+
"application/json": ".json",
|
|
34
|
+
"text/plain": ".txt",
|
|
35
|
+
"text/html": ".html",
|
|
36
|
+
"text/css": ".css",
|
|
37
|
+
"application/javascript": ".js",
|
|
38
|
+
"video/mp4": ".mp4",
|
|
39
|
+
"video/webm": ".webm",
|
|
40
|
+
"audio/mpeg": ".mp3",
|
|
41
|
+
"audio/wav": ".wav",
|
|
42
|
+
"application/zip": ".zip"
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
18
47
|
// libs/storage/src/lib/storage-local.ts
|
|
19
48
|
import { existsSync, mkdirSync, writeFileSync, unlinkSync, readFileSync, lstatSync } from "node:fs";
|
|
20
49
|
import { join, extname, resolve, normalize } from "node:path";
|
|
@@ -84,30 +113,10 @@ function localStorageAdapter(options) {
|
|
|
84
113
|
}
|
|
85
114
|
};
|
|
86
115
|
}
|
|
87
|
-
function getExtensionFromMimeType(mimeType) {
|
|
88
|
-
const mimeToExt = {
|
|
89
|
-
"image/jpeg": ".jpg",
|
|
90
|
-
"image/png": ".png",
|
|
91
|
-
"image/gif": ".gif",
|
|
92
|
-
"image/webp": ".webp",
|
|
93
|
-
"image/svg+xml": ".svg",
|
|
94
|
-
"application/pdf": ".pdf",
|
|
95
|
-
"application/json": ".json",
|
|
96
|
-
"text/plain": ".txt",
|
|
97
|
-
"text/html": ".html",
|
|
98
|
-
"text/css": ".css",
|
|
99
|
-
"application/javascript": ".js",
|
|
100
|
-
"video/mp4": ".mp4",
|
|
101
|
-
"video/webm": ".webm",
|
|
102
|
-
"audio/mpeg": ".mp3",
|
|
103
|
-
"audio/wav": ".wav",
|
|
104
|
-
"application/zip": ".zip"
|
|
105
|
-
};
|
|
106
|
-
return mimeToExt[mimeType] ?? "";
|
|
107
|
-
}
|
|
108
116
|
var init_storage_local = __esm({
|
|
109
117
|
"libs/storage/src/lib/storage-local.ts"() {
|
|
110
118
|
"use strict";
|
|
119
|
+
init_storage_utils();
|
|
111
120
|
}
|
|
112
121
|
});
|
|
113
122
|
|
|
@@ -171,7 +180,7 @@ function s3StorageAdapter(options) {
|
|
|
171
180
|
return {
|
|
172
181
|
async upload(file, uploadOptions) {
|
|
173
182
|
const s3 = await getClient();
|
|
174
|
-
const ext = extname2(file.originalName) ||
|
|
183
|
+
const ext = extname2(file.originalName) || getExtensionFromMimeType(file.mimeType);
|
|
175
184
|
const filename = uploadOptions?.filename ? `${uploadOptions.filename}${ext}` : `${randomUUID2()}${ext}`;
|
|
176
185
|
const key = uploadOptions?.directory ? `${uploadOptions.directory}/${filename}` : filename;
|
|
177
186
|
await s3.send(
|
|
@@ -260,31 +269,11 @@ function s3StorageAdapter(options) {
|
|
|
260
269
|
}
|
|
261
270
|
};
|
|
262
271
|
}
|
|
263
|
-
function getExtensionFromMimeType2(mimeType) {
|
|
264
|
-
const mimeToExt = {
|
|
265
|
-
"image/jpeg": ".jpg",
|
|
266
|
-
"image/png": ".png",
|
|
267
|
-
"image/gif": ".gif",
|
|
268
|
-
"image/webp": ".webp",
|
|
269
|
-
"image/svg+xml": ".svg",
|
|
270
|
-
"application/pdf": ".pdf",
|
|
271
|
-
"application/json": ".json",
|
|
272
|
-
"text/plain": ".txt",
|
|
273
|
-
"text/html": ".html",
|
|
274
|
-
"text/css": ".css",
|
|
275
|
-
"application/javascript": ".js",
|
|
276
|
-
"video/mp4": ".mp4",
|
|
277
|
-
"video/webm": ".webm",
|
|
278
|
-
"audio/mpeg": ".mp3",
|
|
279
|
-
"audio/wav": ".wav",
|
|
280
|
-
"application/zip": ".zip"
|
|
281
|
-
};
|
|
282
|
-
return mimeToExt[mimeType] ?? "";
|
|
283
|
-
}
|
|
284
272
|
var S3Client, PutObjectCommand, DeleteObjectCommand, HeadObjectCommand, GetObjectCommand, getSignedUrl;
|
|
285
273
|
var init_storage_s3 = __esm({
|
|
286
274
|
"libs/storage/src/lib/storage-s3.ts"() {
|
|
287
275
|
"use strict";
|
|
276
|
+
init_storage_utils();
|
|
288
277
|
}
|
|
289
278
|
});
|
|
290
279
|
|
|
@@ -501,6 +490,7 @@ var init_mime_validator = __esm({
|
|
|
501
490
|
var src_exports = {};
|
|
502
491
|
__export(src_exports, {
|
|
503
492
|
detectMimeType: () => detectMimeType,
|
|
493
|
+
getExtensionFromMimeType: () => getExtensionFromMimeType,
|
|
504
494
|
isMimeTypeAllowed: () => isMimeTypeAllowed,
|
|
505
495
|
localStorageAdapter: () => localStorageAdapter,
|
|
506
496
|
mimeTypeMatches: () => mimeTypeMatches,
|
|
@@ -513,6 +503,7 @@ var init_src = __esm({
|
|
|
513
503
|
init_storage_types();
|
|
514
504
|
init_storage_local();
|
|
515
505
|
init_storage_s3();
|
|
506
|
+
init_storage_utils();
|
|
516
507
|
init_mime_validator();
|
|
517
508
|
}
|
|
518
509
|
});
|