@intlayer/design-system 5.1.4 → 5.1.5

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.
Files changed (160) hide show
  1. package/dist/.vite/manifest.json +34 -88
  2. package/dist/Form-BZUDRfoN.js.map +1 -1
  3. package/dist/Form-yi0CMK-a.cjs.map +1 -1
  4. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs +1 -1
  5. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs +1 -1
  6. package/dist/components/Command/index.d.ts +1 -1
  7. package/dist/components/Container/index.cjs +5 -6
  8. package/dist/components/Container/index.cjs.map +1 -1
  9. package/dist/components/Container/index.mjs +5 -6
  10. package/dist/components/Container/index.mjs.map +1 -1
  11. package/dist/components/DictionaryEditor/DictionaryEditor.cjs +3 -3
  12. package/dist/components/DictionaryEditor/DictionaryEditor.cjs.map +1 -1
  13. package/dist/components/DictionaryEditor/DictionaryEditor.d.ts +1 -1
  14. package/dist/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
  15. package/dist/components/DictionaryEditor/DictionaryEditor.mjs +3 -3
  16. package/dist/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
  17. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs +33 -20
  18. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs.map +1 -1
  19. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.d.ts.map +1 -1
  20. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs +34 -21
  21. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs.map +1 -1
  22. package/dist/components/DictionaryFieldEditor/ContentEditor.cjs +2 -2
  23. package/dist/components/DictionaryFieldEditor/ContentEditor.cjs.map +1 -1
  24. package/dist/components/DictionaryFieldEditor/ContentEditor.mjs +3 -3
  25. package/dist/components/DictionaryFieldEditor/ContentEditor.mjs.map +1 -1
  26. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs +10 -7
  27. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs.map +1 -1
  28. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
  29. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +10 -7
  30. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
  31. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs.map +1 -1
  32. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts +1 -1
  33. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts.map +1 -1
  34. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs.map +1 -1
  35. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +1 -1
  36. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +1 -1
  37. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +92 -120
  38. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs.map +1 -1
  39. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts +1 -1
  40. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts.map +1 -1
  41. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +94 -122
  42. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
  43. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs +0 -143
  44. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs.map +1 -1
  45. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts +0 -143
  46. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts.map +1 -1
  47. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs +0 -143
  48. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs.map +1 -1
  49. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.cjs +1 -2
  50. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.cjs.map +1 -1
  51. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.d.ts +0 -3
  52. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.d.ts.map +1 -1
  53. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.mjs +1 -2
  54. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.mjs.map +1 -1
  55. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +51 -70
  56. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
  57. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts +1 -1
  58. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts.map +1 -1
  59. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +51 -70
  60. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
  61. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +52 -103
  62. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
  63. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts +3 -3
  64. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
  65. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +56 -107
  66. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
  67. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs +0 -32
  68. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs.map +1 -1
  69. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts +0 -32
  70. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts.map +1 -1
  71. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs +0 -32
  72. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs.map +1 -1
  73. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs +1 -0
  74. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs.map +1 -1
  75. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.d.ts.map +1 -1
  76. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs +1 -0
  77. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs.map +1 -1
  78. package/dist/components/DictionaryFieldEditor/index.cjs +0 -2
  79. package/dist/components/DictionaryFieldEditor/index.cjs.map +1 -1
  80. package/dist/components/DictionaryFieldEditor/index.d.ts +0 -1
  81. package/dist/components/DictionaryFieldEditor/index.d.ts.map +1 -1
  82. package/dist/components/DictionaryFieldEditor/index.mjs +0 -2
  83. package/dist/components/DictionaryFieldEditor/index.mjs.map +1 -1
  84. package/dist/components/Form/FormBase.cjs +0 -1
  85. package/dist/components/Form/FormBase.cjs.map +1 -1
  86. package/dist/components/Form/FormBase.d.ts +1 -4
  87. package/dist/components/Form/FormBase.d.ts.map +1 -1
  88. package/dist/components/Form/FormBase.mjs +0 -1
  89. package/dist/components/Form/FormBase.mjs.map +1 -1
  90. package/dist/components/Form/elements/EditableFieldInputElement.d.ts +1 -1
  91. package/dist/components/Form/elements/EditableFieldInputElement.d.ts.map +1 -1
  92. package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts +1 -1
  93. package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts.map +1 -1
  94. package/dist/components/Input/Checkbox.cjs +0 -1
  95. package/dist/components/Input/Checkbox.cjs.map +1 -1
  96. package/dist/components/Input/Checkbox.mjs +0 -1
  97. package/dist/components/Input/Checkbox.mjs.map +1 -1
  98. package/dist/components/Input/Input.cjs +1 -1
  99. package/dist/components/Input/Input.cjs.map +1 -1
  100. package/dist/components/Input/Input.mjs +1 -1
  101. package/dist/components/Input/Input.mjs.map +1 -1
  102. package/dist/components/KeyboardScreenAdapter/index.cjs +25 -0
  103. package/dist/components/KeyboardScreenAdapter/index.cjs.map +1 -0
  104. package/dist/components/KeyboardScreenAdapter/index.d.ts +3 -0
  105. package/dist/components/KeyboardScreenAdapter/index.d.ts.map +1 -0
  106. package/dist/components/KeyboardScreenAdapter/index.mjs +25 -0
  107. package/dist/components/KeyboardScreenAdapter/index.mjs.map +1 -0
  108. package/dist/components/MaxHeightSmoother/index.cjs +2 -0
  109. package/dist/components/MaxHeightSmoother/index.cjs.map +1 -1
  110. package/dist/components/MaxHeightSmoother/index.d.ts.map +1 -1
  111. package/dist/components/MaxHeightSmoother/index.mjs +2 -0
  112. package/dist/components/MaxHeightSmoother/index.mjs.map +1 -1
  113. package/dist/components/Modal/Modal.cjs +15 -13
  114. package/dist/components/Modal/Modal.cjs.map +1 -1
  115. package/dist/components/Modal/Modal.d.ts.map +1 -1
  116. package/dist/components/Modal/Modal.mjs +15 -13
  117. package/dist/components/Modal/Modal.mjs.map +1 -1
  118. package/dist/components/RightDrawer/RightDrawer.cjs +1 -1
  119. package/dist/components/RightDrawer/RightDrawer.cjs.map +1 -1
  120. package/dist/components/RightDrawer/RightDrawer.mjs +1 -1
  121. package/dist/components/RightDrawer/RightDrawer.mjs.map +1 -1
  122. package/dist/components/Select/Multiselect.cjs +0 -1
  123. package/dist/components/Select/Multiselect.cjs.map +1 -1
  124. package/dist/components/Select/Multiselect.d.ts.map +1 -1
  125. package/dist/components/Select/Multiselect.mjs +1 -2
  126. package/dist/components/Select/Multiselect.mjs.map +1 -1
  127. package/dist/components/Select/Select.cjs +0 -1
  128. package/dist/components/Select/Select.cjs.map +1 -1
  129. package/dist/components/Select/Select.d.ts.map +1 -1
  130. package/dist/components/Select/Select.mjs +0 -1
  131. package/dist/components/Select/Select.mjs.map +1 -1
  132. package/dist/components/index.cjs +2 -2
  133. package/dist/components/index.d.ts +1 -0
  134. package/dist/components/index.d.ts.map +1 -1
  135. package/dist/components/index.mjs +2 -2
  136. package/dist/hooks/index.cjs +2 -0
  137. package/dist/hooks/index.cjs.map +1 -1
  138. package/dist/hooks/index.d.ts +1 -0
  139. package/dist/hooks/index.d.ts.map +1 -1
  140. package/dist/hooks/index.mjs +2 -0
  141. package/dist/hooks/index.mjs.map +1 -1
  142. package/dist/hooks/useAsync/useAsyncStateStore.cjs +8 -14
  143. package/dist/hooks/useAsync/useAsyncStateStore.cjs.map +1 -1
  144. package/dist/hooks/useAsync/useAsyncStateStore.d.ts.map +1 -1
  145. package/dist/hooks/useAsync/useAsyncStateStore.mjs +8 -14
  146. package/dist/hooks/useAsync/useAsyncStateStore.mjs.map +1 -1
  147. package/dist/hooks/useKeyboardDetector.cjs +27 -0
  148. package/dist/hooks/useKeyboardDetector.cjs.map +1 -0
  149. package/dist/hooks/useKeyboardDetector.d.ts +5 -0
  150. package/dist/hooks/useKeyboardDetector.d.ts.map +1 -0
  151. package/dist/hooks/useKeyboardDetector.mjs +27 -0
  152. package/dist/hooks/useKeyboardDetector.mjs.map +1 -0
  153. package/dist/{index-BTDHuTxL.js → index-B1w5h_6-.js} +7 -7
  154. package/dist/index-B1w5h_6-.js.map +1 -0
  155. package/dist/{index-Db5Dym4h.cjs → index-U1U6ySIn.cjs} +7 -7
  156. package/dist/index-U1U6ySIn.cjs.map +1 -0
  157. package/dist/tailwind.css +1 -1
  158. package/package.json +17 -17
  159. package/dist/index-BTDHuTxL.js.map +0 -1
  160. package/dist/index-Db5Dym4h.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useAsyncStateStore.cjs","sources":["../../../src/hooks/useAsync/useAsyncStateStore.tsx"],"sourcesContent":["'use client';\n\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useReducer,\n} from 'react';\n\n/**\n * Represents the states for a given key in the asynchronous state management.\n * This includes flags for loading, fetched, invalidation, and success/error status.\n * It also keeps track of the fetched datetime, retry counts, the data itself, and whether queries are enabled.\n */\ntype States<T> = {\n isLoading: boolean;\n isFetched: boolean;\n isInvalidated: boolean;\n fetchedDateTime: null | Date;\n error: string | null;\n isSuccess: boolean;\n data: T | null;\n errorCount: number;\n isEnabled: boolean;\n};\n\n/**\n * Holds a mapping from a key (string) to its associated state.\n */\ntype StateSlice<T> = {\n [key: string]: States<T>;\n};\n\n/**\n * Describes all the possible actions that can be dispatched to the reducer.\n * These actions allow setting or updating states for specific keys or multiple keys at once,\n * handling errors, and resetting states.\n */\ntype Actions<T> =\n | { type: 'SET_QUERY_STATE'; key: string; value: Partial<States<T>> }\n | { type: 'MAKE_QUERY_IN_ERROR'; key: string; error: string }\n | { type: 'SET_QUERIES_STATE'; keys: string[]; value: Partial<States<T>> }\n | { type: 'RESET_KEY_STATE'; keys: string[] }\n | { type: 'RESET_STATE'; excludeKeys: string[] };\n\n/**\n * The shape of the entire asynchronous state, holding all states in a single object.\n */\ntype AsyncState<T> = {\n states: StateSlice<T>;\n};\n\n/**\n * Creates a default state object with initial values. This is useful when a key\n * has not been initialized yet or when resetting a state back to defaults.\n */\nconst createDefaultStates = <T,>(): States<T> => ({\n isFetched: false,\n fetchedDateTime: null,\n isLoading: false,\n isInvalidated: false,\n error: null,\n isSuccess: false,\n data: null,\n errorCount: 0,\n isEnabled: true,\n});\n\n/**\n * Ensures that a given value is returned as an array.\n * If the value is undefined or null, returns an empty array.\n * If the value is not already an array, wraps it in one.\n */\nconst ensureArray = <T,>(value?: T | T[]): T[] => {\n if (!value) {\n // If no value is provided, return an empty array\n return [];\n } else if (Array.isArray(value)) {\n // If it's already an array, just return it\n return value;\n }\n // If it's a single value, wrap it in an array\n return [value];\n};\n\n/**\n * Given a list of selector keys and a list of keys that may contain arguments,\n * this function returns all keys that match the selectors. Matching is determined\n * by comparing the initial part (split by \"/\") of the key.\n *\n * For example:\n * selectorsKeys = [\"user\", \"posts\"]\n * keysWithArgs = [\"user/123\", \"posts/active\", \"comments/42\"]\n * Result = [\"user/123\", \"posts/active\"]\n */\nconst getMatchKeys = (\n selectorsKeys: string[],\n keysWithArgs: string[]\n): string[] =>\n keysWithArgs.filter((key) => selectorsKeys.includes(key.split('/')[0]));\n\n/**\n * The reducer function handling all state transitions. It takes the current state and an action,\n * and returns a new state based on the type of the action.\n *\n * Actions include:\n * - SET_QUERY_STATE: Update a single key with partial new state.\n * - MAKE_QUERY_IN_ERROR: Mark a single key as errored and update related flags.\n * - SET_QUERIES_STATE: Update multiple keys at once with partial new state.\n * - RESET_KEY_STATE: Reset certain keys to their default states.\n * - RESET_STATE: Reset all keys to their default states except those excluded.\n */\nconst reducer = <T,>(\n state: AsyncState<T>,\n action: Actions<T>\n): AsyncState<T> => {\n switch (action.type) {\n case 'SET_QUERY_STATE': {\n const { key, value } = action;\n return {\n ...state,\n states: {\n ...state.states,\n [key]: {\n // Merge existing state for the key or default state if not present\n ...(state.states[key] ?? createDefaultStates<T>()),\n ...value,\n },\n },\n };\n }\n case 'MAKE_QUERY_IN_ERROR': {\n const { key, error } = action;\n return {\n ...state,\n states: {\n ...state.states,\n [key]: {\n // Merge existing state or default if not found\n ...(state.states[key] ?? createDefaultStates<T>()),\n // Explicitly set error and related flags\n error,\n isFetched: true,\n isSuccess: false,\n errorCount: (state.states[key]?.errorCount ?? 0) + 1,\n isLoading: false,\n isInvalidated: false,\n },\n },\n };\n }\n case 'SET_QUERIES_STATE': {\n const { keys, value } = action;\n const keyArray = ensureArray(keys);\n if (keyArray.length === 0) return state;\n\n // Update multiple keys in a single action\n const updatedStates = { ...state.states };\n keyArray.forEach((key) => {\n updatedStates[key] = {\n ...(state.states[key] ?? createDefaultStates<T>()),\n ...value,\n };\n });\n\n return {\n ...state,\n states: updatedStates,\n };\n }\n case 'RESET_KEY_STATE': {\n const { keys } = action;\n const keyArray = ensureArray(keys);\n if (keyArray.length === 0) return state;\n\n // Find all keys that match the given selectors\n const allKeys = Object.keys(state.states);\n const matchedKeys = getMatchKeys(keyArray, allKeys);\n if (matchedKeys.length === 0) return state;\n\n // Reset the matched keys back to default states\n const resetStates = { ...state.states };\n matchedKeys.forEach((key) => {\n resetStates[key] = createDefaultStates<T>();\n });\n\n return {\n ...state,\n states: resetStates,\n };\n }\n case 'RESET_STATE': {\n const excludeArray = ensureArray(action.excludeKeys);\n const allKeys = Object.keys(state.states);\n const matchedKeys = getMatchKeys(excludeArray, allKeys);\n\n // Reset all states except those that match the exclude keys\n const newStates: StateSlice<T> = {};\n allKeys.forEach((key) => {\n newStates[key] = matchedKeys.includes(key)\n ? state.states[key]\n : createDefaultStates<T>();\n });\n\n return {\n ...state,\n states: newStates,\n };\n }\n default:\n return state;\n }\n};\n\n/**\n * The context type that will be provided to consumers.\n * It exposes a set of functions for interacting with the asynchronous state:\n * - getStates: Retrieve the current state for a given key.\n * - setQueryState: Partially update a single key's state.\n * - setQueriesState: Partially update multiple keys' states.\n * - makeQueryInError: Set a particular key into an error state.\n * - resetKeyState: Reset certain keys to their default states.\n * - resetState: Reset all keys to their default states except a set of excluded ones.\n */\ntype AsyncStateContextType<T> = {\n getStates: (key: string) => States<T>;\n setQueryState: (key: string, value: Partial<States<T>>) => void;\n setQueriesState: (keys: string[], value: Partial<States<T>>) => void;\n makeQueryInError: (key: string, error: string) => void;\n resetKeyState: (keys: string[]) => void;\n resetState: (excludedKeys: string[]) => void;\n};\n\n/**\n * Creates a React context for asynchronous state management.\n * This context will be provided by the AsyncStateProvider and consumed by hooks like useAsyncState.\n */\nconst AsyncStateContext = createContext<AsyncStateContextType<unknown> | null>(\n null\n);\n\n/**\n * A provider component that wraps its children and provides the asynchronous\n * state context. It uses the reducer to manage states and dispatch actions\n * based on consumer interactions.\n *\n * @param children The React children elements that should have access to this context.\n */\nexport const AsyncStateProvider = ({ children }: PropsWithChildren<{}>) => {\n // Initialize the reducer with an empty state object\n const [asyncState, dispatch] = useReducer(reducer, { states: {} });\n\n /**\n * Retrieve the state associated with a given key. If no state exists for that key,\n * return a default state.\n *\n * @param key The key for which to retrieve the state.\n */\n const getStates = (key: string) =>\n asyncState.states[key] ?? createDefaultStates<unknown>();\n\n /**\n * Partially update the state for a given key.\n *\n * @param key The key to update.\n * @param value A partial state object to merge with the existing state.\n */\n const setQueryState = (key: string, value: Partial<States<unknown>>) => {\n dispatch({ type: 'SET_QUERY_STATE', key, value });\n };\n\n /**\n * Partially update the state for multiple keys at once.\n *\n * @param keys An array of keys to update.\n * @param value A partial state object to merge with each key's existing state.\n */\n const setQueriesState = (keys: string[], value: Partial<States<unknown>>) => {\n dispatch({ type: 'SET_QUERIES_STATE', keys, value });\n };\n\n /**\n * Mark a given query as having encountered an error.\n *\n * @param key The key associated with the query.\n * @param error The error message to set.\n */\n const makeQueryInError = (key: string, error: string) => {\n dispatch({ type: 'MAKE_QUERY_IN_ERROR', key, error });\n };\n\n /**\n * Reset certain keys back to their default states.\n *\n * @param keys The keys to reset.\n */\n const resetKeyState = (keys: string[]) => {\n dispatch({ type: 'RESET_KEY_STATE', keys });\n };\n\n /**\n * Reset the entire state back to defaults, except for keys that match the excluded ones.\n *\n * @param excludedKeys Keys that should not be reset.\n */\n const resetState = (excludedKeys: string[]) => {\n dispatch({ type: 'RESET_STATE', excludeKeys: excludedKeys });\n };\n\n return (\n <AsyncStateContext.Provider\n value={{\n getStates,\n setQueryState,\n setQueriesState,\n makeQueryInError,\n resetKeyState,\n resetState,\n }}\n >\n {children}\n </AsyncStateContext.Provider>\n );\n};\n\n/**\n * A custom hook for accessing the asynchronous state context. It throws an error if used\n * outside of a provider.\n *\n * @returns The asynchronous state context value.\n */\nexport const useAsyncState = () => {\n const context = useContext(AsyncStateContext);\n if (!context) {\n throw new Error('useAsyncState must be used within an AsyncStateProvider');\n }\n return context;\n};\n"],"names":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AAAA,IAEF;AACS,aAAA;AAAA,EAAA;AAEb;AAyBA,MAAM,oBAAoBA,aAAA;AAAA,EACxB;AACF;AASO,MAAM,qBAAqB,CAAC,EAAE,eAAsC;AAEnE,QAAA,CAAC,YAAY,QAAQ,IAAIC,aAAAA,WAAW,SAAS,EAAE,QAAQ,CAAA,GAAI;AAQjE,QAAM,YAAY,CAAC,QACjB,WAAW,OAAO,GAAG,KAAK,oBAA6B;AAQnD,QAAA,gBAAgB,CAAC,KAAa,UAAoC;AACtE,aAAS,EAAE,MAAM,mBAAmB,KAAK,OAAO;AAAA,EAClD;AAQM,QAAA,kBAAkB,CAAC,MAAgB,UAAoC;AAC3E,aAAS,EAAE,MAAM,qBAAqB,MAAM,OAAO;AAAA,EACrD;AAQM,QAAA,mBAAmB,CAAC,KAAa,UAAkB;AACvD,aAAS,EAAE,MAAM,uBAAuB,KAAK,OAAO;AAAA,EACtD;AAOM,QAAA,gBAAgB,CAAC,SAAmB;AACxC,aAAS,EAAE,MAAM,mBAAmB,KAAA,CAAM;AAAA,EAC5C;AAOM,QAAA,aAAa,CAAC,iBAA2B;AAC7C,aAAS,EAAE,MAAM,eAAe,aAAa,cAAc;AAAA,EAC7D;AAGE,SAAAC,2BAAA;AAAA,IAAC,kBAAkB;AAAA,IAAlB;AAAA,MACC,OAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MAEC;AAAA,IAAA;AAAA,EACH;AAEJ;AAQO,MAAM,gBAAgB,MAAM;AAC3B,QAAA,UAAUC,wBAAW,iBAAiB;AAC5C,MAAI,CAAC,SAAS;AACN,UAAA,IAAI,MAAM,yDAAyD;AAAA,EAAA;AAEpE,SAAA;AACT;;;"}
1
+ {"version":3,"file":"useAsyncStateStore.cjs","sources":["../../../src/hooks/useAsync/useAsyncStateStore.tsx"],"sourcesContent":["'use client';\n\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useReducer,\n} from 'react';\n\n/**\n * Represents the states for a given key in the asynchronous state management.\n * This includes flags for loading, fetched, invalidation, and success/error status.\n * It also keeps track of the fetched datetime, retry counts, the data itself, and whether queries are enabled.\n */\ntype States<T> = {\n isLoading: boolean;\n isFetched: boolean;\n isInvalidated: boolean;\n fetchedDateTime: null | Date;\n error: string | null;\n isSuccess: boolean;\n data: T | null;\n errorCount: number;\n isEnabled: boolean;\n};\n\n/**\n * Holds a mapping from a key (string) to its associated state.\n */\ntype StateSlice<T> = {\n [key: string]: States<T>;\n};\n\n/**\n * Describes all the possible actions that can be dispatched to the reducer.\n * These actions allow setting or updating states for specific keys or multiple keys at once,\n * handling errors, and resetting states.\n */\ntype Actions<T> =\n | { type: 'SET_QUERY_STATE'; key: string; value: Partial<States<T>> }\n | { type: 'MAKE_QUERY_IN_ERROR'; key: string; error: string }\n | { type: 'SET_QUERIES_STATE'; keys: string[]; value: Partial<States<T>> }\n | { type: 'RESET_KEY_STATE'; keys: string[] }\n | { type: 'RESET_STATE'; excludeKeys: string[] };\n\n/**\n * The shape of the entire asynchronous state, holding all states in a single object.\n */\ntype AsyncState<T> = {\n states: StateSlice<T>;\n};\n\n/**\n * Creates a default state object with initial values. This is useful when a key\n * has not been initialized yet or when resetting a state back to defaults.\n */\nconst createDefaultStates = <T,>(): States<T> => ({\n isFetched: false,\n fetchedDateTime: null,\n isLoading: false,\n isInvalidated: false,\n error: null,\n isSuccess: false,\n data: null,\n errorCount: 0,\n isEnabled: true,\n});\n\n/**\n * Given a list of selector keys and a list of keys that may contain arguments,\n * this function returns all keys that match the selectors. Matching is determined\n * by comparing the initial part (split by \"/\") of the key.\n *\n * For example:\n * selectorsKeys = [\"user\", \"posts\"]\n * keysWithArgs = [\"user/123\", \"posts/active\", \"comments/42\"]\n * Result = [\"user/123\", \"posts/active\"]\n */\nconst getMatchKeys = (\n selectorsKeys: string[],\n keysWithArgs: string[]\n): string[] =>\n keysWithArgs.filter((key) => selectorsKeys.includes(key.split('/')[0]));\n\n/**\n * The reducer function handling all state transitions. It takes the current state and an action,\n * and returns a new state based on the type of the action.\n *\n * Actions include:\n * - SET_QUERY_STATE: Update a single key with partial new state.\n * - MAKE_QUERY_IN_ERROR: Mark a single key as errored and update related flags.\n * - SET_QUERIES_STATE: Update multiple keys at once with partial new state.\n * - RESET_KEY_STATE: Reset certain keys to their default states.\n * - RESET_STATE: Reset all keys to their default states except those excluded.\n */\nconst reducer = <T,>(\n state: AsyncState<T>,\n action: Actions<T>\n): AsyncState<T> => {\n switch (action.type) {\n case 'SET_QUERY_STATE': {\n const { key, value } = action;\n return {\n ...state,\n states: {\n ...state.states,\n [key]: {\n // Merge existing state for the key or default state if not present\n ...(state.states[key] ?? createDefaultStates<T>()),\n ...value,\n },\n },\n };\n }\n case 'MAKE_QUERY_IN_ERROR': {\n const { key, error } = action;\n return {\n ...state,\n states: {\n ...state.states,\n [key]: {\n // Merge existing state or default if not found\n ...(state.states[key] ?? createDefaultStates<T>()),\n // Explicitly set error and related flags\n error,\n isFetched: true,\n isSuccess: false,\n errorCount: (state.states[key]?.errorCount ?? 0) + 1,\n isLoading: false,\n isInvalidated: false,\n },\n },\n };\n }\n case 'SET_QUERIES_STATE': {\n const { keys, value } = action;\n const keyArray = [keys].flat();\n\n // Find all keys that match the given selectors\n const allKeys = Object.keys(state.states);\n const matchedKeys = getMatchKeys(keyArray, allKeys);\n if (matchedKeys.length === 0) return state;\n\n // Update multiple keys in a single action\n const updatedStates = structuredClone(state.states);\n matchedKeys.forEach((key) => {\n updatedStates[key] = {\n ...(state.states[key] ?? createDefaultStates<T>()),\n ...value,\n };\n });\n\n return {\n ...state,\n states: updatedStates,\n };\n }\n case 'RESET_KEY_STATE': {\n const { keys } = action;\n const keyArray = [keys].flat();\n if (keyArray.length === 0) return state;\n\n // Find all keys that match the given selectors\n const allKeys = Object.keys(state.states);\n const matchedKeys = getMatchKeys(keyArray, allKeys);\n if (matchedKeys.length === 0) return state;\n\n // Reset the matched keys back to default states\n const resetStates = { ...state.states };\n matchedKeys.forEach((key) => {\n resetStates[key] = createDefaultStates<T>();\n });\n\n return {\n ...state,\n states: resetStates,\n };\n }\n case 'RESET_STATE': {\n const excludeArray = [action.excludeKeys].flat();\n const allKeys = Object.keys(state.states);\n\n const matchedKeys = getMatchKeys(excludeArray, allKeys);\n\n // Reset all states except those that match the exclude keys\n const newStates: StateSlice<T> = {};\n allKeys.forEach((key) => {\n newStates[key] = matchedKeys.includes(key)\n ? state.states[key]\n : createDefaultStates<T>();\n });\n\n return {\n ...state,\n states: newStates,\n };\n }\n default:\n return state;\n }\n};\n\n/**\n * The context type that will be provided to consumers.\n * It exposes a set of functions for interacting with the asynchronous state:\n * - getStates: Retrieve the current state for a given key.\n * - setQueryState: Partially update a single key's state.\n * - setQueriesState: Partially update multiple keys' states.\n * - makeQueryInError: Set a particular key into an error state.\n * - resetKeyState: Reset certain keys to their default states.\n * - resetState: Reset all keys to their default states except a set of excluded ones.\n */\ntype AsyncStateContextType<T> = {\n getStates: (key: string) => States<T>;\n setQueryState: (key: string, value: Partial<States<T>>) => void;\n setQueriesState: (keys: string[], value: Partial<States<T>>) => void;\n makeQueryInError: (key: string, error: string) => void;\n resetKeyState: (keys: string[]) => void;\n resetState: (excludedKeys: string[]) => void;\n};\n\n/**\n * Creates a React context for asynchronous state management.\n * This context will be provided by the AsyncStateProvider and consumed by hooks like useAsyncState.\n */\nconst AsyncStateContext = createContext<AsyncStateContextType<unknown> | null>(\n null\n);\n\n/**\n * A provider component that wraps its children and provides the asynchronous\n * state context. It uses the reducer to manage states and dispatch actions\n * based on consumer interactions.\n *\n * @param children The React children elements that should have access to this context.\n */\nexport const AsyncStateProvider = ({ children }: PropsWithChildren<{}>) => {\n // Initialize the reducer with an empty state object\n const [asyncState, dispatch] = useReducer(reducer, { states: {} });\n\n /**\n * Retrieve the state associated with a given key. If no state exists for that key,\n * return a default state.\n *\n * @param key The key for which to retrieve the state.\n */\n const getStates = (key: string) =>\n asyncState.states[key] ?? createDefaultStates<unknown>();\n\n /**\n * Partially update the state for a given key.\n *\n * @param key The key to update.\n * @param value A partial state object to merge with the existing state.\n */\n const setQueryState = (key: string, value: Partial<States<unknown>>) => {\n dispatch({ type: 'SET_QUERY_STATE', key, value });\n };\n\n /**\n * Partially update the state for multiple keys at once.\n *\n * @param keys An array of keys to update.\n * @param value A partial state object to merge with each key's existing state.\n */\n const setQueriesState = (keys: string[], value: Partial<States<unknown>>) => {\n dispatch({ type: 'SET_QUERIES_STATE', keys, value });\n };\n\n /**\n * Mark a given query as having encountered an error.\n *\n * @param key The key associated with the query.\n * @param error The error message to set.\n */\n const makeQueryInError = (key: string, error: string) => {\n dispatch({ type: 'MAKE_QUERY_IN_ERROR', key, error });\n };\n\n /**\n * Reset certain keys back to their default states.\n *\n * @param keys The keys to reset.\n */\n const resetKeyState = (keys: string[]) => {\n dispatch({ type: 'RESET_KEY_STATE', keys });\n };\n\n /**\n * Reset the entire state back to defaults, except for keys that match the excluded ones.\n *\n * @param excludedKeys Keys that should not be reset.\n */\n const resetState = (excludedKeys: string[]) => {\n dispatch({ type: 'RESET_STATE', excludeKeys: excludedKeys });\n };\n\n return (\n <AsyncStateContext.Provider\n value={{\n getStates,\n setQueryState,\n setQueriesState,\n makeQueryInError,\n resetKeyState,\n resetState,\n }}\n >\n {children}\n </AsyncStateContext.Provider>\n );\n};\n\n/**\n * A custom hook for accessing the asynchronous state context. It throws an error if used\n * outside of a provider.\n *\n * @returns The asynchronous state context value.\n */\nexport const useAsyncState = () => {\n const context = useContext(AsyncStateContext);\n if (!context) {\n throw new Error('useAsyncState must be used within an AsyncStateProvider');\n }\n return context;\n};\n"],"names":["createContext","useReducer","jsx","useContext"],"mappings":";;;;;AAwDA,MAAM,sBAAsB,OAAsB;AAAA,EAChD,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,eAAe;AAAA,EACf,OAAO;AAAA,EACP,WAAW;AAAA,EACX,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,WAAW;A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AK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAkLF;;;;;;;;;GASG;AACH,KAAK,qBAAqB,CAAC,CAAC,IAAI;IAC9B,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC;IACtC,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAChE,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACrE,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACxC,UAAU,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC9C,CAAC;AAUF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,iBAAkB,iBAAiB,CAAC,EAAE,CAAC,4CA2ErE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,sCAMzB,CAAC"}
@@ -12,14 +12,6 @@ const createDefaultStates = () => ({
12
12
  errorCount: 0,
13
13
  isEnabled: true
14
14
  });
15
- const ensureArray = (value) => {
16
- if (!value) {
17
- return [];
18
- } else if (Array.isArray(value)) {
19
- return value;
20
- }
21
- return [value];
22
- };
23
15
  const getMatchKeys = (selectorsKeys, keysWithArgs) => keysWithArgs.filter((key) => selectorsKeys.includes(key.split("/")[0]));
24
16
  const reducer = (state, action) => {
25
17
  switch (action.type) {
@@ -59,10 +51,12 @@ const reducer = (state, action) => {
59
51
  }
60
52
  case "SET_QUERIES_STATE": {
61
53
  const { keys, value } = action;
62
- const keyArray = ensureArray(keys);
63
- if (keyArray.length === 0) return state;
64
- const updatedStates = { ...state.states };
65
- keyArray.forEach((key) => {
54
+ const keyArray = [keys].flat();
55
+ const allKeys = Object.keys(state.states);
56
+ const matchedKeys = getMatchKeys(keyArray, allKeys);
57
+ if (matchedKeys.length === 0) return state;
58
+ const updatedStates = structuredClone(state.states);
59
+ matchedKeys.forEach((key) => {
66
60
  updatedStates[key] = {
67
61
  ...state.states[key] ?? createDefaultStates(),
68
62
  ...value
@@ -75,7 +69,7 @@ const reducer = (state, action) => {
75
69
  }
76
70
  case "RESET_KEY_STATE": {
77
71
  const { keys } = action;
78
- const keyArray = ensureArray(keys);
72
+ const keyArray = [keys].flat();
79
73
  if (keyArray.length === 0) return state;
80
74
  const allKeys = Object.keys(state.states);
81
75
  const matchedKeys = getMatchKeys(keyArray, allKeys);
@@ -90,7 +84,7 @@ const reducer = (state, action) => {
90
84
  };
91
85
  }
92
86
  case "RESET_STATE": {
93
- const excludeArray = ensureArray(action.excludeKeys);
87
+ const excludeArray = [action.excludeKeys].flat();
94
88
  const allKeys = Object.keys(state.states);
95
89
  const matchedKeys = getMatchKeys(excludeArray, allKeys);
96
90
  const newStates = {};
@@ -1 +1 @@
1
- {"version":3,"file":"useAsyncStateStore.mjs","sources":["../../../src/hooks/useAsync/useAsyncStateStore.tsx"],"sourcesContent":["'use client';\n\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useReducer,\n} from 'react';\n\n/**\n * Represents the states for a given key in the asynchronous state management.\n * This includes flags for loading, fetched, invalidation, and success/error status.\n * It also keeps track of the fetched datetime, retry counts, the data itself, and whether queries are enabled.\n */\ntype States<T> = {\n isLoading: boolean;\n isFetched: boolean;\n isInvalidated: boolean;\n fetchedDateTime: null | Date;\n error: string | null;\n isSuccess: boolean;\n data: T | null;\n errorCount: number;\n isEnabled: boolean;\n};\n\n/**\n * Holds a mapping from a key (string) to its associated state.\n */\ntype StateSlice<T> = {\n [key: string]: States<T>;\n};\n\n/**\n * Describes all the possible actions that can be dispatched to the reducer.\n * These actions allow setting or updating states for specific keys or multiple keys at once,\n * handling errors, and resetting states.\n */\ntype Actions<T> =\n | { type: 'SET_QUERY_STATE'; key: string; value: Partial<States<T>> }\n | { type: 'MAKE_QUERY_IN_ERROR'; key: string; error: string }\n | { type: 'SET_QUERIES_STATE'; keys: string[]; value: Partial<States<T>> }\n | { type: 'RESET_KEY_STATE'; keys: string[] }\n | { type: 'RESET_STATE'; excludeKeys: string[] };\n\n/**\n * The shape of the entire asynchronous state, holding all states in a single object.\n */\ntype AsyncState<T> = {\n states: StateSlice<T>;\n};\n\n/**\n * Creates a default state object with initial values. This is useful when a key\n * has not been initialized yet or when resetting a state back to defaults.\n */\nconst createDefaultStates = <T,>(): States<T> => ({\n isFetched: false,\n fetchedDateTime: null,\n isLoading: false,\n isInvalidated: false,\n error: null,\n isSuccess: false,\n data: null,\n errorCount: 0,\n isEnabled: true,\n});\n\n/**\n * Ensures that a given value is returned as an array.\n * If the value is undefined or null, returns an empty array.\n * If the value is not already an array, wraps it in one.\n */\nconst ensureArray = <T,>(value?: T | T[]): T[] => {\n if (!value) {\n // If no value is provided, return an empty array\n return [];\n } else if (Array.isArray(value)) {\n // If it's already an array, just return it\n return value;\n }\n // If it's a single value, wrap it in an array\n return [value];\n};\n\n/**\n * Given a list of selector keys and a list of keys that may contain arguments,\n * this function returns all keys that match the selectors. Matching is determined\n * by comparing the initial part (split by \"/\") of the key.\n *\n * For example:\n * selectorsKeys = [\"user\", \"posts\"]\n * keysWithArgs = [\"user/123\", \"posts/active\", \"comments/42\"]\n * Result = [\"user/123\", \"posts/active\"]\n */\nconst getMatchKeys = (\n selectorsKeys: string[],\n keysWithArgs: string[]\n): string[] =>\n keysWithArgs.filter((key) => selectorsKeys.includes(key.split('/')[0]));\n\n/**\n * The reducer function handling all state transitions. It takes the current state and an action,\n * and returns a new state based on the type of the action.\n *\n * Actions include:\n * - SET_QUERY_STATE: Update a single key with partial new state.\n * - MAKE_QUERY_IN_ERROR: Mark a single key as errored and update related flags.\n * - SET_QUERIES_STATE: Update multiple keys at once with partial new state.\n * - RESET_KEY_STATE: Reset certain keys to their default states.\n * - RESET_STATE: Reset all keys to their default states except those excluded.\n */\nconst reducer = <T,>(\n state: AsyncState<T>,\n action: Actions<T>\n): AsyncState<T> => {\n switch (action.type) {\n case 'SET_QUERY_STATE': {\n const { key, value } = action;\n return {\n ...state,\n states: {\n ...state.states,\n [key]: {\n // Merge existing state for the key or default state if not present\n ...(state.states[key] ?? createDefaultStates<T>()),\n ...value,\n },\n },\n };\n }\n case 'MAKE_QUERY_IN_ERROR': {\n const { key, error } = action;\n return {\n ...state,\n states: {\n ...state.states,\n [key]: {\n // Merge existing state or default if not found\n ...(state.states[key] ?? createDefaultStates<T>()),\n // Explicitly set error and related flags\n error,\n isFetched: true,\n isSuccess: false,\n errorCount: (state.states[key]?.errorCount ?? 0) + 1,\n isLoading: false,\n isInvalidated: false,\n },\n },\n };\n }\n case 'SET_QUERIES_STATE': {\n const { keys, value } = action;\n const keyArray = ensureArray(keys);\n if (keyArray.length === 0) return state;\n\n // Update multiple keys in a single action\n const updatedStates = { ...state.states };\n keyArray.forEach((key) => {\n updatedStates[key] = {\n ...(state.states[key] ?? createDefaultStates<T>()),\n ...value,\n };\n });\n\n return {\n ...state,\n states: updatedStates,\n };\n }\n case 'RESET_KEY_STATE': {\n const { keys } = action;\n const keyArray = ensureArray(keys);\n if (keyArray.length === 0) return state;\n\n // Find all keys that match the given selectors\n const allKeys = Object.keys(state.states);\n const matchedKeys = getMatchKeys(keyArray, allKeys);\n if (matchedKeys.length === 0) return state;\n\n // Reset the matched keys back to default states\n const resetStates = { ...state.states };\n matchedKeys.forEach((key) => {\n resetStates[key] = createDefaultStates<T>();\n });\n\n return {\n ...state,\n states: resetStates,\n };\n }\n case 'RESET_STATE': {\n const excludeArray = ensureArray(action.excludeKeys);\n const allKeys = Object.keys(state.states);\n const matchedKeys = getMatchKeys(excludeArray, allKeys);\n\n // Reset all states except those that match the exclude keys\n const newStates: StateSlice<T> = {};\n allKeys.forEach((key) => {\n newStates[key] = matchedKeys.includes(key)\n ? state.states[key]\n : createDefaultStates<T>();\n });\n\n return {\n ...state,\n states: newStates,\n };\n }\n default:\n return state;\n }\n};\n\n/**\n * The context type that will be provided to consumers.\n * It exposes a set of functions for interacting with the asynchronous state:\n * - getStates: Retrieve the current state for a given key.\n * - setQueryState: Partially update a single key's state.\n * - setQueriesState: Partially update multiple keys' states.\n * - makeQueryInError: Set a particular key into an error state.\n * - resetKeyState: Reset certain keys to their default states.\n * - resetState: Reset all keys to their default states except a set of excluded ones.\n */\ntype AsyncStateContextType<T> = {\n getStates: (key: string) => States<T>;\n setQueryState: (key: string, value: Partial<States<T>>) => void;\n setQueriesState: (keys: string[], value: Partial<States<T>>) => void;\n makeQueryInError: (key: string, error: string) => void;\n resetKeyState: (keys: string[]) => void;\n resetState: (excludedKeys: string[]) => void;\n};\n\n/**\n * Creates a React context for asynchronous state management.\n * This context will be provided by the AsyncStateProvider and consumed by hooks like useAsyncState.\n */\nconst AsyncStateContext = createContext<AsyncStateContextType<unknown> | null>(\n null\n);\n\n/**\n * A provider component that wraps its children and provides the asynchronous\n * state context. It uses the reducer to manage states and dispatch actions\n * based on consumer interactions.\n *\n * @param children The React children elements that should have access to this context.\n */\nexport const AsyncStateProvider = ({ children }: PropsWithChildren<{}>) => {\n // Initialize the reducer with an empty state object\n const [asyncState, dispatch] = useReducer(reducer, { states: {} });\n\n /**\n * Retrieve the state associated with a given key. If no state exists for that key,\n * return a default state.\n *\n * @param key The key for which to retrieve the state.\n */\n const getStates = (key: string) =>\n asyncState.states[key] ?? createDefaultStates<unknown>();\n\n /**\n * Partially update the state for a given key.\n *\n * @param key The key to update.\n * @param value A partial state object to merge with the existing state.\n */\n const setQueryState = (key: string, value: Partial<States<unknown>>) => {\n dispatch({ type: 'SET_QUERY_STATE', key, value });\n };\n\n /**\n * Partially update the state for multiple keys at once.\n *\n * @param keys An array of keys to update.\n * @param value A partial state object to merge with each key's existing state.\n */\n const setQueriesState = (keys: string[], value: Partial<States<unknown>>) => {\n dispatch({ type: 'SET_QUERIES_STATE', keys, value });\n };\n\n /**\n * Mark a given query as having encountered an error.\n *\n * @param key The key associated with the query.\n * @param error The error message to set.\n */\n const makeQueryInError = (key: string, error: string) => {\n dispatch({ type: 'MAKE_QUERY_IN_ERROR', key, error });\n };\n\n /**\n * Reset certain keys back to their default states.\n *\n * @param keys The keys to reset.\n */\n const resetKeyState = (keys: string[]) => {\n dispatch({ type: 'RESET_KEY_STATE', keys });\n };\n\n /**\n * Reset the entire state back to defaults, except for keys that match the excluded ones.\n *\n * @param excludedKeys Keys that should not be reset.\n */\n const resetState = (excludedKeys: string[]) => {\n dispatch({ type: 'RESET_STATE', excludeKeys: excludedKeys });\n };\n\n return (\n <AsyncStateContext.Provider\n value={{\n getStates,\n setQueryState,\n setQueriesState,\n makeQueryInError,\n resetKeyState,\n resetState,\n }}\n >\n {children}\n </AsyncStateContext.Provider>\n );\n};\n\n/**\n * A custom hook for accessing the asynchronous state context. It throws an error if used\n * outside of a provider.\n *\n * @returns The asynchronous state context value.\n */\nexport const useAsyncState = () => {\n const context = useContext(AsyncStateContext);\n if (!context) {\n throw new Error('useAsyncState must be used within an AsyncStateProvider');\n }\n return context;\n};\n"],"names":[],"mappings":";;;AAwDA,MAAM,sBAAsB,OAAsB;AAAA,EAChD,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,eAAe;AAAA,EACf,OAAO;AAAA,EACP,WAAW;AAAA,EACX,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,WAAW;AACb;AAOA,MAAM,cAAc,CAAK,UAAyB;AAChD,MAAI,CAAC,OAAO;AAEV,WAAO,CAAC;AAAA,EACC,WAAA,MAAM,QAAQ,KAAK,GAA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AO;AAAA,EAClD;AAQM,QAAA,kBAAkB,CAAC,MAAgB,UAAoC;AAC3E,aAAS,EAAE,MAAM,qBAAqB,MAAM,OAAO;AAAA,EACrD;AAQM,QAAA,mBAAmB,CAAC,KAAa,UAAkB;AACvD,aAAS,EAAE,MAAM,uBAAuB,KAAK,OAAO;AAAA,EACtD;AAOM,QAAA,gBAAgB,CAAC,SAAmB;AACxC,aAAS,EAAE,MAAM,mBAAmB,KAAA,CAAM;AAAA,EAC5C;AAOM,QAAA,aAAa,CAAC,iBAA2B;AAC7C,aAAS,EAAE,MAAM,eAAe,aAAa,cAAc;AAAA,EAC7D;AAGE,SAAA;AAAA,IAAC,kBAAkB;AAAA,IAAlB;AAAA,MACC,OAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MAEC;AAAA,IAAA;AAAA,EACH;AAEJ;AAQO,MAAM,gBAAgB,MAAM;AAC3B,QAAA,UAAU,WAAW,iBAAiB;AAC5C,MAAI,CAAC,SAAS;AACN,UAAA,IAAI,MAAM,yDAAyD;AAAA,EAAA;AAEpE,SAAA;AACT;"}
1
+ {"version":3,"file":"useAsyncStateStore.mjs","sources":["../../../src/hooks/useAsync/useAsyncStateStore.tsx"],"sourcesContent":["'use client';\n\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useReducer,\n} from 'react';\n\n/**\n * Represents the states for a given key in the asynchronous state management.\n * This includes flags for loading, fetched, invalidation, and success/error status.\n * It also keeps track of the fetched datetime, retry counts, the data itself, and whether queries are enabled.\n */\ntype States<T> = {\n isLoading: boolean;\n isFetched: boolean;\n isInvalidated: boolean;\n fetchedDateTime: null | Date;\n error: string | null;\n isSuccess: boolean;\n data: T | null;\n errorCount: number;\n isEnabled: boolean;\n};\n\n/**\n * Holds a mapping from a key (string) to its associated state.\n */\ntype StateSlice<T> = {\n [key: string]: States<T>;\n};\n\n/**\n * Describes all the possible actions that can be dispatched to the reducer.\n * These actions allow setting or updating states for specific keys or multiple keys at once,\n * handling errors, and resetting states.\n */\ntype Actions<T> =\n | { type: 'SET_QUERY_STATE'; key: string; value: Partial<States<T>> }\n | { type: 'MAKE_QUERY_IN_ERROR'; key: string; error: string }\n | { type: 'SET_QUERIES_STATE'; keys: string[]; value: Partial<States<T>> }\n | { type: 'RESET_KEY_STATE'; keys: string[] }\n | { type: 'RESET_STATE'; excludeKeys: string[] };\n\n/**\n * The shape of the entire asynchronous state, holding all states in a single object.\n */\ntype AsyncState<T> = {\n states: StateSlice<T>;\n};\n\n/**\n * Creates a default state object with initial values. This is useful when a key\n * has not been initialized yet or when resetting a state back to defaults.\n */\nconst createDefaultStates = <T,>(): States<T> => ({\n isFetched: false,\n fetchedDateTime: null,\n isLoading: false,\n isInvalidated: false,\n error: null,\n isSuccess: false,\n data: null,\n errorCount: 0,\n isEnabled: true,\n});\n\n/**\n * Given a list of selector keys and a list of keys that may contain arguments,\n * this function returns all keys that match the selectors. Matching is determined\n * by comparing the initial part (split by \"/\") of the key.\n *\n * For example:\n * selectorsKeys = [\"user\", \"posts\"]\n * keysWithArgs = [\"user/123\", \"posts/active\", \"comments/42\"]\n * Result = [\"user/123\", \"posts/active\"]\n */\nconst getMatchKeys = (\n selectorsKeys: string[],\n keysWithArgs: string[]\n): string[] =>\n keysWithArgs.filter((key) => selectorsKeys.includes(key.split('/')[0]));\n\n/**\n * The reducer function handling all state transitions. It takes the current state and an action,\n * and returns a new state based on the type of the action.\n *\n * Actions include:\n * - SET_QUERY_STATE: Update a single key with partial new state.\n * - MAKE_QUERY_IN_ERROR: Mark a single key as errored and update related flags.\n * - SET_QUERIES_STATE: Update multiple keys at once with partial new state.\n * - RESET_KEY_STATE: Reset certain keys to their default states.\n * - RESET_STATE: Reset all keys to their default states except those excluded.\n */\nconst reducer = <T,>(\n state: AsyncState<T>,\n action: Actions<T>\n): AsyncState<T> => {\n switch (action.type) {\n case 'SET_QUERY_STATE': {\n const { key, value } = action;\n return {\n ...state,\n states: {\n ...state.states,\n [key]: {\n // Merge existing state for the key or default state if not present\n ...(state.states[key] ?? createDefaultStates<T>()),\n ...value,\n },\n },\n };\n }\n case 'MAKE_QUERY_IN_ERROR': {\n const { key, error } = action;\n return {\n ...state,\n states: {\n ...state.states,\n [key]: {\n // Merge existing state or default if not found\n ...(state.states[key] ?? createDefaultStates<T>()),\n // Explicitly set error and related flags\n error,\n isFetched: true,\n isSuccess: false,\n errorCount: (state.states[key]?.errorCount ?? 0) + 1,\n isLoading: false,\n isInvalidated: false,\n },\n },\n };\n }\n case 'SET_QUERIES_STATE': {\n const { keys, value } = action;\n const keyArray = [keys].flat();\n\n // Find all keys that match the given selectors\n const allKeys = Object.keys(state.states);\n const matchedKeys = getMatchKeys(keyArray, allKeys);\n if (matchedKeys.length === 0) return state;\n\n // Update multiple keys in a single action\n const updatedStates = structuredClone(state.states);\n matchedKeys.forEach((key) => {\n updatedStates[key] = {\n ...(state.states[key] ?? createDefaultStates<T>()),\n ...value,\n };\n });\n\n return {\n ...state,\n states: updatedStates,\n };\n }\n case 'RESET_KEY_STATE': {\n const { keys } = action;\n const keyArray = [keys].flat();\n if (keyArray.length === 0) return state;\n\n // Find all keys that match the given selectors\n const allKeys = Object.keys(state.states);\n const matchedKeys = getMatchKeys(keyArray, allKeys);\n if (matchedKeys.length === 0) return state;\n\n // Reset the matched keys back to default states\n const resetStates = { ...state.states };\n matchedKeys.forEach((key) => {\n resetStates[key] = createDefaultStates<T>();\n });\n\n return {\n ...state,\n states: resetStates,\n };\n }\n case 'RESET_STATE': {\n const excludeArray = [action.excludeKeys].flat();\n const allKeys = Object.keys(state.states);\n\n const matchedKeys = getMatchKeys(excludeArray, allKeys);\n\n // Reset all states except those that match the exclude keys\n const newStates: StateSlice<T> = {};\n allKeys.forEach((key) => {\n newStates[key] = matchedKeys.includes(key)\n ? state.states[key]\n : createDefaultStates<T>();\n });\n\n return {\n ...state,\n states: newStates,\n };\n }\n default:\n return state;\n }\n};\n\n/**\n * The context type that will be provided to consumers.\n * It exposes a set of functions for interacting with the asynchronous state:\n * - getStates: Retrieve the current state for a given key.\n * - setQueryState: Partially update a single key's state.\n * - setQueriesState: Partially update multiple keys' states.\n * - makeQueryInError: Set a particular key into an error state.\n * - resetKeyState: Reset certain keys to their default states.\n * - resetState: Reset all keys to their default states except a set of excluded ones.\n */\ntype AsyncStateContextType<T> = {\n getStates: (key: string) => States<T>;\n setQueryState: (key: string, value: Partial<States<T>>) => void;\n setQueriesState: (keys: string[], value: Partial<States<T>>) => void;\n makeQueryInError: (key: string, error: string) => void;\n resetKeyState: (keys: string[]) => void;\n resetState: (excludedKeys: string[]) => void;\n};\n\n/**\n * Creates a React context for asynchronous state management.\n * This context will be provided by the AsyncStateProvider and consumed by hooks like useAsyncState.\n */\nconst AsyncStateContext = createContext<AsyncStateContextType<unknown> | null>(\n null\n);\n\n/**\n * A provider component that wraps its children and provides the asynchronous\n * state context. It uses the reducer to manage states and dispatch actions\n * based on consumer interactions.\n *\n * @param children The React children elements that should have access to this context.\n */\nexport const AsyncStateProvider = ({ children }: PropsWithChildren<{}>) => {\n // Initialize the reducer with an empty state object\n const [asyncState, dispatch] = useReducer(reducer, { states: {} });\n\n /**\n * Retrieve the state associated with a given key. If no state exists for that key,\n * return a default state.\n *\n * @param key The key for which to retrieve the state.\n */\n const getStates = (key: string) =>\n asyncState.states[key] ?? createDefaultStates<unknown>();\n\n /**\n * Partially update the state for a given key.\n *\n * @param key The key to update.\n * @param value A partial state object to merge with the existing state.\n */\n const setQueryState = (key: string, value: Partial<States<unknown>>) => {\n dispatch({ type: 'SET_QUERY_STATE', key, value });\n };\n\n /**\n * Partially update the state for multiple keys at once.\n *\n * @param keys An array of keys to update.\n * @param value A partial state object to merge with each key's existing state.\n */\n const setQueriesState = (keys: string[], value: Partial<States<unknown>>) => {\n dispatch({ type: 'SET_QUERIES_STATE', keys, value });\n };\n\n /**\n * Mark a given query as having encountered an error.\n *\n * @param key The key associated with the query.\n * @param error The error message to set.\n */\n const makeQueryInError = (key: string, error: string) => {\n dispatch({ type: 'MAKE_QUERY_IN_ERROR', key, error });\n };\n\n /**\n * Reset certain keys back to their default states.\n *\n * @param keys The keys to reset.\n */\n const resetKeyState = (keys: string[]) => {\n dispatch({ type: 'RESET_KEY_STATE', keys });\n };\n\n /**\n * Reset the entire state back to defaults, except for keys that match the excluded ones.\n *\n * @param excludedKeys Keys that should not be reset.\n */\n const resetState = (excludedKeys: string[]) => {\n dispatch({ type: 'RESET_STATE', excludeKeys: excludedKeys });\n };\n\n return (\n <AsyncStateContext.Provider\n value={{\n getStates,\n setQueryState,\n setQueriesState,\n makeQueryInError,\n resetKeyState,\n resetState,\n }}\n >\n {children}\n </AsyncStateContext.Provider>\n );\n};\n\n/**\n * A custom hook for accessing the asynchronous state context. It throws an error if used\n * outside of a provider.\n *\n * @returns The asynchronous state context value.\n */\nexport const useAsyncState = () => {\n const context = useContext(AsyncStateContext);\n if (!context) {\n throw new Error('useAsyncState must be used within an AsyncStateProvider');\n }\n return context;\n};\n"],"names":[],"mappings":";;;AAwDA,MAAM,sBAAsB,OAAsB;AAAA,EAChD,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,eAAe;AAAA,EACf,OAAO;AAAA,EACP,WAAW;AAAA,EACX,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,WAAW;AACb;AAYA,MAAM,eAAe,CACnB,eACA,iBAEA,aAAa,OAAO,CAAC,QAAQ,cAAc,SAAS,IAAI,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;AAaxE,MAAM,UAAU,CACd,OACA,WACkB;AAClB,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,mBAAmB;AAChB,YAAA,EAAE,KAAK,MAAA,IAAU;AAChB,aAAA;AAAA,QACL,GAAG;AAAA,QACH,QAAQ;AAAA,UACN,GAAG,MAAM;AAAA,UACT,CAAC,GAAG,GAAG;AAAA;AAAA,YAEL,GAAI,MAAM,OAAO,GAAG,KAAK,oB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AA2B;AAC7C,aAAS,EAAE,MAAM,eAAe,aAAa,cAAc;AAAA,EAC7D;AAGE,SAAA;AAAA,IAAC,kBAAkB;AAAA,IAAlB;AAAA,MACC,OAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MAEC;AAAA,IAAA;AAAA,EACH;AAEJ;AAQO,MAAM,gBAAgB,MAAM;AAC3B,QAAA,UAAU,WAAW,iBAAiB;AAC5C,MAAI,CAAC,SAAS;AACN,UAAA,IAAI,MAAM,yDAAyD;AAAA,EAAA;AAEpE,SAAA;AACT;"}
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ const ReactExports = require("react");
5
+ const useKeyboardDetector = () => {
6
+ const [windowHeight, setWindowHeight] = ReactExports.useState(null);
7
+ ReactExports.useEffect(() => {
8
+ const updateHeight = () => {
9
+ const isKeyboardOpen = Boolean(
10
+ window.visualViewport?.height && window.visualViewport.height < window.innerHeight - 100
11
+ );
12
+ if (isKeyboardOpen && window.visualViewport) {
13
+ setWindowHeight(window.visualViewport.height);
14
+ } else {
15
+ setWindowHeight(null);
16
+ }
17
+ };
18
+ window.visualViewport?.addEventListener("resize", updateHeight);
19
+ updateHeight();
20
+ return () => {
21
+ window.visualViewport?.removeEventListener("resize", updateHeight);
22
+ };
23
+ }, []);
24
+ return { windowHeight, isKeyboardOpen: windowHeight !== null };
25
+ };
26
+ exports.useKeyboardDetector = useKeyboardDetector;
27
+ //# sourceMappingURL=useKeyboardDetector.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeyboardDetector.cjs","sources":["../../src/hooks/useKeyboardDetector.ts"],"sourcesContent":["'use client';\n\nimport { useState, useEffect } from 'react';\n\nexport const useKeyboardDetector = () => {\n const [windowHeight, setWindowHeight] = useState<number | null>(null);\n\n useEffect(() => {\n const updateHeight = () => {\n const isKeyboardOpen = Boolean(\n window.visualViewport?.height &&\n window.visualViewport.height < window.innerHeight - 100\n );\n\n if (isKeyboardOpen && window.visualViewport) {\n setWindowHeight(window.visualViewport.height);\n } else {\n setWindowHeight(null);\n }\n };\n\n // Listen for changes in visualViewport height\n window.visualViewport?.addEventListener('resize', updateHeight);\n updateHeight(); // Set initial height\n\n return () => {\n window.visualViewport?.removeEventListener('resize', updateHeight);\n };\n }, []);\n\n return { windowHeight, isKeyboardOpen: windowHeight !== null };\n};\n"],"names":["useState","useEffect"],"mappings":";;;;AAIO,MAAM,sBAAsB,MAAM;AACvC,QAAM,CAAC,cAAc,eAAe,IAAIA,aAAAA,SAAwB,IAAI;AAEpEC,eAAAA,UAAU,MAAM;AACd,UAAM,eAAe,MAAM;AACzB,YAAM,iBAAiB;AAAA,QACrB,OAAO,gBAAgB,UACrB,OAAO,eAAe,SAAS,OAAO,cAAc;AAAA,MACxD;AAEI,UAAA,kBAAkB,OAAO,gBAAgB;AAC3B,wBAAA,OAAO,eAAe,MAAM;AAAA,MAAA,OACvC;AACL,wBAAgB,IAAI;AAAA,MAAA;AAAA,IAExB;AAGO,WAAA,gBAAgB,iBAAiB,UAAU,YAAY;AACjD,iBAAA;AAEb,WAAO,MAAM;AACJ,aAAA,gBAAgB,oBAAoB,UAAU,YAAY;AAAA,IACnE;AAAA,EACF,GAAG,EAAE;AAEL,SAAO,EAAE,cAAc,gBAAgB,iBAAiB,KAAK;AAC/D;;"}
@@ -0,0 +1,5 @@
1
+ export declare const useKeyboardDetector: () => {
2
+ windowHeight: number | null;
3
+ isKeyboardOpen: boolean;
4
+ };
5
+ //# sourceMappingURL=useKeyboardDetector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeyboardDetector.d.ts","sourceRoot":"","sources":["../../src/hooks/useKeyboardDetector.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB;;;CA2B/B,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { useState, useEffect } from "react";
3
+ const useKeyboardDetector = () => {
4
+ const [windowHeight, setWindowHeight] = useState(null);
5
+ useEffect(() => {
6
+ const updateHeight = () => {
7
+ const isKeyboardOpen = Boolean(
8
+ window.visualViewport?.height && window.visualViewport.height < window.innerHeight - 100
9
+ );
10
+ if (isKeyboardOpen && window.visualViewport) {
11
+ setWindowHeight(window.visualViewport.height);
12
+ } else {
13
+ setWindowHeight(null);
14
+ }
15
+ };
16
+ window.visualViewport?.addEventListener("resize", updateHeight);
17
+ updateHeight();
18
+ return () => {
19
+ window.visualViewport?.removeEventListener("resize", updateHeight);
20
+ };
21
+ }, []);
22
+ return { windowHeight, isKeyboardOpen: windowHeight !== null };
23
+ };
24
+ export {
25
+ useKeyboardDetector
26
+ };
27
+ //# sourceMappingURL=useKeyboardDetector.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeyboardDetector.mjs","sources":["../../src/hooks/useKeyboardDetector.ts"],"sourcesContent":["'use client';\n\nimport { useState, useEffect } from 'react';\n\nexport const useKeyboardDetector = () => {\n const [windowHeight, setWindowHeight] = useState<number | null>(null);\n\n useEffect(() => {\n const updateHeight = () => {\n const isKeyboardOpen = Boolean(\n window.visualViewport?.height &&\n window.visualViewport.height < window.innerHeight - 100\n );\n\n if (isKeyboardOpen && window.visualViewport) {\n setWindowHeight(window.visualViewport.height);\n } else {\n setWindowHeight(null);\n }\n };\n\n // Listen for changes in visualViewport height\n window.visualViewport?.addEventListener('resize', updateHeight);\n updateHeight(); // Set initial height\n\n return () => {\n window.visualViewport?.removeEventListener('resize', updateHeight);\n };\n }, []);\n\n return { windowHeight, isKeyboardOpen: windowHeight !== null };\n};\n"],"names":[],"mappings":";;AAIO,MAAM,sBAAsB,MAAM;AACvC,QAAM,CAAC,cAAc,eAAe,IAAI,SAAwB,IAAI;AAEpE,YAAU,MAAM;AACd,UAAM,eAAe,MAAM;AACzB,YAAM,iBAAiB;AAAA,QACrB,OAAO,gBAAgB,UACrB,OAAO,eAAe,SAAS,OAAO,cAAc;AAAA,MACxD;AAEI,UAAA,kBAAkB,OAAO,gBAAgB;AAC3B,wBAAA,OAAO,eAAe,MAAM;AAAA,MAAA,OACvC;AACL,wBAAgB,IAAI;AAAA,MAAA;AAAA,IAExB;AAGO,WAAA,gBAAgB,iBAAiB,UAAU,YAAY;AACjD,iBAAA;AAEb,WAAO,MAAM;AACJ,aAAA,gBAAgB,oBAAoB,UAAU,YAAY;AAAA,IACnE;AAAA,EACF,GAAG,EAAE;AAEL,SAAO,EAAE,cAAc,gBAAgB,iBAAiB,KAAK;AAC/D;"}
@@ -69,7 +69,7 @@ const fetcher = async (url, ...options) => {
69
69
  return await response.json();
70
70
  };
71
71
  const getAiAPI = (authAPIOptions = {}, intlayerConfig) => {
72
- const { backendURL } = getConfiguration().editor;
72
+ const backendURL = getConfiguration().editor.backendURL;
73
73
  const AI_API_ROUTE = `${backendURL}/api/ai`;
74
74
  const auditContentDeclaration = async (body, otherOptions = {}) => await fetcher(
75
75
  `${AI_API_ROUTE}/audit/dictionary`,
@@ -260,7 +260,7 @@ const getAuthAPI = (authAPIOptions = {}, intlayerConfig) => {
260
260
  };
261
261
  getAuthAPI();
262
262
  const getDictionaryAPI = (authAPIOptions = {}, intlayerConfig) => {
263
- const { backendURL } = getConfiguration().editor;
263
+ const backendURL = getConfiguration().editor.backendURL;
264
264
  const PROJECT_API_ROUTE = `${backendURL}/api/dictionary`;
265
265
  const getDictionaries = async (filters, otherOptions = {}) => await fetcher(
266
266
  PROJECT_API_ROUTE,
@@ -359,7 +359,7 @@ const getEditorAPI = (authAPIOptions = {}, intlayerConfig) => {
359
359
  };
360
360
  getEditorAPI();
361
361
  const getOrganizationAPI = (authAPIOptions = {}, intlayerConfig) => {
362
- const { backendURL } = getConfiguration().editor;
362
+ const backendURL = getConfiguration().editor.backendURL;
363
363
  const ORGANIZATION_API_ROUTE = `${backendURL}/api/organization`;
364
364
  const getOrganizations = async (filters, otherOptions = {}) => await fetcher(
365
365
  ORGANIZATION_API_ROUTE,
@@ -448,7 +448,7 @@ const getOrganizationAPI = (authAPIOptions = {}, intlayerConfig) => {
448
448
  };
449
449
  getOrganizationAPI();
450
450
  const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
451
- const { backendURL } = getConfiguration().editor;
451
+ const backendURL = getConfiguration().editor.backendURL;
452
452
  const PROJECT_API_ROUTE = `${backendURL}/api/project`;
453
453
  const getProjects = async (filters, otherOptions = {}) => await fetcher(
454
454
  PROJECT_API_ROUTE,
@@ -586,7 +586,7 @@ const getStripeAPI = (authAPIOptions = {}, intlayerConfig) => {
586
586
  };
587
587
  };
588
588
  const getTagAPI = (authAPIOptions = {}, intlayerConfig) => {
589
- const { backendURL } = getConfiguration().editor;
589
+ const backendURL = getConfiguration().editor.backendURL;
590
590
  const PROJECT_API_ROUTE = `${backendURL}/api/tag`;
591
591
  const getTags = async (filters, otherOptions = {}) => await fetcher(
592
592
  PROJECT_API_ROUTE,
@@ -631,7 +631,7 @@ const getTagAPI = (authAPIOptions = {}, intlayerConfig) => {
631
631
  };
632
632
  getTagAPI();
633
633
  const getUserAPI = (authAPIOptions = {}, intlayerConfig) => {
634
- const { backendURL } = getConfiguration().editor;
634
+ const backendURL = getConfiguration().editor.backendURL;
635
635
  const USER_API_ROUTE = `${backendURL}/api/user`;
636
636
  const getUsers = async (filters, otherOptions = {}) => await fetcher(
637
637
  USER_API_ROUTE,
@@ -708,4 +708,4 @@ const intlayerAPI = getIntlayerAPI();
708
708
  export {
709
709
  intlayerAPI as i
710
710
  };
711
- //# sourceMappingURL=index-BTDHuTxL.js.map
711
+ //# sourceMappingURL=index-B1w5h_6-.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-B1w5h_6-.js","sources":["../../api/src/fetcher.ts","../../api/src/getIntlayerAPI/ai.ts","../../api/src/getIntlayerAPI/auth.ts","../../api/src/getIntlayerAPI/dictionary.ts","../../api/src/getIntlayerAPI/editor.ts","../../api/src/getIntlayerAPI/organization.ts","../../api/src/getIntlayerAPI/project.ts","../../api/src/getIntlayerAPI/stripe.ts","../../api/src/getIntlayerAPI/tag.ts","../../api/src/getIntlayerAPI/user.ts","../../api/src/getIntlayerAPI/index.ts"],"sourcesContent":["/**\n * Type definition for options used in the fetcher function.\n * Extends the standard RequestInit interface (excluding 'body'),\n * and adds 'body' and 'params' properties for convenience.\n */\nexport type FetcherOptions = Omit<RequestInit, 'body'> & {\n /**\n * Body of the request. Should be a key-value pair object.\n */\n body?: Record<string, unknown>;\n /**\n * Query parameters to be appended to the URL.\n */\n params?:\n | Record<string, string | string[] | undefined>\n | string[]\n | URLSearchParams;\n};\n\n/**\n * Default options for the fetcher function.\n * Sets the default method to 'GET', the 'Content-Type' header to 'application/json',\n * and includes credentials in the request.\n */\nexport const fetcherOptions: FetcherOptions = {\n method: 'GET', // Default HTTP method\n headers: {\n 'Content-Type': 'application/json', // Default content type\n },\n credentials: 'include',\n};\n\n/**\n * Utility function to remove properties with undefined values from an object.\n * This helps prevent sending undefined values in the request options.\n *\n * @param obj - The object to clean.\n * @returns The cleaned object without undefined values.\n */\nconst removeUndefined = (obj: object) => {\n Object.keys(obj).forEach((key) => {\n if (obj[key as keyof typeof obj] === undefined) {\n delete obj[key as keyof typeof obj];\n }\n });\n return obj;\n};\n\n/**\n * Deeply merges an array of objects into a single object.\n * Later objects in the array overwrite properties of earlier ones.\n *\n * @template T - The type of objects being merged.\n * @param objects - An array of objects to merge.\n * @returns The merged object.\n */\nconst deepMerge = <T extends object>(objects: (T | undefined)[]): T =>\n objects.reduce((acc, obj) => {\n const acc1: T = (acc ?? {}) as T;\n const obj1: T = removeUndefined(obj ?? {}) as T;\n\n if (typeof acc1 === 'object' && typeof obj1 === 'object') {\n // Merge the two objects\n return { ...acc1, ...obj1 };\n }\n\n // If one of them is not an object, return the defined one\n return obj1 ?? acc1;\n }, {} as T)!;\n\n/**\n * Fetcher function to make HTTP requests.\n * It merges default options with user-provided options,\n * handles query parameters and request body,\n * and returns the parsed JSON response.\n *\n * @template T - The expected type of the response data.\n * @param url - The endpoint URL.\n * @param options - Additional options to customize the request.\n * @returns A promise that resolves with the response data of type T.\n *\n * @example\n * ```typescript\n * // Making a GET request with query parameters\n * const data = await fetcher<MyResponseType>('https://api.example.com/data', {\n * params: { search: 'query' },\n * });\n *\n * // Making a POST request with a JSON body\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * });\n *\n * // Merge body, headers, and params\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * headers: { 'Content-Type': 'application/json' },\n * params: { search: 'query' },\n * },\n * {\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1 },\n * });\n * ```\n *\n * Result:\n * ```typescript\n * {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1, search: 'query' },\n * body: { key: 'value' },\n * }\n * ```\n */\nexport const fetcher = async <T>(\n url: string,\n ...options: FetcherOptions[]\n): Promise<T> => {\n const { signal } = new AbortController();\n\n // Initialize query parameters string and request body string\n let paramsString = '';\n let bodyString: string | undefined = undefined;\n\n // Extract other options excluding 'body', 'params', and 'headers'\n const otherOptions = options.map(\n ({ body, params, headers, ...otherOptions }) => otherOptions\n );\n\n // Merge default options with user-provided options\n const mergedOptions = deepMerge([fetcherOptions, ...otherOptions]);\n\n // Merge default headers with user-provided headers\n const mergedHeaders = deepMerge([\n fetcherOptions.headers,\n ...options.map((option) => option.headers),\n ]);\n\n // Merge query parameters\n const params = deepMerge(options.map((option) => option.params));\n\n const method = mergedOptions.method;\n\n // If the request method is not 'GET' or 'HEAD', prepare the request body\n if (method !== 'GET' && method !== 'HEAD') {\n // Merge all 'body' options\n const body = deepMerge(options.map((option) => option.body));\n if (\n mergedHeaders?.['Content-Type' as keyof HeadersInit] ===\n 'application/x-www-form-urlencoded'\n ) {\n // If the content type is 'application/x-www-form-urlencoded', encode the body accordingly\n bodyString = new URLSearchParams(\n body as Record<string, string>\n ).toString();\n } else {\n // Otherwise, stringify the body as JSON\n bodyString = JSON.stringify(body);\n }\n }\n\n // If there are query parameters, append them to the URL\n if (Object.entries(params).length > 0) {\n paramsString = `?${new URLSearchParams(\n params as Record<string, string>\n ).toString()}`;\n }\n\n // Prepare the final request options\n const formattedOptions: RequestInit = {\n ...mergedOptions,\n headers: mergedHeaders,\n body: bodyString,\n signal,\n };\n\n // Construct the full URL with query parameters\n const urlResult = `${url}${paramsString}`;\n\n // Make the HTTP request using fetch\n const response = await fetch(urlResult, formattedOptions);\n\n if (!response.ok) {\n const result = await response.json();\n\n console.error(result);\n\n // You can customize the error message or include more details\n throw new Error(JSON.stringify(result.error) ?? 'An error occurred');\n }\n return await response.json();\n};\n","import type {\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationFieldBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationFieldResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationMetadataBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationMetadataResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditTagBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditTagResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AskDocQuestionBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AskDocQuestionResult,\n // @ts-ignore: @intlayer/backend is not built yet\n} from '@intlayer/backend';\n\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getAiAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor.backendURL ?? getConfiguration().editor.backendURL;\n const AI_API_ROUTE = `${backendURL}/api/ai`;\n\n /**\n * Audits a content declaration file\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclaration = async (\n body?: AuditContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationResult>(\n `${AI_API_ROUTE}/audit/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a content declaration field\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclarationField = async (\n body?: AuditContentDeclarationFieldBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationFieldResult>(\n `${AI_API_ROUTE}/audit/dictionary/field`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a content declaration file to retrieve title, description and tags\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclarationMetadata = async (\n body?: AuditContentDeclarationMetadataBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationMetadataResult>(\n `${AI_API_ROUTE}/audit/dictionary/metadata`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a tag\n * @param body - Audit tag parameters.\n * @returns Audited tag content.\n */\n const auditTag = async (\n body?: AuditTagBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditTagResult>(\n `${AI_API_ROUTE}/audit/tag`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Asks a question to the AI related to the documentation\n */\n const askDocQuestion = async (\n body?: AskDocQuestionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AskDocQuestionResult>(\n `${AI_API_ROUTE}/ask`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n return {\n auditContentDeclaration,\n auditContentDeclarationField,\n auditContentDeclarationMetadata,\n auditTag,\n askDocQuestion,\n };\n};\n\nexport const userAPI = getAiAPI();\n","import type {\n // @ts-ignore: @intlayer/backend is not built yet\n AskResetPasswordBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AskResetPasswordResult,\n // @ts-ignore: @intlayer/backend is not built yet\n CreateSessionBody,\n // @ts-ignore: @intlayer/backend is not built yet\n CreateSessionResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetSessionInformationQuery,\n // @ts-ignore: @intlayer/backend is not built yet\n GithubLoginQueryParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GoogleLoginQueryParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetSessionInformationResult,\n // @ts-ignore: @intlayer/backend is not built yet\n LoginBody,\n // @ts-ignore: @intlayer/backend is not built yet\n LoginResult,\n // @ts-ignore: @intlayer/backend is not built yet\n RegisterBody,\n // @ts-ignore: @intlayer/backend is not built yet\n RegisterQuery,\n // @ts-ignore: @intlayer/backend is not built yet\n RegisterResult,\n // @ts-ignore: @intlayer/backend is not built yet\n ResetPasswordParams,\n // @ts-ignore: @intlayer/backend is not built yet\n ResetPasswordResult,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdatePasswordBody,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdatePasswordResult,\n // @ts-ignore: @intlayer/backend is not built yet\n ValidEmailParams,\n // @ts-ignore: @intlayer/backend is not built yet\n ValidEmailResult,\n // @ts-ignore: @intlayer/backend is not built yet\n SetCSRFTokenResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetOAuth2TokenBody,\n // @ts-ignore: @intlayer/backend is not built yet\n GetOAuth2TokenResult,\n // @ts-ignore: @intlayer/backend is not built yet\n UserAPI,\n // @ts-ignore: @intlayer/backend is not built yet\n CheckIfUserHasPasswordResult,\n // @ts-ignore @intlayer/backend is not build yet\n} from '@intlayer/backend';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getAuthAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const { backendURL, clientId, clientSecret } = (\n intlayerConfig ?? getConfiguration()\n ).editor;\n const AUTH_API_ROUTE = `${backendURL}/api/auth`;\n\n /**\n * Logs in a user with the provided credentials.\n * @param user - User credentials.\n */\n const login = async (user: LoginBody, otherOptions: FetcherOptions = {}) =>\n await fetcher<LoginResult>(\n `${AUTH_API_ROUTE}/login`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n }\n );\n\n /**\n * Gets the login with GitHub URL.\n * @param params - The parameters for the login with GitHub URL.\n * @returns The login with GitHub URL.\n */\n const getLoginWithGitHubURL = (params: GithubLoginQueryParams): string => {\n const searchParams = new URLSearchParams(params);\n\n return `${AUTH_API_ROUTE}/login/github?${searchParams.toString()}`;\n };\n\n /**\n * Gets the login with Google URL.\n * @param params - The parameters for the login with Google URL.\n * @returns The login with Google URL.\n */\n const getLoginWithGoogleURL = (params: GoogleLoginQueryParams): string => {\n const searchParams = new URLSearchParams(params);\n\n return `${AUTH_API_ROUTE}/login/google?${searchParams.toString()}`;\n };\n\n /**\n * Registers a new user with the provided credentials.\n * @param user - User credentials.\n * @returns User object.\n */\n const register = async (\n user: RegisterBody,\n query: RegisterQuery = {},\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RegisterResult>(\n `${AUTH_API_ROUTE}/register`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n params: query,\n }\n );\n\n /**\n * Signs out the user.\n * @returns User object.\n */\n const logout = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<void>(\n `${AUTH_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Ask to resets the password of a user with the provided email address.\n * @param email - Email address of the user.\n * @returns User object.\n */\n const askResetPassword = async (\n email: AskResetPasswordBody['email'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AskResetPasswordResult>(\n `${AUTH_API_ROUTE}/password/reset`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { email },\n }\n );\n\n /**\n * Resets the password of a user with the provided email address.\n * @param email - Email address of the user.\n * @returns User object.\n */\n const resetPassword = async (\n params: ResetPasswordParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ResetPasswordResult>(\n `${AUTH_API_ROUTE}/password/reset`,\n authAPIOptions,\n otherOptions,\n { params, method: 'POST' }\n );\n\n /**\n * Changes the password of a user with the provided data.\n * @param data - New password and confirmation.\n * @returns User object.\n */\n const changePassword = async (\n data: UpdatePasswordBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdatePasswordResult>(\n `${AUTH_API_ROUTE}/password`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: data,\n }\n );\n\n /**\n * Checks if a user has a password.\n * @param params - User ID.\n * @returns User object.\n */\n const checkIfUserHasPassword = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<CheckIfUserHasPasswordResult>(\n `${AUTH_API_ROUTE}/password/has`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n /**\n * Verifies the email address of a user with the provided token.\n * @param params - User ID and secret key.\n * @returns User object.\n */\n const verifyEmail = async (\n { userId, secret }: ValidEmailParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ValidEmailResult>(\n `${AUTH_API_ROUTE}/active/${userId}/${secret}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Gets the verify email status URL to use in the SSE.\n * @param userId - User ID.\n * @returns The verify email status URL.\n */\n const getVerifyEmailStatusURL = (userId: string | UserAPI['_id']) =>\n `${AUTH_API_ROUTE}/verify-email-status/${String(userId)}`;\n\n /**\n * Creates a session for a user.\n * @param params - User ID and secret key.\n * @returns User object.\n */\n const createSession = async (\n data: CreateSessionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreateSessionResult>(\n `${AUTH_API_ROUTE}/session`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: data,\n }\n );\n\n /**\n * Gets a session and user.\n * @param sessionToken - Session token.\n * @param otherOptions - Fetcher options.\n * @returns Session and user information.\n */\n const getSession = async (\n sessionToken?: GetSessionInformationQuery['session_token'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetSessionInformationResult>(\n `${backendURL}/session`,\n authAPIOptions,\n otherOptions,\n { params: { session_token: sessionToken } }\n );\n\n /**\n * Gets the CSRF token.\n * @param otherOptions - Fetcher options.\n * @returns The CSRF token.\n */\n const getCSRFToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<SetCSRFTokenResult>(\n `${backendURL}/csrf-token`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Gets an oAuth2 accessToken\n * @return The token information\n */\n const getOAuth2AccessToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetOAuth2TokenResult>(\n `${backendURL}/oauth2/token`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: {\n grant_type: 'client_credentials',\n client_id: clientId!,\n client_secret: clientSecret!,\n } satisfies GetOAuth2TokenBody,\n }\n );\n\n return {\n login,\n getLoginWithGitHubURL,\n getLoginWithGoogleURL,\n register,\n logout,\n resetPassword,\n askResetPassword,\n checkIfUserHasPassword,\n verifyEmail,\n getVerifyEmailStatusURL,\n changePassword,\n createSession,\n getSession,\n getCSRFToken,\n getOAuth2AccessToken,\n };\n};\n\nexport const authAPI = getAuthAPI();\n","import type {\n // @ts-ignore: @intlayer/backend is not built yet\n AddDictionaryBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AddDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n DeleteDictionaryParam,\n // @ts-ignore: @intlayer/backend is not built yet\n DeleteDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionariesParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionariesResult,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateDictionaryParam,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateDictionaryBody,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n PushDictionariesBody,\n // @ts-ignore: @intlayer/backend is not built yet\n PushDictionariesResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionaryParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionaryQuery,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionariesKeysResult,\n // @ts-ignore @intlayer/backend is not build yet\n} from '@intlayer/backend';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getDictionaryAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor.backendURL ?? getConfiguration().editor.backendURL;\n const PROJECT_API_ROUTE = `${backendURL}/api/dictionary`;\n\n /**\n * Retrieves a list of dictionaries based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getDictionaries = async (\n filters?: GetDictionariesParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetDictionariesResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n params: filters,\n }\n );\n\n /**\n * Retrieves a list of dictionary keys related to the project.\n */\n const getDictionariesKeys = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetDictionariesKeysResult>(\n `${PROJECT_API_ROUTE}/keys`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Retrieves a dictionary by its key and version.\n * @param dictionaryKey - Dictionary key.\n * @param version - Dictionary version of content.\n */\n const getDictionary = async (\n dictionaryKey: GetDictionaryParams['dictionaryKey'],\n version?: GetDictionaryQuery['version'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetDictionaryResult>(\n `${PROJECT_API_ROUTE}/${dictionaryKey}`,\n authAPIOptions,\n otherOptions,\n {\n params: version ? { version: version.toString() } : undefined,\n }\n );\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const addDictionary = async (\n dictionary: AddDictionaryBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddDictionaryResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { dictionary },\n }\n );\n\n const pushDictionaries = async (\n dictionaries: PushDictionariesBody['dictionaries'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushDictionariesResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { dictionaries },\n }\n );\n\n /**\n * Updates an existing dictionary in the database.\n * @param dictionary - Updated dictionary data.\n */\n const updateDictionary = async (\n dictionaryId: UpdateDictionaryParam['dictionaryId'],\n dictionary: UpdateDictionaryBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateDictionaryResult>(\n `${PROJECT_API_ROUTE}/${dictionaryId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: dictionary,\n }\n );\n\n /**\n * Deletes a dictionary from the database by its ID.\n * @param id - Dictionary ID.\n */\n const deleteDictionary = async (\n id: DeleteDictionaryParam['dictionaryId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteDictionaryResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { id },\n }\n );\n\n return {\n getDictionaries,\n getDictionariesKeys,\n getDictionary,\n pushDictionaries,\n addDictionary,\n updateDictionary,\n deleteDictionary,\n };\n};\n\nexport const dictionaryAPI = getDictionaryAPI();\n","import {\n getConfiguration as getLocaleConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config/client';\nimport type {\n // @ts-ignore: intlayer-editor is not built yet\n GetConfigurationResult,\n // @ts-ignore: intlayer-editor is not built yet\n WriteContentDeclarationBody,\n // @ts-ignore: intlayer-editor is not built yet\n WriteContentDeclarationResult,\n // @ts-ignore: intlayer-editor is not built yet\n} from 'intlayer-editor';\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getEditorAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const { editorURL } = (intlayerConfig ?? getLocaleConfiguration()).editor;\n const EDITOR_API_ROUTE = `${editorURL}/api`;\n\n /**\n * Get the Intlayer configuration\n */\n const getConfiguration = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetConfigurationResult> => {\n const response = await fetcher<GetConfigurationResult>(\n `${EDITOR_API_ROUTE}/config`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data;\n };\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const writeDictionary = async (\n dictionary: WriteContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) => {\n await fetcher<WriteContentDeclarationResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { dictionary },\n }\n );\n };\n\n return {\n getConfiguration,\n writeDictionary,\n };\n};\n\nexport const editorAPI = getEditorAPI();\n","import type {\n // @ts-ignore: @intlayer/backend is not built yet\n AddOrganizationBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AddOrganizationResult,\n // @ts-ignore: @intlayer/backend is not built yet\n DeleteOrganizationResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetOrganizationParam,\n // @ts-ignore: @intlayer/backend is not built yet\n GetOrganizationResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetOrganizationsParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetOrganizationsResult,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateOrganizationBody,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateOrganizationResult,\n // @ts-ignore: @intlayer/backend is not built yet\n SelectOrganizationParam,\n // @ts-ignore: @intlayer/backend is not built yet\n SelectOrganizationResult,\n // @ts-ignore: @intlayer/backend is not built yet\n UnselectOrganizationResult,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateOrganizationMembersBody,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateOrganizationMembersResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AddOrganizationMemberBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AddOrganizationMemberResult,\n // @ts-ignore @intlayer/backend is not build yet\n} from '@intlayer/backend';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getOrganizationAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor.backendURL ?? getConfiguration().editor.backendURL;\n const ORGANIZATION_API_ROUTE = `${backendURL}/api/organization`;\n\n /**\n * Retrieves a list of organizations based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getOrganizations = async (\n filters?: GetOrganizationsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetOrganizationsResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n params: filters,\n }\n );\n\n /**\n * Retrieves an organization by its ID.\n * @param organizationId - Organization ID.\n */\n const getOrganization = async (\n organizationId: GetOrganizationParam['organizationId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/${String(organizationId)}`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Adds a new organization to the database.\n * @param organization - Organization data.\n */\n const addOrganization = async (\n organization: AddOrganizationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: organization,\n }\n );\n\n /**\n * Updates an existing organization in the database.\n * @param organization - Updated organization data.\n */\n const updateOrganization = async (\n organization: UpdateOrganizationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: organization,\n }\n );\n\n /**\n * Update members to the organization in the database.\n * @param body - Updated organization members data.\n */\n const updateOrganizationMembers = async (\n body: UpdateOrganizationMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationMembersResult>(\n `${ORGANIZATION_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /**\n * Add member to the organization in the database.\n * @param body - Updated organization members data.\n */\n const addOrganizationMember = async (\n body: AddOrganizationMemberBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<AddOrganizationMemberResult>(\n `${ORGANIZATION_API_ROUTE}/member`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Deletes an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const deleteOrganization = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Select an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const selectOrganization = async (\n organizationId: SelectOrganizationParam['organizationId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/${String(organizationId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const unselectOrganization = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n return {\n getOrganizations,\n getOrganization,\n addOrganization,\n addOrganizationMember,\n updateOrganization,\n updateOrganizationMembers,\n deleteOrganization,\n selectOrganization,\n unselectOrganization,\n };\n};\n\nexport const organizationAPI = getOrganizationAPI();\n","import type {\n // @ts-ignore: @intlayer/backend is not built yet\n AddProjectBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AddProjectResult,\n // @ts-ignore: @intlayer/backend is not built yet\n DeleteProjectResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetProjectsParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetProjectsResult,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateProjectBody,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateProjectResult,\n // @ts-ignore: @intlayer/backend is not built yet\n SelectProjectParam,\n // @ts-ignore: @intlayer/backend is not built yet\n SelectProjectResult,\n // @ts-ignore: @intlayer/backend is not built yet\n UnselectProjectResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AddNewAccessKeyBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AddNewAccessKeyResponse,\n // @ts-ignore: @intlayer/backend is not built yet\n DeleteAccessKeyBody,\n // @ts-ignore: @intlayer/backend is not built yet\n DeleteAccessKeyResponse,\n // @ts-ignore: @intlayer/backend is not built yet\n RefreshAccessKeyBody,\n // @ts-ignore: @intlayer/backend is not built yet\n RefreshAccessKeyResponse,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateProjectMembersBody,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateProjectMembersResult,\n // @ts-ignore @intlayer/backend is not build yet\n PushProjectConfigurationBody,\n // @ts-ignore @intlayer/backend is not build yet\n PushProjectConfigurationResult,\n // @ts-ignore @intlayer/backend is not build yet\n} from '@intlayer/backend';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor.backendURL ?? getConfiguration().editor.backendURL;\n const PROJECT_API_ROUTE = `${backendURL}/api/project`;\n\n /**\n * Retrieves a list of projects based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getProjects = async (\n filters?: GetProjectsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetProjectsResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n params: filters,\n }\n );\n\n /**\n * Adds a new project to the database.\n * @param project - Project data.\n */\n const addProject = async (\n project: AddProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: project,\n }\n );\n\n /**\n * Updates an existing project in the database.\n * @param project - Updated project data.\n */\n const updateProject = async (\n project: UpdateProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: project,\n }\n );\n\n /**\n * Updates project members in the database.\n * @param project - Updated project data.\n */\n const updateProjectMembers = async (\n body: UpdateProjectMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectMembersResult>(\n `${PROJECT_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /** Pushes a project configuration to the database.\n * @param projectConfiguration - Project configuration data.\n */\n const pushProjectConfiguration = async (\n projectConfiguration: PushProjectConfigurationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushProjectConfigurationResult>(\n `${PROJECT_API_ROUTE}/configuration`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: projectConfiguration,\n }\n );\n\n /**\n * Deletes a project from the database by its ID.\n * @param id - Project ID.\n */\n const deleteProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n `${PROJECT_API_ROUTE}/${String(projectId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n `${PROJECT_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { clientId },\n }\n );\n\n return {\n getProjects,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n };\n};\n\nexport const projectAPI = getProjectAPI();\n","import type {\n // @ts-ignore: @intlayer/backend is not built yet\n GetCheckoutSessionBody,\n // @ts-ignore: @intlayer/backend is not built yet\n GetCheckoutSessionResult,\n // @ts-ignore @intlayer/backend is not build yet\n} from '@intlayer/backend';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getStripeAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = (intlayerConfig ?? getConfiguration()).editor.backendURL;\n const STRIPE_API_ROUTE = `${backendURL}/api/stripe`;\n\n /**\n * Retrieves a checkout session.\n * @param body - Checkout session body.\n */\n const getSubscription = async (\n body?: GetCheckoutSessionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetCheckoutSessionResult>(\n `${STRIPE_API_ROUTE}/create-subscription`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Cancels a subscription.\n * @param body - Checkout session body.\n */\n const cancelSubscription = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetCheckoutSessionResult>(\n `${STRIPE_API_ROUTE}/cancel-subscription`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n return {\n getSubscription,\n cancelSubscription,\n };\n};\n","import type {\n // @ts-ignore: @intlayer/backend is not built yet\n AddTagBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AddTagResult,\n // @ts-ignore: @intlayer/backend is not built yet\n DeleteTagParams,\n // @ts-ignore: @intlayer/backend is not built yet\n DeleteTagResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetTagsParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetTagsResult,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateTagBody,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateTagParams,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateTagResult,\n // @ts-ignore @intlayer/backend is not build yet\n} from '@intlayer/backend';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getTagAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor.backendURL ?? getConfiguration().editor.backendURL;\n const PROJECT_API_ROUTE = `${backendURL}/api/tag`;\n\n /**\n * Retrieves a list of tags based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getTags = async (\n filters?: GetTagsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetTagsResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n params: filters,\n }\n );\n\n /**\n * Adds a new tag to the database.\n * @param tag - Tag data.\n */\n const addTag = async (tag: AddTagBody, otherOptions: FetcherOptions = {}) =>\n await fetcher<AddTagResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: tag,\n }\n );\n\n /**\n * Updates an existing tag in the database.\n * @param tag - Updated tag data.\n */\n const updateTag = async (\n tagId: UpdateTagParams['tagId'],\n tag: UpdateTagBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateTagResult>(\n `${PROJECT_API_ROUTE}/${tagId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: tag,\n }\n );\n\n /**\n * Deletes a tag from the database by its ID.\n * @param tagId - Tag ID.\n */\n const deleteTag = async (\n tagId: DeleteTagParams['tagId'],\n\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteTagResult>(\n `${PROJECT_API_ROUTE}/${tagId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n return {\n getTags,\n addTag,\n updateTag,\n deleteTag,\n };\n};\n\nexport const tagAPI = getTagAPI();\n","import type {\n // @ts-ignore: @intlayer/backend is not built yet\n CreateUserBody,\n // @ts-ignore: @intlayer/backend is not built yet\n CreateUserResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetUserByAccountParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetUserByAccountResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetUserByEmailParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetUserByEmailResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetUserByIdParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetUserByIdResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetUsersParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetUsersResult,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateUserBody,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateUserResult,\n // @ts-ignore @intlayer/backend is not build yet\n} from '@intlayer/backend';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getUserAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor.backendURL ?? getConfiguration().editor.backendURL;\n const USER_API_ROUTE = `${backendURL}/api/user`;\n\n /**\n * Retrieves a list of users based on filters and pagination.\n * @param filters - Filters and pagination options.\n * @returns List of users.\n */\n const getUsers = async (\n filters?: GetUsersParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUsersResult>(\n USER_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n params: filters,\n }\n );\n\n /**\n * Retrieves a user by ID.\n * @param userId - User ID.\n * @returns User object.\n */\n const getUserById = async (\n userId: GetUserByIdParams['userId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByIdResult>(\n `${USER_API_ROUTE}/${userId}`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Retrieves a user by email.\n * @param email - User email.\n * @returns User object.\n */\n const getUserByEmail = async (\n email: GetUserByEmailParams['email'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByEmailResult>(\n `${USER_API_ROUTE}/email/${email}`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Retrieves a user by account.\n * @param providerAccountId - The provider account ID.\n * @param provider - The provider of the account.\n */\n const getUserByAccount = async (\n providerAccountId: GetUserByAccountParams['providerAccountId'],\n provider: GetUserByAccountParams['provider'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByAccountResult>(\n `${USER_API_ROUTE}/account/${provider}/${providerAccountId}`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Creates a new user.\n * @param user - User credentials.\n * @returns User object.\n */\n const createUser = async (\n user: CreateUserBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreateUserResult>(\n `${USER_API_ROUTE}/`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n }\n );\n\n /**\n * Updates the user with the provided data.\n * @param user - Updated user data.\n * @returns User object.\n */\n const updateUser = async (\n user: UpdateUserBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateUserResult>(\n `${USER_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: user,\n }\n );\n\n /**\n * Deletes a user with the provided ID.\n * @param userId - User ID.\n * @returns User object.\n */\n const deleteUser = async (\n userId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateUserResult>(\n `${USER_API_ROUTE}/${userId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n return {\n createUser,\n getUsers,\n getUserById,\n getUserByAccount,\n getUserByEmail,\n updateUser,\n deleteUser,\n };\n};\n\nexport const userAPI = getUserAPI();\n","import { type IntlayerConfig } from '@intlayer/config/client';\nimport type { FetcherOptions } from '../fetcher';\nimport { getAiAPI } from './ai';\nimport { getAuthAPI } from './auth';\nimport { getDictionaryAPI } from './dictionary';\nimport { getEditorAPI } from './editor';\nimport { getOrganizationAPI } from './organization';\nimport { getProjectAPI } from './project';\nimport { getStripeAPI } from './stripe';\nimport { getTagAPI } from './tag';\nimport { getUserAPI } from './user';\n\nexport const getIntlayerAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => ({\n organization: getOrganizationAPI(authAPIOptions, intlayerConfig),\n project: getProjectAPI(authAPIOptions, intlayerConfig),\n user: getUserAPI(authAPIOptions, intlayerConfig),\n auth: getAuthAPI(authAPIOptions, intlayerConfig),\n dictionary: getDictionaryAPI(authAPIOptions, intlayerConfig),\n stripe: getStripeAPI(authAPIOptions, intlayerConfig),\n ai: getAiAPI(authAPIOptions, intlayerConfig),\n tag: getTagAPI(authAPIOptions, intlayerConfig),\n editor: getEditorAPI(authAPIOptions, intlayerConfig),\n});\n\nexport const intlayerAPI = getIntlayerAPI();\n"],"names":["params","otherOptions","getLocaleConfiguration","getConfiguration"],"mappings":";AAwBO,MAAM,iBAAiC;AAAA,EAC5C,QAAQ;AAAA;AAAA,EACR,SAAS;AAAA,IACP,gBAAgB;AAAA;AAAA,EAClB;AAAA,EACA,aAAa;AACf;AASA,MAAM,kBAAkB,CAAC,QAAgB;AACvC,SAAO,KAAK,GAAG,EAAE,QAAQ,CAAC,QAAQ;AAC5B,QAAA,IAAI,GAAuB,MAAM,QAAW;AAC9C,aAAO,IAAI,GAAuB;AAAA,IAAA;AAAA,EACpC,CACD;AACM,SAAA;AACT;AAUA,MAAM,YAAY,CAAmB,YACnC,QAAQ,OAAO,CAAC,KAAK,QAAQ;AACrB,QAAA,OAAW,OAAO,CAAC;AACzB,QAAM,OAAU,gBAAgB,OAAO,EAAE;AAEzC,MAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU;AAExD,WAAO,EAAE,GAAG,MAA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;AAAA,IAAA;AAAA,EAEZ;AAEK,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEuB,WAAW;AC7J3B,MAAM,iBAAiB,CAC5B,iBAAiC,IACjC,oBACI;AAAA,EACJ,cAAc,mBAAmB,cAA8B;AAAA,EAC/D,SAAS,cAAc,cAA8B;AAAA,EACrD,MAAM,WAAW,cAA8B;AAAA,EAC/C,MAAM,WAAW,cAA8B;AAAA,EAC/C,YAAY,iBAAiB,cAA8B;AAAA,EAC3D,QAAQ,aAAa,cAA8B;AAAA,EACnD,IAAI,SAAS,cAA8B;AAAA,EAC3C,KAAK,UAAU,cAA8B;AAAA,EAC7C,QAAQ,aAAa,cAA8B;AACrD;AAEO,MAAM,cAAc,eAAe;"}
@@ -70,7 +70,7 @@ const fetcher = async (url, ...options) => {
70
70
  return await response.json();
71
71
  };
72
72
  const getAiAPI = (authAPIOptions = {}, intlayerConfig) => {
73
- const { backendURL } = client.getConfiguration().editor;
73
+ const backendURL = client.getConfiguration().editor.backendURL;
74
74
  const AI_API_ROUTE = `${backendURL}/api/ai`;
75
75
  const auditContentDeclaration = async (body, otherOptions = {}) => await fetcher(
76
76
  `${AI_API_ROUTE}/audit/dictionary`,
@@ -261,7 +261,7 @@ const getAuthAPI = (authAPIOptions = {}, intlayerConfig) => {
261
261
  };
262
262
  getAuthAPI();
263
263
  const getDictionaryAPI = (authAPIOptions = {}, intlayerConfig) => {
264
- const { backendURL } = client.getConfiguration().editor;
264
+ const backendURL = client.getConfiguration().editor.backendURL;
265
265
  const PROJECT_API_ROUTE = `${backendURL}/api/dictionary`;
266
266
  const getDictionaries = async (filters, otherOptions = {}) => await fetcher(
267
267
  PROJECT_API_ROUTE,
@@ -360,7 +360,7 @@ const getEditorAPI = (authAPIOptions = {}, intlayerConfig) => {
360
360
  };
361
361
  getEditorAPI();
362
362
  const getOrganizationAPI = (authAPIOptions = {}, intlayerConfig) => {
363
- const { backendURL } = client.getConfiguration().editor;
363
+ const backendURL = client.getConfiguration().editor.backendURL;
364
364
  const ORGANIZATION_API_ROUTE = `${backendURL}/api/organization`;
365
365
  const getOrganizations = async (filters, otherOptions = {}) => await fetcher(
366
366
  ORGANIZATION_API_ROUTE,
@@ -449,7 +449,7 @@ const getOrganizationAPI = (authAPIOptions = {}, intlayerConfig) => {
449
449
  };
450
450
  getOrganizationAPI();
451
451
  const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
452
- const { backendURL } = client.getConfiguration().editor;
452
+ const backendURL = client.getConfiguration().editor.backendURL;
453
453
  const PROJECT_API_ROUTE = `${backendURL}/api/project`;
454
454
  const getProjects = async (filters, otherOptions = {}) => await fetcher(
455
455
  PROJECT_API_ROUTE,
@@ -587,7 +587,7 @@ const getStripeAPI = (authAPIOptions = {}, intlayerConfig) => {
587
587
  };
588
588
  };
589
589
  const getTagAPI = (authAPIOptions = {}, intlayerConfig) => {
590
- const { backendURL } = client.getConfiguration().editor;
590
+ const backendURL = client.getConfiguration().editor.backendURL;
591
591
  const PROJECT_API_ROUTE = `${backendURL}/api/tag`;
592
592
  const getTags = async (filters, otherOptions = {}) => await fetcher(
593
593
  PROJECT_API_ROUTE,
@@ -632,7 +632,7 @@ const getTagAPI = (authAPIOptions = {}, intlayerConfig) => {
632
632
  };
633
633
  getTagAPI();
634
634
  const getUserAPI = (authAPIOptions = {}, intlayerConfig) => {
635
- const { backendURL } = client.getConfiguration().editor;
635
+ const backendURL = client.getConfiguration().editor.backendURL;
636
636
  const USER_API_ROUTE = `${backendURL}/api/user`;
637
637
  const getUsers = async (filters, otherOptions = {}) => await fetcher(
638
638
  USER_API_ROUTE,
@@ -707,4 +707,4 @@ const getIntlayerAPI = (authAPIOptions = {}, intlayerConfig) => ({
707
707
  });
708
708
  const intlayerAPI = getIntlayerAPI();
709
709
  exports.intlayerAPI = intlayerAPI;
710
- //# sourceMappingURL=index-Db5Dym4h.cjs.map
710
+ //# sourceMappingURL=index-U1U6ySIn.cjs.map