@medialane/sdk 0.190.0 → 0.192.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 CHANGED
@@ -822,13 +822,14 @@ var MAX_IPFS_GATEWAY_RESPONSE_BYTES = 25 * 1024 * 1024;
822
822
 
823
823
  // src/uploads.ts
824
824
  var MB = 1024 * 1024;
825
+ var MAX_UPLOAD_BYTES = 90 * MB;
826
+ var IMAGE_EXTENSIONS = [".jpg", ".jpeg", ".png", ".gif", ".svg", ".webp", ".avif"];
825
827
  var UPLOAD_LIMITS = {
826
828
  image: {
827
- maxBytes: 50 * MB,
828
- mimeTypes: ["image/jpeg", "image/png", "image/gif", "image/svg+xml", "image/webp"]
829
+ mimeTypes: ["image/jpeg", "image/png", "image/gif", "image/svg+xml", "image/webp", "image/avif"],
830
+ extensions: IMAGE_EXTENSIONS
829
831
  },
830
832
  document: {
831
- maxBytes: 20 * MB,
832
833
  mimeTypes: [
833
834
  "application/pdf",
834
835
  "application/msword",
@@ -838,10 +839,10 @@ var UPLOAD_LIMITS = {
838
839
  "text/plain",
839
840
  "text/markdown",
840
841
  "application/octet-stream"
841
- ]
842
+ ],
843
+ extensions: [".pdf", ".doc", ".docx", ".odt", ".rtf", ".txt", ".md"]
842
844
  },
843
845
  media: {
844
- maxBytes: 100 * MB,
845
846
  mimeTypes: [
846
847
  "image/jpeg",
847
848
  "image/png",
@@ -858,7 +859,8 @@ var UPLOAD_LIMITS = {
858
859
  "audio/webm",
859
860
  "audio/flac",
860
861
  "application/pdf"
861
- ]
862
+ ],
863
+ extensions: [...IMAGE_EXTENSIONS, ".mp4", ".webm", ".ogv", ".ogg", ".mp3", ".wav", ".flac", ".pdf"]
862
864
  }
863
865
  };
864
866
  function formatFileSize(bytes) {
@@ -866,10 +868,24 @@ function formatFileSize(bytes) {
866
868
  return `${Number.isInteger(mb) ? mb : mb.toFixed(1)} MB`;
867
869
  }
868
870
  function uploadSizeError(file, kind = "image") {
869
- const { maxBytes } = UPLOAD_LIMITS[kind];
870
- if (file.size <= maxBytes) return null;
871
+ if (file.size <= MAX_UPLOAD_BYTES) return null;
871
872
  const noun = kind === "image" ? "image" : "file";
872
- return `That ${noun} is ${formatFileSize(file.size)}. Please choose one under ${formatFileSize(maxBytes)}.`;
873
+ return `That ${noun} is ${formatFileSize(file.size)}. Please choose one under ${formatFileSize(MAX_UPLOAD_BYTES)}.`;
874
+ }
875
+ function acceptFor(kind) {
876
+ const { mimeTypes, extensions } = UPLOAD_LIMITS[kind];
877
+ return [...mimeTypes, ...extensions].join(",");
878
+ }
879
+ function typeList(extensions) {
880
+ const names = extensions.map((ext) => ext.slice(1).toUpperCase());
881
+ return names.length > 1 ? `${names.slice(0, -1).join(", ")} or ${names[names.length - 1]}` : names.join("");
882
+ }
883
+ function uploadError(file, kind = "image") {
884
+ const { mimeTypes, extensions } = UPLOAD_LIMITS[kind];
885
+ const name = (file.name ?? "").toLowerCase();
886
+ const allowed = mimeTypes.includes(file.type) || file.type === "" && extensions.some((ext) => name.endsWith(ext));
887
+ if (!allowed) return `Choose ${kind === "image" ? "an image" : "a file"} in ${typeList(extensions)}.`;
888
+ return uploadSizeError(file, kind);
873
889
  }
874
890
 
875
891
  Object.defineProperty(exports, "ApiClient", {
@@ -1180,10 +1196,12 @@ exports.IPFS_SAFE_CONTENT_TYPE_PREFIXES = IPFS_SAFE_CONTENT_TYPE_PREFIXES;
1180
1196
  exports.MAX_IMAGE_PROXY_BYTES = MAX_IMAGE_PROXY_BYTES;
1181
1197
  exports.MAX_IMAGE_REDIRECTS = MAX_IMAGE_REDIRECTS;
1182
1198
  exports.MAX_IPFS_GATEWAY_RESPONSE_BYTES = MAX_IPFS_GATEWAY_RESPONSE_BYTES;
1199
+ exports.MAX_UPLOAD_BYTES = MAX_UPLOAD_BYTES;
1183
1200
  exports.OPEN_LICENSES = OPEN_LICENSES;
1184
1201
  exports.RESERVED_TRAITS = RESERVED_TRAITS;
1185
1202
  exports.RunRequestError = RunRequestError;
1186
1203
  exports.UPLOAD_LIMITS = UPLOAD_LIMITS;
1204
+ exports.acceptFor = acceptFor;
1187
1205
  exports.buildAssetMetadata = buildAssetMetadata;
1188
1206
  exports.buildCollectionMetadata = buildCollectionMetadata;
1189
1207
  exports.createAppGateway = createAppGateway;
@@ -1207,6 +1225,7 @@ exports.readBodyWithCap = readBodyWithCap;
1207
1225
  exports.resolveRemixPolicy = resolveRemixPolicy;
1208
1226
  exports.resolveSafeImageContentType = resolveSafeImageContentType;
1209
1227
  exports.uploadDirectoryToBackend = uploadDirectoryToBackend;
1228
+ exports.uploadError = uploadError;
1210
1229
  exports.uploadFileToBackend = uploadFileToBackend;
1211
1230
  exports.uploadJsonToBackend = uploadJsonToBackend;
1212
1231
  exports.uploadSizeError = uploadSizeError;