@donotdev/crud 0.1.45 → 0.2.2
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/README.md +13 -9
- package/dist/CrudService.bulk.js +1 -1
- package/dist/CrudService.bulkAcross.js +1 -1
- package/dist/CrudService.cache.d.ts.map +1 -1
- package/dist/CrudService.cache.js +1 -1
- package/dist/CrudService.d.ts +12 -0
- package/dist/CrudService.d.ts.map +1 -1
- package/dist/CrudService.internal.d.ts +24 -4
- package/dist/CrudService.internal.d.ts.map +1 -1
- package/dist/CrudService.internal.js +2 -2
- package/dist/CrudService.js +1 -1
- package/dist/CrudService.mutations.d.ts.map +1 -1
- package/dist/CrudService.mutations.js +1 -1
- package/dist/CrudService.optimistic.d.ts.map +1 -1
- package/dist/CrudService.optimistic.js +1 -1
- package/dist/CrudService.queries.d.ts +5 -0
- package/dist/CrudService.queries.d.ts.map +1 -1
- package/dist/CrudService.queries.js +1 -1
- package/dist/CrudService.subscriptions.d.ts.map +1 -1
- package/dist/CrudService.subscriptions.js +1 -1
- package/dist/CrudStore.js +1 -1
- package/dist/FieldRegistry.d.ts +0 -11
- package/dist/FieldRegistry.d.ts.map +1 -1
- package/dist/FieldRegistry.js +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.d.ts +0 -2
- package/dist/components/FormFieldRenderer.d.ts.map +1 -1
- package/dist/components/FormFieldRenderer.js +1 -1
- package/dist/components/FormLayout.js +1 -1
- package/dist/components/YearFilter.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/ControlledFieldArrayField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledFieldArrayField.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.d.ts.map +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.d.ts.map +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/ControlledReferenceField.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 +1 -11
- 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.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.d.ts +8 -0
- package/dist/components/form/fields/ImageFieldComponent.d.ts.map +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/fieldTypeRegistry.store.js +1 -1
- package/dist/fieldTypeRegistry.types.d.ts +0 -10
- package/dist/fieldTypeRegistry.types.d.ts.map +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.js +1 -1
- package/dist/forms/index.js +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.js +1 -1
- package/dist/hooks/useCrudFilters.js +1 -1
- package/dist/hooks/useCrudPageSize.js +1 -1
- package/dist/hooks/useEntityFavorites.js +1 -1
- package/dist/hooks/useFieldConditions.js +1 -1
- package/dist/hooks/useFileUpload.js +1 -1
- package/dist/hooks/useReferenceResolver.js +1 -1
- package/dist/hooks/useRelatedItems.js +1 -1
- package/dist/index.d.ts +1 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/registerBuiltinFieldTypes.d.ts.map +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/symbol-index.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +7 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/useBaseCrudList.d.ts.map +1 -1
- package/dist/useBaseCrudList.js +1 -1
- package/dist/useCrud.d.ts.map +1 -1
- package/dist/useCrud.js +1 -1
- package/dist/useCrudCardList.js +1 -1
- package/dist/useCrudDoc.d.ts +59 -0
- package/dist/useCrudDoc.d.ts.map +1 -0
- package/dist/useCrudDoc.js +1 -0
- package/dist/useCrudList.js +1 -1
- package/dist/useServerPrefetch.d.ts +34 -0
- package/dist/useServerPrefetch.d.ts.map +1 -0
- package/dist/useServerPrefetch.js +1 -0
- package/dist/utils/clientListProcessing.js +1 -1
- package/dist/utils/collections.js +1 -1
- package/dist/utils/fileStorage.js +1 -1
- package/dist/utils/imageProcessing.d.ts +45 -3
- package/dist/utils/imageProcessing.d.ts.map +1 -1
- package/dist/utils/imageProcessing.js +1 -1
- package/dist/utils/imageStorage.js +1 -1
- package/dist/utils/imageUtils.js +1 -1
- package/dist/utils/matchesFilter.js +1 -1
- package/dist/utils/mergeWithOptimistic.d.ts +13 -0
- package/dist/utils/mergeWithOptimistic.d.ts.map +1 -1
- package/dist/utils/mergeWithOptimistic.js +1 -1
- package/dist/utils/sanitizeHtml.d.ts +1 -0
- package/dist/utils/sanitizeHtml.d.ts.map +1 -1
- package/dist/utils/sanitizeHtml.js +1 -1
- package/dist/utils/scopeUtils.js +1 -1
- package/dist/utils/uploadValidation.js +1 -1
- package/dist/workflows/WorkflowPersistence.js +1 -1
- package/dist/workflows/defineWorkflow.js +1 -1
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/useEntityWorkflow.js +1 -1
- package/guidelines/COMPONENTS.md +9 -2
- package/guidelines/CRUD.md +1 -0
- package/package.json +14 -16
package/dist/types.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @since 0.0.1
|
|
12
12
|
* @author AMBROISE PARK Consulting
|
|
13
13
|
*/
|
|
14
|
-
import type { BulkAcrossBatch, BulkAcrossResult, BulkOperations, BulkResult, CrudCreateInput, dndevSchema, ICrudAdapter, QueryClient, QueryOptions, PaginatedQueryResult, ListSchemaType, SecurityContext } from '@donotdev/core';
|
|
14
|
+
import type { BulkAcrossBatch, BulkAcrossResult, BulkOperations, BulkResult, CrudCreateInput, CrudDocQuery, CrudListQuery, dndevSchema, ICrudAdapter, QueryClient, QueryOptions, PaginatedQueryResult, ListSchemaType, SecurityContext } from '@donotdev/core';
|
|
15
15
|
/**
|
|
16
16
|
* Optimistic operation status
|
|
17
17
|
*/
|
|
@@ -175,19 +175,15 @@ export interface MutationOptions {
|
|
|
175
175
|
export interface CrudServiceInterface {
|
|
176
176
|
/** Initialize the CRUD adapter from the provider registry. Call configureProviders() first. */
|
|
177
177
|
initialize(): Promise<void>;
|
|
178
|
+
/** Attach the configured CRUD provider synchronously (safe during render). */
|
|
179
|
+
attachProvider(): boolean;
|
|
180
|
+
/** Server render: list queries run with `client` read as the holder of `accessToken`. */
|
|
181
|
+
bindRequestAccessToken(client: object, accessToken: string): boolean;
|
|
178
182
|
setStore(store: CrudStoreApi): void;
|
|
179
183
|
/** Schema accepts unknown since OperationSchemas stores dndevSchema<unknown>. T is for return type. */
|
|
180
|
-
getListQueryOptions<T>(collection: string, queryOptions: QueryOptions, schema: dndevSchema<unknown>, cacheOptions?: CacheOptions, schemaType?: ListSchemaType):
|
|
181
|
-
queryKey: readonly string[];
|
|
182
|
-
queryFn: () => Promise<PaginatedQueryResult<T>>;
|
|
183
|
-
staleTime: number;
|
|
184
|
-
};
|
|
184
|
+
getListQueryOptions<T>(collection: string, queryOptions: QueryOptions, schema: dndevSchema<unknown>, cacheOptions?: CacheOptions, schemaType?: ListSchemaType): CrudListQuery<T>;
|
|
185
185
|
/** Schema accepts unknown since OperationSchemas stores dndevSchema<unknown>. T is for return type. */
|
|
186
|
-
getDocQueryOptions<T>(collection: string, id: string, schema: dndevSchema<unknown>, cacheOptions?: CacheOptions):
|
|
187
|
-
queryKey: readonly string[];
|
|
188
|
-
queryFn: () => Promise<T | null>;
|
|
189
|
-
staleTime: number;
|
|
190
|
-
};
|
|
186
|
+
getDocQueryOptions<T>(collection: string, id: string, schema: dndevSchema<unknown>, cacheOptions?: CacheOptions): CrudDocQuery<T>;
|
|
191
187
|
get<T>(collection: string, id: string, schema: dndevSchema<T>, options?: CacheOptions): Promise<T | null>;
|
|
192
188
|
query<T>(collection: string, options: QueryOptions, schema: dndevSchema<T>, cacheOptions?: CacheOptions, schemaType?: ListSchemaType): Promise<PaginatedQueryResult<T>>;
|
|
193
189
|
set<T>(collection: string, id: string, data: T, schema: dndevSchema<T>, options?: MutationOptions): Promise<void>;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;CAItB,CAAC;AAEX,uFAAuF;AACvF,MAAM,MAAM,gBAAgB,GAC1B,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAEjE,yCAAyC;AACzC,eAAO,MAAM,cAAc;;;IAGzB,0EAA0E;;;CAGlE,CAAC;AAEX,mFAAmF;AACnF,MAAM,MAAM,aAAa,GACvB,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,iEAAiE;IACjE,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,aAAa,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG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,MAAM,GAAG,IAAI,CAAC;IAC7B,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;CACnD"}
|
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBaseCrudList.d.ts","sourceRoot":"","sources":["../src/useBaseCrudList.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,cAAc,EAEd,YAAY,EACb,MAAM,gBAAgB,CAAC;AAMxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"useBaseCrudList.d.ts","sourceRoot":"","sources":["../src/useBaseCrudList.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,cAAc,EAEd,YAAY,EACb,MAAM,gBAAgB,CAAC;AAMxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAWhD,+BAA+B;AAC/B,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACnC,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,kCAAkC;AAClC,MAAM,WAAW,sBAAsB,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IAClE,wDAAwD;IACxD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,sCAAsC;AACtC,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE;QAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC5C,mDAAmD;IACnD,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,8BAA8B;IAC9B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,wCAAwC;IACxC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,WAAW,EAAE,OAAO,CAAC;IACrB,4EAA4E;IAC5E,aAAa,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACpC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACvE,kBAAkB,EAAE,SAAS,GAAG,MAAM,EACtC,UAAU,EAAE,cAAc,EAC1B,UAAU,EAAE,gBAAgB,GAAG,IAAI,EACnC,OAAO,GAAE,sBAAsB,CAAC,CAAC,CAAM,GACtC,qBAAqB,CAAC,CAAC,CAAC,CA8Q1B"}
|
package/dist/useBaseCrudList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as
|
|
1
|
+
import{useMemo as R,useCallback as Z,useRef as V,useState as $,useEffect as ee}from"react";import{isClient as te,useQuery as se}from"@donotdev/core";import{useCrudStore as re}from"./CrudStore";import{CRUD_OPERATION as j}from"./types";import{useCrud as x,getCrudServiceInstance as ie,EMPTY_OPTIMISTIC as ae}from"./useCrud";import{useServerPrefetch as oe}from"./useServerPrefetch";import{mergeWithOptimistic as ne}from"./utils/mergeWithOptimistic";import{injectScopeFilter as le,getCurrentScopeValue as ce}from"./utils/scopeUtils";const ue=1e3;function me(k,p,t,y={}){const M=y.enabled??!0,T=x("status"),c=T==="ready",B=x(k,y),{error:w,invalidate:A,_collection:d,_schemas:v,_cacheOptions:S,_scope:C}=B,q=re(e=>e.collections[d]?.optimistic||ae),E=V(new Map([[1,null]])),O=V(0),[L,K]=$(!1),o=t?.mode==="auto"?L?"server":"client":t?.mode??"client",N=ce(C),g=R(()=>{if(!c||!v)return null;const e=ie();if(!e)return null;const h=p==="listCard"?v.listCard:v.list,n=le(y.queryOptions,C);if(!t)return e.getListQueryOptions(d,n,h,S,p);if(o==="client"){const l=t.mode==="auto"&&!n?.limit?{...n,limit:ue}:n;return e.getListQueryOptions(d,l,h,S,p)}const u=E.current,m=O.current,{page:f,pageSize:s}=t;let a,r;if(u.has(f))a=u.get(f)??void 0,r=s;else if(f>m&&u.has(m)){const l=f-m;a=u.get(m)??void 0,r=l*s}else a=void 0,r=f*s;return e.getListQueryOptions(d,{...n,limit:r,startAfter:a},h,S,p)},[c,d,S,v?"hasSchema":"noSchema",p,o,t?.page,t?.pageSize,y.queryOptions,C?.provider,N]),{data:i,isLoading:U,isFetching:W,error:Y,refetch:I}=se({queryKey:g?.queryKey??["crud",d,"disabled"],queryFn:g?.queryFn??(()=>Promise.resolve({items:[]})),staleTime:g?.staleTime,enabled:M&&!!g});oe(g,M,C);const _=!te();ee(()=>{t?.mode==="auto"&&!L&&i&&i.total!=null&&i.total>i.items.length&&K(!0)},[i,t?.mode,L]);const P=R(()=>{if(!i||!c)return{items:[],total:void 0};let e=i.items;if(o==="server"&&t&&e.length>0){const s=E.current,a=O.current,{page:r,pageSize:l}=t,H=e.length;if(Math.ceil(H/l)>1||r>a){const F=s.has(r)?r:a+1;for(let b=F;b<=r;b++){const Q=(b-F+1)*l-1;if(Q<e.length){const X=e[Q];s.set(b+1,X.id)}}}i.lastVisible&&s.set(r+1,i.lastVisible),O.current=Math.max(a,r);const D=s.has(r)?0:(r-a-1)*l,J=D+l;e=e.slice(D,J)}const h=ne(e,q),n=new Set(e.map(s=>s.id));let u=0,m=0;for(const[s,a]of Object.entries(q))a.operation===j.ADD&&!n.has(s)?u++:a.operation===j.DELETE&&n.has(s)&&m++;const f=(i.total??e.length)+u-m;return{items:h,total:f}},[i,q,c,o,t?.page,t?.pageSize]),z=Z(async()=>{c&&(o==="server"&&(E.current=new Map([[1,null]]),O.current=0),await A(),await I())},[A,I,c,o]);if(!c){const e=async()=>{};return{status:T,data:{items:[],total:void 0},items:[],loading:!0,fetching:!1,error:w,mutate:e,refresh:e,isAvailable:!1,effectiveMode:o}}const G=P?.items??[];return{status:T,data:P,items:G,loading:_?M&&i===void 0:U,fetching:_?!1:W,error:_?null:Y??w,mutate:z,refresh:z,isAvailable:!0,effectiveMode:o}}export{me as useBaseCrudList};
|
package/dist/useCrud.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrud.d.ts","sourceRoot":"","sources":["../src/useCrud.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,UAAU,EAEV,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,OAAO,EACP,WAAW,EAEZ,MAAM,gBAAgB,CAAC;AAIxB,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACZ,eAAe,EAChB,MAAM,SAAS,CAAC;AAMjB,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,CAAC;AACtD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,CAAC;AAgB5D;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,oBAAoB,GAAG,IAAI,CAEpE;
|
|
1
|
+
{"version":3,"file":"useCrud.d.ts","sourceRoot":"","sources":["../src/useCrud.ts"],"names":[],"mappings":"AAyBA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AAE,gBAAgB,GAAG,SAAS,CAAC;IACvC,8BAA8B;IAC9B,aAAa,EAAE,YAAY,CAAC;IAC5B,wDAAwD;IACxD,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;CACjC;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,QAAQ,GAAG,aAAa,CAAC;AACtD,wBAAgB,OAAO,CAAC,CAAC,SAAS,SAAS,EACzC,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAC1C,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,wBAAgB,OAAO,CACrB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AACrE,wBAAgB,OAAO,CACrB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAE3D,kBAAkB,EAAE,SAAS,GAAG,MAAM,EACtC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAC1B,aAAa,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/useCrud.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useEffect as
|
|
1
|
+
"use client";import{useEffect as L,useMemo as w,useCallback as o}from"react";import{useFeatureConsent as W,FRAMEWORK_FEATURES as Z,FEATURE_STATUS as f,handleError as B,isClient as H,createSchemas as J,DEGRADED_CRUD_API as Q,getGlobalSingleton as V}from"@donotdev/core";import{getCrudService as F}from"./CrudService";import{useCrudStore as d}from"./CrudStore";import{injectScope as C,injectScopeFilter as X}from"./utils/scopeUtils";const $={},ee={};function M(){return V("crud-service",()=>({service:null,initPromise:null,errorNotified:!1}))}function i(){return g()}function g(){const u=M(),n=u.service??F();return n.attachProvider()?(u.service||(n.setStore(d),u.service=n),n):null}function te(u,n={}){const p=W(Z.CRUD),N=d(e=>e.crudService),y=p&&!N&&!g(),b=p?y?f.INITIALIZING:f.READY:f.DEGRADED,h=u==="status",v=!h&&typeof u=="object"?u:n.entity,r=h?"__status__":typeof u=="string"?u:u.collection,l=v?.scope,_=n.noCache??!1,A=n.staleTime,m=w(()=>({noCache:_,staleTime:A}),[_,A]),s=w(()=>{if(!h){if(n.schema){const e=n.schema;return{create:e,draft:e,update:e,get:e,list:e,listCard:e,delete:e}}if(v)return J(v)}},[h,n.schema,v?.name,r]),U=d(e=>e.collections[r]?.loading||!1),E=d(e=>e.collections[r]?.error||null);L(()=>{if(!H()||!p||!s)return;const{crudService:e}=d.getState(),a=g();if(a){e||d.getState().setCrudService(a);return}const t=M();e||t.service||t.initPromise||(t.initPromise=(async()=>{try{if(t.service||d.getState().crudService)return;const c=F();t.service=c,c.setStore(d),await c.initialize(),t.errorNotified=!1,d.getState().setCrudService(c)}catch(c){t.errorNotified||(B(c,{userMessage:"Failed to initialize CRUD service.",context:{collection:r},severity:"error"}),t.errorNotified=!0)}finally{t.initPromise=null}})())},[p,r,s?"hasSchema":"noSchema"]);const T=y||U,Y=b===f.READY,G=o(async e=>{const a=i();return!a||!s?null:a.get(r,e,s.get,m)},[r,s?"hasSchema":"noSchema",m]),O=o(async(e,a,t)=>{const c=i();if(!c||!s)return;const S=C(a,l),K=S?.status==="draft"?s.draft:s.create;await c.set(r,e,S,K,t)},[r,s?"hasSchema":"noSchema",l?.provider]),j=o(async(e,a,t)=>{const c=i();c&&await c.update(r,e,a,s?.update,t)},[r,s]),q=o(async(e,a)=>{const t=i();t&&await t.delete(r,e,a)},[r]),x=o(async(e,a)=>{const t=i();if(!t||!s)return"";const c=C(e,l),S=c?.status==="draft"?s.draft:s.create;return t.add(r,c,S,a)},[r,s?"hasSchema":"noSchema",l?.provider]),D=o(async(e,a)=>{const t=i();return t?t.bulkAcross(e,a):{results:{}}},[]),I=o(async(e,a)=>{const t=i();if(!t||!s)return{insertedIds:[],updatedIds:[],deletedIds:[]};const c={inserts:e.inserts?.map(S=>C(S,l)),updates:e.updates,deletes:e.deletes};return t.bulk(r,c,{create:s.create,draft:s.draft,update:s.update},a)},[r,s?"hasSchema":"noSchema",l?.provider]),z=o(async e=>{const a=i();if(!a||!s)return[];const t=X(e,l);return(await a.query(r,t,s.list,m)).items},[r,s?"hasSchema":"noSchema",m,l?.provider]),R=o((e,a)=>{const t=i();return!t||!s?()=>{}:t.subscribe(r,e,a,s.get)},[r,s?"hasSchema":"noSchema"]),P=o((e,a)=>{const t=i();return!t||!s?()=>{}:t.subscribeToCollection(r,e,a,s.list)},[r,s?"hasSchema":"noSchema"]),k=o(async()=>{const e=i();e&&await e.invalidateCollection(r)},[r]);return h?b:Y?{status:f.READY,loading:T,error:E,get:G,set:O,update:j,delete:q,add:x,bulk:I,bulkAcross:D,query:z,subscribe:R,subscribeToCollection:P,invalidate:k,isAvailable:!0,_collection:r,_schemas:s,_cacheOptions:m,_scope:l}:{...Q,status:b,loading:T,error:E,subscribe:R,subscribeToCollection:P,invalidate:k,bulk:I,bulkAcross:D,_collection:r,_schemas:s,_cacheOptions:m,_scope:l}}export{$ as EMPTY_DATA,ee as EMPTY_OPTIMISTIC,i as getCrudServiceInstance,te as useCrud};
|
package/dist/useCrudCardList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as
|
|
1
|
+
import{useMemo as d}from"react";import{useCrudFilters as p}from"./hooks/useCrudFilters";import{useBaseCrudList as f}from"./useBaseCrudList";import{applyFilters as h,applySearch as y,applySort as g}from"./utils/clientListProcessing";function C(a,t={}){const o={enabled:t.enabled,queryOptions:t.queryOptions,schema:t.schema,entity:t.entity,staleTime:t.staleTime,noCache:t.noCache},e=f(a,"listCard",null,o),s=typeof a=="string"?null:a,n=s?.collection??a,{filters:l}=p({collection:n}),i=t.clientSort===null?null:t.clientSort??s?.defaultSort??null,{processed:u,filteredTotal:c}=d(()=>{let r=e.items;s&&Object.keys(l).length>0&&(r=h(r,l,s)),s&&t.searchQuery&&(r=y(r,t.searchQuery,s));const m=r.length;return i&&(r=g(r,i)),{processed:r,filteredTotal:m}},[e.items,l,t.searchQuery,i,s]);return{status:e.status,data:e.data?{items:e.data.items}:null,items:e.items,processed:u,filteredTotal:c,loading:e.loading,fetching:e.fetching,error:e.error,mutate:e.mutate,refresh:e.refresh,isAvailable:e.isAvailable}}export{C as useCrudCardList};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { AnyEntity, FeatureStatus, InferEntityRow } from '@donotdev/core';
|
|
2
|
+
import type { UseCrudOptions } from './useCrud';
|
|
3
|
+
/**
|
|
4
|
+
* Options for the {@link useCrudDoc} hook.
|
|
5
|
+
* No `noCache`: the hook is a view of the shared cache entry (use `refresh()` to re-read).
|
|
6
|
+
*/
|
|
7
|
+
export interface UseCrudDocOptions<T> extends Omit<UseCrudOptions<T>, 'noCache'> {
|
|
8
|
+
/** Fetch automatically when `id` is set (default: true) */
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** Return type of the {@link useCrudDoc} hook. */
|
|
12
|
+
export interface UseCrudDocReturn<T> {
|
|
13
|
+
status: FeatureStatus;
|
|
14
|
+
/**
|
|
15
|
+
* The document, with pending optimistic changes applied.
|
|
16
|
+
* null while loading, without `id`, or when no document exists.
|
|
17
|
+
*/
|
|
18
|
+
data: T | null;
|
|
19
|
+
/** True during the initial fetch, or while CRUD initializes with an `id` to read */
|
|
20
|
+
loading: boolean;
|
|
21
|
+
/** True during a background refetch (show a subtle indicator) */
|
|
22
|
+
fetching: boolean;
|
|
23
|
+
/** True once the read settled and no document exists for `id` */
|
|
24
|
+
notFound: boolean;
|
|
25
|
+
/** Read error (access denied, network, adapter) */
|
|
26
|
+
error: Error | null;
|
|
27
|
+
/** Re-read the document from the backend (no-op without `id` or while CRUD is unavailable) */
|
|
28
|
+
refresh: () => Promise<void>;
|
|
29
|
+
isAvailable: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* React hook for reading one document, reactive to the CRUD cache.
|
|
33
|
+
*
|
|
34
|
+
* Use this hook for:
|
|
35
|
+
* - Detail / view pages
|
|
36
|
+
* - Any component showing a document that may be edited elsewhere on the page
|
|
37
|
+
*
|
|
38
|
+
* Shares the cache key `['crud', collection, 'get', id]` with `useCrud().get()`
|
|
39
|
+
* and every mutation, so an edit made anywhere shows up here without a refetch.
|
|
40
|
+
* Pass `null` / `undefined` as `id` to wait (no fetch, not loading).
|
|
41
|
+
*
|
|
42
|
+
* @template T - Document type
|
|
43
|
+
* @param entityOrCollection - Entity definition or collection name
|
|
44
|
+
* @param id - Document id; null/undefined disables the read
|
|
45
|
+
* @param options - Configuration options
|
|
46
|
+
* @returns The document and its read state
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```tsx
|
|
50
|
+
* const { data: car, loading, notFound } = useCrudDoc(carEntity, carId);
|
|
51
|
+
* if (loading) return <Spinner />;
|
|
52
|
+
* if (notFound) return <Text>{t('notFound')}</Text>;
|
|
53
|
+
* return <Text>{car?.model}</Text>;
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function useCrudDoc<E extends AnyEntity>(entity: E, id: string | null | undefined, options?: UseCrudDocOptions<InferEntityRow<E>>): UseCrudDocReturn<InferEntityRow<E>>;
|
|
57
|
+
export declare function useCrudDoc<T extends Record<string, unknown> = Record<string, unknown>>(collection: string, id: string | null | undefined, options?: UseCrudDocOptions<T>): UseCrudDocReturn<T>;
|
|
58
|
+
export declare function useCrudDoc<T extends Record<string, unknown> = Record<string, unknown>>(entityOrCollection: AnyEntity | string, id: string | null | undefined, options?: UseCrudDocOptions<T>): UseCrudDocReturn<T>;
|
|
59
|
+
//# sourceMappingURL=useCrud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AG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAE3D,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC7B,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC7B,gBAAgB,CAAC,CAAC,CAAC,CAAC;AACvB,wBAAgB,UAAU,CACxB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAE3D,kBAAkB,EAAE,SAAS,GAAG,MAAM,EACtC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC7B,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC7B,gBAAgB,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCallback as S}from"react";import{FEATURE_STATUS as g,isClient as _,useQuery as q}from"@donotdev/core";import{useCrudStore as D}from"./CrudStore";import{useCrud as y,getCrudServiceInstance as E}from"./useCrud";import{useServerPrefetch as O}from"./useServerPrefetch";import{applyOptimisticToDoc as Q}from"./utils/mergeWithOptimistic";function k(h,r,l={}){const s=l.enabled??!0,o=y("status"),n=o===g.READY,{_collection:t,_schemas:u,_cacheOptions:v,_scope:T}=y(h,l),A=D(F=>r?F.collections[t]?.optimistic[r]:void 0),c=n?E():null,e=c&&u&&r?c.getDocQueryOptions(t,r,u.get,v):null,{data:i,isLoading:C,isFetching:I,error:b,refetch:d}=q({queryKey:e?.queryKey??["crud",t,"get",null],queryFn:e?.queryFn??(()=>Promise.resolve(null)),staleTime:e?.staleTime,enabled:s&&!!e});O(e,s,T);const a=!_(),m=!!e,f=S(async()=>{m&&await d()},[d,m]);if(!n)return{status:o,data:null,loading:o===g.INITIALIZING&&s&&!!r,fetching:!1,notFound:!1,error:null,refresh:f,isAvailable:!1};const p=Q(i??null,A);return{status:o,data:p,loading:a?s&&!!e&&i===void 0:C,fetching:a?!1:I,notFound:i!==void 0&&p===null,error:a?null:b,refresh:f,isAvailable:!0}}export{k as useCrudDoc};
|
package/dist/useCrudList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as h}from"react";import{useCrudFilters as
|
|
1
|
+
import{useMemo as h}from"react";import{useCrudFilters as g}from"./hooks/useCrudFilters";import{useBaseCrudList as S}from"./useBaseCrudList";import{applyFilters as C,applySearch as T,applySort as b}from"./utils/clientListProcessing";function Q(s,e={}){const l=e.pagination??"auto",n=e.page??1,p=e.pageSize??10,c={mode:l,page:n,pageSize:p},u={enabled:e.enabled,queryOptions:e.queryOptions,schema:e.schema,entity:e.entity,staleTime:e.staleTime,noCache:e.noCache},o=S(s,"list",c,u),r=typeof s=="string"?null:s,m=r?.collection??s,{filters:a}=g({collection:m}),i=e.clientSort===null?null:e.clientSort??r?.defaultSort??null,{processed:d,filteredTotal:y}=h(()=>{let t=o.items;r&&Object.keys(a).length>0&&(t=C(t,a,r)),r&&e.searchQuery&&(t=T(t,e.searchQuery,r));const f=t.length;return i&&(t=b(t,i)),{processed:t,filteredTotal:f}},[o.items,a,e.searchQuery,i,r]);return{...o,processed:d,filteredTotal:y}}export{Q as useCrudList};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ScopeConfig } from '@donotdev/core';
|
|
2
|
+
/** A CRUD query descriptor (`getListQueryOptions` / `getDocQueryOptions`). */
|
|
3
|
+
interface PrefetchableQuery<TData> {
|
|
4
|
+
readonly queryKey: readonly unknown[];
|
|
5
|
+
readonly queryFn: (context: {
|
|
6
|
+
client: object;
|
|
7
|
+
}) => Promise<TData>;
|
|
8
|
+
readonly staleTime: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Server render: fetch the query before rendering, so the HTML carries the data and the
|
|
12
|
+
* streamed hydration (NextJsAppProviders) seeds the browser cache under the same key:
|
|
13
|
+
* the first paint is final (no loading → content swap, image in the initial HTML).
|
|
14
|
+
* Signed-out visitors read with the public role; signed-in visitors with their own
|
|
15
|
+
* access token (adapter.forAccessToken; the database verifies it), i.e. exactly what
|
|
16
|
+
* their browser would read. Without a usable token (or an adapter that cannot read
|
|
17
|
+
* as a token holder) the browser loads it. Scoped (tenant) entities never prefetch.
|
|
18
|
+
*
|
|
19
|
+
* No-op in the browser. Call unconditionally (it calls hooks).
|
|
20
|
+
*
|
|
21
|
+
* "Settled" is read from the cache entry, not from the observer result: on the retry
|
|
22
|
+
* render the observer masks a stored error (retryOnMount: it plans a fetch on mount,
|
|
23
|
+
* which never happens on the server), and suspending again would repeat the failed
|
|
24
|
+
* read forever.
|
|
25
|
+
*
|
|
26
|
+
* @param query - Query descriptor, or null while the CRUD service is not ready
|
|
27
|
+
* @param enabled - The calling hook's `enabled` option
|
|
28
|
+
* @param scope - Entity scope; scoped entities are never prefetched
|
|
29
|
+
* @throws {Promise<undefined>} Suspends the render until the read settles
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export declare function useServerPrefetch<TData>(query: PrefetchableQuery<TData> | null, enabled: boolean, scope: ScopeConfig | undefined): void;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=useServerPrefetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useServerPrefetch.d.ts","sourceRoot":"","sources":["../src/useServerPrefetch.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIlD,8EAA8E;AAC9E,UAAU,iBAAiB,CAAC,KAAK;IAC/B,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IAClE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EACrC,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,IAAI,EACtC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,WAAW,GAAG,SAAS,GAC7B,IAAI,CA4BN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{hasProvider as u,isClient as a,useAuthSessionSnapshot as c,useQueryClient as i}from"@donotdev/core";import{getCrudServiceInstance as h}from"./useCrud";function f(r,n,o){const s=i(),e=c();if(a()||!n||!r||o)return;const t=s.getQueryState(r.queryKey);if(!(t&&(t.data!==void 0||t.error)||!(!u("auth")||e?.user===null||e?.user&&e.accessToken&&h()?.bindRequestAccessToken(s,e.accessToken))))throw s.fetchQuery(r).then(()=>{},()=>{})}export{f as useServerPrefetch};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{matchesFilter as u}from"./matchesFilter";import{getValueType as
|
|
1
|
+
import{matchesFilter as u}from"./matchesFilter";import{getValueType as f}from"../fieldTypeRegistry.store";function d(t,r,l){const i=Object.entries(r);return i.length===0?t:t.filter(n=>i.every(([s,a])=>{const e=l.fields[s]?.type||"text";return u(n[s],a,e)}))}function c(t){if(t.search?.fields&&t.search.fields.length>0)return t.search.fields;const r=new Set(["string"]),l=[];for(const[i,n]of Object.entries(t.fields)){if(n.visibility==="hidden"||n.visibility==="technical")continue;const s=f(n.type);s&&r.has(s)&&l.push(i)}return l}function p(t,r,l){if(!r||r.trim()==="")return t;const i=r.toLowerCase(),n=c(l);return n.length===0?t.filter(s=>Object.values(s).some(a=>a==null?!1:String(a).toLowerCase().includes(i))):t.filter(s=>n.some(a=>{const e=s[a];return e==null?!1:typeof e=="object"&&"formatted_address"in e?String(e.formatted_address).toLowerCase().includes(i):String(e).toLowerCase().includes(i)}))}function m(t,r){if(typeof r=="function")return[...t].sort(r);const{field:l,direction:i="asc"}=r,n=i==="desc"?-1:1;return[...t].sort((s,a)=>{const e=s[l],o=a[l];return e==null&&o==null?0:e==null?1:o==null?-1:typeof e=="number"&&typeof o=="number"?(e-o)*n:typeof e=="object"&&"amount"in e&&typeof o=="object"&&"amount"in o?(e.amount-o.amount)*n:e instanceof Date&&o instanceof Date?(e.getTime()-o.getTime())*n:String(e).localeCompare(String(o))*n})}export{d as applyFilters,p as applySearch,m as applySort,c as getSearchableFields};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCrudService as
|
|
1
|
+
import{getCrudService as c}from"../CrudService";async function p(r,n){const e=c(),a=[],t=n.range?.start??1,o=n.range?.end??28;for(let s=t;s<=o;s++){const m=String(s),i=await e.get(n.path(r),m,n.schema);i&&a.push(i)}return a}async function d(r,n,e){const a=c();for(const t of e){const o=n.idOf(t);await a.set(n.path(r),o,t,n.schema)}}async function h(r,n,e){const a=c();if(n.idFrom){const t=n.idFrom(e);return a.set(n.path(r),t,e,n.schema)}return a.add(n.path(r),e,n.schema)}export{h as appendToCollection,p as loadDeterministicRange,d as upsertDeterministic};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{handleError as d,getProvider as
|
|
1
|
+
"use client";import{handleError as d,getProvider as u}from"@donotdev/core";function h(e){return e.replace(/[^a-zA-Z0-9.-]/g,"_").replace(/_{2,}/g,"_").toLowerCase()}async function f(e,t={}){const{storagePath:r,filename:n,onProgress:o,signal:s}=t,i=Date.now(),c=h(e.name),a=n||`${i}_${c}`,l=r?`${r}/${a}`:a;try{return{url:(await u("storage").upload(e,{storagePath:r,filename:a,onProgress:o?p=>o({bytesTransferred:0,totalBytes:0,progress:p}):void 0,signal:s})).url,filename:e.name,size:e.size,mimeType:e.type,uploadedAt:new Date().toISOString()}}catch(p){throw d(p,{userMessage:"Failed to upload file",severity:"error",context:{filename:e.name,fileSize:e.size}})}}async function w(e,t={}){const r=[],n=e.reduce((s,i)=>s+i.size,0);let o=0;for(const s of e){if(t.signal?.aborted)throw new Error("Upload cancelled");const i=t.onProgress?a=>{const l=a.bytesTransferred/a.totalBytes*s.size;t.onProgress({bytesTransferred:o+l,totalBytes:n,progress:(o+l)/n*100})}:void 0,c=await f(s,{...t,onProgress:i});r.push(c),o+=s.size}return r}async function v(e){try{await u("storage").delete(e.url)}catch(t){throw d(t,{userMessage:"Failed to delete file",severity:"error",context:{url:e.url,filename:e.filename}}),t}}function y(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function m(e){const t=e.split(".");return t.length>1?t.pop().toLowerCase():""}function M(e,t){const r=t?m(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"],n=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,n)).toFixed(1))} ${r[n]}`}const g=["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 F(){return[...g,...x].join(",")}export{x as DOCUMENT_EXTENSIONS,g as DOCUMENT_MIME_TYPES,v as deleteFile,z as formatFileSize,y as generateFileId,F as getDocumentAcceptString,m as getFileExtension,M as getFileIcon,f as uploadFile,w as uploadFiles};
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @since 0.0.1
|
|
7
7
|
* @author AMBROISE PARK Consulting
|
|
8
8
|
*/
|
|
9
|
+
import * as v from 'valibot';
|
|
9
10
|
export interface ProcessedImage {
|
|
10
11
|
fullBlob: Blob;
|
|
11
12
|
thumbBlob: Blob;
|
|
@@ -21,10 +22,21 @@ export interface ProcessImageOptions {
|
|
|
21
22
|
thumbWidth?: number;
|
|
22
23
|
/** Thumbnail height (default: 225) */
|
|
23
24
|
thumbHeight?: number;
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Target aspect ratio, center-cropped (default: 4/3). `'original'` keeps the
|
|
27
|
+
* source ratio: full and thumbnail are scaled to fit inside their max boxes,
|
|
28
|
+
* never cropped (editorial / product photography).
|
|
29
|
+
*/
|
|
30
|
+
aspectRatio?: number | 'original';
|
|
31
|
+
/** WebP quality of the full-size image (0-1, default: 0.85) */
|
|
27
32
|
quality?: number;
|
|
33
|
+
/** WebP quality of the thumbnail (0-1, default: 0.65) */
|
|
34
|
+
thumbQuality?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Canvas fill behind the image (default: '#FFFFFF'). `'transparent'` keeps the
|
|
37
|
+
* alpha channel of cut-out PNGs (packshots shown on a tinted surface).
|
|
38
|
+
*/
|
|
39
|
+
background?: string;
|
|
28
40
|
/** Crop region from react-easy-crop (overrides automatic center crop) */
|
|
29
41
|
crop?: {
|
|
30
42
|
x: number;
|
|
@@ -33,6 +45,36 @@ export interface ProcessImageOptions {
|
|
|
33
45
|
height: number;
|
|
34
46
|
};
|
|
35
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Shape of `options.fieldSpecific.image` on `image` / `images` entity fields:
|
|
50
|
+
* upload processing settings (crop excluded — that is a per-upload UI action).
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* images: {
|
|
55
|
+
* name: 'images', type: 'images', label: 'fields.images',
|
|
56
|
+
* options: { fieldSpecific: { storagePath: 'products', image: {
|
|
57
|
+
* maxWidth: 2400, maxHeight: 2400, thumbWidth: 960, thumbHeight: 960,
|
|
58
|
+
* aspectRatio: 'original', quality: 0.9, thumbQuality: 0.85, background: 'transparent',
|
|
59
|
+
* } } },
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare const imageProcessingOptionsSchema: v.StrictObjectSchema<{
|
|
64
|
+
readonly maxWidth: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 16, undefined>, v.MaxValueAction<number, 8192, undefined>]>, undefined>;
|
|
65
|
+
readonly maxHeight: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 16, undefined>, v.MaxValueAction<number, 8192, undefined>]>, undefined>;
|
|
66
|
+
readonly thumbWidth: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 16, undefined>, v.MaxValueAction<number, 8192, undefined>]>, undefined>;
|
|
67
|
+
readonly thumbHeight: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 16, undefined>, v.MaxValueAction<number, 8192, undefined>]>, undefined>;
|
|
68
|
+
readonly aspectRatio: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"original", undefined>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0.1, undefined>, v.MaxValueAction<number, 10, undefined>]>], undefined>, undefined>;
|
|
69
|
+
readonly quality: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0.1, undefined>, v.MaxValueAction<number, 1, undefined>]>, undefined>;
|
|
70
|
+
readonly thumbQuality: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0.1, undefined>, v.MaxValueAction<number, 1, undefined>]>, undefined>;
|
|
71
|
+
readonly background: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
72
|
+
}, undefined>;
|
|
73
|
+
/**
|
|
74
|
+
* Reads `fieldSpecific.image` from an entity field. Returns undefined when absent
|
|
75
|
+
* (framework defaults apply); throws on an invalid config so a typo fails loud.
|
|
76
|
+
*/
|
|
77
|
+
export declare function readImageProcessingOptions(fieldSpecific: unknown): Omit<ProcessImageOptions, 'crop'> | undefined;
|
|
36
78
|
/**
|
|
37
79
|
* Resize and convert image to WebP with 4:3 aspect ratio
|
|
38
80
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageProcessing.d.ts","sourceRoot":"","sources":["../../src/utils/imageProcessing.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,IAAI,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB
|
|
1
|
+
{"version":3,"file":"imageProcessing.d.ts","sourceRoot":"","sources":["../../src/utils/imageProcessing.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,IAAI,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,wD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I=e.strictObject({maxWidth:e.optional(y),maxHeight:e.optional(y),thumbWidth:e.optional(y),thumbHeight:e.optional(y),aspectRatio:e.optional(e.union([e.literal("original"),e.pipe(e.number(),e.minValue(.1),e.maxValue(10))])),quality:e.optional(E),thumbQuality:e.optional(E),background:e.optional(e.pipe(e.string(),e.minLength(1)))});function Q(t){if(typeof t!="object"||t===null)return;const a=t.image;if(a!==void 0)return e.parse(I,a)}const v=new WeakMap;function S(t){return JSON.stringify({maxWidth:t.maxWidth,maxHeight:t.maxHeight,thumbWidth:t.thumbWidth,thumbHeight:t.thumbHeight,aspectRatio:t.aspectRatio,quality:t.quality,thumbQuality:t.thumbQuality,background:t.background,crop:t.crop})}async function j(t,a={}){const r=S(a),h=v.get(t);if(h?.has(r))return h.get(r);const{maxWidth:u=1920,maxHeight:o=1440,thumbWidth:i=300,thumbHeight:l=225,aspectRatio:g=4/3,quality:d=.85,thumbQuality:p=.65,background:m="#FFFFFF",crop:n}=a;return new Promise((b,w)=>{const s=new Image,F=new FileReader;F.onload=c=>{s.src=c.target?.result},F.onerror=()=>w(new Error("Failed to read file")),s.onload=async()=>{try{const c=n?n.width:s.width,W=n?n.height:s.height,H=g==="original",f=H?c/W:g,{width:R,height:M}=q(c,W,u,o,f),O=await B(s,R,M,f,d,m,n),V=H?q(c,W,i,l,f):{width:i,height:l},P=await B(s,V.width,V.height,f,p,m,n),k={fullBlob:O,thumbBlob:P,width:R,height:M};let x=v.get(t);x||(x=new Map,v.set(t,x)),x.set(r,k),b(k)}catch(c){w(c)}},s.onerror=()=>w(new Error("Failed to load image")),F.readAsDataURL(t)})}function q(t,a,r,h,u){let o=t,i=a;o>r&&(i=r/o*i,o=r),i>h&&(o=h/i*o,i=h);const l=o/i;return Math.abs(l-u)>.01&&(l>u?i=o/u:o=i*u),{width:Math.round(o),height:Math.round(i)}}async function B(t,a,r,h,u,o,i){const l=document.createElement("canvas"),g=l.getContext("2d");if(!g)throw new Error("Failed to get canvas context");l.width=a,l.height=r,o!=="transparent"&&(g.fillStyle=o,g.fillRect(0,0,a,r));let d,p,m,n;if(i)d=i.x,p=i.y,m=i.width,n=i.height;else{const b=t.width/t.height;m=t.width,n=t.height,d=0,p=0,b>h?(m=t.height*h,d=(t.width-m)/2):b<h&&(n=t.width/h,p=(t.height-n)/2)}return g.drawImage(t,d,p,m,n,0,0,a,r),new Promise((b,w)=>{l.toBlob(s=>{s?b(s):w(new Error("Failed to convert canvas to blob"))},"image/webp",u)})}function z(t,a){return t.type.startsWith("image/")?a&&t.size>a?{valid:!1,error:`File size exceeds ${(a/1048576).toFixed(1)}MB limit`}:{valid:!0}:{valid:!1,error:"File must be an image"}}export{I as imageProcessingOptionsSchema,j as processImage,Q as readImageProcessingOptions,z as validateImageFile};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{handleError as _,getProvider as
|
|
1
|
+
import{handleError as _,getProvider as g}from"@donotdev/core";function P(e){return e.replace(/[^a-zA-Z0-9.-]/g,"_").replace(/_{2,}/g,"_").toLowerCase()}async function v(e,t,l,m={}){const{storagePath:r,filename:f,onProgress:o,signal:n}=m,y=Date.now(),a=(f||`${y}_${P(l)}`).replace(/\.[^/.]+$/,""),h=`${a}_full.webp`,p=`${a}_thumb.webp`,$=r?`${r}/${h}`:h,U=r?`${r}/${p}`:p;try{const u=new File([e],`${a}_full.webp`,{type:"image/webp"}),s=new File([t],`${a}_thumb.webp`,{type:"image/webp"});let w,d;const c=g("storage"),b=await c.upload(u,{storagePath:r,filename:`${a}_full.webp`,onProgress:o?i=>o({bytesTransferred:0,totalBytes:0,progress:i*.5}):void 0,signal:n});if(w=b.url,n?.aborted){try{await c.delete(b.url)}catch{}throw new Error("Upload cancelled")}return d=(await c.upload(s,{storagePath:r,filename:`${a}_thumb.webp`,onProgress:o?i=>o({bytesTransferred:0,totalBytes:0,progress:50+i*.5}):void 0,signal:n})).url,{fullUrl:w,thumbUrl:d}}catch(u){try{const s=g("storage");await s.delete($).catch(()=>{}),await s.delete(U).catch(()=>{})}catch{}throw u}}async function E(e){try{const t=g("storage"),l=[t.delete(e.fullUrl)];e.thumbUrl&&l.push(t.delete(e.thumbUrl)),await Promise.all(l)}catch(t){throw _(t,{userMessage:"Failed to delete image",severity:"error",context:{fullUrl:e.fullUrl,thumbUrl:e.thumbUrl}}),t}}export{E as deleteImage,v 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).slice(2,11)}`}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{getFilterType as
|
|
1
|
+
import{getFilterType as N}from"../fieldTypeRegistry.store";function S(e,t,i){if(!t)return!0;if(Array.isArray(t)){if(t.length===0)return!0;if(!(N(i)==="range"&&(i==="date"||i==="datetime-local"||i==="timestamp")))return t.some(a=>{if(typeof a=="object"&&"date"in a){const D=a.date;if(e==null)return!1;const m=e instanceof Date?e:new Date(e);return isNaN(m.getTime())?!1:m.toISOString().split("T")[0]===D}return String(e)===String(a)});if(e==null)return!1;const r=e instanceof Date?e:new Date(e);if(isNaN(r.getTime()))return!1;const o=r.toISOString().split("T")[0];return t.some(a=>typeof a=="string"?o===a:typeof a=="object"&&"date"in a?o===a.date:!1)}if(typeof t=="object"&&"date"in t&&!("min"in t)&&!Array.isArray(t)){if(!(N(i)==="range"&&(i==="date"||i==="datetime-local"||i==="timestamp")))return!1;const r=t.date;if(!r)return!0;if(e==null)return!1;const o=e instanceof Date?e.toISOString().split("T")[0]:new Date(e).toISOString().split("T")[0];if((i==="datetime-local"||i==="timestamp")&&t.time){const a=e instanceof Date?e.toISOString().slice(11,16):new Date(e).toISOString().slice(11,16);return o===r&&a===t.time}return o===r}if(typeof t=="object"&&"min"in t){const r=N(i);if(!r)return!0;const o=r==="range"&&(i==="date"||i==="datetime-local"||i==="timestamp"),a=r==="range"&&!o,D=i==="price",m=D&&e!=null&&typeof e=="object"?Number(e.amount):a&&e!=null?typeof e=="number"?e:Number(e):NaN;if(a||D){if(typeof t.min=="object"&&t.min!==null&&"date"in t.min)return!1;const n=t,c=typeof n.min=="string"&&n.min!=="",g=typeof n.max=="string"&&n.max!=="";return c&&!g?e==null||isNaN(m)?!1:m>=Number(n.min):!c&&g?e==null?!0:isNaN(m)?!1:m<=Number(n.max):c&&g?e==null||isNaN(m)?!1:m>=Number(n.min)&&m<=Number(n.max):!0}if(o){if(typeof t.min=="object"&&t.min!==null&&"date"in t.min&&!("min"in t.min)){const s=t,l=s.min,u=s.max,w=l?.date&&l.date!=="",y=u?.date&&u.date!=="";if(w&&!y){if(e==null)return!1;const f=e instanceof Date?e:new Date(e);if(isNaN(f.getTime()))return!1;const d=new Date(l.date+(l.time?`T${l.time}:00`:"T00:00:00"));return f>=d}if(!w&&y&&u){if(e==null)return!0;const f=e instanceof Date?e:new Date(e);if(isNaN(f.getTime()))return!1;const d=new Date(u.date+(u.time?`T${u.time}:00`:"T23:59:59"));return f<=d}if(w&&y&&u){if(e==null)return!1;const f=e instanceof Date?e:new Date(e);if(isNaN(f.getTime()))return!1;const d=new Date(l.date+(l.time?`T${l.time}:00`:"T00:00:00")),T=new Date(u.date+(u.time?`T${u.time}:00`:"T23:59:59"));return f>=d&&f<=T}return!0}const n=t,c=typeof n.min=="string"&&n.min!=="",g=typeof n.max=="string"&&n.max!=="";if(c&&!g){if(e==null)return!1;const s=e instanceof Date?e:new Date(e);return isNaN(s.getTime())?!1:s>=new Date(n.min)}if(!c&&g){if(e==null)return!0;const s=e instanceof Date?e:new Date(e);return isNaN(s.getTime())?!1:s<=new Date(n.max)}if(c&&g){if(e==null)return!1;const s=e instanceof Date?e:new Date(e);return isNaN(s.getTime())?!1:s>=new Date(n.min)&&s<=new Date(n.max)}return!0}}if(typeof t=="string"&&N(i)==="rating"){if(e==null)return!1;const r=Number(t),o=typeof e=="number"?e:Number(e);return isNaN(r)||isNaN(o)?!1:o>=r}const p=N(i);if(!p)return!0;if(p==="address")return e==null?!1:typeof e=="object"&&"formatted_address"in e?String(e.formatted_address).toLowerCase().includes(String(t).toLowerCase()):!1;if(p==="multiselect"){if(!Array.isArray(e)||e.length===0)return!1;const r=String(t).toLowerCase();return e.some(o=>String(o).toLowerCase().includes(r))}return e==null?!1:String(e).toLowerCase().includes(String(t).toLowerCase())}export{S as matchesFilter};
|
|
@@ -14,5 +14,18 @@ interface WithId {
|
|
|
14
14
|
* @returns Merged array with optimistic changes applied
|
|
15
15
|
*/
|
|
16
16
|
export declare function mergeWithOptimistic<T extends WithId>(queryData: T[], optimistic: Record<string, OptimisticMeta>): T[];
|
|
17
|
+
/**
|
|
18
|
+
* Apply a pending optimistic operation to one cached document.
|
|
19
|
+
* Single-document counterpart of {@link mergeWithOptimistic}:
|
|
20
|
+
* - delete → null
|
|
21
|
+
* - update → the optimistic value merged over the cached document (the optimistic
|
|
22
|
+
* value can be partial: cold cache, or a snapshot taken from a list row)
|
|
23
|
+
* - add → the cached document when the server already returned it, else the optimistic value
|
|
24
|
+
*
|
|
25
|
+
* @param doc - Document from the TanStack Query cache (null = not found)
|
|
26
|
+
* @param op - Optimistic operation pending for this document id, if any
|
|
27
|
+
* @returns The document to display
|
|
28
|
+
*/
|
|
29
|
+
export declare function applyOptimisticToDoc<T>(doc: T | null, op: OptimisticMeta | undefined): T | null;
|
|
17
30
|
export {};
|
|
18
31
|
//# sourceMappingURL=mergeWithOptimistic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeWithOptimistic.d.ts","sourceRoot":"","sources":["../../src/utils/mergeWithOptimistic.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,UAAU,MAAM;IACd,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAClD,SAAS,EAAE,CAAC,EAAE,EACd,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GACzC,CAAC,EAAE,CAgCL"}
|
|
1
|
+
{"version":3,"file":"mergeWithOptimistic.d.ts","sourceRoot":"","sources":["../../src/utils/mergeWithOptimistic.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,UAAU,MAAM;IACd,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAClD,SAAS,EAAE,CAAC,EAAE,EACd,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GACzC,CAAC,EAAE,CAgCL;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,GAAG,EAAE,CAAC,GAAG,IAAI,EACb,EAAE,EAAE,cAAc,GAAG,SAAS,GAC7B,CAAC,GAAG,IAAI,CAUV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CRUD_OPERATION as
|
|
1
|
+
import{CRUD_OPERATION as a}from"../types";function n(o,t){const s=[],c=new Set;for(const p of o){const i=t[p.id];i?.operation!==a.DELETE&&(i?.operation===a.UPDATE&&i.optimisticData?s.push(i.optimisticData):s.push(p),c.add(p.id))}for(const[p,i]of Object.entries(t))i.operation===a.ADD&&!c.has(p)&&i.optimisticData&&s.push(i.optimisticData);return s}function D(o,t){return t?t.operation===a.DELETE?null:t.operation===a.UPDATE&&t.optimisticData?o?{...o,...t.optimisticData}:t.optimisticData:t.operation===a.ADD&&!o&&t.optimisticData?t.optimisticData:o:o}export{D as applyOptimisticToDoc,n as mergeWithOptimistic};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizeHtml.d.ts","sourceRoot":"","sources":["../../src/utils/sanitizeHtml.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sanitizeHtml.d.ts","sourceRoot":"","sources":["../../src/utils/sanitizeHtml.ts"],"names":[],"mappings":"AAmFA,uFAAuF;AACvF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{sanitizeHtml as a}from"@donotdev/components";const e=["p","h1","h2","h3","h4","h5","h6","blockquote","pre","hr","ul","ol","li","a","strong","b","em","i","u","s","code","br","span","sub","sup","mark","table","thead","tbody","tr","th","td","img","div","figure","figcaption","details","summary"],r=["href","target","rel","src","alt","width","height","class","colspan","rowspan"];function s(t){return a(t,{allowedTags:e,allowedAttributes:r})}export{s as sanitizeHtml};
|
package/dist/utils/scopeUtils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getScopeValue as
|
|
1
|
+
import{getScopeValue as t,CRUD_OPERATORS as c}from"@donotdev/core";function s(r,e){if(!e)return r;const o=t(e.provider);if(!o)throw new Error(`[CRUD] Scope provider "${e.provider}" returned null. Cannot write scoped entity without a scope value. Ensure a scope is selected before creating scoped entities.`);return{...r,[e.field]:o}}function p(r,e){const o=r??{};if(!e||typeof e.field!="string")return o;const n=t(e.provider);if(!n)throw new Error(`[CRUD] Scope provider "${e.provider}" returned null. Cannot query scoped entity without a scope value. Ensure a scope is selected before querying scoped entities.`);const i={field:e.field,operator:c.EQ,value:n};return{...o,where:o.where?[...o.where,i]:[i]}}function u(r){return r?t(r.provider):null}export{u as getCurrentScopeValue,s as injectScope,p as injectScopeFilter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";function
|
|
1
|
+
"use client";function u(t){return!t||typeof t!="string"?!1:t.startsWith("https://")&&!t.startsWith("blob:")}function h(t){return!(!t||typeof t!="object"||!u(t.fullUrl)||t.thumbUrl&&!u(t.thumbUrl))}function i(t,e=""){const s=[];if(t==null)return s;if(typeof t=="string")return t.startsWith("blob:")&&s.push(e||"root"),s;if(typeof t!="object")return s;if(Array.isArray(t))t.forEach((r,o)=>{const n=e?`${e}[${o}]`:`[${o}]`;s.push(...i(r,n))});else{const r=t;if(r.fullUrl!==void 0&&r.thumbUrl!==void 0){const o=r.fullUrl,n=r.thumbUrl,l=typeof o=="string"&&!u(o),c=n&&typeof n=="string"&&!u(n);if(l||c){const f=e||"root";s.push(`${f}.fullUrl or ${f}.thumbUrl contains blob URL`)}}else Object.entries(r).forEach(([o,n])=>{const l=e?`${e}.${o}`:o;s.push(...i(n,l))})}return s}function b(t){return i(t).length>0}export{i as checkForBlobUrls,b as hasBlobUrls,u as isStorageUrl,h as validatePicture};
|