umwd-components 0.1.784 → 0.1.785

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.
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";var e=require("../../../services/common/media/minio/minioUploadService.js"),r=require("../../../../lib/utils.js");exports.uploadMinioMediaAction=async function(o,s){try{const l=Object.fromEntries(s),i=l.bucketName,n=s.getAll("files"),a=l.reference,t=l.refID,u=l.field,c=n.filter(e=>e instanceof File&&e.size>0&&void 0!==e.name);if(0===c.length)return{...o,strapiErrors:null,zodErrors:null,message:"No valid files provided",severity:"error"};({success:!0}).success,console.log(`Uploading ${c.length} file(s):`);const d=[],f=[];for(const o of c)try{const s=await o.arrayBuffer(),l=Buffer.from(s).toString("base64");console.log("Uploading file:",o.name,"Size:",Math.round(l.length/1024/1024),"MB");const n=a&&t&&u?await e.minioUploadService(i,o.name,l,a,t,u):await e.minioUploadService(i,o.name,l);if(!n){f.push(`Failed to upload ${o.name}`);continue}if(n.error){f.push(`Failed to upload ${o.name}: ${n.error.message||"Unknown error"}`);continue}const c=r.flattenAttributes(n);d.push({fileName:o.name,data:c})}catch(e){console.error(`Error uploading ${o.name}:`,e),f.push(`Failed to process ${o.name}`)}return 0===d.length?{...o,strapiErrors:f.length>0?{message:f.join(", ")}:null,zodErrors:null,message:"Failed to upload any files",severity:"error"}:f.length>0&&d.length>0?{...o,data:d,zodErrors:null,strapiErrors:null,message:`Uploaded ${d.length} file(s) successfully. ${f.length} file(s) failed: ${f.join(", ")}`,severity:"warning"}:{...o,data:d,zodErrors:null,strapiErrors:null,message:`Successfully uploaded ${d.length} file(s)`,severity:"success"}}catch(e){return console.error("Upload action error:",e),{...o,strapiErrors:null,zodErrors:null,message:"Failed to process file upload",severity:"error"}}};
6
+ "use strict";var r=require("../../../services/common/media/minio/minioUploadService.js"),e=require("../../../../lib/utils.js");exports.uploadMinioMediaAction=async function(s,o){try{const l=Object.fromEntries(o),i=l.bucketName,t=o.getAll("files"),n=l.reference,a=l.refID,u=l.field,d=t.filter(r=>r instanceof File&&r.size>0&&void 0!==r.name);if(0===d.length)return{...s,strapiErrors:null,zodErrors:null,message:"No valid files provided",severity:"error"};console.log(`Uploading ${d.length} file(s):`);const f=[];for(const r of d){const e=await r.arrayBuffer(),s=Buffer.from(e).toString("base64");f.push({fileName:r.name,fileContent:s}),console.log("Prepared file:",r.name,"Size:",Math.round(s.length/1024/1024),"MB")}const c=await r.minioUploadService(i,f,n,a,u);if(!c)return{...s,strapiErrors:null,zodErrors:null,message:"Failed to upload files",severity:"error"};if(c.error)return{...s,strapiErrors:c.error,zodErrors:null,message:"Failed to upload files",severity:"error"};if(c.errors&&c.errors.length>0){const r=c.uploadResults?.length||0,e=c.errors.length;return{...s,data:c.uploadResults,zodErrors:null,strapiErrors:null,message:`Uploaded ${r} file(s) successfully. ${e} file(s) failed.`,severity:r>0?"warning":"error"}}const p=e.flattenAttributes(c);return{...s,data:p,zodErrors:null,strapiErrors:null,message:`Successfully uploaded ${d.length} file(s)`,severity:"success"}}catch(r){return console.error("Upload action error:",r),{...s,strapiErrors:null,zodErrors:null,message:"Failed to process file upload",severity:"error"}}};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- "use strict";var e=require("../../../get-token.js"),r=require("../../../../../lib/utils.js");exports.minioUploadService=async function(t,o,i,n,a,c){const s=await e.getAuthToken();if(!s)throw new Error("No auth token found");const u=r.getStrapiURL(),f=new URL("/api/minio-plugin/uploadbyreference",u);try{const e=await fetch(f,{headers:{Authorization:`Bearer ${s}`},method:"POST",body:JSON.stringify({data:{bucketName:t,fileName:o,fileContent:i,reference:n,refID:a,field:c}})});return await e.json()}catch(e){throw console.error("Error uploading image:",e),e}};
7
+ "use strict";var e=require("../../../get-token.js"),t=require("../../../../../lib/utils.js");exports.minioUploadService=async function(r,o,i,n,a){const s=await e.getAuthToken();if(!s)throw new Error("No auth token found");const c=t.getStrapiURL(),u=new URL("/api/minio-plugin/uploadbyreference",c);try{const e=await fetch(u,{headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},method:"POST",body:JSON.stringify({data:{bucketName:r,files:o,reference:i,refID:n,field:a}})});return await e.json()}catch(e){throw console.error("Error uploading files:",e),e}};