@donotdev/crud 0.0.15 → 0.0.16
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/CrudService.js +2 -2
- package/dist/CrudStore.js +1 -1
- package/dist/FieldRegistry.d.ts +3 -30
- package/dist/FieldRegistry.d.ts.map +1 -1
- package/dist/FieldRegistry.js +1 -1
- package/dist/adapters/FunctionsAdapter.d.ts.map +1 -1
- package/dist/adapters/FunctionsAdapter.js +1 -1
- package/dist/components/CrudButton.js +1 -1
- package/dist/components/CrudCard.js +1 -1
- package/dist/components/DateFilter.js +1 -1
- package/dist/components/DisplayFieldRenderer.js +1 -1
- package/dist/components/DisplayThumbnail.js +1 -1
- package/dist/components/EntityFilters.js +1 -1
- package/dist/components/FormFieldRenderer.js +1 -1
- package/dist/components/FormLayout.js +1 -1
- package/dist/components/__tests__/EntityFilters.test.js +1 -1
- package/dist/components/__tests__/FormFieldRenderer.test.js +1 -1
- package/dist/components/controlled/complex/ControlledAddressField.js +1 -1
- package/dist/components/controlled/complex/ControlledDateField.js +1 -1
- package/dist/components/controlled/complex/ControlledGeoPointField.js +1 -1
- package/dist/components/controlled/complex/ControlledMapField.js +1 -1
- package/dist/components/controlled/complex/ControlledMultiInputField.js +1 -1
- package/dist/components/controlled/complex/ControlledRichTextField.js +1 -1
- package/dist/components/controlled/complex/ControlledTimestampField.js +1 -1
- package/dist/components/controlled/complex/index.js +1 -1
- package/dist/components/controlled/file/ControlledDocumentField.js +1 -1
- package/dist/components/controlled/file/ControlledFileField.js +1 -1
- package/dist/components/controlled/file/ControlledImageField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiDocumentField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiFileField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiImageField.js +1 -1
- package/dist/components/controlled/file/index.js +1 -1
- package/dist/components/controlled/index.js +1 -1
- package/dist/components/controlled/input/ControlledCheckboxField.js +1 -1
- package/dist/components/controlled/input/ControlledCurrencyField.js +1 -1
- package/dist/components/controlled/input/ControlledDurationField.js +1 -1
- package/dist/components/controlled/input/ControlledGdprConsentField.js +1 -1
- package/dist/components/controlled/input/ControlledNumberField.js +1 -1
- package/dist/components/controlled/input/ControlledPasswordField.js +1 -1
- package/dist/components/controlled/input/ControlledPhoneField.js +1 -1
- package/dist/components/controlled/input/ControlledPriceField.js +1 -1
- package/dist/components/controlled/input/ControlledRangeField.js +1 -1
- package/dist/components/controlled/input/ControlledRatingField.js +1 -1
- package/dist/components/controlled/input/ControlledSwitchField.js +1 -1
- package/dist/components/controlled/input/ControlledTextField.js +1 -1
- package/dist/components/controlled/input/ControlledTextareaField.js +1 -1
- package/dist/components/controlled/input/index.js +1 -1
- package/dist/components/controlled/select/ControlledComboboxField.js +1 -1
- package/dist/components/controlled/select/ControlledDropdownField.js +1 -1
- package/dist/components/controlled/select/ControlledMultiDropdownField.js +1 -1
- package/dist/components/controlled/select/ControlledRadioField.js +1 -1
- package/dist/components/controlled/select/ControlledYearField.js +1 -1
- package/dist/components/controlled/select/index.js +1 -1
- package/dist/components/controlled/types.d.ts +19 -5
- package/dist/components/controlled/types.d.ts.map +1 -1
- package/dist/components/controlled/types.js +1 -1
- package/dist/components/fields/display/AvatarFieldDisplay.js +1 -1
- package/dist/components/fields/display/BadgeFieldDisplay.js +1 -1
- package/dist/components/fields/display/ButtonFieldDisplay.js +1 -1
- package/dist/components/fields/display/CheckboxFieldDisplay.js +1 -1
- package/dist/components/fields/display/DateFieldDisplay.js +1 -1
- package/dist/components/fields/display/DropdownDisplay.js +1 -1
- package/dist/components/fields/display/FileFieldDisplay.js +1 -1
- package/dist/components/fields/display/GeoPointFieldDisplay.js +1 -1
- package/dist/components/fields/display/HiddenFieldDisplay.js +1 -1
- package/dist/components/fields/display/ImageFieldDisplay.js +1 -1
- package/dist/components/fields/display/LinkFieldDisplay.js +1 -1
- package/dist/components/fields/display/MapFieldDisplay.js +1 -1
- package/dist/components/fields/display/MultiDropdownDisplay.js +1 -1
- package/dist/components/fields/display/MultiInputTextFieldDisplay.js +1 -1
- package/dist/components/fields/display/NumberFieldDisplay.js +1 -1
- package/dist/components/fields/display/PasswordFieldDisplay.js +1 -1
- package/dist/components/fields/display/PhoneNumberDisplay.js +1 -1
- package/dist/components/fields/display/RadioFieldDisplay.js +1 -1
- package/dist/components/fields/display/RangeFieldDisplay.js +1 -1
- package/dist/components/fields/display/ReferenceFieldDisplay.js +1 -1
- package/dist/components/fields/display/RichTextDisplay.js +2 -2
- package/dist/components/fields/display/TextAreaDisplay.js +1 -1
- package/dist/components/fields/display/TextFieldDisplay.js +1 -1
- package/dist/components/fields/display/TimestampFieldDisplay.js +1 -1
- package/dist/components/fields/display/index.js +1 -1
- package/dist/components/form/fields/AddressFieldComponent.js +1 -1
- package/dist/components/form/fields/AvatarFieldComponent.js +1 -1
- package/dist/components/form/fields/BadgeFieldComponent.js +1 -1
- package/dist/components/form/fields/ButtonFieldComponent.js +1 -1
- package/dist/components/form/fields/CheckboxFieldComponent.js +1 -1
- package/dist/components/form/fields/ComboboxComponent.js +1 -1
- package/dist/components/form/fields/CurrencyFieldComponent.js +1 -1
- package/dist/components/form/fields/DateFieldComponent.js +1 -1
- package/dist/components/form/fields/DocumentFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/DocumentFieldComponent.js +1 -1
- package/dist/components/form/fields/DropdownComponent.js +1 -1
- package/dist/components/form/fields/DurationFieldComponent.js +1 -1
- package/dist/components/form/fields/FileFieldComponent.js +1 -1
- package/dist/components/form/fields/GdprConsentFieldComponent.js +1 -1
- package/dist/components/form/fields/GeoPointFieldComponent.js +1 -1
- package/dist/components/form/fields/HiddenFieldComponent.js +1 -1
- package/dist/components/form/fields/ImageFieldComponent.js +1 -1
- package/dist/components/form/fields/MapFieldComponent.js +1 -1
- package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
- package/dist/components/form/fields/MultiInputTextFieldComponent.js +1 -1
- package/dist/components/form/fields/NumberFieldComponent.js +1 -1
- package/dist/components/form/fields/PasswordFieldComponent.js +1 -1
- package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
- package/dist/components/form/fields/PriceFieldComponent.js +1 -1
- package/dist/components/form/fields/RadioFieldComponent.js +1 -1
- package/dist/components/form/fields/RangeFieldComponent.js +1 -1
- package/dist/components/form/fields/RatingFieldComponent.js +1 -1
- package/dist/components/form/fields/ReferenceFieldComponent.js +1 -1
- package/dist/components/form/fields/RichTextComponent.js +1 -1
- package/dist/components/form/fields/SwitchFieldComponent.js +1 -1
- package/dist/components/form/fields/TextAreaComponent.js +1 -1
- package/dist/components/form/fields/TextFieldComponent.js +1 -1
- package/dist/components/form/fields/TimestampFieldComponent.js +1 -1
- package/dist/components/form/fields/index.js +1 -1
- package/dist/components/form/fields/internal/TiptapEditor.js +2 -2
- package/dist/components/form/internal/ImageViewerDialog.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/contexts/UploadContext.js +1 -1
- package/dist/contexts/index.js +1 -1
- package/dist/fieldTypeRegistry.js +1 -1
- package/dist/forms/hooks/index.js +1 -1
- package/dist/forms/hooks/useController.js +1 -1
- package/dist/forms/hooks/useEntityField.js +1 -1
- package/dist/forms/hooks/useEntityForm.d.ts +3 -2
- package/dist/forms/hooks/useEntityForm.d.ts.map +1 -1
- package/dist/forms/hooks/useEntityForm.js +1 -1
- package/dist/forms/index.js +1 -1
- package/dist/forms/types.d.ts +0 -8
- package/dist/forms/types.d.ts.map +1 -1
- package/dist/forms/utils/buildInitialValues.js +1 -1
- package/dist/forms/utils/getFieldsForOperation.js +1 -1
- package/dist/forms/utils/index.js +1 -1
- package/dist/forms/utils/isFieldEditable.js +1 -1
- package/dist/forms/utils/translateFieldLabel.js +1 -1
- package/dist/forms/utils/validateEntity.js +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useCrudFilters.js +1 -1
- package/dist/hooks/useEntityFavorites.js +1 -1
- package/dist/hooks/useFileUpload.d.ts.map +1 -1
- package/dist/hooks/useFileUpload.js +1 -1
- package/dist/hooks/useFormNavigationGuard.js +1 -1
- package/dist/hooks/useRelatedItems.js +1 -1
- package/dist/hooks/useUnsavedChangesWarning.d.ts +3 -24
- package/dist/hooks/useUnsavedChangesWarning.d.ts.map +1 -1
- package/dist/hooks/useUnsavedChangesWarning.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/registerBuiltinFieldTypes.js +1 -1
- package/dist/stores/FormStore.js +1 -1
- package/dist/stores/UploadStore.js +1 -1
- package/dist/stores/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.js +1 -1
- package/dist/useBaseCrudList.js +1 -1
- package/dist/useCrud.js +1 -1
- package/dist/useCrudCardList.js +1 -1
- package/dist/useCrudList.js +1 -1
- package/dist/utils/collections.js +1 -1
- package/dist/utils/fileStorage.js +1 -1
- package/dist/utils/imageProcessing.js +1 -1
- package/dist/utils/imageStorage.d.ts.map +1 -1
- package/dist/utils/imageStorage.js +1 -1
- package/dist/utils/imageUtils.js +1 -1
- package/dist/utils/mergeWithOptimistic.js +1 -1
- package/dist/utils/sanitizeHtml.js +1 -1
- package/dist/utils/scopeUtils.js +1 -1
- package/dist/utils/uploadValidation.d.ts.map +1 -1
- package/dist/utils/uploadValidation.js +1 -1
- package/package.json +5 -8
package/dist/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const E={PENDING:"pending",CONFIRMED:"confirmed",FAILED:"failed"},e={ADD:"add",UPDATE:"update",SET:"set",DELETE:"delete"};export{e as CRUD_OPERATION,E as OPTIMISTIC_STATUSES};
|
package/dist/useBaseCrudList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as
|
|
1
|
+
import{useMemo as D,useCallback as G,useRef as F}from"react";import{useQuery as H}from"@donotdev/core";import{useCrudStore as J}from"./CrudStore";import{useCrud as P,getCrudServiceInstance as X,EMPTY_OPTIMISTIC as Z}from"./useCrud";import{mergeWithOptimistic as $}from"./utils/mergeWithOptimistic";import{injectScopeFilter as ee,getCurrentScopeValue as te}from"./utils/scopeUtils";import{CRUD_OPERATION as Q}from"./types";function se(V,p,t,g={}){const j=g.enabled??!0,C=P("status"),a=C==="ready",x=P(V,g),{error:q,invalidate:_,_collection:m,_schemas:f,_cacheOptions:O,_scope:b}=x,M=J(e=>e.collections[m]?.optimistic||Z),T=F(new Map([[1,null]])),h=F(0),K=te(b),y=D(()=>{if(!a||!f)return null;const e=X();if(!e)return null;const v=p==="listCard"?f.listCard:f.list,d=ee(g.queryOptions,b);if(!t||t.mode==="client")return e.getListQueryOptions(m,d,v,O,p);const o=T.current,n=h.current,{page:l,pageSize:s}=t;let i,r;if(o.has(l))i=o.get(l)??void 0,r=s;else if(l>n&&o.has(n)){const u=l-n;i=o.get(n)??void 0,r=u*s}else i=void 0,r=l*s;return e.getListQueryOptions(m,{...d,limit:r,startAfter:i},v,O,p)},[a,m,O,f?"hasSchema":"noSchema",p,t?.mode,t?.page,t?.pageSize,g.queryOptions,b?.provider,K]),{data:c,isLoading:R,isFetching:k,error:B,refetch:w}=H({queryKey:y?.queryKey??["crud",m,"disabled"],queryFn:y?.queryFn??(()=>Promise.resolve({items:[]})),staleTime:y?.staleTime,enabled:j&&!!y}),A=D(()=>{if(!c||!a)return{items:[],total:void 0};let e=c.items;if(t?.mode==="server"&&e.length>0){const s=T.current,i=h.current,{page:r,pageSize:u}=t,U=e.length;if(Math.ceil(U/u)>1||r>i){const L=s.has(r)?r:i+1;for(let S=L;S<=r;S++){const z=(S-L+1)*u-1;if(z<e.length){const Y=e[z];s.set(S+1,Y.id)}}}c.lastVisible&&s.set(r+1,c.lastVisible),h.current=Math.max(i,r);const I=s.has(r)?0:(r-i-1)*u,W=I+u;e=e.slice(I,W)}const v=$(e,M),d=new Set(e.map(s=>s.id));let o=0,n=0;for(const[s,i]of Object.entries(M))i.operation===Q.ADD&&!d.has(s)?o++:i.operation===Q.DELETE&&d.has(s)&&n++;const l=(c.total??e.length)+o-n;return{items:v,total:t?l:void 0}},[c,M,a,t?.mode,t?.page,t?.pageSize]),E=G(async()=>{a&&(t?.mode==="server"&&(T.current=new Map([[1,null]]),h.current=0),await _(),await w())},[_,w,a,t?.mode]);if(!a){const e=async()=>{};return{status:C,data:{items:[],total:void 0},items:[],loading:!1,fetching:!1,error:q,mutate:e,refresh:e,isAvailable:!1}}const N=A?.items??[];return{status:C,data:A,items:N,loading:R,fetching:k,error:B??q,mutate:E,refresh:E,isAvailable:!0}}export{se as useBaseCrudList};
|
package/dist/useCrud.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useEffect as
|
|
1
|
+
"use client";import{useEffect as K,useMemo as F,useCallback as n}from"react";import{useFeatureConsent as L,FRAMEWORK_FEATURES as W,FEATURE_STATUS as m,handleError as Z,isClient as B,createSchemas as H,DEGRADED_CRUD_API as J}from"@donotdev/core";import{getCrudService as Q}from"./CrudService";import{useCrudStore as u}from"./CrudStore";import{injectScope as M,injectScopeFilter as V}from"./utils/scopeUtils";const X={},$={};let _=null,E=null,b=!1;function r(){return _}function ee(l,d={}){const f=L(W.CRUD),U=u(e=>e.crudService),g=f&&!U,y=f?g?m.INITIALIZING:m.READY:m.DEGRADED,S=l==="status",p=!S&&typeof l=="object"?l:d.entity,a=S?"__status__":typeof l=="string"?l:l.collection,o=p?.scope,v=d.noCache??!1,T=d.staleTime,h=F(()=>({noCache:v,staleTime:T}),[v,T]),t=F(()=>{if(!S){if(d.schema){const e=d.schema;return{create:e,draft:e,update:e,get:e,list:e,listCard:e,delete:e}}if(p)return H(p)}},[S,d.schema,p?.name,a]),Y=u(e=>e.collections[a]?.loading||!1),A=u(e=>e.collections[a]?.error||null),O=null;K(()=>{if(!B()||!f||!t)return;const{crudService:e}=u.getState();e||_||E||(E=(async()=>{try{if(_||u.getState().crudService)return;const s=Q();_=s,s.setStore(u),await s.initialize(),b=!1,u.getState().setCrudService(s)}catch(s){b||(Z(s,{userMessage:"Failed to initialize CRUD service.",context:{collection:a},severity:"error"}),b=!0)}finally{E=null}})())},[f,a,t?"hasSchema":"noSchema"]);const D=g||Y,P=y===m.READY,j=n(async e=>{const s=r();return!s||!t?null:s.get(a,e,t.get,h)},[a,t?"hasSchema":"noSchema",h]),G=n(async(e,s,c)=>{const i=r();if(!i||!t)return;const C=M(s,o),k=C?.status==="draft"?t.draft:t.create;await i.set(a,e,C,k,c)},[a,t?"hasSchema":"noSchema",o?.provider]),q=n(async(e,s,c)=>{const i=r();i&&await i.update(a,e,s,t?.update,c)},[a,t]),x=n(async(e,s)=>{const c=r();c&&await c.delete(a,e,s)},[a]),z=n(async(e,s)=>{const c=r();if(!c||!t)return"";const i=M(e,o),C=i?.status==="draft"?t.draft:t.create;return c.add(a,i,C,s)},[a,t?"hasSchema":"noSchema",o?.provider]),N=n(async e=>{const s=r();if(!s||!t)return[];const c=V(e,o);return(await s.query(a,c,t.list,h)).items},[a,t?"hasSchema":"noSchema",h,o?.provider]),R=n((e,s)=>{const c=r();return!c||!t?()=>{}:c.subscribe(a,e,s,t.get)},[a,t?"hasSchema":"noSchema"]),I=n((e,s)=>{const c=r();return!c||!t?()=>{}:c.subscribeToCollection(a,e,s,t.list)},[a,t?"hasSchema":"noSchema"]),w=n(async()=>{const e=r();e&&await e.invalidateCollection(a)},[a]);return S?y:P?{status:m.READY,data:O,loading:D,error:A,get:j,set:G,update:q,delete:x,add:z,query:N,subscribe:R,subscribeToCollection:I,invalidate:w,isAvailable:!0,_collection:a,_schemas:t,_cacheOptions:h,_scope:o}:{...J,status:y,loading:D,error:A,subscribe:R,subscribeToCollection:I,invalidate:w,_collection:a,_schemas:t,_cacheOptions:h,_scope:o}}export{X as EMPTY_DATA,$ as EMPTY_OPTIMISTIC,r as getCrudServiceInstance,ee as useCrud};
|
package/dist/useCrudCardList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useBaseCrudList as
|
|
1
|
+
import{useBaseCrudList as i}from"./useBaseCrudList";function r(s,t={}){const a={enabled:t.enabled,queryOptions:t.queryOptions,schema:t.schema,entity:t.entity,staleTime:t.staleTime,noCache:t.noCache},e=i(s,"listCard",null,a);return{status:e.status,data:e.data?{items:e.data.items}:null,items:e.items,loading:e.loading,fetching:e.fetching,error:e.error,mutate:e.mutate,refresh:e.refresh,isAvailable:e.isAvailable}}export{r as useCrudCardList};
|
package/dist/useCrudList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useBaseCrudList as
|
|
1
|
+
import{useBaseCrudList as p}from"./useBaseCrudList";function r(a,e={}){const t=e.pagination??"client",i=e.page??1,n=e.pageSize??10,s={mode:t,page:i,pageSize:n},o={enabled:e.enabled,queryOptions:e.queryOptions,schema:e.schema,entity:e.entity,staleTime:e.staleTime,noCache:e.noCache};return p(a,"list",s,o)}export{r as useCrudList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCrudService as
|
|
1
|
+
import{getCrudService as i}from"../CrudService";async function p(a,t){const e=i(),s=[],o=t.range?.start??1,c=t.range?.end??28;for(let r=o;r<=c;r++){const m=String(r),n=await e.get(t.path(a),m,t.schema);n&&s.push(n)}return s}async function d(a,t,e){const s=i();for(const o of e){const c=t.idOf(o);await s.set(t.path(a),c,o,t.schema)}}async function h(a,t,e){const s=i();if(t.idFrom){const o=t.idFrom(e);return s.set(t.path(a),o,e,t.schema)}return s.add(t.path(a),e,t.schema)}export{h as appendToCollection,p as loadDeterministicRange,d as upsertDeterministic};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{handleError as d,hasProvider as
|
|
1
|
+
"use client";import{handleError as d,hasProvider as u,getProvider as f}from"@donotdev/core";function y(e){return e.replace(/[^a-zA-Z0-9.-]/g,"_").replace(/_{2,}/g,"_").toLowerCase()}async function m(e,t={}){const{storagePath:r="uploads/files",filename:s,onProgress:o}=t,n=Date.now(),i=y(e.name),l=s||`${n}_${i}`,c=`${r}/${l}`;try{let a;if(u("storage"))a=(await f("storage").upload(e,{storagePath:r,filename:l,onProgress:o?p=>o({bytesTransferred:0,totalBytes:0,progress:p}):void 0})).url;else{const{uploadFileResumable:p}=await import("@donotdev/firebase"),{promise:w}=p(e,{basePath:r,filename:l,onProgress:o,metadata:{contentType:e.type}});a=(await w).url}return{url:a,filename:e.name,size:e.size,mimeType:e.type,uploadedAt:new Date().toISOString()}}catch(a){throw d(a,{userMessage:"Failed to upload file",severity:"error",context:{filename:e.name,fileSize:e.size}})}}async function v(e,t={}){const r=[],s=e.reduce((n,i)=>n+i.size,0);let o=0;for(const n of e){const i=t.onProgress?c=>{const a=c.bytesTransferred/c.totalBytes*n.size;t.onProgress({bytesTransferred:o+a,totalBytes:s,progress:(o+a)/s*100})}:void 0,l=await m(n,{...t,onProgress:i});r.push(l),o+=n.size}return r}async function F(e){try{if(u("storage"))await f("storage").delete(e.url);else{const{deleteFileByUrl:t}=await import("@donotdev/firebase");await t(e.url)}}catch(t){throw d(t,{userMessage:"Failed to delete file",severity:"error",context:{url:e.url,filename:e.filename}}),t}}function M(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function g(e){const t=e.split(".");return t.length>1?t.pop().toLowerCase():""}function P(e,t){const r=t?g(t):"";if(e){if(e.startsWith("image/"))return"image";if(e.startsWith("video/"))return"video";if(e.startsWith("audio/"))return"audio";if(e==="application/pdf")return"pdf";if(e.includes("word")||e.includes("document"))return"doc";if(e.includes("excel")||e.includes("spreadsheet"))return"xls";if(e.includes("powerpoint")||e.includes("presentation"))return"ppt"}switch(r){case"pdf":return"pdf";case"doc":case"docx":return"doc";case"xls":case"xlsx":case"csv":return"xls";case"ppt":case"pptx":return"ppt";case"md":case"txt":return"text";case"html":case"htm":return"html";case"zip":case"rar":case"7z":return"archive";default:return"file"}}function z(e){if(e===0)return"0 B";const t=1024,r=["B","KB","MB","GB"],s=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,s)).toFixed(1))} ${r[s]}`}const h=["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain","text/markdown","text/html","text/csv"],x=[".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".txt",".md",".html",".csv"];function B(){return[...h,...x].join(",")}export{x as DOCUMENT_EXTENSIONS,h as DOCUMENT_MIME_TYPES,F as deleteFile,z as formatFileSize,M as generateFileId,B as getDocumentAcceptString,g as getFileExtension,P as getFileIcon,m as uploadFile,v as uploadFiles};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
async function
|
|
1
|
+
async function v(t,r={}){const{maxWidth:o=1920,maxHeight:n=1440,thumbWidth:s=300,thumbHeight:i=225,aspectRatio:e=4/3,quality:l=.85,transparentBackground:c=!0,crop:h}=r;return new Promise((u,d)=>{const a=new Image,g=new FileReader;g.onload=w=>{a.src=w.target?.result},g.onerror=()=>d(new Error("Failed to read file")),a.onload=async()=>{try{const{width:w,height:m}=x(h?h.width:a.width,h?h.height:a.height,o,n,e),b=await F(a,w,m,e,l,c,h),f=await F(a,s,i,e,.65,c,h);u({fullBlob:b,thumbBlob:f,width:w,height:m})}catch(w){d(w)}},a.onerror=()=>d(new Error("Failed to load image")),g.readAsDataURL(t)})}function x(t,r,o,n,s){let i=t,e=r;i>o&&(e=o/i*e,i=o),e>n&&(i=n/e*i,e=n);const l=i/e;return Math.abs(l-s)>.01&&(l>s?e=i/s:i=e*s),{width:Math.round(i),height:Math.round(e)}}async function F(t,r,o,n,s,i,e){const l=document.createElement("canvas"),c=l.getContext("2d");if(!c)throw new Error("Failed to get canvas context");l.width=r,l.height=o,i?c.clearRect(0,0,r,o):(c.fillStyle="#FFFFFF",c.fillRect(0,0,r,o));let h,u,d,a;if(e)h=e.x,u=e.y,d=e.width,a=e.height;else{const g=t.width/t.height;d=t.width,a=t.height,h=0,u=0,g>n?(d=t.height*n,h=(t.width-d)/2):g<n&&(a=t.width/n,u=(t.height-a)/2)}return c.drawImage(t,h,u,d,a,0,0,r,o),new Promise((g,w)=>{l.toBlob(m=>{m?g(m):w(new Error("Failed to convert canvas to blob"))},"image/webp",s)})}function y(t,r){return t.type.startsWith("image/")?r&&t.size>r?{valid:!1,error:`File size exceeds ${(r/1048576).toFixed(1)}MB limit`}:{valid:!0}:{valid:!1,error:"File must be an image"}}export{v as processImage,y as validateImageFile};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageStorage.d.ts","sourceRoot":"","sources":["../../src/utils/imageStorage.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,iGAAiG;AACjG,KAAK,sBAAsB,GAAG,CAAC,QAAQ,EAAE;IACvC,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,KAAK,IAAI,CAAC;AAEX,YAAY,EAAE,OAAO,EAAE,CAAC;AAExB,MAAM,WAAW,cAAc;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wBAAwB;IACxB,UAAU,CAAC,EAAE,sBAAsB,CAAC;CACrC;AAYD;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,IAAI,EACd,SAAS,EAAE,IAAI,EACf,gBAAgB,EAAE,MAAM,EACxB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,OAAO,CAAC,CA6GlB;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"imageStorage.d.ts","sourceRoot":"","sources":["../../src/utils/imageStorage.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,iGAAiG;AACjG,KAAK,sBAAsB,GAAG,CAAC,QAAQ,EAAE;IACvC,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,KAAK,IAAI,CAAC;AAEX,YAAY,EAAE,OAAO,EAAE,CAAC;AAExB,MAAM,WAAW,cAAc;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wBAAwB;IACxB,UAAU,CAAC,EAAE,sBAAsB,CAAC;CACrC;AAYD;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,IAAI,EACd,SAAS,EAAE,IAAI,EACf,gBAAgB,EAAE,MAAM,EACxB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,OAAO,CAAC,CA6GlB;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{handleError as
|
|
1
|
+
import{handleError as _,hasProvider as g,getProvider as w}from"@donotdev/core";function v(e){return e.replace(/[^a-zA-Z0-9.-]/g,"_").replace(/_{2,}/g,"_").toLowerCase()}async function B(e,t,o,d={}){const{storagePath:i="uploads/images",filename:f,onProgress:a}=d,y=Date.now(),r=(f||`${y}_${v(o)}`).replace(/\.[^/.]+$/,""),b=`${i}/${r}_full.webp`,h=`${i}/${r}_thumb.webp`;try{const c=new File([e],`${r}_full.webp`,{type:"image/webp"}),s=new File([t],`${r}_thumb.webp`,{type:"image/webp"});let n,u;if(g("storage")){const l=w("storage");n=(await l.upload(c,{storagePath:i,filename:`${r}_full.webp`,onProgress:a?m=>a({bytesTransferred:0,totalBytes:0,progress:m*.5}):void 0})).url,u=(await l.upload(s,{storagePath:i,filename:`${r}_thumb.webp`,onProgress:a?m=>a({bytesTransferred:0,totalBytes:0,progress:50+m*.5}):void 0})).url}else{const{uploadFileResumable:l}=await import("@donotdev/firebase"),m=a?p=>{a({bytesTransferred:p.bytesTransferred,totalBytes:p.totalBytes*2,progress:p.progress*.5})}:void 0,{promise:U}=l(c,{basePath:i,filename:`${r}_full.webp`,onProgress:m,metadata:{contentType:"image/webp"}});n=(await U).url;const P=a?p=>{a({bytesTransferred:p.bytesTransferred+e.size,totalBytes:e.size+t.size,progress:50+p.progress*.5})}:void 0,{promise:$}=l(s,{basePath:i,filename:`${r}_thumb.webp`,onProgress:P,metadata:{contentType:"image/webp"}});u=(await $).url}return{fullUrl:n,thumbUrl:u}}catch(c){try{if(g("storage")){const s=w("storage");await s.delete(b).catch(()=>{}),await s.delete(h).catch(()=>{})}else{const{getFileUrl:s,deleteFileByUrl:n}=await import("@donotdev/firebase"),u=await s(b).catch(()=>null),l=await s(h).catch(()=>null);u&&await n(u).catch(()=>{}),l&&await n(l).catch(()=>{})}}catch{}throw c}}async function F(e){try{if(g("storage")){const t=w("storage"),o=[t.delete(e.fullUrl)];e.thumbUrl&&o.push(t.delete(e.thumbUrl)),await Promise.all(o)}else{const{deleteFileByUrl:t}=await import("@donotdev/firebase"),o=[t(e.fullUrl)];e.thumbUrl&&o.push(t(e.thumbUrl)),await Promise.all(o)}}catch(t){throw _(t,{userMessage:"Failed to delete image",severity:"error",context:{fullUrl:e.fullUrl,thumbUrl:e.thumbUrl}}),t}}export{F as deleteImage,B as uploadImage};
|
package/dist/utils/imageUtils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
async function d(e){const t=await e.arrayBuffer(),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(
|
|
1
|
+
async function d(e){const t=await e.arrayBuffer(),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(a=>a.toString(16).padStart(2,"0")).join("")}function h(e){return URL.createObjectURL(e)}function u(e){e.startsWith("blob:")&&URL.revokeObjectURL(e)}async function l(e){return new Promise((t,r)=>{const a=new Image,i=new FileReader;i.onload=n=>{if(!n.target?.result){r(new Error("Failed to read file"));return}a.src=n.target.result},i.onerror=()=>r(new Error("Failed to read file")),a.onload=()=>{const n=document.createElement("canvas"),o=n.getContext("2d");if(!o){r(new Error("Failed to get canvas context"));return}n.width=a.height,n.height=a.width,o.translate(n.width/2,n.height/2),o.rotate(Math.PI/2),o.drawImage(a,-a.width/2,-a.height/2),n.toBlob(s=>{if(s){const c=new File([s],e.name,{type:e.type,lastModified:Date.now()});t(c)}else r(new Error("Failed to create blob from canvas"))},e.type,.95)},a.onerror=()=>r(new Error("Failed to load image")),i.readAsDataURL(e)})}class g{undoStack=[];redoStack=[];maxStackSize=50;push(t){this.undoStack.push(t),this.undoStack.length>this.maxStackSize&&this.undoStack.shift(),this.redoStack=[]}undo(){const t=this.undoStack.pop();return t?(this.redoStack.push(t),t):null}redo(){const t=this.redoStack.pop();return t?(this.undoStack.push(t),t):null}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}clear(){this.undoStack=[],this.redoStack=[]}}function S(e,t){return e.filter(r=>r.hash===t)}function w(){return`img_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}export{g as UndoRedoManager,h as createPreviewURL,S as findDuplicatesByHash,d as generateFileHash,w as generateImageId,u as revokePreviewURL,l as rotateImage90};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CRUD_OPERATION as
|
|
1
|
+
import{CRUD_OPERATION as a}from"../types";function n(e,s){const o=[],p=new Set;for(const i of e){const t=s[i.id];t?.operation!==a.DELETE&&(t?.operation===a.UPDATE&&t.optimisticData?o.push(t.optimisticData):o.push(i),p.add(i.id))}for(const[i,t]of Object.entries(s))t.operation===a.ADD&&!p.has(i)&&t.optimisticData&&o.push(t.optimisticData);return o}export{n as mergeWithOptimistic};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const r=/<script[\s\S]*?<\/script>/gi,e=/\s+on\w+\s*=\s*["'][^"']*["']/gi,i=/\s+(?:xlink:)?href\s*=\s*["']\s*javascript:[^"']*["']/gi,c=/\s+src\s*=\s*["']\s*javascript:[^"']*["']/gi;function t(s){return s.replace(r,"").replace(e,"").replace(i,"").replace(c,"")}export{t as sanitizeHtml};
|
package/dist/utils/scopeUtils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getScopeValue as n,CRUD_OPERATORS as
|
|
1
|
+
import{getScopeValue as n,CRUD_OPERATORS as u}from"@donotdev/core";function c(e,t){if(!t)return e;const r=n(t.provider);return r?{...e,[t.field]:r}:e}function f(e,t){const r=e??{};if(!t||typeof t.field!="string")return r;const o=n(t.provider);if(!o)return r;const i={field:t.field,operator:u.EQ,value:o};return{...r,where:r.where?[...r.where,i]:[i]}}function p(e){return e?n(e.provider):null}export{p as getCurrentScopeValue,c as injectScope,f as injectScopeFilter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadValidation.d.ts","sourceRoot":"","sources":["../../src/utils/uploadValidation.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGjD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAMzD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,SAAK,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"uploadValidation.d.ts","sourceRoot":"","sources":["../../src/utils/uploadValidation.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGjD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAMzD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,SAAK,GAAG,MAAM,EAAE,CAmDnE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAElD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";function
|
|
1
|
+
"use client";function o(r){return!r||typeof r!="string"?!1:r.startsWith("https://")&&!r.startsWith("blob:")}function h(r){return!(!r||typeof r!="object"||!o(r.fullUrl)||r.thumbUrl&&!o(r.thumbUrl))}function i(r,l=""){const t=[];if(r==null)return t;if(typeof r=="string")return r.startsWith("blob:")&&t.push(l||"root"),t;if(typeof r!="object")return t;if(Array.isArray(r))r.forEach((e,s)=>{const n=l?`${l}[${s}]`:`[${s}]`;t.push(...i(e,n))});else{const e=r;if(e.fullUrl!==void 0&&e.thumbUrl!==void 0){const s=e.fullUrl,n=e.thumbUrl,u=typeof s=="string"&&!o(s),c=n&&typeof n=="string"&&!o(n);if(u||c){const f=l||"root";t.push(`${f}.fullUrl or ${f}.thumbUrl contains blob URL`)}}else Object.entries(e).forEach(([s,n])=>{const u=l?`${l}.${s}`:s;t.push(...i(n,u))})}return t}function b(r){return i(r).length>0}export{i as checkForBlobUrls,b as hasBlobUrls,o as isStorageUrl,h as validatePicture};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@donotdev/crud",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -47,19 +47,19 @@
|
|
|
47
47
|
"dev": "tsc --noEmit --watch --listFiles false --listEmittedFiles false",
|
|
48
48
|
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
49
49
|
"lint": "eslint src/",
|
|
50
|
-
"type-check": "tsc --noEmit"
|
|
50
|
+
"type-check": "bunx tsc --noEmit"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@dnd-kit/core": "^6.3.1",
|
|
54
54
|
"@dnd-kit/sortable": "^10.0.0",
|
|
55
55
|
"@dnd-kit/utilities": "^3.2.2",
|
|
56
|
-
"@donotdev/components": "^0.0.
|
|
57
|
-
"@donotdev/core": "^0.0.
|
|
56
|
+
"@donotdev/components": "^0.0.19",
|
|
57
|
+
"@donotdev/core": "^0.0.25",
|
|
58
58
|
"@hookform/resolvers": "^5.2.2",
|
|
59
59
|
"react-easy-crop": "^5.5.6"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@donotdev/firebase": "^0.0.
|
|
62
|
+
"@donotdev/firebase": "^0.0.12",
|
|
63
63
|
"@tiptap/extension-placeholder": "^3.19.0",
|
|
64
64
|
"@tiptap/pm": "^3.19.0",
|
|
65
65
|
"@tiptap/react": "^3.19.0",
|
|
@@ -89,9 +89,6 @@
|
|
|
89
89
|
},
|
|
90
90
|
"firebase": {
|
|
91
91
|
"optional": true
|
|
92
|
-
},
|
|
93
|
-
"tiptap": {
|
|
94
|
-
"optional": true
|
|
95
92
|
}
|
|
96
93
|
}
|
|
97
94
|
}
|