@intlayer/design-system 3.5.5 → 3.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.vite/manifest.json +297 -54
- package/dist/CodeBlockShiki-BlmZyrr7.cjs +29 -0
- package/dist/CodeBlockShiki-BlmZyrr7.cjs.map +1 -0
- package/dist/CodeBlockShiki-CcpV9SVi.js +29 -0
- package/dist/CodeBlockShiki-CcpV9SVi.js.map +1 -0
- package/dist/Form-0D7KBafQ.cjs +311 -0
- package/dist/Form-0D7KBafQ.cjs.map +1 -0
- package/dist/Form-7BqwvjVI.cjs +320 -0
- package/dist/Form-7BqwvjVI.cjs.map +1 -0
- package/dist/Form-B2UufQRJ.cjs +319 -0
- package/dist/Form-B2UufQRJ.cjs.map +1 -0
- package/dist/Form-BB0kpER9.cjs +301 -0
- package/dist/Form-BB0kpER9.cjs.map +1 -0
- package/dist/Form-BDcoNTLV.cjs.map +1 -1
- package/dist/Form-BTogr-fp.js +312 -0
- package/dist/Form-BTogr-fp.js.map +1 -0
- package/dist/Form-BVkkvSKP.js +312 -0
- package/dist/Form-BVkkvSKP.js.map +1 -0
- package/dist/Form-Be6Uhb5-.js +312 -0
- package/dist/Form-Be6Uhb5-.js.map +1 -0
- package/dist/Form-BmQQnl-6.js +312 -0
- package/dist/Form-BmQQnl-6.js.map +1 -0
- package/dist/Form-Bp_ubH9I.cjs +311 -0
- package/dist/Form-Bp_ubH9I.cjs.map +1 -0
- package/dist/Form-BtqRbgLu.cjs +311 -0
- package/dist/Form-BtqRbgLu.cjs.map +1 -0
- package/dist/Form-COVZyto7.cjs +311 -0
- package/dist/Form-COVZyto7.cjs.map +1 -0
- package/dist/Form-CVD_3nCD.js +312 -0
- package/dist/Form-CVD_3nCD.js.map +1 -0
- package/dist/Form-Cfklj1_H.js +320 -0
- package/dist/Form-Cfklj1_H.js.map +1 -0
- package/dist/Form-ClAAiVNm.cjs +311 -0
- package/dist/Form-ClAAiVNm.cjs.map +1 -0
- package/dist/Form-DGLgTAdY.js +302 -0
- package/dist/Form-DGLgTAdY.js.map +1 -0
- package/dist/Form-DhsgC7kB.js.map +1 -1
- package/dist/Form-OK9zfg6E.js +321 -0
- package/dist/Form-OK9zfg6E.js.map +1 -0
- package/dist/components/Accordion/Accordion.cjs +7 -15
- package/dist/components/Accordion/Accordion.cjs.map +1 -1
- package/dist/components/Accordion/Accordion.d.ts +0 -1
- package/dist/components/Accordion/Accordion.d.ts.map +1 -1
- package/dist/components/Accordion/Accordion.mjs +8 -16
- package/dist/components/Accordion/Accordion.mjs.map +1 -1
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.cjs +1 -1
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.mjs +1 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.cjs +1 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.mjs +1 -1
- package/dist/components/Auth/SignInForm/SignInForm.cjs +1 -1
- package/dist/components/Auth/SignInForm/SignInForm.mjs +1 -1
- package/dist/components/Auth/SignUpForm/SignUpForm.cjs +1 -1
- package/dist/components/Auth/SignUpForm/SignUpForm.mjs +1 -1
- package/dist/components/Auth/SignUpForm/signUpForm.content.d.ts +11 -11
- package/dist/components/Breadcrumb/index.cjs +5 -2
- package/dist/components/Breadcrumb/index.cjs.map +1 -1
- package/dist/components/Breadcrumb/index.d.ts.map +1 -1
- package/dist/components/Breadcrumb/index.mjs +5 -2
- package/dist/components/Breadcrumb/index.mjs.map +1 -1
- package/dist/components/Button/Button.cjs +47 -25
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.d.ts +2 -0
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.mjs +47 -25
- package/dist/components/Button/Button.mjs.map +1 -1
- package/dist/components/ClickOutsideDiv/index.cjs +26 -0
- package/dist/components/ClickOutsideDiv/index.cjs.map +1 -0
- package/dist/components/ClickOutsideDiv/index.d.ts +6 -0
- package/dist/components/ClickOutsideDiv/index.d.ts.map +1 -0
- package/dist/components/ClickOutsideDiv/index.mjs +26 -0
- package/dist/components/ClickOutsideDiv/index.mjs.map +1 -0
- package/dist/components/Container/index.cjs +1 -1
- package/dist/components/Container/index.cjs.map +1 -1
- package/dist/components/Container/index.mjs +1 -1
- package/dist/components/Container/index.mjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditorCode.cjs +78 -0
- package/dist/components/ContentEditor/ContentEditorCode.cjs.map +1 -0
- package/dist/components/ContentEditor/ContentEditorCode.d.ts +11 -0
- package/dist/components/ContentEditor/ContentEditorCode.d.ts.map +1 -0
- package/dist/components/ContentEditor/ContentEditorCode.mjs +78 -0
- package/dist/components/ContentEditor/ContentEditorCode.mjs.map +1 -0
- package/dist/components/ContentEditor/ContentEditorTextArea.cjs +30 -26
- package/dist/components/ContentEditor/ContentEditorTextArea.cjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditorTextArea.d.ts +2 -1
- package/dist/components/ContentEditor/ContentEditorTextArea.d.ts.map +1 -1
- package/dist/components/ContentEditor/ContentEditorTextArea.mjs +30 -26
- package/dist/components/ContentEditor/ContentEditorTextArea.mjs.map +1 -1
- package/dist/components/CopyToClipboard/index.cjs +1 -1
- package/dist/components/CopyToClipboard/index.cjs.map +1 -1
- package/dist/components/CopyToClipboard/index.d.ts.map +1 -1
- package/dist/components/CopyToClipboard/index.mjs +1 -1
- package/dist/components/CopyToClipboard/index.mjs.map +1 -1
- package/dist/components/DictionaryEditor/ItemLayout.cjs +0 -1
- package/dist/components/DictionaryEditor/ItemLayout.cjs.map +1 -1
- package/dist/components/DictionaryEditor/ItemLayout.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/ItemLayout.mjs +0 -1
- package/dist/components/DictionaryEditor/ItemLayout.mjs.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs +4 -4
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs +4 -4
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs +5 -3
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts +2 -0
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs +5 -3
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +162 -70
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +164 -72
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs +123 -0
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts +14 -0
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs +123 -0
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.cjs +9 -2
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.content.cjs +15 -0
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.content.d.ts +1 -0
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.content.mjs +15 -0
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.d.ts +6 -0
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.mjs +9 -2
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +13 -5
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts +2 -0
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +13 -5
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs +8 -6
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.d.ts +2 -0
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs +8 -6
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs +129 -66
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.d.ts +4 -2
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs +128 -65
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/JSONEditor.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/JSONEditor.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/LocaleSelector/LocaleSelector.d.ts +8 -0
- package/dist/components/DictionaryFieldEditor/LocaleSelector/LocaleSelector.d.ts.map +1 -0
- package/dist/components/DictionaryFieldEditor/LocaleSelector/LocaleSelectorContext.d.ts +13 -0
- package/dist/components/DictionaryFieldEditor/LocaleSelector/LocaleSelectorContext.d.ts.map +1 -0
- package/dist/components/DictionaryFieldEditor/LocaleSelector/localeSelector.content.d.ts +9 -0
- package/dist/components/DictionaryFieldEditor/LocaleSelector/localeSelector.content.d.ts.map +1 -0
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +15 -19
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +15 -19
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeEditor.cjs +24 -11
- package/dist/components/DictionaryFieldEditor/NodeEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeEditor.d.ts +2 -0
- package/dist/components/DictionaryFieldEditor/NodeEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeEditor.mjs +24 -11
- package/dist/components/DictionaryFieldEditor/NodeEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs +2 -2
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs +2 -2
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +3 -5
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +4 -6
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs +13 -13
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs +13 -13
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcher.cjs +73 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcher.cjs.map +1 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcher.d.ts +7 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcher.d.ts.map +1 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcher.mjs +73 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcher.mjs.map +1 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.cjs +37 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.cjs.map +1 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.d.ts +14 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.d.ts.map +1 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.mjs +37 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.mjs.map +1 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/index.cjs +8 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/index.cjs.map +1 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/index.d.ts +3 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/index.d.ts.map +1 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/index.mjs +8 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/index.mjs.map +1 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.cjs +54 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.cjs.map +1 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.d.ts +10 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.d.ts.map +1 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.mjs +55 -0
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.mjs.map +1 -0
- package/dist/components/DictionaryFieldEditor/index.cjs +5 -0
- package/dist/components/DictionaryFieldEditor/index.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/index.d.ts +1 -0
- package/dist/components/DictionaryFieldEditor/index.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/index.mjs +6 -1
- package/dist/components/DictionaryFieldEditor/index.mjs.map +1 -1
- package/dist/components/EditableField/EditableFieldInput.cjs +5 -1
- package/dist/components/EditableField/EditableFieldInput.cjs.map +1 -1
- package/dist/components/EditableField/EditableFieldInput.d.ts.map +1 -1
- package/dist/components/EditableField/EditableFieldInput.mjs +6 -2
- package/dist/components/EditableField/EditableFieldInput.mjs.map +1 -1
- package/dist/components/EditableField/EditableFieldTextArea.cjs +2 -8
- package/dist/components/EditableField/EditableFieldTextArea.cjs.map +1 -1
- package/dist/components/EditableField/EditableFieldTextArea.d.ts.map +1 -1
- package/dist/components/EditableField/EditableFieldTextArea.mjs +2 -8
- package/dist/components/EditableField/EditableFieldTextArea.mjs.map +1 -1
- package/dist/components/Form/Form.cjs +1 -1
- package/dist/components/Form/Form.d.ts +2 -0
- package/dist/components/Form/Form.d.ts.map +1 -1
- package/dist/components/Form/Form.mjs +1 -1
- package/dist/components/Form/FormLabel.cjs +6 -2
- package/dist/components/Form/FormLabel.cjs.map +1 -1
- package/dist/components/Form/FormLabel.d.ts.map +1 -1
- package/dist/components/Form/FormLabel.mjs +6 -2
- package/dist/components/Form/FormLabel.mjs.map +1 -1
- package/dist/components/Form/elements/AutoSizeTextAreaElement.cjs +7 -0
- package/dist/components/Form/elements/AutoSizeTextAreaElement.cjs.map +1 -0
- package/dist/components/Form/elements/AutoSizeTextAreaElement.d.ts +9 -0
- package/dist/components/Form/elements/AutoSizeTextAreaElement.d.ts.map +1 -0
- package/dist/components/Form/elements/AutoSizeTextAreaElement.mjs +7 -0
- package/dist/components/Form/elements/AutoSizeTextAreaElement.mjs.map +1 -0
- package/dist/components/Form/elements/CheckboxElement.cjs +1 -1
- package/dist/components/Form/elements/CheckboxElement.mjs +1 -1
- package/dist/components/Form/elements/EditableFieldInputElement.cjs +1 -1
- package/dist/components/Form/elements/EditableFieldInputElement.d.ts +1 -1
- package/dist/components/Form/elements/EditableFieldInputElement.d.ts.map +1 -1
- package/dist/components/Form/elements/EditableFieldInputElement.mjs +1 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.cjs +1 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts +1 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts.map +1 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.mjs +1 -1
- package/dist/components/Form/elements/FormElement.cjs +1 -1
- package/dist/components/Form/elements/FormElement.mjs +1 -1
- package/dist/components/Form/elements/InputElement.cjs +1 -1
- package/dist/components/Form/elements/InputElement.mjs +1 -1
- package/dist/components/Form/elements/InputPasswordElement.cjs +1 -1
- package/dist/components/Form/elements/InputPasswordElement.mjs +1 -1
- package/dist/components/Form/elements/MultiselectElement.cjs +1 -1
- package/dist/components/Form/elements/MultiselectElement.mjs +1 -1
- package/dist/components/Form/elements/SelectElement.cjs +1 -1
- package/dist/components/Form/elements/SelectElement.d.ts.map +1 -1
- package/dist/components/Form/elements/SelectElement.mjs +1 -1
- package/dist/components/Form/elements/SwitchSelectorElement.cjs +1 -1
- package/dist/components/Form/elements/SwitchSelectorElement.mjs +1 -1
- package/dist/components/Form/elements/TextAreaElement.cjs +1 -1
- package/dist/components/Form/elements/TextAreaElement.mjs +1 -1
- package/dist/components/Form/elements/index.cjs +1 -1
- package/dist/components/Form/elements/index.mjs +1 -1
- package/dist/components/Form/index.cjs +1 -1
- package/dist/components/Form/index.mjs +1 -1
- package/dist/components/Form/layout/FormItemLayout.cjs +1 -1
- package/dist/components/Form/layout/FormItemLayout.d.ts.map +1 -1
- package/dist/components/Form/layout/FormItemLayout.mjs +1 -1
- package/dist/components/Form/layout/index.cjs +1 -1
- package/dist/components/Form/layout/index.mjs +1 -1
- package/dist/components/IDE/Code.cjs +77 -0
- package/dist/components/IDE/Code.cjs.map +1 -0
- package/dist/components/IDE/Code.d.ts +18 -0
- package/dist/components/IDE/Code.d.ts.map +1 -0
- package/dist/components/IDE/Code.mjs +77 -0
- package/dist/components/IDE/Code.mjs.map +1 -0
- package/dist/components/IDE/CodeBlock.cjs +54 -0
- package/dist/components/IDE/CodeBlock.cjs.map +1 -0
- package/dist/components/IDE/CodeBlock.d.ts +12 -0
- package/dist/components/IDE/CodeBlock.d.ts.map +1 -0
- package/dist/components/IDE/CodeBlock.mjs +54 -0
- package/dist/components/IDE/CodeBlock.mjs.map +1 -0
- package/dist/components/IDE/CodeBlockClient.cjs +55 -0
- package/dist/components/IDE/CodeBlockClient.cjs.map +1 -0
- package/dist/components/IDE/CodeBlockClient.mjs +55 -0
- package/dist/components/IDE/CodeBlockClient.mjs.map +1 -0
- package/dist/components/IDE/CodeBlockLoader.cjs +28 -0
- package/dist/components/IDE/CodeBlockLoader.cjs.map +1 -0
- package/dist/components/IDE/CodeBlockLoader.d.ts +4 -0
- package/dist/components/IDE/CodeBlockLoader.d.ts.map +1 -0
- package/dist/components/IDE/CodeBlockLoader.mjs +28 -0
- package/dist/components/IDE/CodeBlockLoader.mjs.map +1 -0
- package/dist/components/IDE/CodeBlockServer.cjs +53 -0
- package/dist/components/IDE/CodeBlockServer.cjs.map +1 -0
- package/dist/components/IDE/CodeBlockServer.d.ts +12 -0
- package/dist/components/IDE/CodeBlockServer.d.ts.map +1 -0
- package/dist/components/IDE/CodeBlockServer.mjs +53 -0
- package/dist/components/IDE/CodeBlockServer.mjs.map +1 -0
- package/dist/components/IDE/CodeBlockShiki.d.ts +3 -0
- package/dist/components/IDE/CodeBlockShiki.d.ts.map +1 -0
- package/dist/components/IDE/CodeBlockclient.d.ts +12 -0
- package/dist/components/IDE/CodeBlockclient.d.ts.map +1 -0
- package/dist/components/IDE/CodeConditionalRenderer.cjs +20 -0
- package/dist/components/IDE/CodeConditionalRenderer.cjs.map +1 -0
- package/dist/components/IDE/CodeConditionalRenderer.d.ts +4 -0
- package/dist/components/IDE/CodeConditionalRenderer.d.ts.map +1 -0
- package/dist/components/IDE/CodeConditionalRenderer.mjs +20 -0
- package/dist/components/IDE/CodeConditionalRenderer.mjs.map +1 -0
- package/dist/components/IDE/CodeContext.cjs +57 -0
- package/dist/components/IDE/CodeContext.cjs.map +1 -0
- package/dist/components/IDE/CodeContext.d.ts +26 -0
- package/dist/components/IDE/CodeContext.d.ts.map +1 -0
- package/dist/components/IDE/CodeContext.mjs +57 -0
- package/dist/components/IDE/CodeContext.mjs.map +1 -0
- package/dist/components/IDE/CodeFormatSelector.cjs +30 -0
- package/dist/components/IDE/CodeFormatSelector.cjs.map +1 -0
- package/dist/components/IDE/CodeFormatSelector.d.ts +3 -0
- package/dist/components/IDE/CodeFormatSelector.d.ts.map +1 -0
- package/dist/components/IDE/CodeFormatSelector.mjs +30 -0
- package/dist/components/IDE/CodeFormatSelector.mjs.map +1 -0
- package/dist/components/IDE/CodeRenderer.cjs +27 -0
- package/dist/components/IDE/CodeRenderer.cjs.map +1 -0
- package/dist/components/IDE/CodeRenderer.d.ts +5 -0
- package/dist/components/IDE/CodeRenderer.d.ts.map +1 -0
- package/dist/components/IDE/CodeRenderer.mjs +27 -0
- package/dist/components/IDE/CodeRenderer.mjs.map +1 -0
- package/dist/components/IDE/ContentDeclarationFormatSelector.cjs +28 -0
- package/dist/components/IDE/ContentDeclarationFormatSelector.cjs.map +1 -0
- package/dist/components/IDE/ContentDeclarationFormatSelector.d.ts +3 -0
- package/dist/components/IDE/ContentDeclarationFormatSelector.d.ts.map +1 -0
- package/dist/components/IDE/ContentDeclarationFormatSelector.mjs +28 -0
- package/dist/components/IDE/ContentDeclarationFormatSelector.mjs.map +1 -0
- package/dist/components/IDE/EditableCodeBlock.d.ts +9 -0
- package/dist/components/IDE/EditableCodeBlock.d.ts.map +1 -0
- package/dist/components/IDE/MarkDownRender.cjs +2 -3
- package/dist/components/IDE/MarkDownRender.cjs.map +1 -1
- package/dist/components/IDE/MarkDownRender.d.ts.map +1 -1
- package/dist/components/IDE/MarkDownRender.mjs +1 -2
- package/dist/components/IDE/MarkDownRender.mjs.map +1 -1
- package/dist/components/IDE/PackageManagerSelector.cjs +20 -0
- package/dist/components/IDE/PackageManagerSelector.cjs.map +1 -0
- package/dist/components/IDE/PackageManagerSelector.d.ts +3 -0
- package/dist/components/IDE/PackageManagerSelector.d.ts.map +1 -0
- package/dist/components/IDE/PackageManagerSelector.mjs +20 -0
- package/dist/components/IDE/PackageManagerSelector.mjs.map +1 -0
- package/dist/components/IDE/index.cjs +2 -2
- package/dist/components/IDE/index.d.ts +1 -1
- package/dist/components/IDE/index.d.ts.map +1 -1
- package/dist/components/IDE/index.mjs +1 -1
- package/dist/components/Link/Link.cjs +3 -4
- package/dist/components/Link/Link.cjs.map +1 -1
- package/dist/components/Link/Link.d.ts +1 -1
- package/dist/components/Link/Link.d.ts.map +1 -1
- package/dist/components/Link/Link.mjs +3 -4
- package/dist/components/Link/Link.mjs.map +1 -1
- package/dist/components/Loader/index.cjs +6 -1
- package/dist/components/Loader/index.cjs.map +1 -1
- package/dist/components/Loader/index.content.cjs +23 -0
- package/dist/components/Loader/index.content.cjs.map +1 -0
- package/dist/components/Loader/index.content.d.ts +8 -0
- package/dist/components/Loader/index.content.d.ts.map +1 -0
- package/dist/components/Loader/index.content.mjs +23 -0
- package/dist/components/Loader/index.content.mjs.map +1 -0
- package/dist/components/Loader/index.d.ts +2 -2
- package/dist/components/Loader/index.d.ts.map +1 -1
- package/dist/components/Loader/index.mjs +6 -1
- package/dist/components/Loader/index.mjs.map +1 -1
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSelectorContext.d.ts +13 -0
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSelectorContext.d.ts.map +1 -0
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.cjs +218 -0
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.cjs.map +1 -0
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.d.ts +8 -0
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.d.ts.map +1 -0
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs +218 -0
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs.map +1 -0
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.cjs +42 -0
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.cjs.map +1 -0
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.d.ts +15 -0
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.d.ts.map +1 -0
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs +42 -0
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs.map +1 -0
- package/dist/components/LocaleSwitcherContentDropDown/index.cjs +8 -0
- package/dist/components/LocaleSwitcherContentDropDown/index.cjs.map +1 -0
- package/dist/components/LocaleSwitcherContentDropDown/index.d.ts +3 -0
- package/dist/components/LocaleSwitcherContentDropDown/index.d.ts.map +1 -0
- package/dist/components/LocaleSwitcherContentDropDown/index.mjs +8 -0
- package/dist/components/LocaleSwitcherContentDropDown/index.mjs.map +1 -0
- package/dist/components/LocaleSwitcherContentDropDown/localeSwitcher.content.cjs +118 -0
- package/dist/components/LocaleSwitcherContentDropDown/localeSwitcher.content.cjs.map +1 -0
- package/dist/components/LocaleSwitcherContentDropDown/localeSwitcher.content.d.ts +18 -0
- package/dist/components/LocaleSwitcherContentDropDown/localeSwitcher.content.d.ts.map +1 -0
- package/dist/components/LocaleSwitcherContentDropDown/localeSwitcher.content.mjs +119 -0
- package/dist/components/LocaleSwitcherContentDropDown/localeSwitcher.content.mjs.map +1 -0
- package/dist/components/LocaleSwitcherDropDown/LocaleSwitcher.cjs +14 -22
- package/dist/components/LocaleSwitcherDropDown/LocaleSwitcher.cjs.map +1 -1
- package/dist/components/LocaleSwitcherDropDown/LocaleSwitcher.d.ts.map +1 -1
- package/dist/components/LocaleSwitcherDropDown/LocaleSwitcher.mjs +14 -22
- package/dist/components/LocaleSwitcherDropDown/LocaleSwitcher.mjs.map +1 -1
- package/dist/components/MarkDownRender/index.cjs +59 -30
- package/dist/components/MarkDownRender/index.cjs.map +1 -1
- package/dist/components/MarkDownRender/index.d.ts +2 -0
- package/dist/components/MarkDownRender/index.d.ts.map +1 -1
- package/dist/components/MarkDownRender/index.mjs +60 -31
- package/dist/components/MarkDownRender/index.mjs.map +1 -1
- package/dist/components/Modal/Modal.cjs +21 -13
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.d.ts +2 -2
- package/dist/components/Modal/Modal.d.ts.map +1 -1
- package/dist/components/Modal/Modal.mjs +22 -14
- package/dist/components/Modal/Modal.mjs.map +1 -1
- package/dist/components/SwitchSelector/index.cjs +4 -0
- package/dist/components/SwitchSelector/index.cjs.map +1 -1
- package/dist/components/SwitchSelector/index.d.ts.map +1 -1
- package/dist/components/SwitchSelector/index.mjs +5 -1
- package/dist/components/SwitchSelector/index.mjs.map +1 -1
- package/dist/components/index.cjs +17 -5
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.mjs +16 -4
- package/dist/components/index.mjs.map +1 -1
- package/dist/hooks/index.cjs +9 -1
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.mjs +10 -2
- package/dist/hooks/intlayerAPIHooks.cjs +82 -5
- package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
- package/dist/hooks/intlayerAPIHooks.d.ts +13 -2
- package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
- package/dist/hooks/intlayerAPIHooks.mjs +82 -5
- package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
- package/dist/hooks/useAsync/useAsync.cjs +81 -78
- package/dist/hooks/useAsync/useAsync.cjs.map +1 -1
- package/dist/hooks/useAsync/useAsync.d.ts +5 -25
- package/dist/hooks/useAsync/useAsync.d.ts.map +1 -1
- package/dist/hooks/useAsync/useAsync.mjs +81 -78
- package/dist/hooks/useAsync/useAsync.mjs.map +1 -1
- package/dist/hooks/useAsync/useAsyncStateStore.cjs +3 -7
- package/dist/hooks/useAsync/useAsyncStateStore.cjs.map +1 -1
- package/dist/hooks/useAsync/useAsyncStateStore.d.ts +1 -1
- package/dist/hooks/useAsync/useAsyncStateStore.d.ts.map +1 -1
- package/dist/hooks/useAsync/useAsyncStateStore.mjs +3 -7
- package/dist/hooks/useAsync/useAsyncStateStore.mjs.map +1 -1
- package/dist/hooks/useGetAllDictionaries.cjs +5 -3
- package/dist/hooks/useGetAllDictionaries.cjs.map +1 -1
- package/dist/hooks/useGetAllDictionaries.d.ts +4 -1
- package/dist/hooks/useGetAllDictionaries.d.ts.map +1 -1
- package/dist/hooks/useGetAllDictionaries.mjs +5 -3
- package/dist/hooks/useGetAllDictionaries.mjs.map +1 -1
- package/dist/hooks/useIntlayerAPI.d.ts +12 -2
- package/dist/hooks/useIntlayerAPI.d.ts.map +1 -1
- package/dist/hooks/usePersistedStore.cjs +22 -8
- package/dist/hooks/usePersistedStore.cjs.map +1 -1
- package/dist/hooks/usePersistedStore.d.ts.map +1 -1
- package/dist/hooks/usePersistedStore.mjs +22 -8
- package/dist/hooks/usePersistedStore.mjs.map +1 -1
- package/dist/libs/intlayer-api/ai.cjs +43 -3
- package/dist/libs/intlayer-api/ai.cjs.map +1 -1
- package/dist/libs/intlayer-api/ai.d.ts +11 -3
- package/dist/libs/intlayer-api/ai.d.ts.map +1 -1
- package/dist/libs/intlayer-api/ai.mjs +43 -3
- package/dist/libs/intlayer-api/ai.mjs.map +1 -1
- package/dist/libs/intlayer-api/dictionary.cjs +2 -2
- package/dist/libs/intlayer-api/dictionary.cjs.map +1 -1
- package/dist/libs/intlayer-api/dictionary.d.ts +3 -3
- package/dist/libs/intlayer-api/dictionary.d.ts.map +1 -1
- package/dist/libs/intlayer-api/dictionary.mjs +2 -2
- package/dist/libs/intlayer-api/dictionary.mjs.map +1 -1
- package/dist/libs/intlayer-api/index.cjs +3 -1
- package/dist/libs/intlayer-api/index.cjs.map +1 -1
- package/dist/libs/intlayer-api/index.d.ts +24 -4
- package/dist/libs/intlayer-api/index.d.ts.map +1 -1
- package/dist/libs/intlayer-api/index.mjs +3 -1
- package/dist/libs/intlayer-api/index.mjs.map +1 -1
- package/dist/libs/intlayer-api/tag.cjs +52 -0
- package/dist/libs/intlayer-api/tag.cjs.map +1 -0
- package/dist/libs/intlayer-api/tag.d.ts +16 -0
- package/dist/libs/intlayer-api/tag.d.ts.map +1 -0
- package/dist/libs/intlayer-api/tag.mjs +52 -0
- package/dist/libs/intlayer-api/tag.mjs.map +1 -0
- package/dist/tailwind.css +1 -1
- package/package.json +18 -19
|
@@ -316,7 +316,11 @@ const usePushDictionaries = (args) => useAppAsync(
|
|
|
316
316
|
"pushDictionaries",
|
|
317
317
|
useIntlayerAuth().dictionary.pushDictionaries,
|
|
318
318
|
{
|
|
319
|
-
invalidateQueries: [
|
|
319
|
+
invalidateQueries: [
|
|
320
|
+
"getDictionaries",
|
|
321
|
+
"getDictionary",
|
|
322
|
+
"getDictionariesKeys"
|
|
323
|
+
],
|
|
320
324
|
...args
|
|
321
325
|
}
|
|
322
326
|
);
|
|
@@ -324,7 +328,7 @@ const useUpdateDictionary = (args) => useAppAsync(
|
|
|
324
328
|
"updateDictionary",
|
|
325
329
|
useIntlayerAuth().dictionary.updateDictionary,
|
|
326
330
|
{
|
|
327
|
-
invalidateQueries: ["getDictionaries"],
|
|
331
|
+
invalidateQueries: ["getDictionaries", "getDictionary"],
|
|
328
332
|
...args
|
|
329
333
|
}
|
|
330
334
|
);
|
|
@@ -332,10 +336,44 @@ const useDeleteDictionary = (args) => useAppAsync(
|
|
|
332
336
|
"deleteDictionary",
|
|
333
337
|
useIntlayerAuth().dictionary.deleteDictionary,
|
|
334
338
|
{
|
|
335
|
-
invalidateQueries: [
|
|
339
|
+
invalidateQueries: [
|
|
340
|
+
"getDictionaries",
|
|
341
|
+
"getDictionary",
|
|
342
|
+
"getDictionariesKeys"
|
|
343
|
+
],
|
|
336
344
|
...args
|
|
337
345
|
}
|
|
338
346
|
);
|
|
347
|
+
const useGetTags = (args) => useAppAsync(
|
|
348
|
+
"getTags",
|
|
349
|
+
useIntlayerAuth().tag.getTags,
|
|
350
|
+
{
|
|
351
|
+
cache: true,
|
|
352
|
+
store: true,
|
|
353
|
+
retryLimit: 3,
|
|
354
|
+
autoFetch: true,
|
|
355
|
+
revalidation: true,
|
|
356
|
+
revalidateTime: 5 * 60 * 1e3,
|
|
357
|
+
// 5 minutes
|
|
358
|
+
...args
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
requireUser: true,
|
|
362
|
+
requireOrganization: true
|
|
363
|
+
}
|
|
364
|
+
);
|
|
365
|
+
const useAddTag = (args) => useAppAsync("addTag", useIntlayerAuth().tag.addTag, {
|
|
366
|
+
invalidateQueries: ["getTags"],
|
|
367
|
+
...args
|
|
368
|
+
});
|
|
369
|
+
const useUpdateTag = (args) => useAppAsync("updateTag", useIntlayerAuth().tag.updateTag, {
|
|
370
|
+
invalidateQueries: ["getTags"],
|
|
371
|
+
...args
|
|
372
|
+
});
|
|
373
|
+
const useDeleteTag = (args) => useAppAsync("deleteTag", useIntlayerAuth().tag.deleteTag, {
|
|
374
|
+
invalidateQueries: ["getTags"],
|
|
375
|
+
...args
|
|
376
|
+
});
|
|
339
377
|
const useGetSubscription = (args) => useAppAsync(
|
|
340
378
|
"getSubscription",
|
|
341
379
|
useIntlayerAuth().stripe.getSubscription,
|
|
@@ -354,19 +392,55 @@ const useCancelSubscription = (args) => useAppAsync(
|
|
|
354
392
|
requireOrganization: true
|
|
355
393
|
}
|
|
356
394
|
);
|
|
357
|
-
const
|
|
395
|
+
const useAuditContentDeclaration = (args) => useAppAsync(
|
|
396
|
+
"auditContentDeclaration",
|
|
397
|
+
useIntlayerAuth().ai.auditContentDeclaration,
|
|
398
|
+
args,
|
|
399
|
+
{
|
|
400
|
+
requireUser: true,
|
|
401
|
+
requireOrganization: true,
|
|
402
|
+
requireProject: true
|
|
403
|
+
}
|
|
404
|
+
);
|
|
405
|
+
const useAuditContentDeclarationMetadata = (args) => useAppAsync(
|
|
406
|
+
"auditContentDeclaration",
|
|
407
|
+
useIntlayerAuth().ai.auditContentDeclarationMetadata,
|
|
408
|
+
args,
|
|
409
|
+
{
|
|
410
|
+
requireUser: true,
|
|
411
|
+
requireOrganization: true,
|
|
412
|
+
requireProject: true
|
|
413
|
+
}
|
|
414
|
+
);
|
|
415
|
+
const useAuditContentDeclarationField = (args) => useAppAsync(
|
|
416
|
+
"auditContentDeclarationField",
|
|
417
|
+
useIntlayerAuth().ai.auditContentDeclarationField,
|
|
418
|
+
args,
|
|
419
|
+
{
|
|
420
|
+
requireUser: true,
|
|
421
|
+
requireOrganization: true,
|
|
422
|
+
requireProject: true
|
|
423
|
+
}
|
|
424
|
+
);
|
|
425
|
+
const useAuditTag = (args) => useAppAsync("auditTag", useIntlayerAuth().ai.auditTag, args, {
|
|
358
426
|
requireUser: true,
|
|
359
427
|
requireOrganization: true,
|
|
360
428
|
requireProject: true
|
|
361
429
|
});
|
|
430
|
+
const useAskDocQuestion = (args) => useAppAsync("askDocQuestion", useIntlayerAuth().ai.askDocQuestion, args);
|
|
362
431
|
export {
|
|
363
432
|
useAddDictionary,
|
|
364
433
|
useAddNewAccessKey,
|
|
365
434
|
useAddOrganization,
|
|
366
435
|
useAddOrganizationMember,
|
|
367
436
|
useAddProject,
|
|
437
|
+
useAddTag,
|
|
438
|
+
useAskDocQuestion,
|
|
368
439
|
useAskResetPassword,
|
|
369
|
-
|
|
440
|
+
useAuditContentDeclaration,
|
|
441
|
+
useAuditContentDeclarationField,
|
|
442
|
+
useAuditContentDeclarationMetadata,
|
|
443
|
+
useAuditTag,
|
|
370
444
|
useCancelSubscription,
|
|
371
445
|
useChangePassword,
|
|
372
446
|
useCheckIfUserHasPassword,
|
|
@@ -375,6 +449,7 @@ export {
|
|
|
375
449
|
useDeleteDictionary,
|
|
376
450
|
useDeleteOrganization,
|
|
377
451
|
useDeleteProject,
|
|
452
|
+
useDeleteTag,
|
|
378
453
|
useDeleteUser,
|
|
379
454
|
useGetDictionaries,
|
|
380
455
|
useGetDictionariesKeys,
|
|
@@ -382,6 +457,7 @@ export {
|
|
|
382
457
|
useGetOrganizations,
|
|
383
458
|
useGetProjects,
|
|
384
459
|
useGetSubscription,
|
|
460
|
+
useGetTags,
|
|
385
461
|
useGetUserByAccount,
|
|
386
462
|
useGetUsers,
|
|
387
463
|
useLogin,
|
|
@@ -399,6 +475,7 @@ export {
|
|
|
399
475
|
useUpdateOrganizationMembers,
|
|
400
476
|
useUpdateProject,
|
|
401
477
|
useUpdateProjectMembers,
|
|
478
|
+
useUpdateTag,
|
|
402
479
|
useUpdateUser,
|
|
403
480
|
useVerifyEmail
|
|
404
481
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerAPIHooks.mjs","sources":["../../__vite-browser-external","../../src/hooks/intlayerAPIHooks.ts"],"sourcesContent":["export default {}","/* eslint-disable @typescript-eslint/no-explicit-any */\n'use client';\n\nimport process from 'process';\nimport { intlayerAPI } from 'src/libs';\nimport { useAuth } from '../components/Auth/useAuth/index';\nimport { useToast } from '../components/Toaster';\nimport { useAsync, UseAsyncOptions } from './useAsync/useAsync';\nimport { useIntlayerAuth } from './useIntlayerAPI';\n\n/**\n * Hook to handle error logging and toast notifications\n */\nconst useErrorHandling = <T extends UseAsyncOptions<any>>(options: T): T => {\n const { toast } = useToast();\n\n return {\n ...options,\n onError: (errorMessage) => {\n let error;\n\n // If json is valid, parse it\n try {\n error = JSON.parse(errorMessage);\n } catch (e) {\n console.error(e);\n // If json is not valid, set error to the original errorMessage\n\n error = errorMessage;\n }\n\n // render toast for each error if there is more than one\n // otherwise render the toast with the error message\n [error]\n .flatMap((error) => error)\n .forEach((error) =>\n toast({\n title:\n (process.env.NODE_ENV === 'production'\n ? error.title\n : error.code) ?? 'Error',\n description: error.message ?? errorMessage ?? 'An error occurred',\n variant: 'error',\n })\n );\n options.onError?.(errorMessage);\n },\n onSuccess: (data) => {\n if (data.message)\n toast({\n title: data.message,\n description: data.description,\n variant: 'success',\n });\n options.onSuccess?.(data);\n },\n };\n};\n\ntype AuthEnableOptions = {\n requireUser?: boolean;\n requireProject?: boolean;\n requireOrganization?: boolean;\n};\n\n/**\n * Hook to enable authentication\n */\nconst useAuthEnable = <T extends UseAsyncOptions<any>>(\n options: T,\n { requireUser, requireProject, requireOrganization }: AuthEnableOptions = {}\n): T => {\n const { csrfToken, oAuth2AccessToken, session } = useAuth();\n\n const isEnabledOption = options?.enable ?? true;\n const user = session ? session.user : oAuth2AccessToken?.user;\n\n const organization = session\n ? session.organization\n : oAuth2AccessToken?.organization;\n\n const project = session ? session.project : oAuth2AccessToken?.project;\n\n const isUserEnabled = requireUser ? Boolean(user) : true;\n\n const isProjectEnabled = requireProject ? Boolean(project) : true;\n\n const isOrganizationEnabled = requireOrganization\n ? Boolean(organization)\n : true;\n\n const isCSRFEnabled =\n Boolean(csrfToken) ||\n // If auth using session, csrf token is not required\n (!session && Boolean(oAuth2AccessToken));\n\n const isEnabled =\n isEnabledOption &&\n isUserEnabled &&\n isProjectEnabled &&\n isOrganizationEnabled &&\n isCSRFEnabled;\n\n return {\n ...options,\n enable: isEnabled,\n };\n};\n\nconst useAppAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>,\n authOptions?: AuthEnableOptions\n) => {\n // Enhance options using custom hooks\n const optionsWithAuth = useAuthEnable(options ?? {}, authOptions);\n\n const optionsWithErrorHandling = useErrorHandling(optionsWithAuth);\n\n // Call the main useAsync hook with enhanced options\n return useAsync(key, asyncFunction, optionsWithErrorHandling);\n};\n\n/**\n * Auth\n */\n\nexport const useLogin = (\n args?: UseAsyncOptions<typeof intlayerAPI.auth.login>\n) =>\n useAppAsync('login', useIntlayerAuth().auth.login, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useRegister = (\n args?: UseAsyncOptions<typeof intlayerAPI.auth.register>\n) =>\n useAppAsync('register', useIntlayerAuth().auth.register, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useLogout = (\n args?: UseAsyncOptions<typeof intlayerAPI.auth.logout>\n) =>\n useAppAsync('logout', useIntlayerAuth().auth.logout, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useChangePassword = (\n args?: UseAsyncOptions<typeof intlayerAPI.auth.changePassword>\n) => useAppAsync('changePassword', useIntlayerAuth().auth.changePassword, args);\nexport const useAskResetPassword = (\n args?: UseAsyncOptions<typeof intlayerAPI.auth.askResetPassword>\n) =>\n useAppAsync(\n 'askResetPassword',\n useIntlayerAuth().auth.askResetPassword,\n args\n );\nexport const useResetPassword = (\n args?: UseAsyncOptions<typeof intlayerAPI.auth.resetPassword>\n) => useAppAsync('resetPassword', useIntlayerAuth().auth.resetPassword, args);\nexport const useCheckIfUserHasPassword = (\n args?: UseAsyncOptions<typeof intlayerAPI.auth.checkIfUserHasPassword>\n) =>\n useAppAsync(\n 'checkIfUserHasPassword',\n useIntlayerAuth().auth.checkIfUserHasPassword,\n args,\n {\n requireUser: true,\n }\n );\nexport const useVerifyEmail = (\n args?: UseAsyncOptions<typeof intlayerAPI.auth.verifyEmail>\n) => useAppAsync('verifyEmail', useIntlayerAuth().auth.verifyEmail, args);\n\nexport const useGetUserByAccount = (\n args?: UseAsyncOptions<typeof intlayerAPI.user.getUserByAccount>\n) =>\n useAppAsync(\n 'getUserByAccount',\n useIntlayerAuth().user.getUserByAccount,\n args\n );\n\n/**\n * User\n */\n\nexport const useGetUsers = (\n args?: UseAsyncOptions<typeof intlayerAPI.user.getUsers>\n) =>\n useAppAsync(\n 'getUsers',\n useIntlayerAuth().user.getUsers,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n }\n );\nexport const useCreateUser = (\n args?: UseAsyncOptions<typeof intlayerAPI.user.createUser>\n) =>\n useAppAsync('createUser', useIntlayerAuth().user.createUser, {\n invalidateQueries: ['getUsers'],\n ...args,\n });\nexport const useUpdateUser = (\n args?: UseAsyncOptions<typeof intlayerAPI.user.updateUser>\n) =>\n useAppAsync('updateUser', useIntlayerAuth().user.updateUser, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useDeleteUser = (\n args?: UseAsyncOptions<typeof intlayerAPI.user.deleteUser>\n) =>\n useAppAsync('deleteUser', useIntlayerAuth().user.deleteUser, {\n invalidateQueries: ['getUsers'],\n ...args,\n });\n\n/**\n * Organization\n */\n\nexport const useGetOrganizations = (\n args?: UseAsyncOptions<typeof intlayerAPI.organization.getOrganizations>\n) =>\n useAppAsync(\n 'getOrganizations',\n useIntlayerAuth().organization.getOrganizations,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n }\n );\n\nexport const useAddOrganization = (\n args?: UseAsyncOptions<typeof intlayerAPI.organization.addOrganization>\n) =>\n useAppAsync(\n 'addOrganization',\n useIntlayerAuth().organization.addOrganization,\n {\n invalidateQueries: ['getOrganizations'],\n ...args,\n }\n );\nexport const useUpdateOrganization = (\n args?: UseAsyncOptions<typeof intlayerAPI.organization.updateOrganization>\n) =>\n useAppAsync(\n 'updateOrganization',\n useIntlayerAuth().organization.updateOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\nexport const useUpdateOrganizationMembers = (\n args?: UseAsyncOptions<\n typeof intlayerAPI.organization.updateOrganizationMembers\n >\n) =>\n useAppAsync(\n 'updateOrganizationMembers',\n useIntlayerAuth().organization.updateOrganizationMembers,\n {\n invalidateQueries: ['getOrganizations'],\n ...args,\n }\n );\nexport const useAddOrganizationMember = (\n args?: UseAsyncOptions<typeof intlayerAPI.organization.addOrganizationMember>\n) =>\n useAppAsync(\n 'addOrganizationMember',\n useIntlayerAuth().organization.addOrganizationMember,\n {\n invalidateQueries: ['getOrganizations'],\n ...args,\n }\n );\nexport const useDeleteOrganization = (\n args?: UseAsyncOptions<typeof intlayerAPI.organization.deleteOrganization>\n) =>\n useAppAsync(\n 'deleteOrganization',\n useIntlayerAuth().organization.deleteOrganization,\n {\n invalidateQueries: ['getOrganizations'],\n ...args,\n }\n );\nexport const useSelectOrganization = (\n args?: UseAsyncOptions<typeof intlayerAPI.organization.selectOrganization>\n) =>\n useAppAsync(\n 'selectOrganization',\n useIntlayerAuth().organization.selectOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\nexport const useUnselectOrganization = (\n args?: UseAsyncOptions<typeof intlayerAPI.organization.unselectOrganization>\n) =>\n useAppAsync(\n 'unselectOrganization',\n useIntlayerAuth().organization.unselectOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\n\n/**\n * Project\n */\n\nexport const useGetProjects = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.getProjects>\n) =>\n useAppAsync(\n 'getProjects',\n useIntlayerAuth().project.getProjects,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\nexport const useAddProject = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.addProject>\n) =>\n useAppAsync('addProject', useIntlayerAuth().project.addProject, {\n invalidateQueries: ['getProjects'],\n ...args,\n });\nexport const useUpdateProject = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.updateProject>\n) =>\n useAppAsync('updateProject', useIntlayerAuth().project.updateProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useUpdateProjectMembers = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.updateProjectMembers>\n) =>\n useAppAsync(\n 'updateProjectMembers',\n useIntlayerAuth().project.updateProjectMembers,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\nexport const useDeleteProject = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.deleteProject>\n) =>\n useAppAsync('deleteProject', useIntlayerAuth().project.deleteProject, {\n invalidateQueries: ['getProjects'],\n ...args,\n });\nexport const useSelectProject = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.selectProject>\n) =>\n useAppAsync('selectProject', useIntlayerAuth().project.selectProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useUnselectProject = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.unselectProject>\n) =>\n useAppAsync('unselectProject', useIntlayerAuth().project.unselectProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useAddNewAccessKey = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.addNewAccessKey>\n) =>\n useAppAsync('addNewAccessKey', useIntlayerAuth().project.addNewAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useDeleteAccessKey = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.deleteAccessKey>\n) =>\n useAppAsync('deleteAccessKey', useIntlayerAuth().project.deleteAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useRefreshAccessKey = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.refreshAccessKey>\n) =>\n useAppAsync('refreshAccessKey', useIntlayerAuth().project.refreshAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\n/**\n * Dictionary\n */\n\nexport const useGetDictionaries = (\n args?: UseAsyncOptions<typeof intlayerAPI.dictionary.getDictionaries>\n) =>\n useAppAsync(\n 'getDictionaries',\n useIntlayerAuth().dictionary.getDictionaries,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useGetDictionariesKeys = (\n args?: UseAsyncOptions<typeof intlayerAPI.dictionary.getDictionariesKeys>\n) =>\n useAppAsync(\n 'getDictionariesKeys',\n useIntlayerAuth().dictionary.getDictionariesKeys,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useGetDictionary = (\n args?: UseAsyncOptions<typeof intlayerAPI.dictionary.getDictionary>\n) =>\n useAppAsync(\n 'getDictionary',\n useIntlayerAuth().dictionary.getDictionary,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\nexport const useAddDictionary = (\n args?: UseAsyncOptions<typeof intlayerAPI.dictionary.addDictionary>\n) =>\n useAppAsync('addDictionary', useIntlayerAuth().dictionary.addDictionary, {\n invalidateQueries: ['getDictionaries', 'getDictionariesKeys'],\n ...args,\n });\n\nexport const usePushDictionaries = (\n args?: UseAsyncOptions<typeof intlayerAPI.dictionary.pushDictionaries>\n) =>\n useAppAsync(\n 'pushDictionaries',\n useIntlayerAuth().dictionary.pushDictionaries,\n {\n invalidateQueries: ['getDictionaries', 'getDictionariesKeys'],\n ...args,\n }\n );\nexport const useUpdateDictionary = (\n args?: UseAsyncOptions<typeof intlayerAPI.dictionary.updateDictionary>\n) =>\n useAppAsync(\n 'updateDictionary',\n useIntlayerAuth().dictionary.updateDictionary,\n {\n invalidateQueries: ['getDictionaries'],\n ...args,\n }\n );\nexport const useDeleteDictionary = (\n args?: UseAsyncOptions<typeof intlayerAPI.dictionary.deleteDictionary>\n) =>\n useAppAsync(\n 'deleteDictionary',\n useIntlayerAuth().dictionary.deleteDictionary,\n {\n invalidateQueries: ['getDictionaries', 'getDictionariesKeys'],\n ...args,\n }\n );\n\n/**\n * Stripe\n */\n\nexport const useGetSubscription = (\n args?: UseAsyncOptions<typeof intlayerAPI.stripe.getSubscription>\n) =>\n useAppAsync(\n 'getSubscription',\n useIntlayerAuth().stripe.getSubscription,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\n\nexport const useCancelSubscription = (\n args?: UseAsyncOptions<typeof intlayerAPI.stripe.cancelSubscription>\n) =>\n useAppAsync(\n 'cancelSubscription',\n useIntlayerAuth().stripe.cancelSubscription,\n { invalidateQueries: ['getSession'], ...args },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\n\n/**\n * AI\n */\n\nexport const useAuditFile = (\n args?: UseAsyncOptions<typeof intlayerAPI.ai.auditFile>\n) =>\n useAppAsync('auditFile', useIntlayerAuth().ai.auditFile, args, {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n });\n"],"names":["error"],"mappings":";;;;;;;AAAA,MAAe,UAAA,CAAA;ACaf,MAAM,mBAAmB,CAAiC,YAAkB;AACpE,QAAA,EAAE,MAAM,IAAI,SAAS;AAEpB,SAAA;AAAA,IACL,GAAG;AAAA,IACH,SAAS,CAAC,iBAAiB;AACrB,UAAA;AAGA,UAAA;AACM,gBAAA,KAAK,MAAM,YAAY;AAAA,eACxB,GAAG;AACV,gBAAQ,MAAM,CAAC;AAGP,gBAAA;AAAA,MAAA;AAKV,OAAC,KAAK,EACH,QAAQ,CAACA,WAAUA,MAAK,EACxB;AAAA,QAAQ,CAACA,WACR,MAAM;AAAA,UACJ,QACG,QAAQ,IAAI,aAAa,eACtBA,OAAM,QACNA,OAAM,SAAS;AAAA,UACrB,aAAaA,OAAM,WAAW,gBAAgB;AAAA,UAC9C,SAAS;AAAA,QACV,CAAA;AAAA,MACH;AACF,cAAQ,UAAU,YAAY;AAAA,IAChC;AAAA,IACA,WAAW,CAAC,SAAS;AACnB,UAAI,KAAK;AACD,cAAA;AAAA,UACJ,OAAO,KAAK;AAAA,UACZ,aAAa,KAAK;AAAA,UAClB,SAAS;AAAA,QAAA,CAC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AW,MAAM;AAAA,EAC7D,aAAa;AAAA,EACb,qBAAqB;AAAA,EACrB,gBAAgB;AAClB,CAAC;"}
|
|
1
|
+
{"version":3,"file":"intlayerAPIHooks.mjs","sources":["../../__vite-browser-external","../../src/hooks/intlayerAPIHooks.ts"],"sourcesContent":["export default {}","/* eslint-disable @typescript-eslint/no-explicit-any */\n'use client';\n\nimport process from 'process';\nimport { intlayerAPI } from 'src/libs';\nimport { useAuth } from '../components/Auth/useAuth/index';\nimport { useToast } from '../components/Toaster';\nimport { useAsync, UseAsyncOptions } from './useAsync/useAsync';\nimport { useIntlayerAuth } from './useIntlayerAPI';\n\n/**\n * Hook to handle error logging and toast notifications\n */\nconst useErrorHandling = <T extends UseAsyncOptions<any>>(options: T): T => {\n const { toast } = useToast();\n\n return {\n ...options,\n onError: (errorMessage) => {\n let error;\n\n // If json is valid, parse it\n try {\n error = JSON.parse(errorMessage);\n } catch (e) {\n console.error(e);\n // If json is not valid, set error to the original errorMessage\n\n error = errorMessage;\n }\n\n // render toast for each error if there is more than one\n // otherwise render the toast with the error message\n [error]\n .flatMap((error) => error)\n .forEach((error) =>\n toast({\n title:\n (process.env.NODE_ENV === 'production'\n ? error.title\n : error.code) ?? 'Error',\n description: error.message ?? errorMessage ?? 'An error occurred',\n variant: 'error',\n })\n );\n options.onError?.(errorMessage);\n },\n onSuccess: (data) => {\n if (data.message)\n toast({\n title: data.message,\n description: data.description,\n variant: 'success',\n });\n options.onSuccess?.(data);\n },\n };\n};\n\ntype AuthEnableOptions = {\n requireUser?: boolean;\n requireProject?: boolean;\n requireOrganization?: boolean;\n};\n\n/**\n * Hook to enable authentication\n */\nconst useAuthEnable = <T extends UseAsyncOptions<any>>(\n options: T,\n { requireUser, requireProject, requireOrganization }: AuthEnableOptions = {}\n): T => {\n const { csrfToken, oAuth2AccessToken, session } = useAuth();\n\n const isEnabledOption = options?.enable ?? true;\n const user = session ? session.user : oAuth2AccessToken?.user;\n\n const organization = session\n ? session.organization\n : oAuth2AccessToken?.organization;\n\n const project = session ? session.project : oAuth2AccessToken?.project;\n\n const isUserEnabled = requireUser ? Boolean(user) : true;\n\n const isProjectEnabled = requireProject ? Boolean(project) : true;\n\n const isOrganizationEnabled = requireOrganization\n ? Boolean(organization)\n : true;\n\n const isCSRFEnabled =\n Boolean(csrfToken) ||\n // If auth using session, csrf token is not required\n (!session && Boolean(oAuth2AccessToken));\n\n const isEnabled =\n isEnabledOption &&\n isUserEnabled &&\n isProjectEnabled &&\n isOrganizationEnabled &&\n isCSRFEnabled;\n\n return {\n ...options,\n enable: isEnabled,\n };\n};\n\nconst useAppAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>,\n authOptions?: AuthEnableOptions\n) => {\n // Enhance options using custom hooks\n const optionsWithAuth = useAuthEnable(options ?? {}, authOptions);\n\n const optionsWithErrorHandling = useErrorHandling(optionsWithAuth);\n\n // Call the main useAsync hook with enhanced options\n return useAsync(key, asyncFunction, optionsWithErrorHandling);\n};\n\n/**\n * Auth\n */\n\nexport const useLogin = (\n args?: UseAsyncOptions<typeof intlayerAPI.auth.login>\n) =>\n useAppAsync('login', useIntlayerAuth().auth.login, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useRegister = (\n args?: UseAsyncOptions<typeof intlayerAPI.auth.register>\n) =>\n useAppAsync('register', useIntlayerAuth().auth.register, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useLogout = (\n args?: UseAsyncOptions<typeof intlayerAPI.auth.logout>\n) =>\n useAppAsync('logout', useIntlayerAuth().auth.logout, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useChangePassword = (\n args?: UseAsyncOptions<typeof intlayerAPI.auth.changePassword>\n) => useAppAsync('changePassword', useIntlayerAuth().auth.changePassword, args);\nexport const useAskResetPassword = (\n args?: UseAsyncOptions<typeof intlayerAPI.auth.askResetPassword>\n) =>\n useAppAsync(\n 'askResetPassword',\n useIntlayerAuth().auth.askResetPassword,\n args\n );\nexport const useResetPassword = (\n args?: UseAsyncOptions<typeof intlayerAPI.auth.resetPassword>\n) => useAppAsync('resetPassword', useIntlayerAuth().auth.resetPassword, args);\nexport const useCheckIfUserHasPassword = (\n args?: UseAsyncOptions<typeof intlayerAPI.auth.checkIfUserHasPassword>\n) =>\n useAppAsync(\n 'checkIfUserHasPassword',\n useIntlayerAuth().auth.checkIfUserHasPassword,\n args,\n {\n requireUser: true,\n }\n );\nexport const useVerifyEmail = (\n args?: UseAsyncOptions<typeof intlayerAPI.auth.verifyEmail>\n) => useAppAsync('verifyEmail', useIntlayerAuth().auth.verifyEmail, args);\n\nexport const useGetUserByAccount = (\n args?: UseAsyncOptions<typeof intlayerAPI.user.getUserByAccount>\n) =>\n useAppAsync(\n 'getUserByAccount',\n useIntlayerAuth().user.getUserByAccount,\n args\n );\n\n/**\n * User\n */\n\nexport const useGetUsers = (\n args?: UseAsyncOptions<typeof intlayerAPI.user.getUsers>\n) =>\n useAppAsync(\n 'getUsers',\n useIntlayerAuth().user.getUsers,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n }\n );\nexport const useCreateUser = (\n args?: UseAsyncOptions<typeof intlayerAPI.user.createUser>\n) =>\n useAppAsync('createUser', useIntlayerAuth().user.createUser, {\n invalidateQueries: ['getUsers'],\n ...args,\n });\nexport const useUpdateUser = (\n args?: UseAsyncOptions<typeof intlayerAPI.user.updateUser>\n) =>\n useAppAsync('updateUser', useIntlayerAuth().user.updateUser, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useDeleteUser = (\n args?: UseAsyncOptions<typeof intlayerAPI.user.deleteUser>\n) =>\n useAppAsync('deleteUser', useIntlayerAuth().user.deleteUser, {\n invalidateQueries: ['getUsers'],\n ...args,\n });\n\n/**\n * Organization\n */\n\nexport const useGetOrganizations = (\n args?: UseAsyncOptions<typeof intlayerAPI.organization.getOrganizations>\n) =>\n useAppAsync(\n 'getOrganizations',\n useIntlayerAuth().organization.getOrganizations,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n }\n );\n\nexport const useAddOrganization = (\n args?: UseAsyncOptions<typeof intlayerAPI.organization.addOrganization>\n) =>\n useAppAsync(\n 'addOrganization',\n useIntlayerAuth().organization.addOrganization,\n {\n invalidateQueries: ['getOrganizations'],\n ...args,\n }\n );\nexport const useUpdateOrganization = (\n args?: UseAsyncOptions<typeof intlayerAPI.organization.updateOrganization>\n) =>\n useAppAsync(\n 'updateOrganization',\n useIntlayerAuth().organization.updateOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\nexport const useUpdateOrganizationMembers = (\n args?: UseAsyncOptions<\n typeof intlayerAPI.organization.updateOrganizationMembers\n >\n) =>\n useAppAsync(\n 'updateOrganizationMembers',\n useIntlayerAuth().organization.updateOrganizationMembers,\n {\n invalidateQueries: ['getOrganizations'],\n ...args,\n }\n );\nexport const useAddOrganizationMember = (\n args?: UseAsyncOptions<typeof intlayerAPI.organization.addOrganizationMember>\n) =>\n useAppAsync(\n 'addOrganizationMember',\n useIntlayerAuth().organization.addOrganizationMember,\n {\n invalidateQueries: ['getOrganizations'],\n ...args,\n }\n );\nexport const useDeleteOrganization = (\n args?: UseAsyncOptions<typeof intlayerAPI.organization.deleteOrganization>\n) =>\n useAppAsync(\n 'deleteOrganization',\n useIntlayerAuth().organization.deleteOrganization,\n {\n invalidateQueries: ['getOrganizations'],\n ...args,\n }\n );\nexport const useSelectOrganization = (\n args?: UseAsyncOptions<typeof intlayerAPI.organization.selectOrganization>\n) =>\n useAppAsync(\n 'selectOrganization',\n useIntlayerAuth().organization.selectOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\nexport const useUnselectOrganization = (\n args?: UseAsyncOptions<typeof intlayerAPI.organization.unselectOrganization>\n) =>\n useAppAsync(\n 'unselectOrganization',\n useIntlayerAuth().organization.unselectOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\n\n/**\n * Project\n */\n\nexport const useGetProjects = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.getProjects>\n) =>\n useAppAsync(\n 'getProjects',\n useIntlayerAuth().project.getProjects,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\nexport const useAddProject = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.addProject>\n) =>\n useAppAsync('addProject', useIntlayerAuth().project.addProject, {\n invalidateQueries: ['getProjects'],\n ...args,\n });\nexport const useUpdateProject = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.updateProject>\n) =>\n useAppAsync('updateProject', useIntlayerAuth().project.updateProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useUpdateProjectMembers = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.updateProjectMembers>\n) =>\n useAppAsync(\n 'updateProjectMembers',\n useIntlayerAuth().project.updateProjectMembers,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\nexport const useDeleteProject = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.deleteProject>\n) =>\n useAppAsync('deleteProject', useIntlayerAuth().project.deleteProject, {\n invalidateQueries: ['getProjects'],\n ...args,\n });\nexport const useSelectProject = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.selectProject>\n) =>\n useAppAsync('selectProject', useIntlayerAuth().project.selectProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useUnselectProject = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.unselectProject>\n) =>\n useAppAsync('unselectProject', useIntlayerAuth().project.unselectProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useAddNewAccessKey = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.addNewAccessKey>\n) =>\n useAppAsync('addNewAccessKey', useIntlayerAuth().project.addNewAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useDeleteAccessKey = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.deleteAccessKey>\n) =>\n useAppAsync('deleteAccessKey', useIntlayerAuth().project.deleteAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useRefreshAccessKey = (\n args?: UseAsyncOptions<typeof intlayerAPI.project.refreshAccessKey>\n) =>\n useAppAsync('refreshAccessKey', useIntlayerAuth().project.refreshAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\n/**\n * Dictionary\n */\n\nexport const useGetDictionaries = (\n args?: UseAsyncOptions<typeof intlayerAPI.dictionary.getDictionaries>\n) =>\n useAppAsync(\n 'getDictionaries',\n useIntlayerAuth().dictionary.getDictionaries,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useGetDictionariesKeys = (\n args?: UseAsyncOptions<typeof intlayerAPI.dictionary.getDictionariesKeys>\n) =>\n useAppAsync(\n 'getDictionariesKeys',\n useIntlayerAuth().dictionary.getDictionariesKeys,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useGetDictionary = (\n args?: UseAsyncOptions<typeof intlayerAPI.dictionary.getDictionary>\n) =>\n useAppAsync(\n 'getDictionary',\n useIntlayerAuth().dictionary.getDictionary,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\nexport const useAddDictionary = (\n args?: UseAsyncOptions<typeof intlayerAPI.dictionary.addDictionary>\n) =>\n useAppAsync('addDictionary', useIntlayerAuth().dictionary.addDictionary, {\n invalidateQueries: ['getDictionaries', 'getDictionariesKeys'],\n ...args,\n });\n\nexport const usePushDictionaries = (\n args?: UseAsyncOptions<typeof intlayerAPI.dictionary.pushDictionaries>\n) =>\n useAppAsync(\n 'pushDictionaries',\n useIntlayerAuth().dictionary.pushDictionaries,\n {\n invalidateQueries: [\n 'getDictionaries',\n 'getDictionary',\n 'getDictionariesKeys',\n ],\n ...args,\n }\n );\nexport const useUpdateDictionary = (\n args?: UseAsyncOptions<typeof intlayerAPI.dictionary.updateDictionary>\n) =>\n useAppAsync(\n 'updateDictionary',\n useIntlayerAuth().dictionary.updateDictionary,\n {\n invalidateQueries: ['getDictionaries', 'getDictionary'],\n ...args,\n }\n );\nexport const useDeleteDictionary = (\n args?: UseAsyncOptions<typeof intlayerAPI.dictionary.deleteDictionary>\n) =>\n useAppAsync(\n 'deleteDictionary',\n useIntlayerAuth().dictionary.deleteDictionary,\n {\n invalidateQueries: [\n 'getDictionaries',\n 'getDictionary',\n 'getDictionariesKeys',\n ],\n ...args,\n }\n );\n\n/**\n * Tag\n */\n\nexport const useGetTags = (\n args?: UseAsyncOptions<typeof intlayerAPI.tag.getTags>\n) =>\n useAppAsync(\n 'getTags',\n useIntlayerAuth().tag.getTags,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\nexport const useAddTag = (\n args?: UseAsyncOptions<typeof intlayerAPI.tag.addTag>\n) =>\n useAppAsync('addTag', useIntlayerAuth().tag.addTag, {\n invalidateQueries: ['getTags'],\n ...args,\n });\nexport const useUpdateTag = (\n args?: UseAsyncOptions<typeof intlayerAPI.tag.updateTag>\n) =>\n useAppAsync('updateTag', useIntlayerAuth().tag.updateTag, {\n invalidateQueries: ['getTags'],\n ...args,\n });\nexport const useDeleteTag = (\n args?: UseAsyncOptions<typeof intlayerAPI.tag.deleteTag>\n) =>\n useAppAsync('deleteTag', useIntlayerAuth().tag.deleteTag, {\n invalidateQueries: ['getTags'],\n ...args,\n });\n\n/**\n * Stripe\n */\n\nexport const useGetSubscription = (\n args?: UseAsyncOptions<typeof intlayerAPI.stripe.getSubscription>\n) =>\n useAppAsync(\n 'getSubscription',\n useIntlayerAuth().stripe.getSubscription,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\n\nexport const useCancelSubscription = (\n args?: UseAsyncOptions<typeof intlayerAPI.stripe.cancelSubscription>\n) =>\n useAppAsync(\n 'cancelSubscription',\n useIntlayerAuth().stripe.cancelSubscription,\n { invalidateQueries: ['getSession'], ...args },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\n\n/**\n * AI\n */\n\nexport const useAuditContentDeclaration = (\n args?: UseAsyncOptions<typeof intlayerAPI.ai.auditContentDeclaration>\n) =>\n useAppAsync(\n 'auditContentDeclaration',\n useIntlayerAuth().ai.auditContentDeclaration,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAuditContentDeclarationMetadata = (\n args?: UseAsyncOptions<typeof intlayerAPI.ai.auditContentDeclarationMetadata>\n) =>\n useAppAsync(\n 'auditContentDeclaration',\n useIntlayerAuth().ai.auditContentDeclarationMetadata,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAuditContentDeclarationField = (\n args?: UseAsyncOptions<typeof intlayerAPI.ai.auditContentDeclarationField>\n) =>\n useAppAsync(\n 'auditContentDeclarationField',\n useIntlayerAuth().ai.auditContentDeclarationField,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAuditTag = (\n args?: UseAsyncOptions<typeof intlayerAPI.ai.auditTag>\n) =>\n useAppAsync('auditTag', useIntlayerAuth().ai.auditTag, args, {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n });\n\nexport const useAskDocQuestion = (\n args?: UseAsyncOptions<typeof intlayerAPI.ai.askDocQuestion>\n) => useAppAsync('askDocQuestion', useIntlayerAuth().ai.askDocQuestion, args);\n"],"names":["error"],"mappings":";;;;;;;AAAA,MAAe,UAAA,CAAA;ACaf,MAAM,mBAAmB,CAAiC,YAAkB;AACpE,QAAA,EAAE,MAAM,IAAI,SAAS;AAEpB,SAAA;AAAA,IACL,GAAG;AAAA,IACH,SAAS,CAAC,iBAAiB;AACrB,UAAA;AAGA,UAAA;AACM,gBAAA,KAAK,MAAM,YAAY;AAAA,eACxB,GAAG;AACV,gBAAQ,MAAM,CAAC;AAGP,gBAAA;AAAA,MAAA;AAKV,OAAC,KAAK,EACH,QAAQ,CAACA,WAAUA,MAAK,EACxB;AAAA,QAAQ,CAACA,WACR,MAAM;AAAA,UACJ,QACG,QAAQ,IAAI,aAAa,eACtBA,OAAM,QACNA,OAAM,SAAS;AAAA,UACrB,aAAaA,OAAM,WAAW,gBAAgB;AAAA,UAC9C,SAAS;AAAA,QACV,CAAA;AAAA,MACH;AACF,cAAQ,UAAU,YAAY;AAAA,IAChC;AAAA,IACA,WAAW,CAAC,SAAS;AACnB,UAAI,KAAK;AACD,cAAA;AAAA,UACJ,OAAO,KAAK;AAAA,UACZ,aAAa,KAAK;AAAA,UAClB,SAAS;AAAA,QAAA,CACV;AACH,cAAQ,YAAY,IAAI;AAAA,IAAA;AAAA,EAE5B;AACF;AAWA,MAAM,gBAAgB,CACpB,SACA,EAAE,aAAa,gBAAgB,oBAA2C,IAAA,OACpE;AACN,QAAM,EAAE,WAAW,mBAAmB,QAAA,IAAY,QAAQ;AAEpD,QAAA,kBAAkB,SAAS,UAAU;AAC3C,QAAM,OAAO,UAAU,QAAQ,OAAO,mBAAmB;AAEzD,QAAM,eAAe,UACjB,QAAQ,eACR,mBAAmB;AAEvB,QAAM,UA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errorCount
|
|
44
44
|
} = getStates(keyWithArgs);
|
|
45
45
|
const fetch = require$$0.useCallback(
|
|
46
46
|
async (...args2) => {
|
|
@@ -55,9 +55,10 @@ const useAsync = (key, asyncFunction, options) => {
|
|
|
55
55
|
response = result;
|
|
56
56
|
setQueryState(keyWithArgs2, {
|
|
57
57
|
data: result,
|
|
58
|
-
|
|
58
|
+
errorCount: 0,
|
|
59
59
|
isLoading: false,
|
|
60
60
|
isFetched: true,
|
|
61
|
+
fetchedDateTime: /* @__PURE__ */ new Date(),
|
|
61
62
|
isSuccess: true,
|
|
62
63
|
isInvalidated: false,
|
|
63
64
|
error: null
|
|
@@ -74,10 +75,11 @@ const useAsync = (key, asyncFunction, options) => {
|
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
77
|
if (storeEnabled) {
|
|
77
|
-
|
|
78
|
+
localStorage.setItem(keyWithArgs2, JSON.stringify(result));
|
|
78
79
|
}
|
|
79
80
|
}).catch((error2) => {
|
|
80
|
-
|
|
81
|
+
const msg = error2 instanceof Error ? error2.message : String(error2);
|
|
82
|
+
makeQueryInError(keyWithArgs2, msg);
|
|
81
83
|
onError?.(error2.message);
|
|
82
84
|
}).finally(() => {
|
|
83
85
|
pendingPromises.delete(keyWithArgs2);
|
|
@@ -89,15 +91,24 @@ const useAsync = (key, asyncFunction, options) => {
|
|
|
89
91
|
},
|
|
90
92
|
[asyncFunction, keyWithArgs, storeEnabled, cacheEnabled, onSuccess, onError]
|
|
91
93
|
);
|
|
92
|
-
const
|
|
94
|
+
const revalidate = require$$0.useCallback(
|
|
93
95
|
async (...args2) => {
|
|
94
96
|
if (!isEnabled || !enabled) return;
|
|
95
|
-
if (isLoading) return;
|
|
96
|
-
if (!isInvalidated && isSuccess && cacheEnabled && data) return data;
|
|
97
97
|
if (args2) {
|
|
98
|
-
storedArgsRef.current = getArgs(
|
|
98
|
+
storedArgsRef.current = getArgs(args2);
|
|
99
99
|
}
|
|
100
|
-
return await fetch(...
|
|
100
|
+
return await fetch(...storedArgsRef.current);
|
|
101
|
+
},
|
|
102
|
+
[isEnabled, enabled, storedArgsRef, fetch]
|
|
103
|
+
);
|
|
104
|
+
const execute = require$$0.useCallback(
|
|
105
|
+
async (...args2) => {
|
|
106
|
+
if (!isEnabled || !enabled) return;
|
|
107
|
+
if (isLoading) return;
|
|
108
|
+
const shouldReturnData = !isInvalidated && // If data are invalidated, we should refetch to revalidate the data
|
|
109
|
+
isSuccess && cacheEnabled && data;
|
|
110
|
+
if (shouldReturnData) return data;
|
|
111
|
+
return await revalidate(...args2);
|
|
101
112
|
},
|
|
102
113
|
[
|
|
103
114
|
isEnabled,
|
|
@@ -107,43 +118,9 @@ const useAsync = (key, asyncFunction, options) => {
|
|
|
107
118
|
isSuccess,
|
|
108
119
|
data,
|
|
109
120
|
isLoading,
|
|
110
|
-
|
|
121
|
+
revalidate
|
|
111
122
|
]
|
|
112
123
|
);
|
|
113
|
-
const revalidate = require$$0.useCallback(
|
|
114
|
-
async (...args2) => {
|
|
115
|
-
if (!isEnabled || !enabled) return;
|
|
116
|
-
if (args2) {
|
|
117
|
-
storedArgsRef.current = getArgs(...args2);
|
|
118
|
-
}
|
|
119
|
-
const result = await fetch(...storedArgsRef.current);
|
|
120
|
-
return result;
|
|
121
|
-
},
|
|
122
|
-
[isEnabled, enabled, storedArgsRef, fetch]
|
|
123
|
-
);
|
|
124
|
-
const autoRevalidate = require$$0.useCallback(async () => {
|
|
125
|
-
if (!isEnabled || !enabled) return;
|
|
126
|
-
if (isLoading) return;
|
|
127
|
-
if (!(cacheEnabled || storeEnabled)) return;
|
|
128
|
-
if (!isSuccess) return;
|
|
129
|
-
if (!revalidationEnabled || revalidateTime <= 0) return;
|
|
130
|
-
if (!fetchedDateTime) return;
|
|
131
|
-
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
132
|
-
const lastFetchedTime = new Date(fetchedDateTime).getTime();
|
|
133
|
-
const shouldRevalidate = now - lastFetchedTime >= revalidateTime;
|
|
134
|
-
if (shouldRevalidate) {
|
|
135
|
-
return await fetch(...storedArgsRef.current);
|
|
136
|
-
}
|
|
137
|
-
}, [
|
|
138
|
-
cacheEnabled,
|
|
139
|
-
revalidationEnabled,
|
|
140
|
-
revalidateTime,
|
|
141
|
-
isSuccess,
|
|
142
|
-
fetchedDateTime,
|
|
143
|
-
isLoading,
|
|
144
|
-
isEnabled,
|
|
145
|
-
enabled
|
|
146
|
-
]);
|
|
147
124
|
require$$0.useEffect(() => {
|
|
148
125
|
if (enabled !== isEnabled) {
|
|
149
126
|
setQueryState(keyWithArgs, {
|
|
@@ -151,6 +128,29 @@ const useAsync = (key, asyncFunction, options) => {
|
|
|
151
128
|
});
|
|
152
129
|
}
|
|
153
130
|
}, [enabled, isEnabled, keyWithArgs]);
|
|
131
|
+
require$$0.useEffect(() => {
|
|
132
|
+
if (!isEnabled || !enabled) return;
|
|
133
|
+
if (!storeEnabled) return;
|
|
134
|
+
if (isInvalidated || isFetched || data) return;
|
|
135
|
+
const storedData = localStorage.getItem(keyWithArgs);
|
|
136
|
+
try {
|
|
137
|
+
if (storedData) {
|
|
138
|
+
setQueryState(keyWithArgs, {
|
|
139
|
+
data: JSON.parse(storedData)
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
} catch (error2) {
|
|
143
|
+
console.error(error2);
|
|
144
|
+
}
|
|
145
|
+
}, [
|
|
146
|
+
storeEnabled,
|
|
147
|
+
keyWithArgs,
|
|
148
|
+
isFetched,
|
|
149
|
+
isInvalidated,
|
|
150
|
+
isEnabled,
|
|
151
|
+
enabled,
|
|
152
|
+
data
|
|
153
|
+
]);
|
|
154
154
|
require$$0.useEffect(() => {
|
|
155
155
|
if (!autoFetch) return;
|
|
156
156
|
if (!isEnabled || !enabled) return;
|
|
@@ -159,61 +159,59 @@ const useAsync = (key, asyncFunction, options) => {
|
|
|
159
159
|
fetch(...storedArgsRef.current);
|
|
160
160
|
}, [
|
|
161
161
|
autoFetch,
|
|
162
|
-
isFetched,
|
|
163
|
-
isInvalidated,
|
|
164
162
|
isEnabled,
|
|
165
163
|
enabled,
|
|
164
|
+
isFetched,
|
|
165
|
+
isInvalidated,
|
|
166
166
|
isLoading,
|
|
167
167
|
fetch
|
|
168
168
|
]);
|
|
169
169
|
require$$0.useEffect(() => {
|
|
170
170
|
const isRetryEnabled = errorCount > 0 && retryLimit > 0;
|
|
171
|
-
const isRetryLimitReached = errorCount
|
|
171
|
+
const isRetryLimitReached = errorCount > retryLimit;
|
|
172
172
|
if (!isEnabled || !enabled) return;
|
|
173
|
+
if (!isRetryEnabled) return;
|
|
174
|
+
if (isRetryLimitReached) return;
|
|
173
175
|
if (!(cacheEnabled || storeEnabled)) return;
|
|
174
|
-
if (!isRetryEnabled || isRetryLimitReached) return;
|
|
175
|
-
if (isSuccess) return;
|
|
176
176
|
if (isLoading) return;
|
|
177
|
-
|
|
177
|
+
if (isSuccess) return;
|
|
178
|
+
const timeout = setTimeout(() => {
|
|
178
179
|
fetch(...storedArgsRef.current);
|
|
179
180
|
}, retryTime);
|
|
180
|
-
return () => clearTimeout(
|
|
181
|
+
return () => clearTimeout(timeout);
|
|
181
182
|
}, [
|
|
182
|
-
|
|
183
|
+
isEnabled,
|
|
183
184
|
errorCount,
|
|
184
185
|
retryLimit,
|
|
186
|
+
enabled,
|
|
185
187
|
retryTime,
|
|
188
|
+
cacheEnabled,
|
|
189
|
+
storeEnabled,
|
|
186
190
|
isSuccess,
|
|
187
|
-
isEnabled,
|
|
188
|
-
enabled,
|
|
189
191
|
isLoading,
|
|
190
|
-
|
|
191
|
-
storeEnabled
|
|
192
|
+
fetch
|
|
192
193
|
]);
|
|
193
194
|
require$$0.useEffect(() => {
|
|
194
|
-
|
|
195
|
-
return () => clearInterval(interval);
|
|
196
|
-
}, [autoRevalidate, revalidateTime]);
|
|
197
|
-
require$$0.useEffect(() => {
|
|
195
|
+
if (!revalidationEnabled || revalidateTime <= 0) return;
|
|
198
196
|
if (!isEnabled || !enabled) return;
|
|
199
|
-
if (
|
|
200
|
-
if (
|
|
201
|
-
if (
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
data: JSON.parse(storedData)
|
|
207
|
-
});
|
|
208
|
-
}
|
|
197
|
+
if (isLoading) return;
|
|
198
|
+
if (!isSuccess || !fetchedDateTime) return;
|
|
199
|
+
if (!(cacheEnabled || storeEnabled)) return;
|
|
200
|
+
const timeout = setTimeout(() => {
|
|
201
|
+
fetch(...storedArgsRef.current);
|
|
202
|
+
}, revalidateTime);
|
|
203
|
+
return () => clearTimeout(timeout);
|
|
209
204
|
}, [
|
|
205
|
+
revalidationEnabled,
|
|
206
|
+
revalidateTime,
|
|
207
|
+
cacheEnabled,
|
|
210
208
|
storeEnabled,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
209
|
+
isSuccess,
|
|
210
|
+
fetchedDateTime,
|
|
211
|
+
isLoading,
|
|
214
212
|
isEnabled,
|
|
215
213
|
enabled,
|
|
216
|
-
|
|
214
|
+
fetch
|
|
217
215
|
]);
|
|
218
216
|
const setDataMemo = require$$0.useCallback(
|
|
219
217
|
(data2) => {
|
|
@@ -226,15 +224,20 @@ const useAsync = (key, asyncFunction, options) => {
|
|
|
226
224
|
const memoResult = require$$0.useMemo(
|
|
227
225
|
() => ({
|
|
228
226
|
isFetched,
|
|
229
|
-
isLoading,
|
|
230
227
|
isInvalidated,
|
|
231
228
|
error,
|
|
232
|
-
isSuccess,
|
|
233
229
|
data,
|
|
234
|
-
|
|
235
|
-
|
|
230
|
+
errorCount,
|
|
231
|
+
isSuccess,
|
|
236
232
|
isEnabled,
|
|
233
|
+
isDisabled: !isEnabled,
|
|
234
|
+
isLoading,
|
|
235
|
+
isWaitingData: isLoading && !isFetched && !data,
|
|
236
|
+
// Check if the data is still being fetched. Stay at true during revalidation or if data are stored in local storage
|
|
237
|
+
isRevalidating: isLoading && isFetched,
|
|
238
|
+
// Check if the data is valid and is being revalidated
|
|
237
239
|
[key]: execute,
|
|
240
|
+
// Name the execute function as the given key to avoid conflicts with other hooks (e.g. `const { fetchUser } = useAsync('fetchUser', () => fetchUserFunction());`)
|
|
238
241
|
revalidate,
|
|
239
242
|
setData: setDataMemo
|
|
240
243
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAsync.cjs","sources":["../../../src/hooks/useAsync/useAsync.ts"],"sourcesContent":["'use client';\n\n// This is an ESLint directive to disable specific rules.\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useAsyncState } from './useAsyncStateStore';\n\n// Pending promises cache to prevent parallel requests when multiple components use the hook\nconst pendingPromises = new Map();\n\n// Defines the base structure for the result of the custom hook.\ntype UseAsyncResultBase<T extends (...args: any[]) => Promise<any>> = {\n isFetched: boolean;\n isLoading: boolean;\n isInvalidated: boolean;\n isSuccess: boolean;\n isDisabled: boolean;\n error: string | null;\n data: Awaited<ReturnType<T>> | null;\n retryCount: number;\n revalidate: T;\n setData: (data: Awaited<ReturnType<T> | null>) => void;\n};\n\n// Options type for the hook, allowing customization of behavior.\nexport type UseAsyncOptions<T extends (...args: any[]) => Promise<any>> = {\n retryLimit?: number; // The number of times the hook should retry the function on failure before giving up\n retryTime?: number; // Time in milliseconds for retrying the data\n cache?: boolean; // Cache the result of the function using zustand\n store?: boolean; // Store the result of the function in session storage\n enable?: boolean; // Enable the hook\n autoFetch?: boolean; // Automatically fetch the data when the hook is mounted\n revalidation?: boolean; // Enable revalidation\n revalidateTime?: number; // Time in milliseconds for revalidating the data\n invalidateQueries?: string[]; // Invalidate other queries when the data is updated\n updateQueries?: string[]; // Update other queries when the data is updated\n onSuccess?: (data: Awaited<ReturnType<T>>) => void; // Callback function that is called when the asynchronous function resolves successfully\n onError?: (error: string) => void; // Callback function that is called when the asynchronous function rejects or encounters an error\n args?: Parameters<T>; // Arguments to pass to the asynchronous function\n};\n\n// Default values for the hook's options\nconst DEFAULT_CACHE_ENABLED = false;\nconst DEFAULT_STORE_ENABLED = false;\nconst DEFAULT_ENABLED = true;\nconst DEFAULT_AUTO_FETCH = false;\nconst DEFAULT_RETRY_LIMIT = 1;\nconst DEFAULT_REVALIDATION_ENABLED = false;\nconst DEFAULT_REVALIDATE_TIME = 5 * 60 * 1000; // 5 minutes\nconst DEFAULT_RETRY_TIME = 5 * 60 * 1000; // 5 minutes\n\n// The main hook type that includes the async function along with its additional properties.\nexport type UseAsyncResult<\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n> = UseAsyncResultBase<T> & Record<U, T>;\n\nconst getArgs = (args?: any[]): any[] =>\n args ? (Array.isArray(args) ? args : [args]) : [];\n\nconst getKeyWithArgs = (key: string, args: any[]) =>\n getArgs(args).length > 0 ? `${key}/${JSON.stringify(args)}` : key;\n\n/**\n * A custom React hook that manages asynchronous operations, providing easy-to-use states and controls over fetching, caching, and retry mechanisms.\n * This hook abstracts away the complexity of handling loading, error, and success states for any asynchronous function.\n *\n * @template U - A string type that extends the keys of the async function, used as a key to store and retrieve state.\n * @template T - A function type that must return a Promise, representing the asynchronous operation to be managed.\n *\n * @param {U} key - A unique identifier for the async operation, used to handle state internally and avoid conflicts.\n * @param {T} asyncFunction - The asynchronous function that will be managed by this hook. This function should return a Promise.\n * @param {UseAsyncOptions<T>} [options] - Optional configuration options to customize the behavior of the hook.\n * @returns {UseAsyncResult<U, T>} The states and controls related to the managed async function. Includes states like isLoading, isSuccess, and provides control methods like revalidate and setData.\n *\n * @typedef {Object} UseAsyncOptions\n * @property {number} [retryTime=300000] - Time in milliseconds for retrying the data after an error occurs.\n * @property {number} [retryLimit=1] - The number of times the hook should retry the asynchronous function on failure before giving up.\n * @property {boolean} [revalidation=false] - Enable revalidation.\n * @property {number} [revalidateTime=300000] - Time in milliseconds after which the cached data is considered stale and the async function is re-invoked, if caching is enabled.\n * @property {boolean} [cache=false] - Whether to cache the result of the async function. When enabled, revalidation is controlled by `revalidateTime`.\n * @property {boolean} [store=false] - Store the result of the function in session storage.\n * @property {boolean} [autoFetch=false] - Whether the hook should automatically invoke the asynchronous function on mount.\n * @property {number} [revalidateTime=300000] - Time in milliseconds after which the cached data is considered stale and the async function is re-invoked, if caching is enabled.\n * @property {string[]} [updateQueries=[]] - Update other queries when the data is updated.\n * @property {string[]} [invalidateQueries=[]] - Invalidate other queries when the data is updated.\n * @property {(data: Awaited<ReturnType<T>>) => void} [onSuccess] - Callback function that is called when the asynchronous function resolves successfully.\n * @property {(error: string) => void} [onError] - Callback function that is called when the asynchronous function rejects or encounters an error.\n * @property {Parameters<T>} [args=[]] - Arguments to pass to the asynchronous function.\n *\n *\n * @example\n * // Example of using useAsync to manage fetching user data from an API.\n * const fetchUserData = async (userId) => {\n * const response = await fetch(`/api/users/${userId}`);\n * if (!response.ok) throw new Error('Failed to fetch');\n * return await response.json();\n * };\n *\n * const UserDetails = ({ userId }) => {\n * const {\n * isLoading,\n * data,\n * error,\n * revalidate,\n * } = useAsync('userDetails', fetchUserData, {\n * cache: true,\n * revalidateTime: 60000, // 1 minute\n * autoFetch: true,\n * onSuccess: (data) => console.log('User data fetched successfully:', data),\n * onError: (error) => console.error('Error fetching user data:', error),\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error}</div>;\n * return (\n * <div>\n * <h1>{data.name}</h1>\n * <button onClick={() => revalidate()}>Refresh</button>\n * </div>\n * );\n * };\n */\nexport const useAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>\n): UseAsyncResult<U, T> => {\n // Resolving optional parameters with default values\n const retryLimit = options?.retryLimit ?? DEFAULT_RETRY_LIMIT;\n const autoFetch = options?.autoFetch ?? DEFAULT_AUTO_FETCH;\n const retryTime = options?.retryTime ?? DEFAULT_RETRY_TIME;\n const cacheEnabled = options?.cache ?? DEFAULT_CACHE_ENABLED;\n const storeEnabled = options?.store ?? DEFAULT_STORE_ENABLED;\n const enabled = options?.enable ?? DEFAULT_ENABLED;\n const revalidationEnabled =\n options?.revalidation ?? DEFAULT_REVALIDATION_ENABLED;\n const revalidateTime = options?.revalidateTime ?? DEFAULT_REVALIDATE_TIME;\n const updateQueries = options?.updateQueries ?? [];\n const invalidateQueries = options?.invalidateQueries ?? [];\n const onSuccess = options?.onSuccess;\n const onError = options?.onError;\n const args = getArgs(options?.args ?? []);\n\n // Using a custom hook to manage state specific to asynchronous operations\n const { getStates, setQueryState, setQueriesState, makeQueryInError } =\n useAsyncState();\n\n // Storing the last arguments used to call the async function\n const storedArgsRef = useRef<any[]>(args);\n\n // Apply different key for different requests\n const keyWithArgs = getKeyWithArgs(key, storedArgsRef.current);\n\n // Retrieving the current state of async operations using the same custom hook\n const {\n isFetched,\n fetchedDateTime,\n isLoading,\n isEnabled,\n error,\n isSuccess,\n isInvalidated,\n data,\n retryCount: errorCount,\n } = getStates(keyWithArgs);\n\n // The core fetching function, designed to be called directly or automatically based on configuration\n const fetch: T = useCallback<T>(\n (async (...args) => {\n const keyWithArgs = getKeyWithArgs(key, args);\n\n if (pendingPromises.has(keyWithArgs)) {\n // Return the existing pending promise\n return pendingPromises.get(keyWithArgs);\n }\n\n const promise = (async () => {\n setQueryState(keyWithArgs, { isLoading: true });\n let response = null;\n\n await asyncFunction(...args)\n .then((result) => {\n response = result;\n\n setQueryState(keyWithArgs, {\n data: result,\n retryCount: 0,\n isLoading: false,\n isFetched: true,\n isSuccess: true,\n isInvalidated: false,\n error: null,\n });\n\n onSuccess?.(result);\n\n // Invalidate other queries if necessary\n if (invalidateQueries.length > 0) {\n setQueriesState(invalidateQueries, {\n isInvalidated: true,\n });\n }\n\n // Update other queries if necessary\n if (updateQueries.length > 0) {\n setQueriesState(updateQueries, {\n data: result,\n });\n }\n\n // Store the result in session storage\n if (storeEnabled) {\n sessionStorage.setItem(keyWithArgs, JSON.stringify(result));\n }\n })\n .catch((error) => {\n makeQueryInError(keyWithArgs, error.message);\n onError?.(error.message);\n })\n .finally(() => {\n // Remove the pending promise from the cache\n pendingPromises.delete(keyWithArgs);\n });\n\n return response;\n })();\n\n // Store the pending promise in the cache\n pendingPromises.set(keyWithArgs, promise);\n\n return await promise;\n }) as T,\n [asyncFunction, keyWithArgs, storeEnabled, cacheEnabled, onSuccess, onError]\n );\n\n // Wrapped execution function to handle disabled state and check for success before re-fetching\n const execute: T = useCallback<T>(\n (async (...args) => {\n if (!isEnabled || !enabled) return;\n if (isLoading) return;\n if (!isInvalidated && isSuccess && cacheEnabled && data) return data;\n\n if (args) {\n storedArgsRef.current = getArgs(...args);\n }\n\n return await fetch(...args);\n }) as T,\n [\n isEnabled,\n enabled,\n isInvalidated,\n cacheEnabled,\n isSuccess,\n data,\n isLoading,\n fetch,\n ]\n );\n\n // Function to revalidate the data when necessary\n const revalidate: T = useCallback<T>(\n (async (...args) => {\n if (!isEnabled || !enabled) return;\n\n if (args) {\n storedArgsRef.current = getArgs(...args);\n }\n\n const result = await fetch(...storedArgsRef.current);\n\n return result;\n }) as T,\n [isEnabled, enabled, storedArgsRef, fetch]\n );\n\n const autoRevalidate = useCallback(async () => {\n if (!isEnabled || !enabled) return;\n if (isLoading) return;\n if (!(cacheEnabled || storeEnabled)) return;\n if (!isSuccess) return;\n if (!revalidationEnabled || revalidateTime <= 0) return;\n if (!fetchedDateTime) return;\n\n const now = new Date().getTime();\n const lastFetchedTime = new Date(fetchedDateTime).getTime();\n const shouldRevalidate = now - lastFetchedTime >= revalidateTime;\n if (shouldRevalidate) {\n return await fetch(...storedArgsRef.current);\n }\n }, [\n cacheEnabled,\n revalidationEnabled,\n revalidateTime,\n isSuccess,\n fetchedDateTime,\n isLoading,\n isEnabled,\n enabled,\n ]);\n\n useEffect(() => {\n if (enabled !== isEnabled) {\n setQueryState(keyWithArgs, {\n isEnabled,\n });\n }\n }, [enabled, isEnabled, keyWithArgs]);\n\n // Auto-fetch data on hook mount if autoFetch is true\n useEffect(() => {\n if (!autoFetch) return;\n if (!isEnabled || !enabled) return;\n if (isFetched && !isInvalidated) return;\n if (isLoading) return;\n\n fetch(...storedArgsRef.current);\n }, [\n autoFetch,\n isFetched,\n isInvalidated,\n isEnabled,\n enabled,\n isLoading,\n fetch,\n ]);\n\n // Handle retry based on conditions set in options\n useEffect(() => {\n const isRetryEnabled = errorCount > 0 && retryLimit > 0;\n const isRetryLimitReached = errorCount >= retryLimit;\n if (!isEnabled || !enabled) return;\n if (!(cacheEnabled || storeEnabled)) return;\n if (!isRetryEnabled || isRetryLimitReached) return;\n if (isSuccess) return;\n if (isLoading) return;\n\n const timeOut = setTimeout(() => {\n fetch(...storedArgsRef.current);\n }, retryTime);\n\n return () => clearTimeout(timeOut);\n }, [\n fetch,\n errorCount,\n retryLimit,\n retryTime,\n isSuccess,\n isEnabled,\n enabled,\n isLoading,\n cacheEnabled,\n storeEnabled,\n ]);\n\n // Handle periodic revalidation if caching is enabled\n useEffect(() => {\n const interval = setInterval(autoRevalidate, revalidateTime);\n\n return () => clearInterval(interval);\n }, [autoRevalidate, revalidateTime]);\n\n // Load data from session storage if storeEnabled is true\n useEffect(() => {\n if (!isEnabled || !enabled) return;\n if (!storeEnabled) return;\n if (isInvalidated) return;\n if (isFetched) return;\n if (data) return;\n\n const storedData = sessionStorage.getItem(keyWithArgs);\n\n if (storedData && JSON.stringify(storedData) !== JSON.stringify(data)) {\n setQueryState(keyWithArgs, {\n data: JSON.parse(storedData),\n });\n }\n }, [\n storeEnabled,\n keyWithArgs,\n isFetched,\n isInvalidated,\n isEnabled,\n enabled,\n data,\n ]);\n\n // Memoization of the setData function to prevent unnecessary re-renders\n const setDataMemo = useCallback(\n (data: Awaited<ReturnType<T> | null>) => {\n setQueryState(keyWithArgs, {\n data,\n });\n },\n [keyWithArgs]\n );\n\n const memoResult = useMemo(\n () => ({\n isFetched,\n isLoading,\n isInvalidated,\n error,\n isSuccess,\n data,\n retryCount: errorCount,\n isDisabled: !isEnabled,\n isEnabled,\n [key]: execute,\n revalidate,\n setData: setDataMemo,\n }),\n [\n isFetched,\n isLoading,\n isInvalidated,\n error,\n isSuccess,\n data,\n errorCount,\n isEnabled,\n key,\n execute,\n revalidate,\n setDataMemo,\n ]\n );\n\n // Return the hook's result, including all state and control functions\n return memoResult as UseAsyncResultBase<T> & Record<U, T>;\n};\n"],"names":["useAsyncState","useRef","useCallback","args","keyWithArgs","error","useEffect","data","useMemo"],"mappings":";;;;;AASA,MAAM,sCAAsB,IAAI;AAkChC,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAC9B,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;AAC3B,MAAM,sBAAsB;AAC5B,MAAM,+BAA+B;AACrC,MAAM,0BAA0B,IAAI,KAAK;AACzC,MAAM,qBAAqB,IAAI,KAAK;AAQpC,MAAM,UAAU,CAAC,SACf,OAAQ,MAAM,QAAQ,IAAI,IAAI,OAAO,CAAC,IAAI,IAAK,CAAC;AAElD,MAAM,iBAAiB,CAAC,KAAa,SACnC,QAAQ,IAAI,EAAE,SAAS,IAAI,GAAG,GAAG,IAAI,KAAK,UAAU,IAAI,CAAC,KAAK;AA8DzD,MAAM,WAAW,CAItB,KACA,eACA,YACyB;AAEnB,QAAA,aAAa,SAAS,cAAc;AACpC,QAAA,YAAY,SAAS,aAAa;AAClC,QAAA,YAAY,SAAS,aAAa;AAClC,QAAA,eAAe,SAAS,SAAS;AACjC,QAAA,eAAe,SAAS,SAAS;AACjC,QAAA,UAAU,SAAS,UAAU;AAC7B,QAAA,sBACJ,SAAS,gBAAgB;AACrB,QAAA,iBAAiB,SAAS,kBAAkB;AAC5C,QAAA,gBAAgB,SAAS,iBAAiB,CAAC;AAC3C,QAAA,oBAAoB,SAAS,qBAAqB,CAAC;AACzD,QAAM,YAAY,SAAS;AAC3B,QAAM,UAAU,SAAS;AACzB,QAAM,OAAO,QAAQ,SAAS,QAAQ,CAAA,CAAE;AAGxC,QAAM,EAAE,WAAW,eAAe,iBAAiB,iBAAA,IACjDA,kCAAAA,cAAc;AAGV,QAAA,gBAAgBC,kBAAc,IAAI;AAGxC,QAAM,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AAI,cAAe;AACnB,QAAI,UAAW;AACf,QAAI,KAAM;AAEJ,UAAA,aAAa,eAAe,QAAQ,WAAW;AAEjD,QAAA,cAAc,KAAK,UAAU,UAAU,MAAM,KAAK,UAAU,IAAI,GAAG;AACrE,oBAAc,aAAa;AAAA,QACzB,MAAM,KAAK,MAAM,UAAU;AAAA,MAAA,CAC5B;AAAA,IAAA;AAAA,EACH,GACC;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAGD,QAAM,cAAcJ,WAAA;AAAA,IAClB,CAACK,UAAwC;AACvC,oBAAc,aAAa;AAAA,QACzB,MAAAA;AAAAA,MAAA,CACD;AAAA,IACH;AAAA,IACA,CAAC,WAAW;AAAA,EACd;AAEA,QAAM,aAAaC,WAAA;AAAA,IACjB,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,YAAY,CAAC;AAAA,MACb;AAAA,MACA,CAAC,GAAG,GAAG;AAAA,MACP;AAAA,MACA,SAAS;AAAA,IAAA;AAAA,IAEX;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AAGO,SAAA;AACT;;"}
|
|
1
|
+
{"version":3,"file":"useAsync.cjs","sources":["../../../src/hooks/useAsync/useAsync.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n'use client';\n\nimport { useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useAsyncState } from './useAsyncStateStore';\n\n// Pending promises cache to prevent parallel requests when multiple components use the hook\nconst pendingPromises = new Map();\n\n// Defines the base structure for the result of the custom hook.\ntype UseAsyncResultBase<T extends (...args: any[]) => Promise<any>> = {\n isFetched: boolean;\n isLoading: boolean;\n isInvalidated: boolean;\n isSuccess: boolean;\n isDisabled: boolean;\n isWaitingData: boolean;\n isRevalidating: boolean;\n error: string | null;\n data: Awaited<ReturnType<T>> | null;\n errorCount: number;\n revalidate: T;\n setData: (data: Awaited<ReturnType<T> | null>) => void;\n};\n\n// Options type for the hook, allowing customization of behavior.\nexport type UseAsyncOptions<T extends (...args: any[]) => Promise<any>> = {\n retryLimit?: number; // The number of times the hook should retry the function on failure before giving up\n retryTime?: number; // Time in milliseconds for retrying the data\n cache?: boolean; // Cache the result of the function\n store?: boolean; // Store the result of the function in local storage\n enable?: boolean; // Enable the hook\n autoFetch?: boolean; // Automatically fetch the data when the hook is mounted\n revalidation?: boolean; // Enable revalidation\n revalidateTime?: number; // Time in milliseconds for revalidating the data\n invalidateQueries?: string[]; // Invalidate other queries when the data is updated\n updateQueries?: string[]; // Update other queries when the data is updated\n onSuccess?: (data: Awaited<ReturnType<T>>) => void; // Callback function that is called when the asynchronous function resolves successfully\n onError?: (error: string) => void; // Callback function that is called when the asynchronous function rejects or encounters an error\n args?: Parameters<T>; // Arguments to pass to the asynchronous function\n};\n\n// Default values for the hook's options\nconst DEFAULT_CACHE_ENABLED = false;\nconst DEFAULT_STORE_ENABLED = false;\nconst DEFAULT_ENABLED = true;\nconst DEFAULT_AUTO_FETCH = false;\nconst DEFAULT_RETRY_LIMIT = 1;\nconst DEFAULT_REVALIDATION_ENABLED = false;\nconst DEFAULT_REVALIDATE_TIME = 5 * 60 * 1000; // 5 minutes\nconst DEFAULT_RETRY_TIME = 5 * 60 * 1000; // 5 minutes\n\n// The main hook type that includes the async function along with its additional properties.\nexport type UseAsyncResult<\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n> = UseAsyncResultBase<T> & Record<U, T>;\n\nconst getArgs = (args?: any[]): any[] =>\n args ? (Array.isArray(args) ? args : [args]) : [];\n\nconst getKeyWithArgs = (key: string, args: any[]) =>\n getArgs(args).length > 0 ? `${key}/${JSON.stringify(args)}` : key;\n\n/**\n * A custom React hook that manages asynchronous operations, providing easy-to-use states and controls over fetching, caching, and retry mechanisms.\n * This hook abstracts away the complexity of handling loading, error, and success states for any asynchronous function.\n *\n *\n * ```tsx\n * // Example of using useAsync to manage fetching user data from an API.\n * const fetchUserData = async (userId) => {\n * const response = await fetch(`/api/users/${userId}`);\n * if (!response.ok) throw new Error('Failed to fetch');\n * return await response.json();\n * };\n *\n * const UserDetails = ({ userId }) => {\n * const {\n * isLoading,\n * data,\n * error,\n * revalidate,\n * } = useAsync('userDetails', fetchUserData, {\n * cache: true,\n * revalidateTime: 60000, // 1 minute\n * autoFetch: true,\n * onSuccess: (data) => console.log('User data fetched successfully:', data),\n * onError: (error) => console.error('Error fetching user data:', error),\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error}</div>;\n * return (\n * <div>\n * <h1>{data.name}</h1>\n * <button onClick={() => revalidate()}>Refresh</button>\n * </div>\n * );\n * };\n * ```\n */\nexport const useAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>\n): UseAsyncResult<U, T> => {\n // Resolving optional parameters with default values\n const retryLimit = options?.retryLimit ?? DEFAULT_RETRY_LIMIT;\n const autoFetch = options?.autoFetch ?? DEFAULT_AUTO_FETCH;\n const retryTime = options?.retryTime ?? DEFAULT_RETRY_TIME;\n const cacheEnabled = options?.cache ?? DEFAULT_CACHE_ENABLED;\n const storeEnabled = options?.store ?? DEFAULT_STORE_ENABLED;\n const enabled = options?.enable ?? DEFAULT_ENABLED;\n const revalidationEnabled =\n options?.revalidation ?? DEFAULT_REVALIDATION_ENABLED;\n const revalidateTime = options?.revalidateTime ?? DEFAULT_REVALIDATE_TIME;\n const updateQueries = options?.updateQueries ?? [];\n const invalidateQueries = options?.invalidateQueries ?? [];\n const onSuccess = options?.onSuccess;\n const onError = options?.onError;\n const args = getArgs(options?.args ?? []);\n\n // Using a custom hook to manage state specific to asynchronous operations\n const { getStates, setQueryState, setQueriesState, makeQueryInError } =\n useAsyncState();\n\n // Storing the last arguments used to call the async function\n const storedArgsRef = useRef<any[]>(args);\n\n // Apply different key for different requests\n const keyWithArgs = getKeyWithArgs(key, storedArgsRef.current);\n\n // Retrieving the current state of async operations using the same custom hook\n const {\n isFetched,\n fetchedDateTime,\n isLoading,\n isEnabled,\n error,\n isSuccess,\n isInvalidated,\n data,\n errorCount,\n } = getStates(keyWithArgs);\n\n /**\n * FETCH FUNCTION\n *\n * Manage parallel fetching across multiple instances of the hook\n * Manage state updates on success and error\n * Manage eventual invalidation of other queries\n */\n const fetch: T = useCallback<T>(\n (async (...args) => {\n const keyWithArgs = getKeyWithArgs(key, args);\n\n if (pendingPromises.has(keyWithArgs)) {\n // Return the existing pending promise\n return pendingPromises.get(keyWithArgs);\n }\n\n const promise = (async () => {\n setQueryState(keyWithArgs, { isLoading: true });\n let response = null;\n\n await asyncFunction(...args)\n .then((result) => {\n response = result;\n\n setQueryState(keyWithArgs, {\n data: result,\n errorCount: 0,\n isLoading: false,\n isFetched: true,\n fetchedDateTime: new Date(),\n isSuccess: true,\n isInvalidated: false,\n error: null,\n });\n\n onSuccess?.(result);\n\n // Invalidate other queries if necessary\n if (invalidateQueries.length > 0) {\n setQueriesState(invalidateQueries, {\n isInvalidated: true,\n });\n }\n\n // Update other queries if necessary\n if (updateQueries.length > 0) {\n setQueriesState(updateQueries, {\n data: result,\n });\n }\n\n // Store the result in local storage\n if (storeEnabled) {\n localStorage.setItem(keyWithArgs, JSON.stringify(result));\n }\n })\n .catch((error) => {\n const msg = error instanceof Error ? error.message : String(error);\n\n makeQueryInError(keyWithArgs, msg);\n onError?.(error.message);\n })\n .finally(() => {\n // Remove the pending promise from the cache\n pendingPromises.delete(keyWithArgs);\n });\n\n return response;\n })();\n\n // Store the pending promise in the cache\n pendingPromises.set(keyWithArgs, promise);\n\n return await promise;\n }) as T,\n [asyncFunction, keyWithArgs, storeEnabled, cacheEnabled, onSuccess, onError]\n );\n\n /**\n * REVALIDATE FUNCTION\n *\n * Wrap core function to handle revalidation\n * Handle arguments caching\n *\n */\n const revalidate: T = useCallback<T>(\n (async (...args) => {\n if (!isEnabled || !enabled) return; // Hook is disabled\n\n if (args) {\n // Revalidation arguments can be different from the initial fetch arguments\n // If arguments are provided, store/update them for future periodic revalidation\n\n storedArgsRef.current = getArgs(args);\n }\n\n return await fetch(...storedArgsRef.current);\n }) as T,\n [isEnabled, enabled, storedArgsRef, fetch]\n );\n\n /**\n * EXECUTION FUNCTION\n *\n * Wrap revalidation function\n * If data is valid return it directly to avoid fetching again\n */\n const execute: T = useCallback<T>(\n (async (...args) => {\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (isLoading) return; // Fetch is already in progress\n\n const shouldReturnData =\n !isInvalidated && // If data are invalidated, we should refetch to revalidate the data\n isSuccess &&\n cacheEnabled &&\n data;\n\n if (shouldReturnData) return data; // Data are already fetched and should be returned directly. Avoid fetching again.\n\n return await revalidate(...args);\n }) as T,\n [\n isEnabled,\n enabled,\n isInvalidated,\n cacheEnabled,\n isSuccess,\n data,\n isLoading,\n revalidate,\n ]\n );\n\n /**\n * HANDLE SYNCHRONIZATION HOOKS DISACTIVATION\n *\n * If one instance of the hook is disabled, the other instances should be disabled too.\n * This is to prevent inconsistencies in the state of the hook.\n */\n useEffect(() => {\n if (enabled !== isEnabled) {\n setQueryState(keyWithArgs, {\n isEnabled,\n });\n }\n }, [enabled, isEnabled, keyWithArgs]);\n\n /**\n * HANDLE LOCAL STORAGE LOADING\n *\n * If store is enabled, load data from local storage\n */\n useEffect(() => {\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (!storeEnabled) return; // Hook should not use local storage\n if (isInvalidated || isFetched || data) return; // Hook have been already mounted and fetched or invalidated\n\n const storedData = localStorage.getItem(keyWithArgs);\n\n // Wrap parsing in a try-catch block to handle invalid JSON data\n try {\n if (storedData) {\n setQueryState(keyWithArgs, {\n data: JSON.parse(storedData),\n });\n }\n } catch (error) {\n console.error(error);\n }\n }, [\n storeEnabled,\n keyWithArgs,\n isFetched,\n isInvalidated,\n isEnabled,\n enabled,\n data,\n ]);\n\n /**\n * HANDLE AUTO-FETCH ON HOOK MOUNT\n *\n * If autoFetch is enabled, fetch the data when the hook is mounted\n */\n useEffect(() => {\n if (!autoFetch) return; // Auto-fetch is disabled\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (isFetched && !isInvalidated) return; // Hook have already fetched or invalidated\n if (isLoading) return; // Fetch is already in progress\n\n fetch(...storedArgsRef.current);\n }, [\n autoFetch,\n isEnabled,\n enabled,\n isFetched,\n isInvalidated,\n isLoading,\n fetch,\n ]);\n\n /**\n * HANDLE RETRY\n *\n * If fetching fails, retry the fetch after a certain time\n */\n useEffect(() => {\n const isRetryEnabled = errorCount > 0 && retryLimit > 0;\n const isRetryLimitReached = errorCount > retryLimit;\n\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (!isRetryEnabled) return; // Retry is disabled\n if (isRetryLimitReached) return; // Retry limit has been reached\n if (!(cacheEnabled || storeEnabled)) return; // Useless to retry if caching is disabled\n if (isLoading) return; // Fetch is already in progress\n if (isSuccess) return; // Hook has already fetched successfully\n\n const timeout = setTimeout(() => {\n fetch(...storedArgsRef.current);\n }, retryTime);\n\n return () => clearTimeout(timeout);\n }, [\n isEnabled,\n errorCount,\n retryLimit,\n enabled,\n retryTime,\n cacheEnabled,\n storeEnabled,\n isSuccess,\n isLoading,\n fetch,\n ]);\n\n /**\n * HANDLE PERIODIC REVALIDATION\n *\n * If revalidation is enabled, revalidate the data periodically\n */\n useEffect(() => {\n if (!revalidationEnabled || revalidateTime <= 0) return; // Revalidation is disabled\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (isLoading) return; // Fetch is already in progress\n if (!isSuccess || !fetchedDateTime) return; // Should retry either of revalidate\n if (!(cacheEnabled || storeEnabled)) return; // Useless to revalidate if caching is disabled\n\n const timeout = setTimeout(() => {\n fetch(...storedArgsRef.current);\n }, revalidateTime);\n\n return () => clearTimeout(timeout);\n }, [\n revalidationEnabled,\n revalidateTime,\n cacheEnabled,\n storeEnabled,\n isSuccess,\n fetchedDateTime,\n isLoading,\n isEnabled,\n enabled,\n fetch,\n ]);\n\n // Memoization of the setData function to prevent unnecessary re-renders\n const setDataMemo = useCallback(\n (data: Awaited<ReturnType<T> | null>) => {\n setQueryState(keyWithArgs, {\n data,\n });\n },\n [keyWithArgs]\n );\n\n // Memoization to prevent unnecessary re-renders\n const memoResult = useMemo(\n () => ({\n isFetched,\n isInvalidated,\n error,\n data,\n errorCount,\n isSuccess,\n isEnabled,\n isDisabled: !isEnabled,\n isLoading,\n isWaitingData: isLoading && !isFetched && !data, // Check if the data is still being fetched. Stay at true during revalidation or if data are stored in local storage\n isRevalidating: isLoading && isFetched, // Check if the data is valid and is being revalidated\n [key]: execute, // Name the execute function as the given key to avoid conflicts with other hooks (e.g. `const { fetchUser } = useAsync('fetchUser', () => fetchUserFunction());`)\n revalidate,\n setData: setDataMemo,\n }),\n [\n isFetched,\n isLoading,\n isInvalidated,\n error,\n isSuccess,\n data,\n errorCount,\n isEnabled,\n key,\n execute,\n revalidate,\n setDataMemo,\n ]\n );\n\n // Return the hook's result, including all state and control functions\n return memoResult as UseAsyncResultBase<T> & Record<U, T>;\n};\n"],"names":["useAsyncState","useRef","useCallback","args","keyWithArgs","error","useEffect","data","useMemo"],"mappings":";;;;;AAQA,MAAM,sCAAsB,IAAI;AAoChC,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAC9B,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;AAC3B,MAAM,sBAAsB;AAC5B,MAAM,+BAA+B;AACrC,MAAM,0BAA0B,IAAI,KAAK;AACzC,MAAM,qBAAqB,IAAI,KAAK;AAQpC,MAAM,UAAU,CAAC,SACf,OAAQ,MAAM,QAAQ,IAAI,IAAI,OAAO,CAAC,IAAI,IAAK,CAAC;AAElD,MAAM,iBAAiB,CAAC,KAAa,SACnC,QAAQ,IA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