@donotdev/testing 0.1.44 → 0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"debugIsousou.d.ts","sourceRoot":"","sources":["../../src/client/debugIsousou.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAUzE,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,CAChC,eAAe,EAAE,GAAG,EACpB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CA0Hf"}
@@ -1 +1 @@
1
- import{getProvider as p}from"@donotdev/core";import{testStorage as d}from"./testStorage";import{testEntity as h}from"./testEntity";import{testImagePipeline as S}from"./testImagePipeline";import{testImageUpload as f}from"./testImageUpload";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 d({storage:o}),s=await d({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 f({fns:i}),r&&r.length>0))for(const s of r)await f({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
+ 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 +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;AAEzE,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAGjB,MAAM,iBAAiB,CAAC;AAmHzB;;;;;;;;;;;;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;AA4GzB;;;;;;;;;;;;GAYG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,CAAC,CA8K3B"}
@@ -1 +1 @@
1
- import{EDITABLE as v}from"@donotdev/core";import{generatePayload as D,getFileFields as P,isMultiFileField as $}from"../common/payloadGenerator";import{reportEntity as C}from"../common/reporter";import{createTestImageBlob as F,createTestFileBlob as M}from"./testStorage";async function y(a,w){const r=performance.now();try{const o=await w();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,w,r,o){const g=[],n={};for(const l of a){const p=["image","images","avatar"].includes(l.type),u=$(l),d=l.options?.fieldSpecific?.storagePath??r,h=p?"upload-image":"upload-file",s=await y(h,async()=>{const t=p?F():M(),E=p?"png":"txt",f=`dndev_test_${l.name}_${Date.now()}.${E}`,m=await w.upload(t,{storagePath:d,filename:f,signal:o,onProgress:e=>{}});if(p){const e={fullUrl:m.url,thumbUrl:m.url};n[l.name]=u?[e]:e}else{const e={url:m.url,filename:f,size:t.size,mimeType:t.type};n[l.name]=u?[e]:e}return m});g.push({...s,step:`${h}`}),s.passed||(n[l.name]=u?[]:null)}return{results:g,values:n}}async function k(a,w){const{providers:r,payload:o,cleanup:g=!0,skip:n=[],storagePath:l,signal:p}=w,{crud:u}=r,d=a.collection,h=performance.now(),s=[];let t;const E=await y("generate-payload",async()=>D(a.fields,o));if(s.push(E),!E.passed)return T(a,d,s,t,void 0,h);let f=E.data;const m=P(a.fields);if(m.length>0&&r.storage){const{results:e,values:i}=await _(m,r.storage,l,p);s.push(...e),f={...f,...i}}else m.length>0&&r.storage;if(!n.includes("create")){const e=await y("create",async()=>{const i=await u.add(d,f);return t=i.id,i});if(s.push(e),!e.passed)return T(a,d,s,t,f,h)}if(!n.includes("get")&&t){const e=await y("get",async()=>{const i=await u.get(d,t);if(!i)throw new Error(`get returned null for id=${t}`);return i});s.push(e)}if(!n.includes("list")){const e=await y("list",async()=>{const i=await u.query(d,{limit:5});if(t){const b=i.items.some(c=>c.id===t)}return i});s.push(e)}if(!n.includes("listCard")){const e=await y("listCard",async()=>await u.query(d,{limit:5},void 0,"listCard"));s.push(e)}if(!n.includes("update")&&t){const e=await y("update",async()=>{const i=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=i?{[i.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(!n.includes("delete")&&t&&g){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,w,r,o,g,n){const l={entity:a.name,collection:w,passed:r.every(p=>p.passed),steps:r,createdId:o,payload:g,duration:Math.round(performance.now()-n)};return C(l),l}export{k as testEntity};
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,14 +1,3 @@
1
- /**
2
- * @fileoverview Deterministic CRUD pipeline test - pure data, no browser APIs.
3
- *
4
- * Input: entity definition + form object (like the store/UI would give)
5
- * Process: real framework code (generate → validate → metadata → adapter)
6
- * Output: the exact payload that Supabase/Firebase would receive
7
- *
8
- * @version 0.2.0
9
- * @since 0.1.0
10
- * @author AMBROISE PARK Consulting
11
- */
12
1
  import type { TestImagePipelineOptions, TestImagePipelineResult } from '../common/types';
13
2
  /**
14
3
  * Test the CRUD pipeline as pure data: form object in → framework processing → adapter payload out.
@@ -1 +1 @@
1
- {"version":3,"file":"testImagePipeline.d.ts","sourceRoot":"","sources":["../../src/client/testImagePipeline.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EAIxB,MAAM,iBAAiB,CAAC;AAoCzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CAqMlC"}
1
+ {"version":3,"file":"testImagePipeline.d.ts","sourceRoot":"","sources":["../../src/client/testImagePipeline.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EAIxB,MAAM,iBAAiB,CAAC;AAkCzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CAqMlC"}
@@ -1 +1 @@
1
- import{reportImagePipeline as U}from"../common/reporter";import{generatePayload as j,getFileFields as w}from"../common/payloadGenerator";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=j(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 U($),$}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
+ 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,13 +1,3 @@
1
- /**
2
- * @fileoverview Browser-side image upload pipeline test — processImage → uploadImage → verify → cleanup
3
- *
4
- * Exercises the REAL upload pipeline using injected functions from @donotdev/crud.
5
- * Runs in browser (requires canvas, fetch). Not for Node/vitest.
6
- *
7
- * @version 0.1.0
8
- * @since 0.1.0
9
- * @author AMBROISE PARK Consulting
10
- */
11
1
  import type { TestImageUploadOptions, TestImageUploadResult } from '../common/types';
12
2
  /**
13
3
  * Create a 100x100 red PNG test image as a File object, with a white diagonal line.
@@ -1 +1 @@
1
- {"version":3,"file":"testImageUpload.d.ts","sourceRoot":"","sources":["../../src/client/testImageUpload.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EAKtB,MAAM,iBAAiB,CAAC;AAOzB;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,SAAmB,GAAG,IAAI,CA6BjE;AAkCD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAsMhC"}
1
+ {"version":3,"file":"testImageUpload.d.ts","sourceRoot":"","sources":["../../src/client/testImageUpload.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EAKtB,MAAM,iBAAiB,CAAC;AAMzB;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,SAAmB,GAAG,IAAI,CA6BjE;AAkCD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAsMhC"}
@@ -1 +1 @@
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
+ 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,9 +1,3 @@
1
- /**
2
- * @fileoverview Standalone storage adapter test — upload, getUrl, delete
3
- * @version 0.1.0
4
- * @since 0.1.0
5
- * @author AMBROISE PARK Consulting
6
- */
7
1
  import type { TestStorageOptions, TestStorageResult } from '../common/types';
8
2
  /**
9
3
  * Generate a minimal valid PNG blob for testing image uploads
@@ -1 +1 @@
1
- {"version":3,"file":"testStorage.d.ts","sourceRoot":"","sources":["../../src/client/testStorage.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,iBAAiB,CAAC;AAOzB;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CA0E1C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAIzC;AAkCD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CA2C5B"}
1
+ {"version":3,"file":"testStorage.d.ts","sourceRoot":"","sources":["../../src/client/testStorage.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,iBAAiB,CAAC;AAMzB;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CA0E1C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAIzC;AAkCD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CA2C5B"}
@@ -1 +1 @@
1
- function a(o){return o?"\x1B[32mPASS\x1B[0m":"\x1B[31mFAIL\x1B[0m"}function r(o){return o<1e3?`${o}ms`:`${(o/1e3).toFixed(2)}s`}function f(o){const s=o.passed?" +":" x",e=r(o.duration),n=o.error?` \u2014 ${o.error}`:"";return`${s} ${o.step} (${e})${n}`}function t(o){const s=`[${a(o.passed)}] ${o.entity} (${o.collection}) \u2014 ${r(o.duration)}`;o.createdId;for(const e of o.steps);if(!o.passed&&o.payload){const e=o.steps.find(n=>n.step==="create"&&!n.passed)}for(const e of o.steps)!e.passed&&e.errorDetail}function p(o){const s=`[${a(o.passed)}] Storage test \u2014 ${r(o.duration)}`;for(const e of o.steps);for(const e of o.steps)!e.passed&&e.errorDetail}function c(o){const s=`[${a(o.passed)}] Image Upload \u2014 ${r(o.duration)}`;o.processed,o.picture;for(const e of o.steps);for(const e of o.steps)!e.passed&&e.errorDetail}function i(o){const s=`[${a(o.passed)}] Image Pipeline \u2014 ${r(o.duration)}`;for(const e of o.steps);for(const e of o.steps)!e.passed&&e.errorDetail}export{t as reportEntity,i as reportImagePipeline,c as reportImageUpload,p as reportStorage};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/testing",
3
- "version": "0.1.44",
3
+ "version": "0.2.0",
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.1.43"
26
+ "@donotdev/core": "^0.2.0"
27
27
  },
28
28
  "files": [
29
29
  "dist",
@@ -48,4 +48,4 @@
48
48
  "registry": "https://registry.npmjs.org",
49
49
  "access": "public"
50
50
  }
51
- }
51
+ }