sass-cms-template-common 0.0.29 → 0.0.30
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/index.d.ts +48 -0
- package/dist/index.js +433 -403
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4620,6 +4620,13 @@ declare interface ISectionsServices {
|
|
|
4620
4620
|
authentication: Authentication;
|
|
4621
4621
|
}
|
|
4622
4622
|
|
|
4623
|
+
/**
|
|
4624
|
+
* `true` si la excepción es una señal interna de control de flujo de Next
|
|
4625
|
+
* (`redirect()`, `notFound()`, `forbidden()`), no un fallo real. Estas NUNCA
|
|
4626
|
+
* deben atraparse: si se tragan, la navegación no ocurre.
|
|
4627
|
+
*/
|
|
4628
|
+
export declare function isFrameworkControlFlowError(error: unknown): boolean;
|
|
4629
|
+
|
|
4623
4630
|
declare interface ISitesServices {
|
|
4624
4631
|
axiosApi: AxiosInstance;
|
|
4625
4632
|
authentication: Authentication;
|
|
@@ -6885,6 +6892,16 @@ export declare interface RecipesPublishCheckResponse extends CmsResponse {
|
|
|
6885
6892
|
/** Estilo del texto relativo (`Intl.RelativeTimeFormat`). */
|
|
6886
6893
|
export declare type RelativeTimeStyle = 'long' | 'short' | 'narrow';
|
|
6887
6894
|
|
|
6895
|
+
export declare interface ResilientFormActionOptions<S> extends ResilientRunOptions {
|
|
6896
|
+
/**
|
|
6897
|
+
* Estado a devolver cuando la llamada no pudo completarse (se agotaron los
|
|
6898
|
+
* reintentos, o la excepción no era de red). Recibe el error crudo y su
|
|
6899
|
+
* clasificación (`null` si no es un fallo de red) para poder distinguir
|
|
6900
|
+
* "servicio caído" de "error inesperado".
|
|
6901
|
+
*/
|
|
6902
|
+
onError: (error: unknown, classified: ClassifiedNetworkError | null) => S;
|
|
6903
|
+
}
|
|
6904
|
+
|
|
6888
6905
|
export declare type ResilientRunner = <T>(fn: () => Promise<T>, options?: ResilientRunOptions) => Promise<T>;
|
|
6889
6906
|
|
|
6890
6907
|
export declare interface ResilientRunOptions {
|
|
@@ -8028,6 +8045,37 @@ export declare type UserAvatarProps = {
|
|
|
8028
8045
|
*/
|
|
8029
8046
|
export declare function useResilientAction(): ResilientRunner;
|
|
8030
8047
|
|
|
8048
|
+
/**
|
|
8049
|
+
* Envuelve el server action de un formulario (`useActionState`) para hacerlo
|
|
8050
|
+
* **resiliente a la red** y, sobre todo, para que **jamás propague la excepción**.
|
|
8051
|
+
*
|
|
8052
|
+
* Por qué existe: al invocar un server action desde el navegador, Next hace un
|
|
8053
|
+
* `fetch` interno. Sin internet ese fetch lanza `TypeError: Failed to fetch`
|
|
8054
|
+
* dentro del render de React; como `useActionState` no atrapa nada, el error
|
|
8055
|
+
* sube al error boundary y **tumba la pantalla** ("recargá la página"). Es
|
|
8056
|
+
* inaceptable en pantallas sin shell —el login—, donde no hay nada que degradar:
|
|
8057
|
+
* se cae todo.
|
|
8058
|
+
*
|
|
8059
|
+
* Qué hace, apoyado en `useResilientAction`:
|
|
8060
|
+
* - **Sin internet:** no pierde el envío. Muestra el toast de "sin conexión"
|
|
8061
|
+
* (vía `CmsNetworkProvider` + `CmsNetworkToaster`), espera la reconexión y
|
|
8062
|
+
* **retoma el llamado** solo (avisando "reintentando…").
|
|
8063
|
+
* - **Backend caído / 5xx / timeout:** reintenta con backoff exponencial.
|
|
8064
|
+
* - **Agotado o error inesperado:** devuelve el estado de `onError` — la pantalla
|
|
8065
|
+
* sigue viva y pinta el mensaje en su lugar.
|
|
8066
|
+
*
|
|
8067
|
+
* Requiere estar dentro de `<CmsNetworkProvider>` y `<CmsToastProvider>`.
|
|
8068
|
+
*
|
|
8069
|
+
* ```ts
|
|
8070
|
+
* const resilientLogin = useResilientFormAction(loginAction, {
|
|
8071
|
+
* service: '/auth/loginValid',
|
|
8072
|
+
* onError: () => ({ error: 'service', field: 'general' }),
|
|
8073
|
+
* });
|
|
8074
|
+
* const [state, formAction, isPending] = useActionState(resilientLogin, {});
|
|
8075
|
+
* ```
|
|
8076
|
+
*/
|
|
8077
|
+
export declare function useResilientFormAction<S>(action: (prevState: S, formData: FormData) => Promise<S>, options: ResilientFormActionOptions<S>): (prevState: S, formData: FormData) => Promise<S>;
|
|
8078
|
+
|
|
8031
8079
|
/** Grupo del sistema devuelto por POST /users/groups/get. */
|
|
8032
8080
|
export declare interface UserGroup {
|
|
8033
8081
|
id: string;
|