@donotdev/testing 0.2.0 → 0.2.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"debugC4all.d.ts","sourceRoot":"","sources":["../../src/client/debugC4all.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,wBAAsB,UAAU,CAAC,SAAS,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAoC9D"}
1
+ {"version":3,"file":"debugC4all.d.ts","sourceRoot":"","sources":["../../src/client/debugC4all.ts"],"names":[],"mappings":"AAgBA;;GAEG;AAEH,wBAAsB,UAAU,CAAC,SAAS,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAoC9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"debugIsousou.d.ts","sourceRoot":"","sources":["../../src/client/debugIsousou.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAMzE,MAAM,WAAW,mBAAmB;IAClC,qGAAqG;IACrG,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,4EAA4E;IAC5E,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,wDAAwD;IACxD,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,gCAAgC;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0BAA0B;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAMD;;;GAGG;AACH,wBAAsB,YAAY,CAChC,eAAe,EAAE,GAAG,EACpB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CA0Hf"}
1
+ {"version":3,"file":"debugIsousou.d.ts","sourceRoot":"","sources":["../../src/client/debugIsousou.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAMzE,MAAM,WAAW,mBAAmB;IAClC,qGAAqG;IACrG,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,4EAA4E;IAC5E,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,wDAAwD;IACxD,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,gCAAgC;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0BAA0B;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAMD;;;GAGG;AACH,wBAAsB,YAAY,CAEhC,eAAe,EAAE,GAAG,EACpB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CA0Hf"}
@@ -1 +1 @@
1
- import{getProvider as p}from"@donotdev/core";import{testEntity as h}from"./testEntity";import{testImagePipeline as S}from"./testImagePipeline";import{testImageUpload as d}from"./testImageUpload";import{testStorage as f}from"./testStorage";async function b(a,l={}){const{pipeline:i,crudFns:c,pictures:e,files:r,skipStorage:g=!1,skipPipeline:u=!1,skipCrud:m=!1}=l,o=p("storage"),w=p("crud"),P=p("callable"),n={reference:`TEST-${Date.now().toString(36).toUpperCase()}`,address:{formatted_address:"1 rue de Rivoli, 75001 Paris, France",latitude:48.8606,longitude:2.3376},district_code:1};if(!g){const t=await f({storage:o}),s=await f({storage:o,storagePath:"test"});if(!(!t.passed&&s.passed)&&!(t.passed&&!s.passed)&&!t.passed&&!s.passed)return}if(!u){const t={...n};if(e&&e.length>0&&(t.pictures=e),await S({entity:a,input:t,fns:c}),i&&(await d({fns:i}),r&&r.length>0))for(const s of r)await d({fns:i,file:s})}!m&&a&&await h(a,{providers:{crud:w,storage:o,callable:P},payload:{...n,...e&&e.length>0?{pictures:e}:{}}})}export{b as debugIsousou};
1
+ import{getProvider as p}from"@donotdev/core";import{testEntity as h}from"./testEntity";import{testImagePipeline as S}from"./testImagePipeline";import{testImageUpload as d}from"./testImageUpload";import{testStorage as f}from"./testStorage";async function b(a,c={}){const{pipeline:i,crudFns:l,pictures:t,files:r,skipStorage:g=!1,skipPipeline:u=!1,skipCrud:m=!1}=c,o=p("storage"),w=p("crud"),P=p("callable"),n={reference:`TEST-${Date.now().toString(36).toUpperCase()}`,address:{formatted_address:"1 rue de Rivoli, 75001 Paris, France",latitude:48.8606,longitude:2.3376},district_code:1};if(!g){const e=await f({storage:o}),s=await f({storage:o,storagePath:"test"});if(!(!e.passed&&s.passed)&&!(e.passed&&!s.passed)&&!e.passed&&!s.passed)return}if(!u){const e={...n};if(t&&t.length>0&&(e.pictures=t),await S({entity:a,input:e,fns:l}),i&&(await d({fns:i}),r&&r.length>0))for(const s of r)await d({fns:i,file:s})}!m&&a&&await h(a,{providers:{crud:w,storage:o,callable:P},payload:{...n,...t&&t.length>0?{pictures:t}:{}}})}export{b as debugIsousou};
@@ -1 +1 @@
1
- {"version":3,"file":"testEntity.d.ts","sourceRoot":"","sources":["../../src/client/testEntity.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,EAAY,KAAK,MAAM,EAAoB,MAAM,gBAAgB,CAAC;AASzE,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAGjB,MAAM,iBAAiB,CAAC;AA4GzB;;;;;;;;;;;;GAYG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,CAAC,CA8K3B"}
1
+ {"version":3,"file":"testEntity.d.ts","sourceRoot":"","sources":["../../src/client/testEntity.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,EAAY,KAAK,MAAM,EAAoB,MAAM,gBAAgB,CAAC;AASzE,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAGjB,MAAM,iBAAiB,CAAC;AAiHzB;;;;;;;;;;;;GAYG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAgL3B"}
@@ -1 +1 @@
1
- import{EDITABLE as v}from"@donotdev/core";import{createTestImageBlob as D,createTestFileBlob as P}from"./testStorage";import{generatePayload as $,getFileFields as C,isMultiFileField as F}from"../common/payloadGenerator";import{reportEntity as M}from"../common/reporter";async function y(a,g){const r=performance.now();try{const o=await g();return{step:a,passed:!0,duration:Math.round(performance.now()-r),data:o}}catch(o){return{step:a,passed:!1,duration:Math.round(performance.now()-r),error:o instanceof Error?o.message:String(o),errorDetail:o}}}async function _(a,g,r,o){const w=[],i={};for(const l of a){const p=["image","images","avatar"].includes(l.type),u=F(l),d=l.options?.fieldSpecific?.storagePath??r,h=p?"upload-image":"upload-file",s=await y(h,async()=>{const t=p?D():P(),E=p?"png":"txt",f=`dndev_test_${l.name}_${Date.now()}.${E}`,m=await g.upload(t,{storagePath:d,filename:f,signal:o,onProgress:e=>{}});if(p){const e={fullUrl:m.url,thumbUrl:m.url};i[l.name]=u?[e]:e}else{const e={url:m.url,filename:f,size:t.size,mimeType:t.type};i[l.name]=u?[e]:e}return m});w.push({...s,step:`${h}`}),s.passed||(i[l.name]=u?[]:null)}return{results:w,values:i}}async function k(a,g){const{providers:r,payload:o,cleanup:w=!0,skip:i=[],storagePath:l,signal:p}=g,{crud:u}=r,d=a.collection,h=performance.now(),s=[];let t;const E=await y("generate-payload",async()=>$(a.fields,o));if(s.push(E),!E.passed)return T(a,d,s,t,void 0,h);let f=E.data;const m=C(a.fields);if(m.length>0&&r.storage){const{results:e,values:n}=await _(m,r.storage,l,p);s.push(...e),f={...f,...n}}else m.length>0&&r.storage;if(!i.includes("create")){const e=await y("create",async()=>{const n=await u.add(d,f);return t=n.id,n});if(s.push(e),!e.passed)return T(a,d,s,t,f,h)}if(!i.includes("get")&&t){const e=await y("get",async()=>{const n=await u.get(d,t);if(!n)throw new Error(`get returned null for id=${t}`);return n});s.push(e)}if(!i.includes("list")){const e=await y("list",async()=>{const n=await u.query(d,{limit:5});if(t){const b=n.items.some(c=>c.id===t)}return n});s.push(e)}if(!i.includes("listCard")){const e=await y("listCard",async()=>await u.query(d,{limit:5},void 0,"listCard"));s.push(e)}if(!i.includes("update")&&t){const e=await y("update",async()=>{const n=Object.values(a.fields).find(c=>c.type==="text"&&c.editable!==!1&&c.editable!==v.GENERATED&&c.editable!==v.COMPUTED&&c.editable!==v.CREATE_ONLY&&c.visibility!=="hidden"&&c.visibility!=="technical"),b=n?{[n.name]:`updated_${Date.now().toString(36)}`}:{};return Object.keys(b).length===0?{skipped:!0}:(await u.update(d,t,b),b)});s.push(e)}if(!i.includes("delete")&&t&&w){const e=await y("delete",async()=>{await u.delete(d,t)});s.push(e)}return T(a,d,s,t,f,h)}function T(a,g,r,o,w,i){const l={entity:a.name,collection:g,passed:r.every(p=>p.passed),steps:r,createdId:o,payload:w,duration:Math.round(performance.now()-i)};return M(l),l}export{k as testEntity};
1
+ import{EDITABLE as E}from"@donotdev/core";import{createTestImageBlob as T,createTestFileBlob as D}from"./testStorage";import{generatePayload as $,getFileFields as C,isMultiFileField as F}from"../common/payloadGenerator";import{reportEntity as M}from"../common/reporter";async function f(s,m){const o=performance.now();try{const l=await m();return{step:s,passed:!0,duration:Math.round(performance.now()-o),data:l}}catch(l){return{step:s,passed:!1,duration:Math.round(performance.now()-o),error:l instanceof Error?l.message:String(l),errorDetail:l}}}async function _(s,m,o,l){const w=[],r={};for(const d of s){const p=["image","images","avatar"].includes(d.type),u=F(d),n=d.options?.fieldSpecific,v=(n&&"storagePath"in n&&typeof n.storagePath=="string"?n.storagePath:void 0)??o,i=p?"upload-image":"upload-file",a=await f(i,async()=>{const g=p?T():D(),y=p?"png":"txt",h=`dndev_test_${d.name}_${Date.now()}.${y}`,t=await m.upload(g,{storagePath:v,filename:h,signal:l,onProgress:e=>{}});if(p){const e={fullUrl:t.url,thumbUrl:t.url};r[d.name]=u?[e]:e}else{const e={url:t.url,filename:h,size:g.size,mimeType:g.type};r[d.name]=u?[e]:e}return t});w.push({...a,step:`${i}`}),a.passed||(r[d.name]=u?[]:null)}return{results:w,values:r}}async function O(s,m){const{providers:o,payload:l,cleanup:w=!0,skip:r=[],storagePath:d,signal:p}=m,{crud:u}=o,n=s.collection,v=performance.now(),i=[];let a;const g=await f("generate-payload",async()=>$(s.fields,l));if(i.push(g),!g.passed)return P(s,n,i,a,void 0,v);let y=g.data;const h=C(s.fields);if(h.length>0&&o.storage){const{results:t,values:e}=await _(h,o.storage,d,p);i.push(...t),y={...y,...e}}else h.length>0&&o.storage;if(!r.includes("create")){const t=await f("create",async()=>{const e=await u.add(n,y);return a=e.id,e});if(i.push(t),!t.passed)return P(s,n,i,a,y,v)}if(!r.includes("get")&&a){const t=await f("get",async()=>{const e=await u.get(n,a);if(!e)throw new Error(`get returned null for id=${a}`);return e});i.push(t)}if(!r.includes("list")){const t=await f("list",async()=>{const e=await u.query(n,{limit:5});if(a){const b=e.items.some(c=>c.id===a)}return e});i.push(t)}if(!r.includes("listCard")){const t=await f("listCard",async()=>await u.query(n,{limit:5},void 0,"listCard"));i.push(t)}if(!r.includes("update")&&a){const t=await f("update",async()=>{const e=Object.values(s.fields).find(c=>c.type==="text"&&c.editable!==!1&&c.editable!==E.GENERATED&&c.editable!==E.COMPUTED&&c.editable!==E.CREATE_ONLY&&c.visibility!=="hidden"&&c.visibility!=="technical"),b=e?{[e.name]:`updated_${Date.now().toString(36)}`}:{};return Object.keys(b).length===0?{skipped:!0}:(await u.update(n,a,b),b)});i.push(t)}if(!r.includes("delete")&&a&&w){const t=await f("delete",async()=>{await u.delete(n,a)});i.push(t)}return P(s,n,i,a,y,v)}function P(s,m,o,l,w,r){const d={entity:s.name,collection:m,passed:o.every(p=>p.passed),steps:o,createdId:l,payload:w,duration:Math.round(performance.now()-r)};return M(d),d}export{O as testEntity};
@@ -1 +1 @@
1
- import{generatePayload as U,getFileFields as w}from"../common/payloadGenerator";import{reportImagePipeline as j}from"../common/reporter";async function d(t,a){const u=performance.now();try{const e=await a();return{step:t,passed:!0,duration:Math.round(performance.now()-u),data:e}}catch(e){return{step:t,passed:!1,duration:Math.round(performance.now()-u),error:e instanceof Error?e.message:String(e),errorDetail:e}}}async function v(t){const{entity:a,input:u={},fns:e}=t,y=performance.now(),c=[];let i;const m=await d("generate-payload",async()=>{const o=U(a.fields,u);for(const[r,s]of Object.entries(o)){const l=A(s),f=r in u?" (override)":""}const n=w(a.fields);if(n.length>0)for(const r of n){const s=o[r.name]}return o});if(c.push(m),!m.passed)return b(c,void 0,y);if(i=m.data,e?.validate){const o=await d("upload-pipeline",async()=>{const n=e.validate(i);return typeof n=="object"&&n!==null&&(i=n),n});if(c.push(o),!o.passed)return b(c,i,y)}const p=w(a.fields).filter(o=>["image","images","avatar"].includes(o.type));if(p.length>0){const o=await d("verify-full-url",async()=>{const r=[];for(const s of p){const l=i[s.name];l!=null&&(Array.isArray(l)?l:[l]).forEach((f,g)=>{const h=`${s.name}[${g}]`;f.fullUrl?f.fullUrl.startsWith("blob:")&&r.push(`${h}.fullUrl is blob: ${f.fullUrl}`):r.push(`${h}.fullUrl is empty`)})}if(r.length>0){for(const s of r);throw new Error(`${r.length} URL issue(s): ${r.join("; ")}`)}return{checked:p.length}});c.push(o);const n=await d("verify-thumb-url",async()=>{const r=[];for(const s of p){const l=i[s.name];l!=null&&(Array.isArray(l)?l:[l]).forEach((f,g)=>{const h=`${s.name}[${g}]`;f.thumbUrl?f.thumbUrl.startsWith("blob:")&&r.push(`${h}.thumbUrl is blob: ${f.thumbUrl}`):r.push(`${h}.thumbUrl is empty`)})}if(r.length>0){for(const s of r);throw new Error(`${r.length} thumbUrl issue(s): ${r.join("; ")}`)}return{checked:p.length}});c.push(n)}if(e?.createMetadata){const o=await d("cleanup-image",async()=>{const n=e.createMetadata();for(const[r,s]of Object.entries(n));return i={...i,...n},n});c.push(o)}for(const[o,n]of Object.entries(i));const $=b(c,i,y);return j($),$}function A(t){if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string")return t.length>60?`"${t.slice(0,57)}..."`:`"${t}"`;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return`Array(${t.length})`;if(typeof t=="object"){const a=Object.keys(t);return`{${a.slice(0,4).join(", ")}${a.length>4?", ...":""}}`}return String(t)}function b(t,a,u){return{passed:t.every(e=>e.passed),steps:t,payload:a,duration:Math.round(performance.now()-u)}}export{v as testImagePipeline};
1
+ import{generatePayload as U,getFileFields as w}from"../common/payloadGenerator";import{reportImagePipeline as j}from"../common/reporter";async function d(e,a){const f=performance.now();try{const t=await a();return{step:e,passed:!0,duration:Math.round(performance.now()-f),data:t}}catch(t){return{step:e,passed:!1,duration:Math.round(performance.now()-f),error:t instanceof Error?t.message:String(t),errorDetail:t}}}async function v(e){const{entity:a,input:f={},fns:t}=e,y=performance.now(),c=[];let i;const m=await d("generate-payload",async()=>{const o=U(a.fields,f);for(const[r,s]of Object.entries(o)){const l=A(s),u=r in f?" (override)":""}const n=w(a.fields);if(n.length>0)for(const r of n){const s=o[r.name]}return o});if(c.push(m),!m.passed)return g(c,void 0,y);if(i=m.data,t?.validate){const o=await d("upload-pipeline",async()=>{const n=t.validate(i);return typeof n=="object"&&n!==null&&(i=n),n});if(c.push(o),!o.passed)return g(c,i,y)}const p=w(a.fields).filter(o=>["image","images","avatar"].includes(o.type));if(p.length>0){const o=await d("verify-full-url",async()=>{const r=[];for(const s of p){const l=i[s.name];l!=null&&(Array.isArray(l)?l:[l]).forEach((u,b)=>{const h=`${s.name}[${b}]`;u.fullUrl?u.fullUrl.startsWith("blob:")&&r.push(`${h}.fullUrl is blob: ${u.fullUrl}`):r.push(`${h}.fullUrl is empty`)})}if(r.length>0){for(const s of r);throw new Error(`${r.length} URL issue(s): ${r.join("; ")}`)}return{checked:p.length}});c.push(o);const n=await d("verify-thumb-url",async()=>{const r=[];for(const s of p){const l=i[s.name];l!=null&&(Array.isArray(l)?l:[l]).forEach((u,b)=>{const h=`${s.name}[${b}]`;u.thumbUrl?u.thumbUrl.startsWith("blob:")&&r.push(`${h}.thumbUrl is blob: ${u.thumbUrl}`):r.push(`${h}.thumbUrl is empty`)})}if(r.length>0){for(const s of r);throw new Error(`${r.length} thumbUrl issue(s): ${r.join("; ")}`)}return{checked:p.length}});c.push(n)}if(t?.createMetadata){const o=await d("cleanup-image",async()=>{const n=t.createMetadata();for(const[r,s]of Object.entries(n));return i={...i,...n},n});c.push(o)}for(const[o,n]of Object.entries(i));const $=g(c,i,y);return j($),$}function A(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e.length>60?`"${e.slice(0,57)}..."`:`"${e}"`;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return`Array(${e.length})`;if(typeof e=="object"){const a=Object.keys(e);return`{${a.slice(0,4).join(", ")}${a.length>4?", ...":""}}`}return String(e)}function g(e,a,f){return{passed:e.every(t=>t.passed),steps:e,payload:a,duration:Math.round(performance.now()-f)}}export{v as testImagePipeline};
@@ -1 +1 @@
1
- import{reportImageUpload as E}from"../common/reporter";function U(l="dndev_test.png"){const r=document.createElement("canvas");r.width=100,r.height=100;const e=r.getContext("2d");if(!e)throw new Error("Failed to get canvas 2d context");e.fillStyle="#CC2200",e.fillRect(0,0,100,100),e.strokeStyle="#FFFFFF",e.lineWidth=3,e.beginPath(),e.moveTo(0,0),e.lineTo(100,100),e.stroke();const n=r.toDataURL("image/png").split(",")[1]??"",u=atob(n),c=new Uint8Array(u.length);for(let s=0;s<u.length;s++)c[s]=u.charCodeAt(s);return new File([c],l,{type:"image/png"})}async function p(l,r){const e=performance.now();try{const n=await r();return{step:l,passed:!0,duration:Math.round(performance.now()-e),data:n}}catch(n){return{step:l,passed:!1,duration:Math.round(performance.now()-e),error:n instanceof Error?n.message:String(n),errorDetail:n}}}async function I(l){const{fns:r,storagePath:e,verifyUrls:n=!0,cleanup:u=!0,signal:c}=l,s=l.file??U(),m=performance.now(),h=[];let o,f,d,g;if(r.processImage){const a=await p("process-image",async()=>{const t=await r.processImage(s);return t.fullBlob.size,t.thumbBlob.size,t.fullBlob.type,t.thumbBlob.type,d=t.fullBlob,g=t.thumbBlob,f={fullSize:t.fullBlob.size,thumbSize:t.thumbBlob.size,width:t.width,height:t.height},{fullSize:t.fullBlob.size,thumbSize:t.thumbBlob.size,width:t.width,height:t.height}});if(h.push(a),!a.passed)return w(h,o,f,m)}else d=s,g=s;const b=await p("upload-pipeline",async()=>{const a=await r.uploadImage(d,g,s.name,{storagePath:e,signal:c,onProgress:t=>{}});if(!a.fullUrl)throw new Error("uploadImage returned empty fullUrl");if(!a.thumbUrl)throw new Error("uploadImage returned empty thumbUrl");if(a.fullUrl.startsWith("blob:"))throw new Error(`fullUrl is a blob URL: ${a.fullUrl}`);if(a.thumbUrl.startsWith("blob:"))throw new Error(`thumbUrl is a blob URL: ${a.thumbUrl}`);return o=a,a});if(h.push(b),!b.passed)return w(h,o,f,m);if(n&&o){const a=await p("verify-full-url",async()=>{const i=await fetch(o.fullUrl,{method:"HEAD",signal:c});if(!i.ok)throw new Error(`fullUrl returned HTTP ${i.status}`);return{status:i.status,contentType:i.headers.get("content-type")}});h.push(a);const t=await p("verify-thumb-url",async()=>{const i=await fetch(o.thumbUrl,{method:"HEAD",signal:c});if(!i.ok)throw new Error(`thumbUrl returned HTTP ${i.status}`);return{status:i.status,contentType:i.headers.get("content-type")}});h.push(t)}if(u&&r.deleteImage&&o){const a=await p("cleanup-image",async()=>(await r.deleteImage(o),{deleted:[o.fullUrl,o.thumbUrl]}));h.push(a)}else u&&r.deleteImage;const y=w(h,o,f,m);return E(y),y}function w(l,r,e,n){return{passed:l.every(u=>u.passed),steps:l,picture:r,processed:e,duration:Math.round(performance.now()-n)}}export{U as createTestImageFile,I as testImageUpload};
1
+ import{reportImageUpload as E}from"../common/reporter";function U(s="dndev_test.png"){const r=document.createElement("canvas");r.width=100,r.height=100;const e=r.getContext("2d");if(!e)throw new Error("Failed to get canvas 2d context");e.fillStyle="#CC2200",e.fillRect(0,0,100,100),e.strokeStyle="#FFFFFF",e.lineWidth=3,e.beginPath(),e.moveTo(0,0),e.lineTo(100,100),e.stroke();const n=r.toDataURL("image/png").split(",")[1]??"",u=atob(n),c=new Uint8Array(u.length);for(let l=0;l<u.length;l++)c[l]=u.charCodeAt(l);return new File([c],s,{type:"image/png"})}async function p(s,r){const e=performance.now();try{const n=await r();return{step:s,passed:!0,duration:Math.round(performance.now()-e),data:n}}catch(n){return{step:s,passed:!1,duration:Math.round(performance.now()-e),error:n instanceof Error?n.message:String(n),errorDetail:n}}}async function I(s){const{fns:r,storagePath:e,verifyUrls:n=!0,cleanup:u=!0,signal:c}=s,l=s.file??U(),m=performance.now(),h=[];let o,f,d,g;if(r.processImage){const a=await p("process-image",async()=>{const t=await r.processImage(l);return t.fullBlob.size,t.thumbBlob.size,t.fullBlob.type,t.thumbBlob.type,d=t.fullBlob,g=t.thumbBlob,f={fullSize:t.fullBlob.size,thumbSize:t.thumbBlob.size,width:t.width,height:t.height},{fullSize:t.fullBlob.size,thumbSize:t.thumbBlob.size,width:t.width,height:t.height}});if(h.push(a),!a.passed)return w(h,o,f,m)}else d=l,g=l;const b=await p("upload-pipeline",async()=>{const a=await r.uploadImage(d,g,l.name,{storagePath:e,signal:c,onProgress:t=>{}});if(!a.fullUrl)throw new Error("uploadImage returned empty fullUrl");if(!a.thumbUrl)throw new Error("uploadImage returned empty thumbUrl");if(a.fullUrl.startsWith("blob:"))throw new Error(`fullUrl is a blob URL: ${a.fullUrl}`);if(a.thumbUrl.startsWith("blob:"))throw new Error(`thumbUrl is a blob URL: ${a.thumbUrl}`);return o=a,a});if(h.push(b),!b.passed)return w(h,o,f,m);if(n&&o){const a=await p("verify-full-url",async()=>{const i=await fetch(o.fullUrl,{method:"HEAD",signal:c});if(!i.ok)throw new Error(`fullUrl returned HTTP ${i.status}`);return{status:i.status,contentType:i.headers.get("content-type")}});h.push(a);const t=await p("verify-thumb-url",async()=>{const i=await fetch(o.thumbUrl,{method:"HEAD",signal:c});if(!i.ok)throw new Error(`thumbUrl returned HTTP ${i.status}`);return{status:i.status,contentType:i.headers.get("content-type")}});h.push(t)}if(u&&r.deleteImage&&o){const a=await p("cleanup-image",async()=>(await r.deleteImage(o),{deleted:[o.fullUrl,o.thumbUrl]}));h.push(a)}else u&&r.deleteImage;const y=w(h,o,f,m);return E(y),y}function w(s,r,e,n){return{passed:s.every(u=>u.passed),steps:s,picture:r,processed:e,duration:Math.round(performance.now()-n)}}export{U as createTestImageFile,I as testImageUpload};
@@ -1 +1 @@
1
- {"version":3,"file":"payloadGenerator.d.ts","sourceRoot":"","sources":["../../src/common/payloadGenerator.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,EAAY,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAoI5D;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAUvD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAE5D;AAMD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACnC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA2CzB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAClC,WAAW,EAAE,CAIf"}
1
+ {"version":3,"file":"payloadGenerator.d.ts","sourceRoot":"","sources":["../../src/common/payloadGenerator.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,EAAY,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAwI5D;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAUvD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAE5D;AAMD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACnC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA2CzB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAClC,WAAW,EAAE,CAIf"}
@@ -1 +1 @@
1
- import{EDITABLE as d}from"@donotdev/core";const c={text:e=>{const t=e.validation?.maxLength??20;return`test_${e.name}_${Date.now().toString(36)}`.slice(0,t)},textarea:e=>`Test ${e.name} content \u2014 generated by @donotdev/testing`,richtext:()=>"<p>Test rich text content</p>",email:()=>`test_${Date.now().toString(36)}@example.com`,url:()=>"https://example.com/test",password:()=>"Test1234!@#$",tel:()=>"+33612345678",iban:()=>"FR7630006000011234567890189",number:e=>{const t=e.validation?.min??0,n=e.validation?.max??100;return Math.floor(t+(n-t)/2)},range:e=>c.number(e),rating:()=>3,year:e=>{const t=e.validation?.min??2e3,n=e.validation?.max??new Date().getFullYear();return Math.floor(t+(n-t)/2)},price:()=>({amount:9900,currency:"EUR",vatIncluded:!0,discountPercent:0}),currency:e=>{const t=e.validation?.min??0,n=e.validation?.max??1e4;return Math.floor(t+(n-t)/2)},select:e=>o(e),radio:e=>o(e),combobox:e=>o(e)??`test_${e.name}`,multiselect:e=>{const t=o(e);return t?[t]:[]},boolean:()=>!0,checkbox:()=>!0,switch:e=>{const t=e.options?.fieldSpecific?.checkedValue;return t!==void 0?t:!0},date:()=>new Date().toISOString().split("T")[0],"datetime-local":()=>new Date().toISOString().slice(0,16),time:()=>"12:00",month:()=>`${new Date().getFullYear()}-01`,week:()=>`${new Date().getFullYear()}-W01`,timestamp:()=>new Date().toISOString(),image:()=>null,images:()=>[],file:()=>null,files:()=>[],document:()=>null,documents:()=>[],avatar:()=>null,address:()=>({formatted_address:"1 rue de Rivoli, 75001 Paris, France",latitude:48.8606,longitude:2.3376}),geopoint:()=>({lat:48.8566,lng:2.3522}),reference:()=>"",hidden:()=>"test_hidden_value",color:()=>"#3B82F6",badge:()=>"test",map:()=>({key1:"value1"}),array:()=>[],"field-array":()=>[],duration:()=>3600,gdprConsent:()=>!0};function o(e){const t=e.validation?.options;return t?(typeof t=="function"?t({}):t)?.[0]?.value:void 0}function u(e){return!(new Set(["id","createdAt","updatedAt","createdById","updatedById","status"]).has(e.name)||e.editable===d.GENERATED||e.editable===d.COMPUTED||e.editable===!1||e.visibility==="hidden")}function r(e){return["image","images","file","files","document","documents","avatar"].includes(e.type)}function m(e){return["images","files","documents"].includes(e.type)}function f(e,t){const n={};for(const[i,a]of Object.entries(e)){if(!u(a)||r(a))continue;if(t&&i in t){n[i]=t[i];continue}const l=c[a.type];if(!l){a.validation?.required&&(n[i]=`test_${a.type}_${i}`);continue}const s=l(a);(a.validation?.required||s!==null)&&(n[i]=s)}if(t)for(const[i,a]of Object.entries(t))i in n||(n[i]=a);return n}function g(e){return Object.values(e).filter(t=>u(t)&&r(t))}export{f as generatePayload,g as getFileFields,r as isFileField,m as isMultiFileField};
1
+ import{EDITABLE as s}from"@donotdev/core";const c={text:e=>{const t=e.validation?.maxLength??20;return`test_${e.name}_${Date.now().toString(36)}`.slice(0,t)},textarea:e=>`Test ${e.name} content \u2014 generated by @donotdev/testing`,richtext:()=>"<p>Test rich text content</p>",email:()=>`test_${Date.now().toString(36)}@example.com`,url:()=>"https://example.com/test",password:()=>"Test1234!@#$",tel:()=>"+33612345678",iban:()=>"FR7630006000011234567890189",number:e=>{const t=e.validation?.min??0,n=e.validation?.max??100;return Math.floor(t+(n-t)/2)},range:e=>c.number(e),rating:()=>3,year:e=>{const t=e.validation?.min??2e3,n=e.validation?.max??new Date().getFullYear();return Math.floor(t+(n-t)/2)},price:()=>({amount:9900,currency:"EUR",vatIncluded:!0,discountPercent:0}),currency:e=>{const t=e.validation?.min??0,n=e.validation?.max??1e4;return Math.floor(t+(n-t)/2)},select:e=>o(e),radio:e=>o(e),combobox:e=>o(e)??`test_${e.name}`,multiselect:e=>{const t=o(e);return t?[t]:[]},boolean:()=>!0,checkbox:()=>!0,switch:e=>{const t=e.options?.fieldSpecific,n=t&&"checkedValue"in t?t.checkedValue:void 0;return n!==void 0?n:!0},date:()=>new Date().toISOString().split("T")[0],"datetime-local":()=>new Date().toISOString().slice(0,16),time:()=>"12:00",month:()=>`${new Date().getFullYear()}-01`,week:()=>`${new Date().getFullYear()}-W01`,timestamp:()=>new Date().toISOString(),image:()=>null,images:()=>[],file:()=>null,files:()=>[],document:()=>null,documents:()=>[],avatar:()=>null,address:()=>({formatted_address:"1 rue de Rivoli, 75001 Paris, France",latitude:48.8606,longitude:2.3376}),geopoint:()=>({lat:48.8566,lng:2.3522}),reference:()=>"",hidden:()=>"test_hidden_value",color:()=>"#3B82F6",badge:()=>"test",map:()=>({key1:"value1"}),array:()=>[],"field-array":()=>[],duration:()=>3600,gdprConsent:()=>!0};function o(e){const t=e.validation?.options;return t?(typeof t=="function"?t({}):t)?.[0]?.value:void 0}function u(e){return!(new Set(["id","createdAt","updatedAt","createdById","updatedById","status"]).has(e.name)||e.editable===s.GENERATED||e.editable===s.COMPUTED||e.editable===!1||e.visibility==="hidden")}function r(e){return["image","images","file","files","document","documents","avatar"].includes(e.type)}function m(e){return["images","files","documents"].includes(e.type)}function f(e,t){const n={};for(const[i,a]of Object.entries(e)){if(!u(a)||r(a))continue;if(t&&i in t){n[i]=t[i];continue}const l=c[a.type];if(!l){a.validation?.required&&(n[i]=`test_${a.type}_${i}`);continue}const d=l(a);(a.validation?.required||d!==null)&&(n[i]=d)}if(t)for(const[i,a]of Object.entries(t))i in n||(n[i]=a);return n}function g(e){return Object.values(e).filter(t=>u(t)&&r(t))}export{f as generatePayload,g as getFileFields,r as isFileField,m as isMultiFileField};
@@ -1 +1 @@
1
- function a(e){return e?"\x1B[32mPASS\x1B[0m":"\x1B[31mFAIL\x1B[0m"}function r(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(2)}s`}function f(e){const t=e.passed?" +":" x",s=r(e.duration),n=e.error?` \u2014 ${e.error}`:"";return`${t} ${e.step} (${s})${n}`}function o(e){const t=`[${a(e.passed)}] ${e.entity} (${e.collection}) \u2014 ${r(e.duration)}`;e.createdId;for(const s of e.steps);if(!e.passed&&e.payload){const s=e.steps.find(n=>n.step==="create"&&!n.passed)}for(const s of e.steps)!s.passed&&s.errorDetail}function p(e){const t=`[${a(e.passed)}] Storage test \u2014 ${r(e.duration)}`;for(const s of e.steps);for(const s of e.steps)!s.passed&&s.errorDetail}function c(e){const t=`[${a(e.passed)}] Image Upload \u2014 ${r(e.duration)}`;e.processed,e.picture;for(const s of e.steps);for(const s of e.steps)!s.passed&&s.errorDetail}function i(e){const t=`[${a(e.passed)}] Image Pipeline \u2014 ${r(e.duration)}`;for(const s of e.steps);for(const s of e.steps)!s.passed&&s.errorDetail}export{o as reportEntity,i as reportImagePipeline,c as reportImageUpload,p as reportStorage};
1
+ function a(s){return s?"\x1B[32mPASS\x1B[0m":"\x1B[31mFAIL\x1B[0m"}function r(s){return s<1e3?`${s}ms`:`${(s/1e3).toFixed(2)}s`}function f(s){const o=s.passed?" +":" x",t=r(s.duration),n=s.error?` \u2014 ${s.error}`:"";return`${o} ${s.step} (${t})${n}`}function e(s){const o=`[${a(s.passed)}] ${s.entity} (${s.collection}) \u2014 ${r(s.duration)}`;s.createdId;for(const t of s.steps);if(!s.passed&&s.payload){const t=s.steps.find(n=>n.step==="create"&&!n.passed)}for(const t of s.steps)!t.passed&&t.errorDetail}function p(s){const o=`[${a(s.passed)}] Storage test \u2014 ${r(s.duration)}`;for(const t of s.steps);for(const t of s.steps)!t.passed&&t.errorDetail}function c(s){const o=`[${a(s.passed)}] Image Upload \u2014 ${r(s.duration)}`;s.processed,s.picture;for(const t of s.steps);for(const t of s.steps)!t.passed&&t.errorDetail}function i(s){const o=`[${a(s.passed)}] Image Pipeline \u2014 ${r(s.duration)}`;for(const t of s.steps);for(const t of s.steps)!t.passed&&t.errorDetail}export{e as reportEntity,i as reportImagePipeline,c as reportImageUpload,p as reportStorage};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/testing",
3
- "version": "0.2.0",
3
+ "version": "0.2.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {},
25
25
  "peerDependencies": {
26
- "@donotdev/core": "^0.2.0"
26
+ "@donotdev/core": "^0.2.3"
27
27
  },
28
28
  "files": [
29
29
  "dist",