@medialane/sdk 0.191.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
@@ -823,9 +823,11 @@ var MAX_IPFS_GATEWAY_RESPONSE_BYTES = 25 * 1024 * 1024;
823
823
  // src/uploads.ts
824
824
  var MB = 1024 * 1024;
825
825
  var MAX_UPLOAD_BYTES = 90 * MB;
826
+ var IMAGE_EXTENSIONS = [".jpg", ".jpeg", ".png", ".gif", ".svg", ".webp", ".avif"];
826
827
  var UPLOAD_LIMITS = {
827
828
  image: {
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
833
  mimeTypes: [
@@ -837,7 +839,8 @@ var UPLOAD_LIMITS = {
837
839
  "text/plain",
838
840
  "text/markdown",
839
841
  "application/octet-stream"
840
- ]
842
+ ],
843
+ extensions: [".pdf", ".doc", ".docx", ".odt", ".rtf", ".txt", ".md"]
841
844
  },
842
845
  media: {
843
846
  mimeTypes: [
@@ -856,7 +859,8 @@ var UPLOAD_LIMITS = {
856
859
  "audio/webm",
857
860
  "audio/flac",
858
861
  "application/pdf"
859
- ]
862
+ ],
863
+ extensions: [...IMAGE_EXTENSIONS, ".mp4", ".webm", ".ogv", ".ogg", ".mp3", ".wav", ".flac", ".pdf"]
860
864
  }
861
865
  };
862
866
  function formatFileSize(bytes) {
@@ -868,6 +872,21 @@ function uploadSizeError(file, kind = "image") {
868
872
  const noun = kind === "image" ? "image" : "file";
869
873
  return `That ${noun} is ${formatFileSize(file.size)}. Please choose one under ${formatFileSize(MAX_UPLOAD_BYTES)}.`;
870
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);
889
+ }
871
890
 
872
891
  Object.defineProperty(exports, "ApiClient", {
873
892
  enumerable: true,
@@ -1182,6 +1201,7 @@ exports.OPEN_LICENSES = OPEN_LICENSES;
1182
1201
  exports.RESERVED_TRAITS = RESERVED_TRAITS;
1183
1202
  exports.RunRequestError = RunRequestError;
1184
1203
  exports.UPLOAD_LIMITS = UPLOAD_LIMITS;
1204
+ exports.acceptFor = acceptFor;
1185
1205
  exports.buildAssetMetadata = buildAssetMetadata;
1186
1206
  exports.buildCollectionMetadata = buildCollectionMetadata;
1187
1207
  exports.createAppGateway = createAppGateway;
@@ -1205,6 +1225,7 @@ exports.readBodyWithCap = readBodyWithCap;
1205
1225
  exports.resolveRemixPolicy = resolveRemixPolicy;
1206
1226
  exports.resolveSafeImageContentType = resolveSafeImageContentType;
1207
1227
  exports.uploadDirectoryToBackend = uploadDirectoryToBackend;
1228
+ exports.uploadError = uploadError;
1208
1229
  exports.uploadFileToBackend = uploadFileToBackend;
1209
1230
  exports.uploadJsonToBackend = uploadJsonToBackend;
1210
1231
  exports.uploadSizeError = uploadSizeError;