@foris/avocado-not-front 1.4.6 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Configures Axios interceptors
3
+ * Intercepts HTTP errors for automatic token refresh handling
4
+ */
5
+ export declare const setupAxiosInterceptors: () => void;
@@ -1,3 +1,4 @@
1
+ import type { ApiConfig } from '../../types/builder.type';
1
2
  import type { AxiosCall } from './useFetchAndLoad';
2
3
  export declare const loadAbort: () => AbortController;
3
4
  /**
@@ -8,7 +9,7 @@ export declare const loadAbort: () => AbortController;
8
9
  * @param abort
9
10
  * @returns {call, controller }
10
11
  */
11
- export declare const get: <T>(api: string, headers?: {}, params?: {}, abort?: boolean) => AxiosCall<T>;
12
+ export declare const get: <T>(api: string, headers?: ApiConfig['headers'] | Record<string, string>, params?: {}, abort?: boolean, userFlow?: string) => AxiosCall<T>;
12
13
  /**
13
14
  *
14
15
  * @param api
@@ -18,7 +19,7 @@ export declare const get: <T>(api: string, headers?: {}, params?: {}, abort?: bo
18
19
  * @param abort
19
20
  * @returns
20
21
  */
21
- export declare const post: <T>(api: string, headers?: {}, data?: {}, params?: {}, abort?: boolean) => AxiosCall<T>;
22
+ export declare const post: <T>(api: string, headers?: ApiConfig['headers'] | Record<string, string>, data?: {}, params?: {}, abort?: boolean, userFlow?: string) => AxiosCall<T>;
22
23
  /**
23
24
  * Axios Put
24
25
  * @param api
@@ -28,7 +29,7 @@ export declare const post: <T>(api: string, headers?: {}, data?: {}, params?: {}
28
29
  * @param abort
29
30
  * @returns {call, controller}
30
31
  */
31
- export declare const put: <T>(api: string, headers?: {}, data?: {}, params?: {}, abort?: boolean) => AxiosCall<T>;
32
+ export declare const put: <T>(api: string, headers?: ApiConfig['headers'] | Record<string, string>, data?: {}, params?: {}, abort?: boolean, userFlow?: string) => AxiosCall<T>;
32
33
  /**
33
34
  * Axios Patch
34
35
  * @param api
@@ -38,4 +39,4 @@ export declare const put: <T>(api: string, headers?: {}, data?: {}, params?: {},
38
39
  * @param abort
39
40
  * @returns {call, controller}
40
41
  */
41
- export declare const patch: <T>(api: string, headers?: {}, data?: {}, params?: {}, abort?: boolean) => AxiosCall<T>;
42
+ export declare const patch: <T>(api: string, headers?: ApiConfig['headers'] | Record<string, string>, data?: {}, params?: {}, abort?: boolean, userFlow?: string) => AxiosCall<T>;
@@ -61,3 +61,11 @@ export declare const setModalOpen: (userFlow: string, isModalOpen: boolean) => v
61
61
  * @param isDrawerOpen - The new isDrawerOpen state
62
62
  */
63
63
  export declare const setDrawerOpen: (userFlow: string, isDrawerOpen: boolean) => void;
64
+ /**
65
+ * Updates the headers in the apiConfig for a specific userFlow.
66
+ * This is used to update headers after token refresh or other authentication changes.
67
+ *
68
+ * @param userFlow - The identifier for the current userFlow
69
+ * @param headers - The new headers value (can be string, object, or function)
70
+ */
71
+ export declare const updateApiConfigHeaders: (userFlow: string, headers: ApiConfig['headers']) => void;
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- ._body_14tsv_1{padding:2rem 2.75rem;width:100%}._body_content_14tsv_5{display:flex;flex-direction:column;gap:.75rem;margin:0 auto;max-width:1440px}._cardNotificationNotFront_t7pln_1{max-width:50%}@media (max-width: 992px){._cardNotificationNotFront_t7pln_1{max-width:100%}}._codeEditor_1t8xs_1:not(:first-child){margin:1rem 0 0}._codeEditor_label_1t8xs_4{color:var(--color-neutral-90);display:block;font-family:Roboto,sans-serif;font-size:.75rem;font-weight:700;line-height:.875rem;margin:0 0 .5rem}._codeEditor_wrapper_1t8xs_13{display:flex;gap:1rem}._codeEditor_wrapper_1t8xs_13 ._input_1t8xs_17,._codeEditor_wrapper_1t8xs_13 ._preview_1t8xs_18{flex:1}._codeEditor_wrapper_1t8xs_13 ._input_1t8xs_17{border-radius:.25rem;border:1px solid var(--color-neutral-30);overflow:hidden}._codeEditor_wrapper_1t8xs_13 ._preview_1t8xs_18{max-height:400px;border-radius:.25rem;border:1px solid var(--color-neutral-30);min-height:400px;overflow-y:auto;padding:.75rem}._contentWrapper_12gyy_1{max-width:1440px}._contentWrapper_12gyy_1._contentWrapper__centered_12gyy_4{margin:0 auto}._dividerNotFront_tze3j_1{margin:1.25rem 0}._header_g1eri_1{padding:1.5rem 2.75rem;background-color:var(--color-gray-80)}._header_content_g1eri_5{display:flex;flex-direction:column;gap:.75rem;margin:0 auto;max-width:1440px}._modalContent_1ynhd_1{display:flex;flex-direction:column;gap:.75rem;max-height:50vh;overflow:auto;padding:0 .25rem .5rem 0;width:calc(100% - .25rem)}@media (max-width: 992px){._modalContent_1ynhd_1{max-height:70vh;overflow:auto}}._row_1bqj4_1{display:flex;width:100%}._row__gap-none_1bqj4_5{gap:0}._row__gap-xxs_1bqj4_8{gap:.25rem}._row__gap-xs_1bqj4_11{gap:.5rem}._row__gap-sm_1bqj4_14{gap:.75rem}._row__gap-md_1bqj4_17{gap:1rem}._row__gap-lg_1bqj4_20{gap:1.25rem}._row__gap-xl_1bqj4_23{gap:1.5rem}._row__gap-xxl_1bqj4_26{gap:2rem}._row__gap-xxxl_1bqj4_29{gap:2.75rem}._row__justify-start_1bqj4_32{justify-content:flex-start}._row__justify-end_1bqj4_35{justify-content:flex-end}._row__justify-center_1bqj4_38{justify-content:center}._row__justify-space-between_1bqj4_41{justify-content:space-between}._row__justify-space-around_1bqj4_44{justify-content:space-around}._row__justify-space-evenly_1bqj4_47{justify-content:space-evenly}._row__align-start_1bqj4_50{align-items:flex-start}._row__align-end_1bqj4_53{align-items:flex-end}._row__align-center_1bqj4_56{align-items:center}._row__align-stretch_1bqj4_59{align-items:stretch}._row__align-baseline_1bqj4_62{align-items:baseline}._row_column_1bqj4_65{display:flex;flex-direction:column;min-height:1px;overflow-wrap:break-word;word-wrap:break-word}._row_column__gap-none_1bqj4_72{gap:0}._row_column__gap-xxs_1bqj4_75{gap:.25rem}._row_column__gap-xs_1bqj4_78{gap:.5rem}._row_column__gap-sm_1bqj4_81{gap:.75rem}._row_column__gap-md_1bqj4_84{gap:1rem}._row_column__gap-lg_1bqj4_87{gap:1.25rem}._row_column__gap-xl_1bqj4_90{gap:1.5rem}._row_column__gap-xxl_1bqj4_93{gap:2rem}._row_column__gap-xxxl_1bqj4_96{gap:2.75rem}._row_column__justify-start_1bqj4_99{justify-content:flex-start}._row_column__justify-end_1bqj4_102{justify-content:flex-end}._row_column__justify-center_1bqj4_105{justify-content:center}._row_column__justify-space-between_1bqj4_108{justify-content:space-between}._row_column__justify-space-around_1bqj4_111{justify-content:space-around}._row_column__justify-space-evenly_1bqj4_114{justify-content:space-evenly}._row_column__align-start_1bqj4_117{align-items:flex-start}._row_column__align-end_1bqj4_120{align-items:flex-end}._row_column__align-center_1bqj4_123{align-items:center}._row_column__align-stretch_1bqj4_126{align-items:stretch}._row_column__align-baseline_1bqj4_129{align-items:baseline}._selectNotFront_1yw9q_1{max-width:364px}@media (max-width: 992px){._selectNotFront_1yw9q_1{max-width:364px}}._spacing_19hqa_1._spacing__xxs_19hqa_1{margin:.25rem 0 0}._spacing_19hqa_1._spacing__xs_19hqa_4{margin:.5rem 0 0}._spacing_19hqa_1._spacing__sm_19hqa_7{margin:.75rem 0 0}._spacing_19hqa_1._spacing__md_19hqa_10{margin:1rem 0 0}._spacing_19hqa_1._spacing__lg_19hqa_13{margin:1.25rem 0 0}._spacing_19hqa_1._spacing__xl_19hqa_16{margin:1.5rem 0 0}._spacing_19hqa_1._spacing__xxl_19hqa_19{margin:2rem 0 0}._spacing_19hqa_1._spacing__xxxl_19hqa_22{margin:2.75rem 0 0}._tableSkeleton_3nr9n_1{display:flex;flex-direction:column;gap:.5rem}._tableArrayPills_3nr9n_7{display:flex;gap:.5rem;flex-wrap:wrap}._textFieldNotFront_cps4i_1{max-width:364px}@media (max-width: 992px){._textFieldNotFront_cps4i_1{max-width:364px}}._accordion_1ri2t_1{flex-shrink:0}._accordion_1ri2t_1 [class*=cardNotificationNotFront]{max-width:100%}._accordionBody_1ri2t_8{display:flex;flex-direction:column;gap:.75rem}._drawer_13pxo_1{z-index:9}._drawerBody_13pxo_5{display:flex;flex-direction:column;gap:.75rem}._drawerFooter_13pxo_11{display:flex;gap:.75rem}
1
+ ._body_14tsv_1{padding:2rem 2.75rem;width:100%}._body_content_14tsv_5{display:flex;flex-direction:column;gap:.75rem;margin:0 auto;max-width:1440px}._cardNotificationNotFront_t7pln_1{max-width:50%}@media (max-width: 992px){._cardNotificationNotFront_t7pln_1{max-width:100%}}._codeEditor_1t8xs_1:not(:first-child){margin:1rem 0 0}._codeEditor_label_1t8xs_4{color:var(--color-neutral-90);display:block;font-family:Roboto,sans-serif;font-size:.75rem;font-weight:700;line-height:.875rem;margin:0 0 .5rem}._codeEditor_wrapper_1t8xs_13{display:flex;gap:1rem}._codeEditor_wrapper_1t8xs_13 ._input_1t8xs_17,._codeEditor_wrapper_1t8xs_13 ._preview_1t8xs_18{flex:1}._codeEditor_wrapper_1t8xs_13 ._input_1t8xs_17{border-radius:.25rem;border:1px solid var(--color-neutral-30);overflow:hidden}._codeEditor_wrapper_1t8xs_13 ._preview_1t8xs_18{max-height:400px;border-radius:.25rem;border:1px solid var(--color-neutral-30);min-height:400px;overflow-y:auto;padding:.75rem}._contentWrapper_12gyy_1{max-width:1440px}._contentWrapper_12gyy_1._contentWrapper__centered_12gyy_4{margin:0 auto}._dividerNotFront_tze3j_1{margin:1.25rem 0}._header_g1eri_1{padding:1.5rem 2.75rem;background-color:var(--color-gray-80)}._header_content_g1eri_5{display:flex;flex-direction:column;gap:.75rem;margin:0 auto;max-width:1440px}._modalNotFront_xyah1_1{align-items:flex-start;min-height:100vh;overflow-x:hidden;overflow-y:auto}._modalNotFront_xyah1_1 div[class*=modal_overlay]{position:fixed}._modalNotFront_xyah1_1 div[class*=modal_content]{margin:2rem auto}._modalNotFront_body_xyah1_13{display:flex;flex-direction:column;gap:.75rem;padding:0 .25rem .5rem 0;width:calc(100% - .25rem)}@media (max-width: 992px){._modalNotFront_xyah1_1 div[class*=modal_content]{margin:0}}._row_1bqj4_1{display:flex;width:100%}._row__gap-none_1bqj4_5{gap:0}._row__gap-xxs_1bqj4_8{gap:.25rem}._row__gap-xs_1bqj4_11{gap:.5rem}._row__gap-sm_1bqj4_14{gap:.75rem}._row__gap-md_1bqj4_17{gap:1rem}._row__gap-lg_1bqj4_20{gap:1.25rem}._row__gap-xl_1bqj4_23{gap:1.5rem}._row__gap-xxl_1bqj4_26{gap:2rem}._row__gap-xxxl_1bqj4_29{gap:2.75rem}._row__justify-start_1bqj4_32{justify-content:flex-start}._row__justify-end_1bqj4_35{justify-content:flex-end}._row__justify-center_1bqj4_38{justify-content:center}._row__justify-space-between_1bqj4_41{justify-content:space-between}._row__justify-space-around_1bqj4_44{justify-content:space-around}._row__justify-space-evenly_1bqj4_47{justify-content:space-evenly}._row__align-start_1bqj4_50{align-items:flex-start}._row__align-end_1bqj4_53{align-items:flex-end}._row__align-center_1bqj4_56{align-items:center}._row__align-stretch_1bqj4_59{align-items:stretch}._row__align-baseline_1bqj4_62{align-items:baseline}._row_column_1bqj4_65{display:flex;flex-direction:column;min-height:1px;overflow-wrap:break-word;word-wrap:break-word}._row_column__gap-none_1bqj4_72{gap:0}._row_column__gap-xxs_1bqj4_75{gap:.25rem}._row_column__gap-xs_1bqj4_78{gap:.5rem}._row_column__gap-sm_1bqj4_81{gap:.75rem}._row_column__gap-md_1bqj4_84{gap:1rem}._row_column__gap-lg_1bqj4_87{gap:1.25rem}._row_column__gap-xl_1bqj4_90{gap:1.5rem}._row_column__gap-xxl_1bqj4_93{gap:2rem}._row_column__gap-xxxl_1bqj4_96{gap:2.75rem}._row_column__justify-start_1bqj4_99{justify-content:flex-start}._row_column__justify-end_1bqj4_102{justify-content:flex-end}._row_column__justify-center_1bqj4_105{justify-content:center}._row_column__justify-space-between_1bqj4_108{justify-content:space-between}._row_column__justify-space-around_1bqj4_111{justify-content:space-around}._row_column__justify-space-evenly_1bqj4_114{justify-content:space-evenly}._row_column__align-start_1bqj4_117{align-items:flex-start}._row_column__align-end_1bqj4_120{align-items:flex-end}._row_column__align-center_1bqj4_123{align-items:center}._row_column__align-stretch_1bqj4_126{align-items:stretch}._row_column__align-baseline_1bqj4_129{align-items:baseline}._selectNotFront_1yw9q_1{max-width:364px}@media (max-width: 992px){._selectNotFront_1yw9q_1{max-width:364px}}._spacing_19hqa_1._spacing__xxs_19hqa_1{margin:.25rem 0 0}._spacing_19hqa_1._spacing__xs_19hqa_4{margin:.5rem 0 0}._spacing_19hqa_1._spacing__sm_19hqa_7{margin:.75rem 0 0}._spacing_19hqa_1._spacing__md_19hqa_10{margin:1rem 0 0}._spacing_19hqa_1._spacing__lg_19hqa_13{margin:1.25rem 0 0}._spacing_19hqa_1._spacing__xl_19hqa_16{margin:1.5rem 0 0}._spacing_19hqa_1._spacing__xxl_19hqa_19{margin:2rem 0 0}._spacing_19hqa_1._spacing__xxxl_19hqa_22{margin:2.75rem 0 0}._tableSkeleton_3nr9n_1{display:flex;flex-direction:column;gap:.5rem}._tableArrayPills_3nr9n_7{display:flex;gap:.5rem;flex-wrap:wrap}._textFieldNotFront_cps4i_1{max-width:364px}@media (max-width: 992px){._textFieldNotFront_cps4i_1{max-width:364px}}._accordion_1ri2t_1{flex-shrink:0}._accordion_1ri2t_1 [class*=cardNotificationNotFront]{max-width:100%}._accordionBody_1ri2t_8{display:flex;flex-direction:column;gap:.75rem}._drawer_13pxo_1{z-index:9}._drawerBody_13pxo_5{display:flex;flex-direction:column;gap:.75rem}._drawerFooter_13pxo_11{display:flex;gap:.75rem}
@@ -12,9 +12,17 @@ export interface ApiConfig {
12
12
  api: string;
13
13
  /**
14
14
  * The headers to be used in the API requests.
15
+ * Can be a string (JSON), a static object, or a function that returns headers dynamically.
16
+ * If it's a function, it will be evaluated on each request to get the latest headers.
15
17
  * Typically contains authentication and content type details.
16
18
  */
17
- headers: string;
19
+ headers: string | Record<string, string> | (() => Record<string, string>);
20
+ /**
21
+ * Optional callback function that is called when a 401 error is detected.
22
+ * This function should handle the token refresh and return the new headers.
23
+ * @returns Promise that resolves to the updated headers object
24
+ */
25
+ onAuthenticationError?: () => Promise<Record<string, string>>;
18
26
  }
19
27
  /**
20
28
  * Type definition for the page type. Determines if the page is a simple page or a form.
@@ -12,6 +12,7 @@ interface BaseDataSource {
12
12
  export interface NotFrontDataSourceRest extends BaseDataSource {
13
13
  type: 'rest';
14
14
  data?: any;
15
+ paginationKeys?: Record<string, string>;
15
16
  }
16
17
  export interface NotFrontDataSourceGraphQL extends BaseDataSource {
17
18
  type: 'graphql';
@@ -1,21 +1,14 @@
1
- import { NotFrontDataSource } from '../types/componentsCore.type';
1
+ import { NotFrontDataSource, NotFrontDataSourceRest } from '../types/componentsCore.type';
2
2
  /**
3
- * Constructs a URL with pagination and search query parameters.
3
+ * Constructs a complete URL with query parameters for REST data sources.
4
+ * Handles pagination, search, and additional params internally.
4
5
  *
5
- * @param baseUrl - The base URL of the data source.
6
- * @param search - The search term to include as a query parameter.
6
+ * @param dataSource - The REST data source configuration.
7
7
  * @param page - The current pagination page number.
8
- * @returns A string with the full URL including query parameters.
8
+ * @param search - Optional search term to include as a query parameter.
9
+ * @returns {string} The complete URL with all query parameters combined.
9
10
  */
10
- export declare const buildPaginatedURL: (baseUrl: string, search: string, page: number) => string;
11
- /**
12
- * Converts an object of key-value pairs into a URI-encoded query string.
13
- *
14
- * @param {Record<string, any>} params - An object where keys and values represent query parameters.
15
- * Values that are `null` or `undefined` will be skipped.
16
- * @returns {string} A properly URI-encoded query string (e.g., "key1=value1&key2=value2").
17
- */
18
- export declare const buildQueryString: (params: Record<string, any>) => string;
11
+ export declare const buildQueryParams: (dataSource: NotFrontDataSourceRest, page: number, search?: string) => string;
19
12
  /**
20
13
  * Utility to build a normalized NotFrontDataSource object for REST or GraphQL requests.
21
14
  *
@@ -0,0 +1,7 @@
1
+ import type { ApiConfig } from '../types/builder.type';
2
+ /**
3
+ * Normalizes headers by evaluating if it's a function, parsing if it's a string, or returning as object
4
+ * @param headers - Headers value (string, object, or function)
5
+ * @returns Normalized headers as Record<string, string>
6
+ */
7
+ export declare const normalizeHeaders: (headers: ApiConfig['headers'] | Record<string, string>) => Record<string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foris/avocado-not-front",
3
- "version": "1.4.6",
3
+ "version": "1.5.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -31,9 +31,9 @@
31
31
  "react-select-async-paginate": "0.7.3",
32
32
  "recharts": "3.1.0",
33
33
  "zustand": "4.5.4",
34
- "@foris/avocado-core": "0.12.3",
35
34
  "@foris/avocado-icons": "1.16.0",
36
- "@foris/avocado-suite": "1.1.1"
35
+ "@foris/avocado-suite": "1.2.0",
36
+ "@foris/avocado-core": "0.12.3"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@testing-library/jest-dom": "6.4.0",