@palbase/backend 8.1.0 → 8.2.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/dist/index.cjs +0 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -18
- package/dist/index.d.ts +20 -18
- package/dist/index.js +0 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -884,7 +884,6 @@ var Patch = makeMethodDecorator("PATCH");
|
|
|
884
884
|
var Delete = makeMethodDecorator("DELETE");
|
|
885
885
|
|
|
886
886
|
// src/decorators/upload.ts
|
|
887
|
-
var MIME_RE2 = /^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*\/[A-Za-z0-9*][A-Za-z0-9!#$&^_.+-]*$/;
|
|
888
887
|
function Upload(subpath, config) {
|
|
889
888
|
const { auth: auth2, rateLimit, ...uploadConfig } = config;
|
|
890
889
|
validateUploadConfigShape(uploadConfig);
|
|
@@ -915,21 +914,6 @@ function validateUploadConfigShape(c) {
|
|
|
915
914
|
if (typeof c.pathTemplate !== "string" || c.pathTemplate.length === 0) {
|
|
916
915
|
throw new Error("@Upload config.pathTemplate must be a non-empty key template");
|
|
917
916
|
}
|
|
918
|
-
if (c.maxSize !== void 0) {
|
|
919
|
-
if (!Number.isInteger(c.maxSize) || c.maxSize <= 0) {
|
|
920
|
-
throw new Error(`@Upload config.maxSize must be a positive integer byte count, got ${c.maxSize}`);
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
if (c.allowedTypes !== void 0) {
|
|
924
|
-
if (!Array.isArray(c.allowedTypes) || c.allowedTypes.length === 0) {
|
|
925
|
-
throw new Error("@Upload config.allowedTypes must be a non-empty array of MIME types when present");
|
|
926
|
-
}
|
|
927
|
-
for (const t of c.allowedTypes) {
|
|
928
|
-
if (typeof t !== "string" || !MIME_RE2.test(t.trim())) {
|
|
929
|
-
throw new Error(`@Upload config.allowedTypes entry "${t}" is not a valid MIME type (e.g. "image/png")`);
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
917
|
}
|
|
934
918
|
function validateUploadAgainstStorage(uploadConfig, storage2, routeLabel) {
|
|
935
919
|
const def = storage2.buckets[uploadConfig.bucket];
|
|
@@ -939,28 +923,6 @@ function validateUploadAgainstStorage(uploadConfig, storage2, routeLabel) {
|
|
|
939
923
|
`@Upload route ${routeLabel} targets bucket "${uploadConfig.bucket}" which is not declared in defineStorage(...). ` + (known.length ? `Known buckets: ${known.join(", ")}.` : "No buckets are declared.")
|
|
940
924
|
);
|
|
941
925
|
}
|
|
942
|
-
if (uploadConfig.maxSize !== void 0 && def.fileSizeLimit !== null && uploadConfig.maxSize > def.fileSizeLimit) {
|
|
943
|
-
throw new Error(
|
|
944
|
-
`@Upload route ${routeLabel} maxSize (${uploadConfig.maxSize} bytes) exceeds bucket "${uploadConfig.bucket}" fileSizeLimit (${def.fileSizeLimit} bytes)`
|
|
945
|
-
);
|
|
946
|
-
}
|
|
947
|
-
if (uploadConfig.allowedTypes !== void 0 && def.allowedMimeTypes !== null) {
|
|
948
|
-
const bucketAllows = (mime) => def.allowedMimeTypes.some((b) => {
|
|
949
|
-
if (b === mime) return true;
|
|
950
|
-
const slash = b.indexOf("/");
|
|
951
|
-
if (slash > 0 && b.slice(slash + 1) === "*") {
|
|
952
|
-
return mime.startsWith(b.slice(0, slash + 1));
|
|
953
|
-
}
|
|
954
|
-
return false;
|
|
955
|
-
});
|
|
956
|
-
for (const t of uploadConfig.allowedTypes) {
|
|
957
|
-
if (!bucketAllows(t)) {
|
|
958
|
-
throw new Error(
|
|
959
|
-
`@Upload route ${routeLabel} allows MIME "${t}" which bucket "${uploadConfig.bucket}" does not (bucket allows: ${def.allowedMimeTypes.join(", ")})`
|
|
960
|
-
);
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
926
|
}
|
|
965
927
|
|
|
966
928
|
// src/decorators/params.ts
|