@gnwebsoft/ui 4.0.3 → 4.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-DKD73ADK.cjs → chunk-2QTXS736.cjs} +28 -77
- package/dist/{chunk-DS524L7W.cjs → chunk-3RZ4JNO3.cjs} +5 -5
- package/dist/chunk-3TYKVE3E.js +2514 -0
- package/dist/chunk-HKO2FXDM.js +2232 -0
- package/dist/chunk-LUW7V5GI.cjs +1 -1
- package/dist/chunk-MVPLBJRK.cjs +1 -1
- package/dist/{chunk-M3NVOZ7L.cjs → chunk-UBPAGZNC.cjs} +8 -6
- package/dist/chunk-XN3KVY4J.js +467 -0
- package/dist/chunk-XTPFOURJ.cjs +72 -0
- package/dist/chunk-Y3QTSDLJ.cjs +1 -1
- package/dist/core/api/ApiClient.d.ts +329 -0
- package/dist/core/api/ApiClient.d.ts.map +1 -0
- package/dist/core/api/CorrelationIdGenerator.d.ts +52 -0
- package/dist/core/api/CorrelationIdGenerator.d.ts.map +1 -0
- package/dist/core/api/Errors/ErrorNormalizer.d.ts +106 -0
- package/dist/core/api/Errors/ErrorNormalizer.d.ts.map +1 -0
- package/dist/core/api/Interceptors/InterceptorManager.d.ts +236 -0
- package/dist/core/api/Interceptors/InterceptorManager.d.ts.map +1 -0
- package/dist/core/api/Models/FilterModel.d.ts +22 -0
- package/dist/core/api/Models/FilterModel.d.ts.map +1 -0
- package/dist/core/api/Models/QueryParams.d.ts +13 -0
- package/dist/core/api/Models/QueryParams.d.ts.map +1 -0
- package/dist/core/api/Models/index.d.ts +3 -0
- package/dist/core/api/Models/index.d.ts.map +1 -0
- package/dist/core/api/RequestManager.d.ts +142 -0
- package/dist/core/api/RequestManager.d.ts.map +1 -0
- package/dist/core/api/Retry/RetryHandler.d.ts +100 -0
- package/dist/core/api/Retry/RetryHandler.d.ts.map +1 -0
- package/dist/core/api/Signals/SignalManager.d.ts +153 -0
- package/dist/core/api/Signals/SignalManager.d.ts.map +1 -0
- package/dist/core/api/Utils/ResponseParser.d.ts +105 -0
- package/dist/core/api/Utils/ResponseParser.d.ts.map +1 -0
- package/dist/core/api/Utils/UrlBuilder.d.ts +111 -0
- package/dist/core/api/Utils/UrlBuilder.d.ts.map +1 -0
- package/dist/core/api/createApiClient.d.ts +265 -0
- package/dist/core/api/createApiClient.d.ts.map +1 -0
- package/dist/core/api/index.d.ts +7 -0
- package/dist/core/api/index.d.ts.map +1 -0
- package/dist/core/api/types/ApiError.d.ts +17 -0
- package/dist/core/api/types/ApiError.d.ts.map +1 -0
- package/dist/core/api/types/ApiResponse.d.ts +76 -0
- package/dist/core/api/types/ApiResponse.d.ts.map +1 -0
- package/dist/core/api/types/CancelToken.d.ts +15 -0
- package/dist/core/api/types/CancelToken.d.ts.map +1 -0
- package/dist/core/api/types/ErrorInterceptor.d.ts +3 -0
- package/dist/core/api/types/ErrorInterceptor.d.ts.map +1 -0
- package/dist/core/api/types/ErrorResponseData.d.ts +68 -0
- package/dist/core/api/types/ErrorResponseData.d.ts.map +1 -0
- package/dist/core/api/types/RequestConfig.d.ts +21 -0
- package/dist/core/api/types/RequestConfig.d.ts.map +1 -0
- package/dist/core/api/types/RequestInterceptor.d.ts +3 -0
- package/dist/core/api/types/RequestInterceptor.d.ts.map +1 -0
- package/dist/core/api/types/ResponseInterceptor.d.ts +3 -0
- package/dist/core/api/types/ResponseInterceptor.d.ts.map +1 -0
- package/dist/core/api/types/ValidationErrors.d.ts +7 -0
- package/dist/core/api/types/ValidationErrors.d.ts.map +1 -0
- package/dist/core/api/types/index.d.ts +10 -0
- package/dist/core/api/types/index.d.ts.map +1 -0
- package/dist/core/api/useValidationErrors.d.ts +11 -0
- package/dist/core/api/useValidationErrors.d.ts.map +1 -0
- package/dist/core/components/AuthorizedView/AuthorizedView.d.ts +7 -0
- package/dist/core/components/AuthorizedView/AuthorizedView.d.ts.map +1 -0
- package/dist/core/components/AuthorizedView/index.d.ts +2 -0
- package/dist/core/components/AuthorizedView/index.d.ts.map +1 -0
- package/dist/core/components/CancelButton/CancelButton.d.ts +4 -0
- package/dist/core/components/CancelButton/CancelButton.d.ts.map +1 -0
- package/dist/core/components/CancelButton/index.d.ts +2 -0
- package/dist/core/components/CancelButton/index.d.ts.map +1 -0
- package/dist/core/components/ClearButton/ClearButton.d.ts +63 -0
- package/dist/core/components/ClearButton/ClearButton.d.ts.map +1 -0
- package/dist/core/components/ClearButton/index.d.ts +2 -0
- package/dist/core/components/ClearButton/index.d.ts.map +1 -0
- package/dist/core/components/Containers/SimpleContainer.d.ts +10 -0
- package/dist/core/components/Containers/SimpleContainer.d.ts.map +1 -0
- package/dist/core/components/Containers/index.d.ts +2 -0
- package/dist/core/components/Containers/index.d.ts.map +1 -0
- package/dist/core/components/FilterButton/FilterButton.d.ts +86 -0
- package/dist/core/components/FilterButton/FilterButton.d.ts.map +1 -0
- package/dist/core/components/FilterButton/index.d.ts +2 -0
- package/dist/core/components/FilterButton/index.d.ts.map +1 -0
- package/dist/core/components/FilterDisplay/FilterChip.d.ts +9 -0
- package/dist/core/components/FilterDisplay/FilterChip.d.ts.map +1 -0
- package/dist/core/components/FilterDisplay/FilterDisplay.d.ts +10 -0
- package/dist/core/components/FilterDisplay/FilterDisplay.d.ts.map +1 -0
- package/dist/core/components/FilterDisplay/index.d.ts +3 -0
- package/dist/core/components/FilterDisplay/index.d.ts.map +1 -0
- package/dist/core/components/FilterWrapper/FilterWrapper.d.ts +99 -0
- package/dist/core/components/FilterWrapper/FilterWrapper.d.ts.map +1 -0
- package/dist/core/components/FilterWrapper/index.d.ts +2 -0
- package/dist/core/components/FilterWrapper/index.d.ts.map +1 -0
- package/dist/core/components/Footer/Footer.d.ts +3 -0
- package/dist/core/components/Footer/Footer.d.ts.map +1 -0
- package/dist/core/components/Footer/index.d.ts +2 -0
- package/dist/core/components/Footer/index.d.ts.map +1 -0
- package/dist/core/components/LabelText/LabelText.d.ts +103 -0
- package/dist/core/components/LabelText/LabelText.d.ts.map +1 -0
- package/dist/core/components/LabelText/index.d.ts +2 -0
- package/dist/core/components/LabelText/index.d.ts.map +1 -0
- package/dist/core/components/RenderIf/RenderIf.d.ts +7 -0
- package/dist/core/components/RenderIf/RenderIf.d.ts.map +1 -0
- package/dist/core/components/RenderIf/index.d.ts +2 -0
- package/dist/core/components/RenderIf/index.d.ts.map +1 -0
- package/dist/core/components/SectionBox/SectionBox.d.ts +15 -0
- package/dist/core/components/SectionBox/SectionBox.d.ts.map +1 -0
- package/dist/core/components/SectionBox/index.d.ts +2 -0
- package/dist/core/components/SectionBox/index.d.ts.map +1 -0
- package/dist/core/components/SimpleTabs/SimpleTabs.d.ts +17 -0
- package/dist/core/components/SimpleTabs/SimpleTabs.d.ts.map +1 -0
- package/dist/core/components/SimpleTabs/index.d.ts +2 -0
- package/dist/core/components/SimpleTabs/index.d.ts.map +1 -0
- package/dist/core/components/SubmitButton/SubmitButton.d.ts +6 -0
- package/dist/core/components/SubmitButton/SubmitButton.d.ts.map +1 -0
- package/dist/core/components/SubmitButton/index.d.ts +2 -0
- package/dist/core/components/SubmitButton/index.d.ts.map +1 -0
- package/dist/core/components/WithRef/WithRef.d.ts +14 -0
- package/dist/core/components/WithRef/WithRef.d.ts.map +1 -0
- package/dist/core/components/WithRef/index.d.ts +2 -0
- package/dist/core/components/WithRef/index.d.ts.map +1 -0
- package/dist/core/components/index.d.ts +15 -0
- package/dist/core/components/index.d.ts.map +1 -0
- package/dist/core/config.d.ts +24 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/hooks/index.d.ts +3 -0
- package/dist/core/hooks/index.d.ts.map +1 -0
- package/dist/core/hooks/makeQuery.d.ts +12 -0
- package/dist/core/hooks/makeQuery.d.ts.map +1 -0
- package/dist/core/hooks/useApiClient.d.ts +3 -0
- package/dist/core/hooks/useApiClient.d.ts.map +1 -0
- package/dist/core/hooks/useFormErrorHandler.d.ts +35 -0
- package/dist/core/hooks/useFormErrorHandler.d.ts.map +1 -0
- package/dist/core/hooks/useListView.d.ts +20 -0
- package/dist/core/hooks/useListView.d.ts.map +1 -0
- package/dist/core/index.cjs +3 -3
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +1 -1
- package/dist/core/models.d.ts +5 -0
- package/dist/core/models.d.ts.map +1 -0
- package/dist/core/types/FilterLabel.d.ts +6 -0
- package/dist/core/types/FilterLabel.d.ts.map +1 -0
- package/dist/core/types/ListModels.d.ts +18 -0
- package/dist/core/types/ListModels.d.ts.map +1 -0
- package/dist/core/types/OptionsRequest.d.ts +4 -0
- package/dist/core/types/OptionsRequest.d.ts.map +1 -0
- package/dist/core/types/index.d.ts +4 -0
- package/dist/core/types/index.d.ts.map +1 -0
- package/dist/core/utils/CacheUtility/index.d.ts +15 -0
- package/dist/core/utils/CacheUtility/index.d.ts.map +1 -0
- package/dist/core/utils/calculateFilterCount.d.ts +2 -0
- package/dist/core/utils/calculateFilterCount.d.ts.map +1 -0
- package/dist/core/utils/format-time.d.ts +79 -0
- package/dist/core/utils/format-time.d.ts.map +1 -0
- package/dist/core/utils/getEmptyObject.d.ts +7 -0
- package/dist/core/utils/getEmptyObject.d.ts.map +1 -0
- package/dist/core/utils/index.d.ts +7 -0
- package/dist/core/utils/index.d.ts.map +1 -0
- package/dist/core/utils/useStableRowCount.d.ts +9 -0
- package/dist/core/utils/useStableRowCount.d.ts.map +1 -0
- package/dist/core/utils/watch/core.d.ts +22 -0
- package/dist/core/utils/watch/core.d.ts.map +1 -0
- package/dist/core/utils/watch/index.d.ts +49 -0
- package/dist/core/utils/watch/index.d.ts.map +1 -0
- package/dist/core/utils/watch/utilities.d.ts +34 -0
- package/dist/core/utils/watch/utilities.d.ts.map +1 -0
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useTransform/enhanced.d.ts +133 -0
- package/dist/hooks/useTransform/enhanced.d.ts.map +1 -0
- package/dist/hooks/useTransform/index.d.ts +93 -0
- package/dist/hooks/useTransform/index.d.ts.map +1 -0
- package/dist/index.cjs +6 -24
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -22
- package/dist/types/AsyncSelectPayload.d.ts +9 -0
- package/dist/types/AsyncSelectPayload.d.ts.map +1 -0
- package/dist/types/OperationResponse.d.ts +5 -0
- package/dist/types/OperationResponse.d.ts.map +1 -0
- package/dist/types/OptionItem.d.ts +75 -0
- package/dist/types/OptionItem.d.ts.map +1 -0
- package/dist/types/api.d.ts +127 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/events.d.ts +74 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/index.cjs +3 -3
- package/dist/types/index.d.ts +17 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -1
- package/dist/types/utilities.d.ts +458 -0
- package/dist/types/utilities.d.ts.map +1 -0
- package/dist/utils/api.d.ts +14 -0
- package/dist/utils/api.d.ts.map +1 -0
- package/dist/utils/api2.d.ts +14 -0
- package/dist/utils/api2.d.ts.map +1 -0
- package/dist/utils/flattenObjectKeys.d.ts +63 -0
- package/dist/utils/flattenObjectKeys.d.ts.map +1 -0
- package/dist/utils/getTimezone.d.ts +4 -0
- package/dist/utils/getTimezone.d.ts.map +1 -0
- package/dist/utils/handleServerErrors.d.ts +70 -0
- package/dist/utils/handleServerErrors.d.ts.map +1 -0
- package/dist/utils/index.cjs +3 -3
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +1 -1
- package/dist/utils/propertyExists.d.ts +35 -0
- package/dist/utils/propertyExists.d.ts.map +1 -0
- package/dist/utils/readValueAsDate.d.ts +4 -0
- package/dist/utils/readValueAsDate.d.ts.map +1 -0
- package/dist/utils/removeLeadingTrailingSlashes.d.ts +2 -0
- package/dist/utils/removeLeadingTrailingSlashes.d.ts.map +1 -0
- package/dist/utils/schemaTools.d.ts +82 -0
- package/dist/utils/schemaTools.d.ts.map +1 -0
- package/dist/utils/typeGuards.d.ts +316 -0
- package/dist/utils/typeGuards.d.ts.map +1 -0
- package/dist/utils/watch/core.d.ts +22 -0
- package/dist/utils/watch/core.d.ts.map +1 -0
- package/dist/utils/watch/index.d.ts +49 -0
- package/dist/utils/watch/index.d.ts.map +1 -0
- package/dist/utils/watch/utilities.d.ts +34 -0
- package/dist/utils/watch/utilities.d.ts.map +1 -0
- package/dist/wrappers/AsyncMultiSelect/AsyncMultiSelect.d.ts +9 -0
- package/dist/wrappers/AsyncMultiSelect/AsyncMultiSelect.d.ts.map +1 -0
- package/dist/wrappers/AsyncMultiSelect/index.d.ts +3 -0
- package/dist/wrappers/AsyncMultiSelect/index.d.ts.map +1 -0
- package/dist/wrappers/AsyncMultiSelect/types.d.ts +19 -0
- package/dist/wrappers/AsyncMultiSelect/types.d.ts.map +1 -0
- package/dist/wrappers/AsyncMultiSelect2/AsyncMultiSelect2.d.ts +8 -0
- package/dist/wrappers/AsyncMultiSelect2/AsyncMultiSelect2.d.ts.map +1 -0
- package/dist/wrappers/AsyncMultiSelect2/index.d.ts +3 -0
- package/dist/wrappers/AsyncMultiSelect2/index.d.ts.map +1 -0
- package/dist/wrappers/AsyncMultiSelect2/types.d.ts +29 -0
- package/dist/wrappers/AsyncMultiSelect2/types.d.ts.map +1 -0
- package/dist/wrappers/AsyncSelect/index.d.ts +9 -0
- package/dist/wrappers/AsyncSelect/index.d.ts.map +1 -0
- package/dist/wrappers/AsyncSelect/types.d.ts +19 -0
- package/dist/wrappers/AsyncSelect/types.d.ts.map +1 -0
- package/dist/wrappers/Button.d.ts +49 -0
- package/dist/wrappers/Button.d.ts.map +1 -0
- package/dist/wrappers/CheckboxElement/CheckboxElement.d.ts +102 -0
- package/dist/wrappers/CheckboxElement/CheckboxElement.d.ts.map +1 -0
- package/dist/wrappers/CheckboxElement/index.d.ts +3 -0
- package/dist/wrappers/CheckboxElement/index.d.ts.map +1 -0
- package/dist/wrappers/CheckboxElement/types.d.ts +76 -0
- package/dist/wrappers/CheckboxElement/types.d.ts.map +1 -0
- package/dist/wrappers/CheckboxGroup/CheckboxGroup.d.ts +96 -0
- package/dist/wrappers/CheckboxGroup/CheckboxGroup.d.ts.map +1 -0
- package/dist/wrappers/CheckboxGroup/EnhancedCheckboxGroup.d.ts +49 -0
- package/dist/wrappers/CheckboxGroup/EnhancedCheckboxGroup.d.ts.map +1 -0
- package/dist/wrappers/CheckboxGroup/enhanced-types.d.ts +171 -0
- package/dist/wrappers/CheckboxGroup/enhanced-types.d.ts.map +1 -0
- package/dist/wrappers/CheckboxGroup/index.d.ts +3 -0
- package/dist/wrappers/CheckboxGroup/index.d.ts.map +1 -0
- package/dist/wrappers/CheckboxGroup/types.d.ts +106 -0
- package/dist/wrappers/CheckboxGroup/types.d.ts.map +1 -0
- package/dist/wrappers/DatePickerElement/DatePickerElement.d.ts +131 -0
- package/dist/wrappers/DatePickerElement/DatePickerElement.d.ts.map +1 -0
- package/dist/wrappers/DatePickerElement/DatePickerElementCore.d.ts +57 -0
- package/dist/wrappers/DatePickerElement/DatePickerElementCore.d.ts.map +1 -0
- package/dist/wrappers/DatePickerElement/hooks/index.d.ts +24 -0
- package/dist/wrappers/DatePickerElement/hooks/index.d.ts.map +1 -0
- package/dist/wrappers/DatePickerElement/hooks/useDatePickerStyles.d.ts +63 -0
- package/dist/wrappers/DatePickerElement/hooks/useDatePickerStyles.d.ts.map +1 -0
- package/dist/wrappers/DatePickerElement/hooks/useDatePickerValidation.d.ts +79 -0
- package/dist/wrappers/DatePickerElement/hooks/useDatePickerValidation.d.ts.map +1 -0
- package/dist/wrappers/DatePickerElement/hooks/useDatePickerValue.d.ts +73 -0
- package/dist/wrappers/DatePickerElement/hooks/useDatePickerValue.d.ts.map +1 -0
- package/dist/wrappers/DatePickerElement/index.d.ts +47 -0
- package/dist/wrappers/DatePickerElement/index.d.ts.map +1 -0
- package/dist/wrappers/DatePickerElement/types.d.ts +183 -0
- package/dist/wrappers/DatePickerElement/types.d.ts.map +1 -0
- package/dist/wrappers/DatePickerElement/utils.d.ts +89 -0
- package/dist/wrappers/DatePickerElement/utils.d.ts.map +1 -0
- package/dist/wrappers/DateTimePickerElement/index.d.ts +1 -0
- package/dist/wrappers/DateTimePickerElement/index.d.ts.map +1 -0
- package/dist/wrappers/DateTimePickerElement/types.d.ts +1 -0
- package/dist/wrappers/DateTimePickerElement/types.d.ts.map +1 -0
- package/dist/wrappers/Field/index.d.ts +42 -0
- package/dist/wrappers/Field/index.d.ts.map +1 -0
- package/dist/wrappers/NumberFieldElement/NumberFieldElement.d.ts +176 -0
- package/dist/wrappers/NumberFieldElement/NumberFieldElement.d.ts.map +1 -0
- package/dist/wrappers/NumberFieldElement/index.d.ts +3 -0
- package/dist/wrappers/NumberFieldElement/index.d.ts.map +1 -0
- package/dist/wrappers/OTPInputElement/HelperText.d.ts +8 -0
- package/dist/wrappers/OTPInputElement/HelperText.d.ts.map +1 -0
- package/dist/wrappers/OTPInputElement/OTPInputElement.d.ts +32 -0
- package/dist/wrappers/OTPInputElement/OTPInputElement.d.ts.map +1 -0
- package/dist/wrappers/OTPInputElement/index.d.ts +3 -0
- package/dist/wrappers/OTPInputElement/index.d.ts.map +1 -0
- package/dist/wrappers/PasswordElement/PasswordElement.d.ts +104 -0
- package/dist/wrappers/PasswordElement/PasswordElement.d.ts.map +1 -0
- package/dist/wrappers/PasswordElement/index.d.ts +2 -0
- package/dist/wrappers/PasswordElement/index.d.ts.map +1 -0
- package/dist/wrappers/RadioButtonGroup/RadioButtonGroup.d.ts +38 -0
- package/dist/wrappers/RadioButtonGroup/RadioButtonGroup.d.ts.map +1 -0
- package/dist/wrappers/RadioButtonGroup/index.d.ts +2 -0
- package/dist/wrappers/RadioButtonGroup/index.d.ts.map +1 -0
- package/dist/wrappers/SelectCascadeElement/SelectCascadeElement.d.ts +22 -0
- package/dist/wrappers/SelectCascadeElement/SelectCascadeElement.d.ts.map +1 -0
- package/dist/wrappers/SelectCascadeElement/index.d.ts +2 -0
- package/dist/wrappers/SelectCascadeElement/index.d.ts.map +1 -0
- package/dist/wrappers/SelectElement/SelectElement.d.ts +152 -0
- package/dist/wrappers/SelectElement/SelectElement.d.ts.map +1 -0
- package/dist/wrappers/SelectElement/index.d.ts +2 -0
- package/dist/wrappers/SelectElement/index.d.ts.map +1 -0
- package/dist/wrappers/SelectMultiElement/SelectMultiElement.d.ts +21 -0
- package/dist/wrappers/SelectMultiElement/SelectMultiElement.d.ts.map +1 -0
- package/dist/wrappers/SelectMultiElement/index.d.ts +2 -0
- package/dist/wrappers/SelectMultiElement/index.d.ts.map +1 -0
- package/dist/wrappers/TextFieldElement/TextFieldElement.d.ts +179 -0
- package/dist/wrappers/TextFieldElement/TextFieldElement.d.ts.map +1 -0
- package/dist/wrappers/TextFieldElement/index.d.ts +3 -0
- package/dist/wrappers/TextFieldElement/index.d.ts.map +1 -0
- package/dist/wrappers/TimePickerElement/TimePickerElement.d.ts +30 -0
- package/dist/wrappers/TimePickerElement/TimePickerElement.d.ts.map +1 -0
- package/dist/wrappers/TimePickerElement/index.d.ts +2 -0
- package/dist/wrappers/TimePickerElement/index.d.ts.map +1 -0
- package/dist/wrappers/index.cjs +3 -4
- package/dist/wrappers/index.d.ts +14 -0
- package/dist/wrappers/index.d.ts.map +1 -0
- package/dist/wrappers/index.js +1 -2
- package/dist/wrappers/types/common.d.ts +87 -0
- package/dist/wrappers/types/common.d.ts.map +1 -0
- package/dist/wrappers/types/index.d.ts +8 -0
- package/dist/wrappers/types/index.d.ts.map +1 -0
- package/package.json +4 -8
- package/dist/chunk-BXWPG6VW.js +0 -108
- package/dist/chunk-EOUSOGZ6.js +0 -2281
- package/dist/chunk-EYXPJMEF.cjs +0 -108
- package/dist/chunk-GHW77WIM.cjs +0 -72
- package/dist/chunk-PUQIPRL2.js +0 -467
- package/dist/chunk-YAYXHYKC.js +0 -2512
- package/dist/i18n/index.cjs +0 -21
- package/dist/i18n/index.js +0 -21
- /package/dist/{chunk-MULSVYFT.js → chunk-6GKAC3KH.js} +0 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages AbortSignal creation and composition for request cancellation and timeouts.
|
|
3
|
+
*
|
|
4
|
+
* This internal class provides utilities for working with the AbortSignal API,
|
|
5
|
+
* enabling sophisticated cancellation patterns by combining multiple cancellation
|
|
6
|
+
* sources and creating timeout-based signals.
|
|
7
|
+
*
|
|
8
|
+
* Key Features:
|
|
9
|
+
* - **Signal Composition**: Combine multiple AbortSignals into one
|
|
10
|
+
* - **Timeout Signals**: Create signals that auto-abort after a delay
|
|
11
|
+
* - **Early Abort Detection**: Immediately abort if any source is already aborted
|
|
12
|
+
* - **Resource Cleanup**: Automatic timeout cleanup on abort
|
|
13
|
+
*
|
|
14
|
+
* Use Cases:
|
|
15
|
+
* - Combine user cancellation + timeout + component unmount signals
|
|
16
|
+
* - Create request deadlines
|
|
17
|
+
* - Implement cascading cancellation
|
|
18
|
+
*
|
|
19
|
+
* @internal This class is not exported from the public API
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* Combining multiple cancellation sources:
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const manager = new SignalManager();
|
|
25
|
+
* const userCancel = new AbortController();
|
|
26
|
+
* const unmountSignal = componentUnmountSignal;
|
|
27
|
+
*
|
|
28
|
+
* // Request will be cancelled if either user clicks cancel OR component unmounts
|
|
29
|
+
* const combined = manager.createCombinedSignal([
|
|
30
|
+
* userCancel.signal,
|
|
31
|
+
* unmountSignal
|
|
32
|
+
* ]);
|
|
33
|
+
*
|
|
34
|
+
* fetch('/api/data', { signal: combined.signal });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare class SignalManager {
|
|
38
|
+
/**
|
|
39
|
+
* Creates a combined AbortController that aborts when any source signal aborts.
|
|
40
|
+
*
|
|
41
|
+
* This method implements the "any" pattern for cancellation: the combined signal
|
|
42
|
+
* will abort as soon as ANY of the source signals abort. This is useful for
|
|
43
|
+
* coordinating multiple cancellation conditions:
|
|
44
|
+
* - User clicks cancel button
|
|
45
|
+
* - Request timeout expires
|
|
46
|
+
* - Component unmounts
|
|
47
|
+
* - Parent request is cancelled
|
|
48
|
+
*
|
|
49
|
+
* **Early Abort Optimization:**
|
|
50
|
+
* If any source signal is already aborted when this method is called,
|
|
51
|
+
* the returned controller is immediately aborted without setting up listeners.
|
|
52
|
+
*
|
|
53
|
+
* **Memory Management:**
|
|
54
|
+
* Event listeners are registered with `{ once: true }` to prevent memory leaks,
|
|
55
|
+
* as they automatically clean up after firing.
|
|
56
|
+
*
|
|
57
|
+
* @param signals - Array of AbortSignals to combine (undefined values are ignored)
|
|
58
|
+
* @returns A new AbortController that aborts when any source signal aborts
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* User cancellation + timeout:
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const userController = new AbortController();
|
|
64
|
+
* const timeout = manager.createTimeoutSignal(30000);
|
|
65
|
+
*
|
|
66
|
+
* const combined = manager.createCombinedSignal([
|
|
67
|
+
* userController.signal,
|
|
68
|
+
* timeout.signal
|
|
69
|
+
* ]);
|
|
70
|
+
*
|
|
71
|
+
* // Request will be cancelled after 30s OR when user clicks cancel
|
|
72
|
+
* fetch('/api/data', { signal: combined.signal });
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* React component with cleanup:
|
|
77
|
+
* ```typescript
|
|
78
|
+
* useEffect(() => {
|
|
79
|
+
* const controller = new AbortController();
|
|
80
|
+
*
|
|
81
|
+
* const combined = manager.createCombinedSignal([
|
|
82
|
+
* controller.signal,
|
|
83
|
+
* unmountSignal // From component lifecycle
|
|
84
|
+
* ]);
|
|
85
|
+
*
|
|
86
|
+
* fetchData(combined.signal);
|
|
87
|
+
*
|
|
88
|
+
* return () => controller.abort(); // Cleanup
|
|
89
|
+
* }, []);
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
createCombinedSignal(signals: Array<AbortSignal | undefined>): AbortController;
|
|
93
|
+
/**
|
|
94
|
+
* Creates an AbortController that automatically aborts after a specified timeout.
|
|
95
|
+
*
|
|
96
|
+
* This method creates a time-based cancellation mechanism useful for implementing
|
|
97
|
+
* request timeouts and deadlines. The signal will automatically abort after the
|
|
98
|
+
* specified duration, providing a consistent timeout experience.
|
|
99
|
+
*
|
|
100
|
+
* **Automatic Cleanup:**
|
|
101
|
+
* If the signal is aborted by other means before the timeout expires, the internal
|
|
102
|
+
* setTimeout is automatically cleared to prevent memory leaks.
|
|
103
|
+
*
|
|
104
|
+
* **Abort Reason:**
|
|
105
|
+
* The abort reason includes the timeout duration for debugging purposes:
|
|
106
|
+
* `"Request timeout after {timeout}ms"`
|
|
107
|
+
*
|
|
108
|
+
* @param timeout - Timeout duration in milliseconds
|
|
109
|
+
* @returns An AbortController that will abort after the timeout
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* Simple request timeout:
|
|
113
|
+
* ```typescript
|
|
114
|
+
* const manager = new SignalManager();
|
|
115
|
+
* const timeout = manager.createTimeoutSignal(5000); // 5 seconds
|
|
116
|
+
*
|
|
117
|
+
* try {
|
|
118
|
+
* const response = await fetch('/api/slow-endpoint', {
|
|
119
|
+
* signal: timeout.signal
|
|
120
|
+
* });
|
|
121
|
+
* const data = await response.json();
|
|
122
|
+
* } catch (error) {
|
|
123
|
+
* if (error.name === 'AbortError') {
|
|
124
|
+
* console.error('Request timed out after 5 seconds');
|
|
125
|
+
* }
|
|
126
|
+
* }
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* Different timeouts for different operations:
|
|
131
|
+
* ```typescript
|
|
132
|
+
* // Short timeout for quick operations
|
|
133
|
+
* const quickTimeout = manager.createTimeoutSignal(2000);
|
|
134
|
+
* await fetch('/api/health', { signal: quickTimeout.signal });
|
|
135
|
+
*
|
|
136
|
+
* // Long timeout for heavy operations
|
|
137
|
+
* const longTimeout = manager.createTimeoutSignal(60000);
|
|
138
|
+
* await fetch('/api/export', { signal: longTimeout.signal });
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* Manual cancellation before timeout:
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const timeout = manager.createTimeoutSignal(30000);
|
|
145
|
+
*
|
|
146
|
+
* // If user cancels, timeout is automatically cleaned up
|
|
147
|
+
* timeout.abort('User cancelled');
|
|
148
|
+
* // Internal setTimeout is cleared, no memory leak
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
createTimeoutSignal(timeout: number): AbortController;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=SignalManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignalManager.d.ts","sourceRoot":"","sources":["../../../../src/core/api/Signals/SignalManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,qBAAa,aAAa;IACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqDG;IACH,oBAAoB,CAClB,OAAO,EAAE,KAAK,CAAC,WAAW,GAAG,SAAS,CAAC,GACtC,eAAe;IAuBlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyDG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe;CAkBtD"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { ResponseData } from '../Models';
|
|
2
|
+
/**
|
|
3
|
+
* Parses HTTP response bodies into appropriate JavaScript types based on Content-Type headers.
|
|
4
|
+
*
|
|
5
|
+
* This internal class handles the complexity of converting various HTTP response formats
|
|
6
|
+
* into usable JavaScript data structures. It intelligently detects the response type
|
|
7
|
+
* and applies the appropriate parsing strategy.
|
|
8
|
+
*
|
|
9
|
+
* Supported Content Types:
|
|
10
|
+
* - **application/json**: Parsed as JSON objects/arrays
|
|
11
|
+
* - **text/*** (text/plain, text/html, etc.): Returned as string
|
|
12
|
+
* - **application/octet-stream**: Returned as Blob for binary data
|
|
13
|
+
* - **Unknown/Missing**: Attempts JSON parse, falls back to text
|
|
14
|
+
*
|
|
15
|
+
* Key Features:
|
|
16
|
+
* - **Automatic Detection**: Uses Content-Type header to determine parsing strategy
|
|
17
|
+
* - **Graceful Fallback**: Attempts JSON parsing for unknown types, falls back to text
|
|
18
|
+
* - **Binary Support**: Handles binary data via Blob
|
|
19
|
+
* - **Type Safety**: Returns typed ResponseData union
|
|
20
|
+
*
|
|
21
|
+
* @internal This class is not exported from the public API
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* Parsing different response types:
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const parser = new ResponseParser();
|
|
27
|
+
*
|
|
28
|
+
* // JSON response
|
|
29
|
+
* const jsonResponse = new Response('{"id": 1}', {
|
|
30
|
+
* headers: { 'Content-Type': 'application/json' }
|
|
31
|
+
* });
|
|
32
|
+
* const data = await parser.parseResponse(jsonResponse);
|
|
33
|
+
* // => { id: 1 }
|
|
34
|
+
*
|
|
35
|
+
* // Text response
|
|
36
|
+
* const textResponse = new Response('Hello World', {
|
|
37
|
+
* headers: { 'Content-Type': 'text/plain' }
|
|
38
|
+
* });
|
|
39
|
+
* const text = await parser.parseResponse(textResponse);
|
|
40
|
+
* // => "Hello World"
|
|
41
|
+
*
|
|
42
|
+
* // Binary response
|
|
43
|
+
* const blobResponse = new Response(binaryData, {
|
|
44
|
+
* headers: { 'Content-Type': 'application/octet-stream' }
|
|
45
|
+
* });
|
|
46
|
+
* const blob = await parser.parseResponse(blobResponse);
|
|
47
|
+
* // => Blob { ... }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare class ResponseParser {
|
|
51
|
+
/**
|
|
52
|
+
* Parses the HTTP response body into an appropriate JavaScript type.
|
|
53
|
+
*
|
|
54
|
+
* The parsing strategy is determined by the Content-Type header:
|
|
55
|
+
* 1. **JSON** (application/json): Calls `response.json()`
|
|
56
|
+
* 2. **Text** (text/*): Calls `response.text()`
|
|
57
|
+
* 3. **Binary** (application/octet-stream): Calls `response.blob()`
|
|
58
|
+
* 4. **Unknown**: Reads as text, attempts JSON parse, falls back to raw text
|
|
59
|
+
*
|
|
60
|
+
* **Fallback Behavior:**
|
|
61
|
+
* For responses without a Content-Type header or with unknown types, the parser
|
|
62
|
+
* attempts to parse as JSON first (common for APIs that don't set proper headers).
|
|
63
|
+
* If JSON parsing fails, it returns the raw text.
|
|
64
|
+
*
|
|
65
|
+
* @param response - The Fetch API Response object to parse
|
|
66
|
+
* @returns Promise resolving to the parsed response data
|
|
67
|
+
* @returns Can be: JSON object/array, string, or Blob depending on Content-Type
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* API response parsing:
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const response = await fetch('/api/users');
|
|
73
|
+
* const data = await parser.parseResponse(response);
|
|
74
|
+
*
|
|
75
|
+
* if (typeof data === 'string') {
|
|
76
|
+
* console.log('Text response:', data);
|
|
77
|
+
* } else if (data instanceof Blob) {
|
|
78
|
+
* console.log('Binary response:', data.size, 'bytes');
|
|
79
|
+
* } else {
|
|
80
|
+
* console.log('JSON response:', data);
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* Handling different content types:
|
|
86
|
+
* ```typescript
|
|
87
|
+
* // CSV file download
|
|
88
|
+
* const csvResponse = await fetch('/api/export.csv');
|
|
89
|
+
* const blob = await parser.parseResponse(csvResponse);
|
|
90
|
+
* // Returns Blob for download
|
|
91
|
+
*
|
|
92
|
+
* // JSON API
|
|
93
|
+
* const jsonResponse = await fetch('/api/users');
|
|
94
|
+
* const users = await parser.parseResponse(jsonResponse);
|
|
95
|
+
* // Returns parsed JSON array
|
|
96
|
+
*
|
|
97
|
+
* // Plain text logs
|
|
98
|
+
* const logResponse = await fetch('/api/logs');
|
|
99
|
+
* const logs = await parser.parseResponse(logResponse);
|
|
100
|
+
* // Returns string
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
parseResponse(response: Response): Promise<ResponseData>;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=ResponseParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResponseParser.d.ts","sourceRoot":"","sources":["../../../../src/core/api/Utils/ResponseParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,qBAAa,cAAc;IACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmDG;IACG,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;CAoB/D"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { QueryParams } from '../Models';
|
|
2
|
+
/**
|
|
3
|
+
* Constructs fully-qualified URLs with proper query parameter encoding.
|
|
4
|
+
*
|
|
5
|
+
* This internal class handles the complexity of URL construction, combining
|
|
6
|
+
* base URLs, endpoints, and query parameters with proper encoding and array
|
|
7
|
+
* handling. It uses the native URL API for reliable URL composition.
|
|
8
|
+
*
|
|
9
|
+
* Key Features:
|
|
10
|
+
* - **URL Composition**: Safely combines base URL and endpoint paths
|
|
11
|
+
* - **Query Parameter Encoding**: Automatic encoding of special characters
|
|
12
|
+
* - **Array Support**: Handles array parameters with multiple values
|
|
13
|
+
* - **Null/Undefined Filtering**: Automatically skips null/undefined values
|
|
14
|
+
* - **Type Safety**: Strongly typed query parameter values
|
|
15
|
+
*
|
|
16
|
+
* Array Handling:
|
|
17
|
+
* Array parameters are serialized by appending the same key multiple times:
|
|
18
|
+
* `?tags=javascript&tags=typescript&tags=react`
|
|
19
|
+
*
|
|
20
|
+
* @internal This class is not exported from the public API
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* Building URLs with query parameters:
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const builder = new UrlBuilder();
|
|
26
|
+
*
|
|
27
|
+
* const url = builder.buildURL(
|
|
28
|
+
* 'https://api.example.com',
|
|
29
|
+
* '/users',
|
|
30
|
+
* { active: true, role: 'admin', page: 1 }
|
|
31
|
+
* );
|
|
32
|
+
* // => "https://api.example.com/users?active=true&role=admin&page=1"
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare class UrlBuilder {
|
|
36
|
+
/**
|
|
37
|
+
* Builds a complete URL by combining base URL, endpoint, and query parameters.
|
|
38
|
+
*
|
|
39
|
+
* The URL construction process:
|
|
40
|
+
* 1. Combines `baseURL` and `endpoint` using URL API
|
|
41
|
+
* 2. Iterates through query parameters
|
|
42
|
+
* 3. Skips null/undefined values
|
|
43
|
+
* 4. Handles arrays by appending multiple values with same key
|
|
44
|
+
* 5. Converts all values to strings
|
|
45
|
+
* 6. Returns fully-qualified URL string
|
|
46
|
+
*
|
|
47
|
+
* **Path Handling:**
|
|
48
|
+
* The endpoint can be either relative or absolute:
|
|
49
|
+
* - Relative: `/users` → Combined with baseURL
|
|
50
|
+
* - Absolute: `https://other-api.com/users` → Uses absolute URL
|
|
51
|
+
*
|
|
52
|
+
* **Encoding:**
|
|
53
|
+
* All parameter values are automatically URL-encoded by the URL API,
|
|
54
|
+
* so special characters (spaces, &, =, etc.) are safely handled.
|
|
55
|
+
*
|
|
56
|
+
* @param baseURL - Base URL for the API (e.g., 'https://api.example.com')
|
|
57
|
+
* @param endpoint - API endpoint path relative to baseURL (e.g., '/users/123')
|
|
58
|
+
* @param params - Optional query parameters as key-value pairs
|
|
59
|
+
* @returns The fully-qualified URL string with encoded query parameters
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* Basic URL construction:
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const url = builder.buildURL(
|
|
65
|
+
* 'https://api.example.com',
|
|
66
|
+
* '/search',
|
|
67
|
+
* { q: 'hello world', limit: 10 }
|
|
68
|
+
* );
|
|
69
|
+
* // => "https://api.example.com/search?q=hello+world&limit=10"
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* Array parameters:
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const url = builder.buildURL(
|
|
76
|
+
* 'https://api.example.com',
|
|
77
|
+
* '/posts',
|
|
78
|
+
* { tags: ['javascript', 'typescript', 'react'] }
|
|
79
|
+
* );
|
|
80
|
+
* // => "https://api.example.com/posts?tags=javascript&tags=typescript&tags=react"
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* Null/undefined handling:
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const url = builder.buildURL(
|
|
87
|
+
* 'https://api.example.com',
|
|
88
|
+
* '/users',
|
|
89
|
+
* {
|
|
90
|
+
* name: 'John',
|
|
91
|
+
* age: null, // Skipped
|
|
92
|
+
* email: undefined // Skipped
|
|
93
|
+
* }
|
|
94
|
+
* );
|
|
95
|
+
* // => "https://api.example.com/users?name=John"
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* Special characters encoding:
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const url = builder.buildURL(
|
|
102
|
+
* 'https://api.example.com',
|
|
103
|
+
* '/search',
|
|
104
|
+
* { q: 'foo & bar', category: 'code/examples' }
|
|
105
|
+
* );
|
|
106
|
+
* // => "https://api.example.com/search?q=foo+%26+bar&category=code%2Fexamples"
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
buildURL(baseURL: string, endpoint: string, params?: QueryParams): string;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=UrlBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UrlBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/api/Utils/UrlBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,UAAU;IACrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM;CAmB1E"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Factory functions for creating and managing ApiClient instances.
|
|
3
|
+
*
|
|
4
|
+
* Provides convenient factory methods for creating pre-configured ApiClient instances
|
|
5
|
+
* with sensible defaults and automatic token management from localStorage.
|
|
6
|
+
*
|
|
7
|
+
* @module createApiClient
|
|
8
|
+
*/
|
|
9
|
+
import { ApiClient } from './ApiClient';
|
|
10
|
+
import type { ErrorInterceptor } from './types/ErrorInterceptor';
|
|
11
|
+
import type { RequestInterceptor } from './types/RequestInterceptor';
|
|
12
|
+
import type { ResponseInterceptor } from './types/ResponseInterceptor';
|
|
13
|
+
/**
|
|
14
|
+
* Configuration options for creating an ApiClient instance.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export interface ApiClientConfig {
|
|
19
|
+
/**
|
|
20
|
+
* Base URL for all API requests.
|
|
21
|
+
* @example 'https://api.example.com'
|
|
22
|
+
*/
|
|
23
|
+
baseURL: string;
|
|
24
|
+
/**
|
|
25
|
+
* Default timeout for requests in milliseconds.
|
|
26
|
+
* @default 30000
|
|
27
|
+
*/
|
|
28
|
+
timeout?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Prefix for auto-generated correlation IDs (e.g., 'api', 'web', 'mobile').
|
|
31
|
+
* @default 'api'
|
|
32
|
+
*/
|
|
33
|
+
correlationIdPrefix: string;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to automatically generate and include correlation IDs in requests.
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
includeCorrelationId?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* localStorage key used to retrieve the auth token.
|
|
41
|
+
* @example 'serviceToken'
|
|
42
|
+
*/
|
|
43
|
+
tokenStorageKey: string;
|
|
44
|
+
/**
|
|
45
|
+
* Initial authentication token to set on the client.
|
|
46
|
+
* @default undefined
|
|
47
|
+
*/
|
|
48
|
+
authToken?: string | null;
|
|
49
|
+
/**
|
|
50
|
+
* Array of request interceptors to register during client creation.
|
|
51
|
+
* @default []
|
|
52
|
+
*/
|
|
53
|
+
requestInterceptors?: RequestInterceptor[];
|
|
54
|
+
/**
|
|
55
|
+
* Array of response interceptors to register during client creation.
|
|
56
|
+
* @default []
|
|
57
|
+
*/
|
|
58
|
+
responseInterceptors?: ResponseInterceptor[];
|
|
59
|
+
/**
|
|
60
|
+
* Array of error interceptors to register during client creation.
|
|
61
|
+
* @default []
|
|
62
|
+
*/
|
|
63
|
+
errorInterceptors?: ErrorInterceptor[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Creates a new ApiClient instance with automatic token management.
|
|
67
|
+
*
|
|
68
|
+
* This factory function:
|
|
69
|
+
* - Requires base URL, correlation ID prefix, and token storage key to be explicitly provided
|
|
70
|
+
* - Sets up automatic authentication token injection from localStorage
|
|
71
|
+
* - Configures correlation ID generation
|
|
72
|
+
* - Registers provided interceptors
|
|
73
|
+
*
|
|
74
|
+
* **Note:** Each call creates a NEW instance. Use {@link getGlobalApiClient} for singleton behavior.
|
|
75
|
+
*
|
|
76
|
+
* @param config - Configuration options for the API client (baseURL, correlationIdPrefix, tokenStorageKey are required)
|
|
77
|
+
* @returns A fully configured ApiClient instance
|
|
78
|
+
* @public
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* Basic usage:
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const client = createApiClient({
|
|
84
|
+
* baseURL: 'https://api.example.com',
|
|
85
|
+
* correlationIdPrefix: 'web',
|
|
86
|
+
* tokenStorageKey: 'serviceToken'
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* Custom configuration with interceptors:
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const client = createApiClient({
|
|
94
|
+
* baseURL: 'https://api.example.com',
|
|
95
|
+
* correlationIdPrefix: 'web',
|
|
96
|
+
* tokenStorageKey: 'authToken',
|
|
97
|
+
* timeout: 60000,
|
|
98
|
+
* requestInterceptors: [
|
|
99
|
+
* async (config) => {
|
|
100
|
+
* console.log('Making request:', config.url);
|
|
101
|
+
* return config;
|
|
102
|
+
* }
|
|
103
|
+
* ]
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* With React Query:
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const apiClient = createApiClient({
|
|
111
|
+
* baseURL: process.env.REACT_APP_API_URL,
|
|
112
|
+
* correlationIdPrefix: 'web',
|
|
113
|
+
* tokenStorageKey: 'serviceToken'
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* const queryClient = new QueryClient();
|
|
117
|
+
*
|
|
118
|
+
* function UserProfile({ userId }) {
|
|
119
|
+
* const { data: response } = useQuery({
|
|
120
|
+
* queryKey: ['user', userId],
|
|
121
|
+
* queryFn: () => apiClient.get(`/users/${userId}`)
|
|
122
|
+
* });
|
|
123
|
+
* const user = response?.apiData; // Access the actual data
|
|
124
|
+
* // ...
|
|
125
|
+
* }
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export declare function createApiClient(config: ApiClientConfig): ApiClient;
|
|
129
|
+
/**
|
|
130
|
+
* Gets or creates a global singleton ApiClient instance.
|
|
131
|
+
*
|
|
132
|
+
* This function implements the singleton pattern for ApiClient. It creates the client
|
|
133
|
+
* on first call and returns the same instance on subsequent calls. This is useful for:
|
|
134
|
+
* - Sharing the same client across your entire application
|
|
135
|
+
* - Avoiding multiple instances with different configurations
|
|
136
|
+
* - Consistent interceptor behavior app-wide
|
|
137
|
+
*
|
|
138
|
+
* **Important:** The config parameter is only used on the FIRST call. Subsequent calls
|
|
139
|
+
* ignore the config and return the existing instance. Use {@link resetGlobalApiClient}
|
|
140
|
+
* first if you need to recreate with different config.
|
|
141
|
+
*
|
|
142
|
+
* @param config - Configuration options (required: baseURL, correlationIdPrefix, tokenStorageKey; only used on first call)
|
|
143
|
+
* @returns The global ApiClient singleton instance
|
|
144
|
+
* @public
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* In your app initialization:
|
|
148
|
+
* ```typescript
|
|
149
|
+
* // src/lib/api.ts
|
|
150
|
+
* export const apiClient = getGlobalApiClient({
|
|
151
|
+
* baseURL: 'https://api.example.com',
|
|
152
|
+
* correlationIdPrefix: 'web',
|
|
153
|
+
* tokenStorageKey: 'serviceToken',
|
|
154
|
+
* timeout: 30000
|
|
155
|
+
* });
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* Import and use throughout your app:
|
|
160
|
+
* ```typescript
|
|
161
|
+
* // src/features/users/api.ts
|
|
162
|
+
* import { getGlobalApiClient } from '@gnwebsoft/ui';
|
|
163
|
+
*
|
|
164
|
+
* // Config ignored on subsequent calls - returns existing instance
|
|
165
|
+
* const client = getGlobalApiClient({
|
|
166
|
+
* baseURL: 'https://api.example.com',
|
|
167
|
+
* correlationIdPrefix: 'web',
|
|
168
|
+
* tokenStorageKey: 'serviceToken'
|
|
169
|
+
* });
|
|
170
|
+
*
|
|
171
|
+
* export async function fetchUsers() {
|
|
172
|
+
* const { apiData } = await client.get('/users');
|
|
173
|
+
* return apiData;
|
|
174
|
+
* }
|
|
175
|
+
* ```
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* Resetting for tests:
|
|
179
|
+
* ```typescript
|
|
180
|
+
* afterEach(() => {
|
|
181
|
+
* resetGlobalApiClient();
|
|
182
|
+
* });
|
|
183
|
+
*
|
|
184
|
+
* test('creates fresh client', () => {
|
|
185
|
+
* const client = getGlobalApiClient({
|
|
186
|
+
* baseURL: 'http://test.local',
|
|
187
|
+
* correlationIdPrefix: 'test',
|
|
188
|
+
* tokenStorageKey: 'testToken'
|
|
189
|
+
* });
|
|
190
|
+
* // New instance with test config
|
|
191
|
+
* });
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
export declare function getGlobalApiClient(config: ApiClientConfig): ApiClient;
|
|
195
|
+
/**
|
|
196
|
+
* Replaces the global singleton ApiClient with a custom instance.
|
|
197
|
+
*
|
|
198
|
+
* Use this when you need fine-grained control over the global client instance,
|
|
199
|
+
* such as in testing scenarios or when you've manually created a client with
|
|
200
|
+
* specific configuration.
|
|
201
|
+
*
|
|
202
|
+
* @param client - The ApiClient instance to use as the global singleton
|
|
203
|
+
* @public
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* Testing with a mock client:
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const mockClient = new ApiClient('http://test.local');
|
|
209
|
+
* mockClient.addResponseInterceptor(async (response) => {
|
|
210
|
+
* // Mock response data
|
|
211
|
+
* return { data: mockData };
|
|
212
|
+
* });
|
|
213
|
+
*
|
|
214
|
+
* setGlobalApiClient(mockClient);
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* Advanced configuration:
|
|
219
|
+
* ```typescript
|
|
220
|
+
* const client = new ApiClient('https://api.example.com', 60000);
|
|
221
|
+
* client.setCorrelationIdPrefix('custom');
|
|
222
|
+
* client.addRequestInterceptor(customInterceptor);
|
|
223
|
+
*
|
|
224
|
+
* setGlobalApiClient(client);
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
export declare function setGlobalApiClient(client: ApiClient): void;
|
|
228
|
+
/**
|
|
229
|
+
* Resets the global ApiClient singleton to null.
|
|
230
|
+
*
|
|
231
|
+
* After calling this, the next call to {@link getGlobalApiClient} will create
|
|
232
|
+
* a fresh instance. This is particularly useful in:
|
|
233
|
+
* - Test cleanup to ensure test isolation
|
|
234
|
+
* - Application logout to clear any cached state
|
|
235
|
+
* - Hot module reloading during development
|
|
236
|
+
*
|
|
237
|
+
* @public
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* Test cleanup:
|
|
241
|
+
* ```typescript
|
|
242
|
+
* afterEach(() => {
|
|
243
|
+
* resetGlobalApiClient();
|
|
244
|
+
* });
|
|
245
|
+
* ```
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* Logout flow:
|
|
249
|
+
* ```typescript
|
|
250
|
+
* function handleLogout() {
|
|
251
|
+
* // Clear authentication
|
|
252
|
+
* localStorage.removeItem('serviceToken');
|
|
253
|
+
*
|
|
254
|
+
* // Cancel all pending requests and reset client
|
|
255
|
+
* const client = getGlobalApiClient();
|
|
256
|
+
* client.cancelAllRequests();
|
|
257
|
+
* resetGlobalApiClient();
|
|
258
|
+
*
|
|
259
|
+
* // Redirect to login
|
|
260
|
+
* navigate('/login');
|
|
261
|
+
* }
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
export declare function resetGlobalApiClient(): void;
|
|
265
|
+
//# sourceMappingURL=createApiClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createApiClient.d.ts","sourceRoot":"","sources":["../../../src/core/api/createApiClient.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAE3C;;;OAGG;IACH,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAE7C;;;OAGG;IACH,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACxC;AAQD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAkDlE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAMrE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAE1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAE5B,cAAc,0BAA0B,CAAC;AAEzC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,mBAAmB,CAAC;AAElC,cAAc,SAAS,CAAC;AAExB,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RequestConfig } from './RequestConfig';
|
|
2
|
+
import type { ValidationErrors } from './ValidationErrors';
|
|
3
|
+
/**
|
|
4
|
+
* Union type for all possible API error categories.
|
|
5
|
+
* Used for consistent error type handling across the API client.
|
|
6
|
+
*/
|
|
7
|
+
export type ApiErrorType = 'validation_error' | 'client_error' | 'server_error' | 'request_cancelled' | 'timeout_error' | 'network_error' | 'unknown_error';
|
|
8
|
+
export interface ApiError extends Error {
|
|
9
|
+
type?: ApiErrorType;
|
|
10
|
+
title?: string;
|
|
11
|
+
status?: number;
|
|
12
|
+
traceId?: string;
|
|
13
|
+
errors?: ValidationErrors;
|
|
14
|
+
isAborted?: boolean;
|
|
15
|
+
config?: RequestConfig;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ApiError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiError.d.ts","sourceRoot":"","sources":["../../../../src/core/api/types/ApiError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB,kBAAkB,GAClB,cAAc,GACd,cAAc,GACd,mBAAmB,GACnB,eAAe,GACf,eAAe,GACf,eAAe,CAAC;AAEpB,MAAM,WAAW,QAAS,SAAQ,KAAK;IACrC,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB"}
|