intelicoreact 1.6.19 → 1.6.20
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/Atomic/FormElements/ActionAlert/ActionAlert.js +102 -1
- package/dist/Atomic/FormElements/AdvancedStatus/AdvancedStatus.js +89 -1
- package/dist/Atomic/FormElements/Calendar/Calendar.js +232 -1
- package/dist/Atomic/FormElements/Calendar/Calendar.props.js +3 -1
- package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.js +101 -1
- package/dist/Atomic/FormElements/CheckboxesLine/CheckboxesLine.js +70 -1
- package/dist/Atomic/FormElements/Datepicker/Datepicker.js +350 -1
- package/dist/Atomic/FormElements/Datepicker/Datepicker.props.js +3 -1
- package/dist/Atomic/FormElements/Datepicker/components/DatepickerCalendar.js +177 -1
- package/dist/Atomic/FormElements/Datepicker/components/DatepickerCalendar.props.js +3 -1
- package/dist/Atomic/FormElements/Dropdown/Dropdown.js +561 -1
- package/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.js +20 -1
- package/dist/Atomic/FormElements/DropdownLiveSearch/DropdownLiveSearch.js +405 -1
- package/dist/Atomic/FormElements/FileLoader/FileLoader.js +94 -1
- package/dist/Atomic/FormElements/FileLoader/partial/LoadZone.js +105 -1
- package/dist/Atomic/FormElements/FileLoader/partial/LoadedContent.js +67 -1
- package/dist/Atomic/FormElements/FileLoaderDescription/FileLoaderDescription.js +247 -1
- package/dist/Atomic/FormElements/FileLoaderLocal/FileLoaderLocal.js +160 -1
- package/dist/Atomic/FormElements/FileLoaderLocalGroup/FileLoaderLocalGroup.js +193 -1
- package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN.js +135 -1
- package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN_old.js +116 -1
- package/dist/Atomic/FormElements/Input/Input.js +467 -1
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +161 -1
- package/dist/Atomic/FormElements/InputColor/InputColor.js +64 -1
- package/dist/Atomic/FormElements/InputCurrency/InputCurrency.js +166 -1
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.js +354 -1
- package/dist/Atomic/FormElements/InputDateRange/components/DateInput.js +71 -1
- package/dist/Atomic/FormElements/InputDateRange/components/Datepicker.js +693 -1
- package/dist/Atomic/FormElements/InputDateRange/components/OpenedPart.js +254 -1
- package/dist/Atomic/FormElements/InputDateRange/components/SelectItem.js +32 -1
- package/dist/Atomic/FormElements/InputDateRange/dependencies.js +200 -1
- package/dist/Atomic/FormElements/InputLink/InputLink.js +99 -1
- package/dist/Atomic/FormElements/InputMask/InputCarretPosition.js +37 -1
- package/dist/Atomic/FormElements/InputMask/InputMask.js +1214 -1
- package/dist/Atomic/FormElements/InputMask/config.js +15 -1
- package/dist/Atomic/FormElements/InputMask/functions.js +58 -1
- package/dist/Atomic/FormElements/InputMask2/InputMask2.js +674 -1
- package/dist/Atomic/FormElements/InputMask2/config.js +15 -1
- package/dist/Atomic/FormElements/InputMask2/functions.js +58 -1
- package/dist/Atomic/FormElements/InputMask3/InputMask3.js +766 -1
- package/dist/Atomic/FormElements/InputMask3/config.js +15 -1
- package/dist/Atomic/FormElements/InputMask3/functions.js +58 -1
- package/dist/Atomic/FormElements/InputWithAction/InputWithAction.js +114 -1
- package/dist/Atomic/FormElements/InputsRow/InputsRow.js +140 -1
- package/dist/Atomic/FormElements/Label/Label.js +82 -1
- package/dist/Atomic/FormElements/MobileCalendar/MobileCalendar.js +506 -1
- package/dist/Atomic/FormElements/MultiSelect/MultiSelect.js +45 -1
- package/dist/Atomic/FormElements/NumericInput/NumericInput.js +331 -1
- package/dist/Atomic/FormElements/RadioGroup/RadioGroup.js +66 -1
- package/dist/Atomic/FormElements/RadioGroupWithInput/RadioGroupWithInput.js +80 -1
- package/dist/Atomic/FormElements/RadioInput/RadioInput.js +64 -1
- package/dist/Atomic/FormElements/RadioRowSwitcher/RadioRowSwitcher.js +54 -1
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.js +183 -1
- package/dist/Atomic/FormElements/RangeInputs/RangeInputs.js +209 -1
- package/dist/Atomic/FormElements/RangeList/RangeList.js +175 -1
- package/dist/Atomic/FormElements/RangeList/partial/RangeListRow.js +43 -1
- package/dist/Atomic/FormElements/RangeSlider/RangeSlider.js +443 -1
- package/dist/Atomic/FormElements/RangeSlider2/RangeSlider2.js +858 -1
- package/dist/Atomic/FormElements/SwitchableRow/SwitchableRow.js +39 -1
- package/dist/Atomic/FormElements/Switcher/Switcher.js +59 -1
- package/dist/Atomic/FormElements/SwitcherCheckbox/SwitcherCheckbox.js +50 -1
- package/dist/Atomic/FormElements/SwitcherHide/SwitcherHide.js +47 -1
- package/dist/Atomic/FormElements/SwitcherRadio/SwitcherRadio.js +96 -1
- package/dist/Atomic/FormElements/SwitcherRange/SwitcherRange.js +40 -1
- package/dist/Atomic/FormElements/SwitcherRangeList/SwitcherRangeList.js +64 -1
- package/dist/Atomic/FormElements/SwitcherTagsDropdown/SwitcherTagsDropdown.js +170 -1
- package/dist/Atomic/FormElements/SwitcherTagsDropdown/partial/States.js +202 -1
- package/dist/Atomic/FormElements/SwitcherTextarea/SwitcherTextarea.js +67 -1
- package/dist/Atomic/FormElements/TagListToDropdown/TagListToDropdown.js +115 -1
- package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.js +826 -1
- package/dist/Atomic/FormElements/Text/Text.js +125 -1
- package/dist/Atomic/FormElements/TextSwitcher/TextSwitcher.js +45 -1
- package/dist/Atomic/FormElements/Textarea/Textarea.js +80 -1
- package/dist/Atomic/FormElements/TieredCheckboxes/TieredCheckboxes.js +176 -1
- package/dist/Atomic/FormElements/TieredCheckboxes/partial/AccordionWithCheckbox.js +62 -1
- package/dist/Atomic/FormElements/TimeRange/TimeRange.js +127 -1
- package/dist/Atomic/FormElements/UserContacts/UserContacts.js +220 -1
- package/dist/Atomic/FormElements/VariantsListRadio/VariantsListRadio.js +83 -1
- package/dist/Atomic/FormElements/VariantsListRadio/partials/VariantsListRadioItem.js +82 -1
- package/dist/Atomic/FormElements/WidgetPseudoTable/WidgetPseudoTable.js +101 -1
- package/dist/Atomic/FormElements/WidgetPseudoTable/partial/constructor.js +29 -1
- package/dist/Atomic/FormElements/WidgetWithSwitchableRows/WidgetWithSwitchableRows.js +113 -1
- package/dist/Atomic/FormElements/WidgetWithSwitchableRows/partial/constructor.js +30 -1
- package/dist/Atomic/Layout/Header/Header.js +85 -1
- package/dist/Atomic/Layout/Spinner/Spinner.js +39 -1
- package/dist/Atomic/UI/Accordion/Accordion.js +118 -1
- package/dist/Atomic/UI/Accordion/AccordionItem.js +181 -1
- package/dist/Atomic/UI/AccordionTable/AccordionTable.js +238 -1
- package/dist/Atomic/UI/AccordionText/AccordionText.js +69 -1
- package/dist/Atomic/UI/AdvancedTag/AdvTag.js +207 -1
- package/dist/Atomic/UI/AdvancedTag/AdvancedTags.js +56 -1
- package/dist/Atomic/UI/Alert/Alert.js +72 -1
- package/dist/Atomic/UI/Arrow/Arrow.js +132 -1
- package/dist/Atomic/UI/Box/Box.js +52 -1
- package/dist/Atomic/UI/Button/Button.js +89 -1
- package/dist/Atomic/UI/ButtonsBar/ButtonsBar.js +72 -1
- package/dist/Atomic/UI/Chart/Chart.js +172 -1
- package/dist/Atomic/UI/Chart/partial/Chart.constants.js +95 -1
- package/dist/Atomic/UI/Chart/partial/ChartTypeSwitcherIcon/ChartTypeSwitcherIcon.js +80 -1
- package/dist/Atomic/UI/Chart/partial/datasetSetters.js +188 -1
- package/dist/Atomic/UI/Chart/partial/optionsConstructor.js +335 -1
- package/dist/Atomic/UI/Chart/partial/optionsSetters.js +43 -1
- package/dist/Atomic/UI/Chart/partial/utils.js +60 -1
- package/dist/Atomic/UI/CircleProgressBar/CircleProgressBar.js +109 -1
- package/dist/Atomic/UI/DateTime/DateTime.js +57 -1
- package/dist/Atomic/UI/DebugContainer/DebugContainer.js +44 -1
- package/dist/Atomic/UI/DebugContainer/useDebugContainer.js +15 -1
- package/dist/Atomic/UI/DoubleString/DoubleString.js +102 -1
- package/dist/Atomic/UI/DynamicIcon/DynamicIcon.js +226 -1
- package/dist/Atomic/UI/ExampleChartIntegration/ExampleChartIntegration.js +221 -1
- package/dist/Atomic/UI/ExampleChartIntegration/partial/utils.js +106 -1
- package/dist/Atomic/UI/Hint/Hint.js +193 -1
- package/dist/Atomic/UI/Hint/partials/_utils.js +51 -1
- package/dist/Atomic/UI/Modal/Modal.js +188 -1
- package/dist/Atomic/UI/Modal/ModalHOC.js +72 -1
- package/dist/Atomic/UI/Modal/partials/ModalFooter.js +46 -1
- package/dist/Atomic/UI/Modal/partials/ModalTitle.js +83 -1
- package/dist/Atomic/UI/Modal/partials/useMobileModal.js +200 -1
- package/dist/Atomic/UI/MonoAccordion/MonoAccordion._test.js +75 -1
- package/dist/Atomic/UI/MonoAccordion/MonoAccordion.js +80 -1
- package/dist/Atomic/UI/NavLine/NavLine.js +293 -1
- package/dist/Atomic/UI/PageTitle/PageTitle.js +75 -1
- package/dist/Atomic/UI/PieChart/PieChart.js +42 -1
- package/dist/Atomic/UI/Price/Price.js +22 -1
- package/dist/Atomic/UI/PriceRange/PriceRange.js +36 -1
- package/dist/Atomic/UI/ProgressLine/ProgressLine.js +71 -1
- package/dist/Atomic/UI/Status/Status.js +59 -1
- package/dist/Atomic/UI/Table/Partials/TdCell.js +87 -1
- package/dist/Atomic/UI/Table/Partials/TdHeader.js +38 -1
- package/dist/Atomic/UI/Table/Partials/TdRow.js +99 -1
- package/dist/Atomic/UI/Table/Partials/TdTitle.js +52 -1
- package/dist/Atomic/UI/Table/Table.js +63 -1
- package/dist/Atomic/UI/Table/TdTypes/TdActions.js +80 -1
- package/dist/Atomic/UI/Table/TdTypes/TdPriority.js +28 -1
- package/dist/Atomic/UI/Table/TdTypes/TdRange.js +13 -1
- package/dist/Atomic/UI/Table/TdTypes/TdWeight.js +53 -1
- package/dist/Atomic/UI/Tag/Tag.js +160 -1
- package/dist/Atomic/UI/TagList/TagList.js +251 -1
- package/dist/Atomic/UI/UserBox/UserBox.js +73 -1
- package/dist/Atomic/UI/WizardStepper/constructor.js +84 -1
- package/dist/Atomic/UI/WizardStepper/index.js +3 -1
- package/dist/Atomic/UI/WizardStepper/ui/StateIcon/StateIcon.js +37 -1
- package/dist/Atomic/UI/WizardStepper/ui/StateIcon/index.js +3 -1
- package/dist/Atomic/UI/WizardStepper/ui/StepRow/StepRow.js +61 -1
- package/dist/Atomic/UI/WizardStepper/ui/StepRow/index.js +3 -1
- package/dist/Atomic/UI/WizardStepper/ui/StepWrapper/StepWrapper.js +39 -1
- package/dist/Atomic/UI/WizardStepper/ui/StepWrapper/index.js +3 -1
- package/dist/Atomic/UI/WizardStepper/ui/icons.js +49 -1
- package/dist/Atomic/UI/WizardStepper/ui/index.js +3 -1
- package/dist/Classes/AbortableFetch.js +454 -1
- package/dist/Classes/AnimatedHandler.js +47 -1
- package/dist/Classes/RESTAPI/index.js +228 -1
- package/dist/Classes/RESTAPI/partials/AbortableFetch.js +457 -1
- package/dist/Classes/RESTAPI/partials/ApiBase.js +48 -1
- package/dist/Classes/RESTAPI/partials/ApiRequestCreators.js +112 -1
- package/dist/Classes/RESTAPI/partials/ApiUtils.js +189 -1
- package/dist/Classes/RESTAPI/partials/CredentialsProcessing.js +252 -1
- package/dist/Classes/RESTAPI/partials/Utils.js +92 -1
- package/dist/Classes/RESTAPI/partials/_outerDependencies.js +3 -1
- package/dist/Classes/RESTAPI/partials/_utils.js +197 -1
- package/dist/Constants/index.constants.js +78 -1
- package/dist/Functions/Portal.js +22 -1
- package/dist/Functions/customEventListener.js +96 -1
- package/dist/Functions/dateTime.js +149 -1
- package/dist/Functions/fieldValueFormatters.js +405 -1
- package/dist/Functions/guards/assertions.js +66 -1
- package/dist/Functions/guards/safeValue.js +30 -1
- package/dist/Functions/guards/typeGuards.js +116 -1
- package/dist/Functions/hooks/useFormFieldsChangesManager.js +95 -1
- package/dist/Functions/locale/createTranslator.js +32 -1
- package/dist/Functions/operations.js +130 -1
- package/dist/Functions/presets/inputMaskPresets.js +170 -1
- package/dist/Functions/presets/inputPresets.js +60 -1
- package/dist/Functions/presets/mobileKeyboardTypesPresets.js +45 -1
- package/dist/Functions/schemas.js +31 -1
- package/dist/Functions/useBodyScrollLock.js +17 -1
- package/dist/Functions/useClickOutside.js +15 -1
- package/dist/Functions/useDebounce.js +17 -1
- package/dist/Functions/useFieldFocus.js +84 -1
- package/dist/Functions/useFormTools/form-drivers/ArrayWithObjects.js +39 -1
- package/dist/Functions/useFormTools/form-drivers/ObjectWithIterableObjects.js +159 -1
- package/dist/Functions/useFormTools/form-drivers/ObjectWithNamedKeyObjects.js +78 -1
- package/dist/Functions/useFormTools/functions/General.js +134 -1
- package/dist/Functions/useFormTools/functions/RenderFields.js +111 -1
- package/dist/Functions/useFormTools/functions/usePrevious.js +12 -1
- package/dist/Functions/useFormTools/index.js +778 -1
- package/dist/Functions/useInputHighlightError.js +67 -1
- package/dist/Functions/useIsMobile/useIsMobile.js +53 -1
- package/dist/Functions/useKeyPress/useHandleKeyPress.js +21 -1
- package/dist/Functions/useKeyPress/useKeyPress.js +75 -1
- package/dist/Functions/useLocalStorage.js +34 -1
- package/dist/Functions/useLocationParams.js +27 -1
- package/dist/Functions/useMediaQuery.js +17 -1
- package/dist/Functions/useMetaInfo.js +43 -1
- package/dist/Functions/useMouseUpOutside.js +16 -1
- package/dist/Functions/useOnlineStatus.js +29 -1
- package/dist/Functions/usePasswordChecker.js +110 -1
- package/dist/Functions/usePrevious.js +12 -1
- package/dist/Functions/useResize.js +31 -1
- package/dist/Functions/useScrollTo.js +17 -1
- package/dist/Functions/useToggle.js +17 -1
- package/dist/Functions/utils.js +522 -1
- package/dist/Langs.js +168 -1
- package/dist/Molecular/CustomIcons/components/AffiliateNetworks.js +21 -1
- package/dist/Molecular/CustomIcons/components/AlertCircle.js +23 -1
- package/dist/Molecular/CustomIcons/components/AppStore.js +29 -1
- package/dist/Molecular/CustomIcons/components/Arrow.js +32 -1
- package/dist/Molecular/CustomIcons/components/ArrowDown.js +17 -1
- package/dist/Molecular/CustomIcons/components/ArrowLeft.js +22 -1
- package/dist/Molecular/CustomIcons/components/ArrowRight.js +22 -1
- package/dist/Molecular/CustomIcons/components/ArrowUp.js +17 -1
- package/dist/Molecular/CustomIcons/components/Bell.js +15 -1
- package/dist/Molecular/CustomIcons/components/Button.js +12 -1
- package/dist/Molecular/CustomIcons/components/Campaigns.js +16 -1
- package/dist/Molecular/CustomIcons/components/Check.js +14 -1
- package/dist/Molecular/CustomIcons/components/Check2.js +12 -1
- package/dist/Molecular/CustomIcons/components/ChevronDown.js +12 -1
- package/dist/Molecular/CustomIcons/components/ChevronDownDisabled.js +11 -1
- package/dist/Molecular/CustomIcons/components/ChevronLeft.js +11 -1
- package/dist/Molecular/CustomIcons/components/ChevronRight.js +11 -1
- package/dist/Molecular/CustomIcons/components/ChevronUp.js +11 -1
- package/dist/Molecular/CustomIcons/components/ChevronUpDown.js +27 -1
- package/dist/Molecular/CustomIcons/components/Close.js +14 -1
- package/dist/Molecular/CustomIcons/components/ColumnsOrder.js +17 -1
- package/dist/Molecular/CustomIcons/components/Delete.js +16 -1
- package/dist/Molecular/CustomIcons/components/Edit.js +15 -1
- package/dist/Molecular/CustomIcons/components/Email.js +31 -1
- package/dist/Molecular/CustomIcons/components/FinturfLogo.js +18 -1
- package/dist/Molecular/CustomIcons/components/FinturfLogo2.js +35 -1
- package/dist/Molecular/CustomIcons/components/Flows.js +15 -1
- package/dist/Molecular/CustomIcons/components/Gift.js +25 -1
- package/dist/Molecular/CustomIcons/components/GoogleAuth.js +29 -1
- package/dist/Molecular/CustomIcons/components/GooglePlay.js +29 -1
- package/dist/Molecular/CustomIcons/components/HelpCircle.js +19 -1
- package/dist/Molecular/CustomIcons/components/HelpCircle2.js +20 -1
- package/dist/Molecular/CustomIcons/components/HelpCircleFilled.js +19 -1
- package/dist/Molecular/CustomIcons/components/Home.js +16 -1
- package/dist/Molecular/CustomIcons/components/Home2.js +22 -1
- package/dist/Molecular/CustomIcons/components/Key.js +23 -1
- package/dist/Molecular/CustomIcons/components/Landers.js +20 -1
- package/dist/Molecular/CustomIcons/components/Lock.js +15 -1
- package/dist/Molecular/CustomIcons/components/Mail.js +26 -1
- package/dist/Molecular/CustomIcons/components/Mastercard.js +73 -1
- package/dist/Molecular/CustomIcons/components/Minus.js +25 -1
- package/dist/Molecular/CustomIcons/components/Offers.js +16 -1
- package/dist/Molecular/CustomIcons/components/Pause.js +28 -1
- package/dist/Molecular/CustomIcons/components/PayPal.js +41 -1
- package/dist/Molecular/CustomIcons/components/PayPalLightLarge.js +28 -1
- package/dist/Molecular/CustomIcons/components/Phone.js +30 -1
- package/dist/Molecular/CustomIcons/components/Play.js +25 -1
- package/dist/Molecular/CustomIcons/components/Plus.js +25 -1
- package/dist/Molecular/CustomIcons/components/Profile.js +16 -1
- package/dist/Molecular/CustomIcons/components/QRCode.js +29 -1
- package/dist/Molecular/CustomIcons/components/Rectangle.js +12 -1
- package/dist/Molecular/CustomIcons/components/Revert.js +13 -1
- package/dist/Molecular/CustomIcons/components/Star.js +14 -1
- package/dist/Molecular/CustomIcons/components/Star2.js +16 -1
- package/dist/Molecular/CustomIcons/components/TrafficSources.js +14 -1
- package/dist/Molecular/CustomIcons/components/Trash.js +15 -1
- package/dist/Molecular/CustomIcons/components/TrashRed.js +15 -1
- package/dist/Molecular/CustomIcons/components/Triggers.js +15 -1
- package/dist/Molecular/CustomIcons/components/User.js +25 -1
- package/dist/Molecular/CustomIcons/components/Visa.js +31 -1
- package/dist/Molecular/CustomIcons/components/X.js +12 -1
- package/dist/Molecular/CustomIcons/index.js +61 -1
- package/dist/Molecular/FormElement/FormElement.js +54 -1
- package/dist/Molecular/FormWithDependOn/FormWithDependOn.js +184 -1
- package/dist/Molecular/FormWithDependOn/partials/_utils.js +53 -1
- package/dist/Molecular/InputAddress/InputAddress.js +620 -1
- package/dist/Molecular/InputPassword/InputPassword.js +48 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1,457 @@
|
|
|
1
|
-
function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function t(e,t,r,n,a,i,s){try{var o=e[i](s),l=o.value}catch(e){r(e);return}o.done?t(l):Promise.resolve(l).then(n,a)}function r(e,t,r){if(!t.has(e))throw TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}function n(e,t){var n=r(e,t,"get");return n.get?n.get.call(e):n.value}function a(e,t,r){if(t.has(e))throw TypeError("Cannot initialize the same private elements twice on an object");t.set(e,r)}function i(e,t,n){var a=r(e,t,"set");if(a.set)a.set.call(e,n);else{if(!a.writable)throw TypeError("attempted to set read only private field");a.value=n}return n}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){s(e,t,r[t])})}return e}function l(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function u(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(t,r){if(t){if("string"==typeof t)return e(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,r)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var h=/*#__PURE__*/new WeakMap,y=/*#__PURE__*/new WeakMap,f=/*#__PURE__*/new WeakMap,b=/*#__PURE__*/new WeakMap,p=/*#__PURE__*/new WeakMap,d=/*#__PURE__*/new WeakMap,v=/*#__PURE__*/new WeakMap,g=/*#__PURE__*/new WeakMap,P=/*#__PURE__*/new WeakMap,m=/*#__PURE__*/new WeakMap,k=/*#__PURE__*/function(){var e;function r(e){if(!(this instanceof r))throw TypeError("Cannot call a class as a function");if(a(this,h,{writable:!0,value:null}),a(this,y,{writable:!0,value:null}),a(this,f,{writable:!0,value:null}),a(this,b,{writable:!0,value:null}),a(this,p,{writable:!0,value:null}),a(this,d,{writable:!0,value:null}),a(this,v,{writable:!0,value:null}),a(this,g,{writable:!0,value:null}),a(this,P,{writable:!0,value:null}),a(this,m,{writable:!0,value:!1}),e&&((void 0===e?"undefined":c(e))!=="object"||Array.isArray(e)))throw Error("Not valid input value!");this.getPathPrefix=this.getPathPrefix.bind(this),this.setPathPrefix=this.setPathPrefix.bind(this),this.getMethod=this.getMethod.bind(this),this.setMethod=this.setMethod.bind(this),this.getQueryParameters=this.getQueryParameters.bind(this),this.getQueryString=this.getQueryString.bind(this),this.setQueryParameters=this.setQueryParameters.bind(this),this.getHeaders=this.getHeaders.bind(this),this.getHeadersObj=this.getHeadersObj.bind(this),this.setHeaders=this.setHeaders.bind(this),this.getBody=this.getBody.bind(this),this.setBody=this.setBody.bind(this),this.getOptions=this.getOptions.bind(this),this.setOptions=this.setOptions.bind(this),this.getCallback=this.getCallback.bind(this),this.setCallback=this.setCallback.bind(this),this.getCatchCallback=this.getCatchCallback.bind(this),this.setCatchCallback=this.setCatchCallback.bind(this),this.getEveryPromiseCallback=this.getEveryPromiseCallback.bind(this),this.setEveryPromiseCallback=this.setEveryPromiseCallback.bind(this),this.getIsResponseAsObject=this.getIsResponseAsObject.bind(this),this.setIsResponseAsObject=this.setIsResponseAsObject.bind(this),this.getProps=this.getProps.bind(this),this.setProps=this.setProps.bind(this),this.request=this.request.bind(this),this.repeatRequest=this.repeatRequest.bind(this),this.setProps(e||{})}return e=[{key:"request",value:function(e){var r,a,i=this;if(!e||(void 0===e?"undefined":c(e))!=="object"&&"string"!=typeof e)throw Error("Not valid props value!");this.requestInput=e;var k=(function(e){var t=this;return("string"==typeof e?[{path:e}]:Array.isArray(e)?u(e):[e]).reduce(function(e,r,a){var i,s,l,v=(void 0===r?"undefined":c(r))!=="object"||null===r||Array.isArray(r)?{}:r,g=v.name,P=v.path,m=v.method,k=v.queryParameters,O=v.headers,w=v.body,j=v.options,E=v.callback,A=v.mergeProps,_=v.isNoPathPrefix,C=v.isSkipEveryPromiseCallback,S=(null!=(i=Object)&&"undefined"!=typeof Symbol&&i[Symbol.hasInstance]?!!i[Symbol.hasInstance](A):A instanceof i)&&!Array.isArray(A)?A:{},R=function(e){var t;return null!=(t=S.all)?t:S[e]};if(!P||"string"!=typeof P)return e;var q=j||{},x=(q.name,q.path,q.pathPrefix,q.method,q.queryParameters,q.headers,q.body,q.options,q.callback,q.mergeProps,function(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}(q,["name","path","pathPrefix","method","queryParameters","headers","body","options","callback","mergeProps"]));return u(e).concat([o({path:P,pathPrefix:"onlyLocal"===R("pathPrefix")||_?"":n(t,h)||"",method:"onlyLocal"===R("method")?m||"GET":"onlyGlobal"===R("method")?n(t,y)||"GET":m||n(t,y)||"GET",queryParameters:(null!=(s=R("queryParameters"))?s:R("query"))==="onlyLocal"?t.getQueryString(t.getQueryArray(k)):(null!=(l=R("queryParameters"))?l:R("query"))==="onlyGlobal"?t.getQueryString(t.getQueryArray(n(t,f))):t.getQueryString(u(t.getQueryArray(n(t,f))).concat(u(t.getQueryArray(k)))),headers:"onlyLocal"===R("headers")?t.getHeadersObj(O||{}):"onlyGlobal"===R("headers")?t.getHeadersObj(o({},n(t,b)||{})):t.getHeadersObj(o({},n(t,b)||{},O||{})),body:"onlyLocal"===R("body")?w||null:"onlyGlobal"===R("body")?n(t,p)||null:w&&n(t,p)&&(void 0===w?"undefined":c(w))===c(n(t,p))&&(void 0===w?"undefined":c(w))==="object"?Array.isArray(w)?u(n(t,p)).concat(u(w)):o({},n(t,p),w):w||n(t,p)||null,options:"onlyLocal"===R("options")?o({},x||{}):"onlyGlobal"===R("options")?o({},n(t,d)||{}):o({},n(t,d)||{},x||{}),callback:E,isSkipEveryPromiseCallback:C},t.getIsResponseAsObject()?{name:g&&"string"==typeof g?g:a}:{})])},[])}).call(this,e);if(!k.length)return Promise.reject(Error("There are no any valid props"));var O=new AbortController,w=this,j=Promise.all(k.map((r=function(e){var t,r;return function(e,t){var r,n,a,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(o){return function(l){var u=[o,l];if(r)throw TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(i=0)),i;)try{if(r=1,n&&(a=2&u[0]?n.return:u[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,u[1])).done)return a;switch(n=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){i.label=u[1];break}if(6===u[0]&&i.label<a[1]){i.label=a[1],a=u;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(u);break}a[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(a){var i;return t=e.path.includes("?")?"&".concat(e.queryParameters.replace(/\?/g,"")):e.queryParameters,r=fetch("".concat(e.pathPrefix).concat(e.path).concat(t),l(o(l(o({},e.options),{method:e.method,headers:e.headers}),e.body?{body:(null==(i=e.body)?void 0:i.constructor)===FormData?i:JSON.stringify(i)}:{}),{signal:O.signal})).then(function(t){return t.request=e,t}).catch(function(t){return Promise.resolve({ok:!1,status:0,statusText:t,request:e})}),n(w,P)&&!e.isSkipEveryPromiseCallback&&(r=r.then(function(e){return n(w,P).call(w,e)})),e.callback&&(r=r.then(function(t){return e.callback(t)})),n(w,m)&&(r=r.then(function(t){return{name:e.name,response:t}})),[2,r]})},a=function(){var e=this,n=arguments;return new Promise(function(a,i){var s=r.apply(e,n);function o(e){t(s,a,i,o,l,"next",e)}function l(e){t(s,a,i,o,l,"throw",e)}o(void 0)})},function(e){return a.apply(this,arguments)})));return j=j.then(function(e){return e.length<2?e[0]:e}),n(this,m)&&(j=j.then(function(t){return Array.isArray(e)&&e.length>1?t.reduce(function(e,t){return l(o({},e),s({},t.name,t.response))},{}):"always"===n(i,m)?s({},t.name,t.response):t.response})),(j=(j=j.then(function(e){return n(i,v)?n(i,v).call(i,e):e})).catch(function(e){return n(i,g)?n(i,g).call(i,e):e})).__proto__.abort=function(){return O.abort()},j}},{key:"repeatRequest",value:function(){return this.request(this.requestInput)}},{key:"getPathPrefix",value:function(){return n(this,h)}},{key:"setPathPrefix",value:function(e){if(e&&"string"!=typeof e)throw Error("Not valid pathPrefix value!");i(this,h,e||null)}},{key:"getMethod",value:function(){return n(this,y)}},{key:"setMethod",value:function(e){if(e&&!["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"].includes(e))throw Error("Not valid method value!");i(this,y,e||null)}},{key:"getQueryParameters",value:function(){return n(this,f)}},{key:"getQueryArray",value:function(e){return"string"==typeof e?("?"===e[0]?e.slice(1):e).split("&"):Array.isArray(e)?e:(void 0===e?"undefined":c(e))==="object"&&null!==e?Object.keys(e).filter(function(t){return!!t&&!!e[t]}).map(function(t){return"".concat(t,"=").concat(e[t])}):[]}},{key:"getQueryString",value:function(e){if(!e)return"";if(!Array.isArray(e))throw Error("Not valid query parameters value!");return e.length?"?".concat(e.join("&")):""}},{key:"setQueryParameters",value:function(e){if(e&&!Array.isArray(e))throw Error("Not valid query parameters value!");i(this,f,e||null)}},{key:"getHeaders",value:function(){return n(this,b)}},{key:"getHeadersObj",value:function(e){var t=new Headers;if(!e)return t;if((void 0===e?"undefined":c(e))!=="object"||Array.isArray(e))throw Error("Not valid headers value!");return Object.keys(e).forEach(function(r){t.append(r,e[r])}),t}},{key:"setHeaders",value:function(e){if(e&&((void 0===e?"undefined":c(e))!=="object"||Array.isArray(e)))throw Error("Not valid headers value!");i(this,b,e||null)}},{key:"getBody",value:function(){return n(this,p)}},{key:"setBody",value:function(e){i(this,p,e)}},{key:"getOptions",value:function(){return n(this,d)}},{key:"setOptions",value:function(e){if(e&&((void 0===e?"undefined":c(e))!=="object"||Array.isArray(e)))throw Error("Not valid options value!");i(this,d,o({},e))}},{key:"getCallback",value:function(){return n(this,v)}},{key:"setCallback",value:function(e){if(e&&"function"!=typeof e)throw Error("Not valid callback value!");i(this,v,e||null)}},{key:"getCatchCallback",value:function(){return n(this,g)}},{key:"setCatchCallback",value:function(e){if(e&&"function"!=typeof e)throw Error("Not valid callback value!");i(this,g,e||null)}},{key:"getEveryPromiseCallback",value:function(){return n(this,P)}},{key:"setEveryPromiseCallback",value:function(e){if(e&&"function"!=typeof e)throw Error("Not valid callback value!");i(this,P,e||null)}},{key:"getIsResponseAsObject",value:function(){return n(this,m)}},{key:"setIsResponseAsObject",value:function(e){i(this,m,"boolean"!=typeof e&&"always"!==e?!!e:e)}},{key:"getProps",value:function(){return{pathPrefix:this.getPathPrefix()||null,method:this.getMethod()||null,queryParameters:this.getQueryParameters()||null,headers:this.getHeaders()||null,body:this.getBody()||null,options:this.getOptions()||null,callback:this.getCallback()||null,everyPromiseCallback:this.getEveryPromiseCallback(),isResponseAsObject:this.getIsResponseAsObject()}}},{key:"setProps",value:function(e){var t=e.pathPrefix,r=e.method,n=e.queryParameters,a=e.headers,i=e.body,s=e.options,o=e.callback,l=e.catchCallback,u=e.everyPromiseCallback,c=e.isResponseAsObject;t&&this.setPathPrefix(t),r&&this.setMethod(r),n&&this.setQueryParameters(this.getQueryArray(n)),a&&this.setHeaders(a),i&&this.setBody(i),s&&this.setOptions(s),o&&this.setCallback(o),l&&this.setCatchCallback(l),u&&this.setEveryPromiseCallback(u),void 0!==c&&this.setIsResponseAsObject(c)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,e),r}();export default k;
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
|
|
3
|
+
const RESPONSE_AS_OBJECT_ALWAYS_VALUE = "always";
|
|
4
|
+
class AbortableFetch {
|
|
5
|
+
#pathPrefix = null;
|
|
6
|
+
|
|
7
|
+
#method = null;
|
|
8
|
+
|
|
9
|
+
#queryParameters = null;
|
|
10
|
+
|
|
11
|
+
#headers = null;
|
|
12
|
+
|
|
13
|
+
#body = null;
|
|
14
|
+
|
|
15
|
+
#options = null;
|
|
16
|
+
|
|
17
|
+
#callback = null;
|
|
18
|
+
|
|
19
|
+
#catchCallback = null;
|
|
20
|
+
|
|
21
|
+
#everyPromiseCallback = null;
|
|
22
|
+
|
|
23
|
+
#isResponseAsObject = false;
|
|
24
|
+
|
|
25
|
+
constructor(input) {
|
|
26
|
+
if (input && (typeof input !== "object" || Array.isArray(input)))
|
|
27
|
+
throw new Error("Not valid input value!");
|
|
28
|
+
this.getPathPrefix = this.getPathPrefix.bind(this);
|
|
29
|
+
this.setPathPrefix = this.setPathPrefix.bind(this);
|
|
30
|
+
this.getMethod = this.getMethod.bind(this);
|
|
31
|
+
this.setMethod = this.setMethod.bind(this);
|
|
32
|
+
this.getQueryParameters = this.getQueryParameters.bind(this);
|
|
33
|
+
this.getQueryString = this.getQueryString.bind(this);
|
|
34
|
+
this.setQueryParameters = this.setQueryParameters.bind(this);
|
|
35
|
+
this.getHeaders = this.getHeaders.bind(this);
|
|
36
|
+
this.getHeadersObj = this.getHeadersObj.bind(this);
|
|
37
|
+
this.setHeaders = this.setHeaders.bind(this);
|
|
38
|
+
this.getBody = this.getBody.bind(this);
|
|
39
|
+
this.setBody = this.setBody.bind(this);
|
|
40
|
+
this.getOptions = this.getOptions.bind(this);
|
|
41
|
+
this.setOptions = this.setOptions.bind(this);
|
|
42
|
+
this.getCallback = this.getCallback.bind(this);
|
|
43
|
+
this.setCallback = this.setCallback.bind(this);
|
|
44
|
+
this.getCatchCallback = this.getCatchCallback.bind(this);
|
|
45
|
+
this.setCatchCallback = this.setCatchCallback.bind(this);
|
|
46
|
+
this.getEveryPromiseCallback = this.getEveryPromiseCallback.bind(this);
|
|
47
|
+
this.setEveryPromiseCallback = this.setEveryPromiseCallback.bind(this);
|
|
48
|
+
this.getIsResponseAsObject = this.getIsResponseAsObject.bind(this);
|
|
49
|
+
this.setIsResponseAsObject = this.setIsResponseAsObject.bind(this);
|
|
50
|
+
this.getProps = this.getProps.bind(this);
|
|
51
|
+
this.setProps = this.setProps.bind(this);
|
|
52
|
+
|
|
53
|
+
this.request = this.request.bind(this);
|
|
54
|
+
this.repeatRequest = this.repeatRequest.bind(this);
|
|
55
|
+
this.setProps(input || {});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
request(props) {
|
|
59
|
+
if (!props || (typeof props !== "object" && typeof props !== "string"))
|
|
60
|
+
throw new Error("Not valid props value!");
|
|
61
|
+
|
|
62
|
+
const stringifyBody = (b) =>
|
|
63
|
+
b?.constructor === FormData ? b : JSON.stringify(b);
|
|
64
|
+
|
|
65
|
+
this.requestInput = props;
|
|
66
|
+
// eslint-disable-next-line no-use-before-define
|
|
67
|
+
const requests = getRequestsArray.call(this, props);
|
|
68
|
+
if (!requests.length)
|
|
69
|
+
return Promise.reject(new Error("There are no any valid props"));
|
|
70
|
+
|
|
71
|
+
const abortController = new AbortController();
|
|
72
|
+
let externalRequest = Promise.all(
|
|
73
|
+
requests.map(async (item) => {
|
|
74
|
+
const safelyQuery = item.path.includes("?")
|
|
75
|
+
? `&${item.queryParameters.replace(/\?/g, "")}`
|
|
76
|
+
: item.queryParameters;
|
|
77
|
+
let request = fetch(`${item.pathPrefix}${item.path}${safelyQuery}`, {
|
|
78
|
+
...item.options,
|
|
79
|
+
method: item.method,
|
|
80
|
+
headers: item.headers,
|
|
81
|
+
...(item.body ? { body: stringifyBody(item.body) } : {}),
|
|
82
|
+
signal: abortController.signal,
|
|
83
|
+
})
|
|
84
|
+
.then((response) => {
|
|
85
|
+
response.request = item;
|
|
86
|
+
return response;
|
|
87
|
+
})
|
|
88
|
+
.catch((response) =>
|
|
89
|
+
Promise.resolve({
|
|
90
|
+
ok: false,
|
|
91
|
+
status: 0,
|
|
92
|
+
statusText: response,
|
|
93
|
+
request: item,
|
|
94
|
+
}),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
if (this.#everyPromiseCallback && !item.isSkipEveryPromiseCallback) {
|
|
98
|
+
request = request.then((response) =>
|
|
99
|
+
this.#everyPromiseCallback(response),
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (item.callback)
|
|
104
|
+
request = request.then((response) => item.callback(response));
|
|
105
|
+
|
|
106
|
+
if (this.#isResponseAsObject)
|
|
107
|
+
request = request.then((response) => ({ name: item.name, response }));
|
|
108
|
+
|
|
109
|
+
return request;
|
|
110
|
+
}),
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
externalRequest = externalRequest.then((response) =>
|
|
114
|
+
response.length < 2 ? response[0] : response,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
if (this.#isResponseAsObject) {
|
|
118
|
+
externalRequest = externalRequest.then((response) => {
|
|
119
|
+
if (Array.isArray(props) && props.length > 1) {
|
|
120
|
+
return response.reduce(
|
|
121
|
+
(ac, item) => ({ ...ac, [item.name]: item.response }),
|
|
122
|
+
{},
|
|
123
|
+
);
|
|
124
|
+
} else {
|
|
125
|
+
return this.#isResponseAsObject === RESPONSE_AS_OBJECT_ALWAYS_VALUE
|
|
126
|
+
? { [response.name]: response.response }
|
|
127
|
+
: response.response;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
externalRequest = externalRequest.then((response) =>
|
|
133
|
+
this.#callback ? this.#callback(response) : response,
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
externalRequest = externalRequest.catch((error) =>
|
|
137
|
+
this.#catchCallback ? this.#catchCallback(error) : error,
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
// eslint-disable-next-line no-proto
|
|
141
|
+
externalRequest.__proto__.abort = () => abortController.abort();
|
|
142
|
+
return externalRequest;
|
|
143
|
+
|
|
144
|
+
function getRequestsArray(input) {
|
|
145
|
+
const requestsArray = (() => {
|
|
146
|
+
if (typeof input === "string") return [{ path: input }];
|
|
147
|
+
return Array.isArray(input) ? [...input] : [input];
|
|
148
|
+
})();
|
|
149
|
+
|
|
150
|
+
return requestsArray.reduce((ac, item, index) => {
|
|
151
|
+
const itemObj =
|
|
152
|
+
typeof item === "object" && item !== null && !Array.isArray(item)
|
|
153
|
+
? item
|
|
154
|
+
: {};
|
|
155
|
+
const {
|
|
156
|
+
name,
|
|
157
|
+
path,
|
|
158
|
+
method,
|
|
159
|
+
queryParameters,
|
|
160
|
+
headers,
|
|
161
|
+
body,
|
|
162
|
+
options,
|
|
163
|
+
callback,
|
|
164
|
+
mergeProps,
|
|
165
|
+
isNoPathPrefix,
|
|
166
|
+
isSkipEveryPromiseCallback,
|
|
167
|
+
} = itemObj;
|
|
168
|
+
|
|
169
|
+
const safelyMergeProps =
|
|
170
|
+
mergeProps instanceof Object && !Array.isArray(mergeProps)
|
|
171
|
+
? mergeProps
|
|
172
|
+
: {};
|
|
173
|
+
const getMergeProps = (key) =>
|
|
174
|
+
safelyMergeProps.all ?? safelyMergeProps[key];
|
|
175
|
+
|
|
176
|
+
if (!path || typeof path !== "string") return ac;
|
|
177
|
+
|
|
178
|
+
const {
|
|
179
|
+
name: omitName,
|
|
180
|
+
path: omitPath,
|
|
181
|
+
pathPrefix: omitPathPrefix,
|
|
182
|
+
method: omitMethod,
|
|
183
|
+
queryParameters: omitQueryParameters,
|
|
184
|
+
headers: omitHeaders,
|
|
185
|
+
body: omitBody,
|
|
186
|
+
options: omitOptions,
|
|
187
|
+
callback: omitCallback,
|
|
188
|
+
mergeProps: omitMergeProps,
|
|
189
|
+
...optionsRest
|
|
190
|
+
} = options || {};
|
|
191
|
+
|
|
192
|
+
return [
|
|
193
|
+
...ac,
|
|
194
|
+
{
|
|
195
|
+
path,
|
|
196
|
+
pathPrefix:
|
|
197
|
+
getMergeProps("pathPrefix") === "onlyLocal" || isNoPathPrefix
|
|
198
|
+
? ""
|
|
199
|
+
: this.#pathPrefix || "",
|
|
200
|
+
method: (() => {
|
|
201
|
+
if (getMergeProps("method") === "onlyLocal")
|
|
202
|
+
return method || "GET";
|
|
203
|
+
return getMergeProps("method") === "onlyGlobal"
|
|
204
|
+
? this.#method || "GET"
|
|
205
|
+
: method || this.#method || "GET";
|
|
206
|
+
})(),
|
|
207
|
+
queryParameters: (() => {
|
|
208
|
+
if (
|
|
209
|
+
(getMergeProps("queryParameters") ?? getMergeProps("query")) ===
|
|
210
|
+
"onlyLocal"
|
|
211
|
+
) {
|
|
212
|
+
return this.getQueryString(this.getQueryArray(queryParameters));
|
|
213
|
+
}
|
|
214
|
+
return (getMergeProps("queryParameters") ??
|
|
215
|
+
getMergeProps("query")) === "onlyGlobal"
|
|
216
|
+
? this.getQueryString(this.getQueryArray(this.#queryParameters))
|
|
217
|
+
: this.getQueryString([
|
|
218
|
+
...this.getQueryArray(this.#queryParameters),
|
|
219
|
+
...this.getQueryArray(queryParameters),
|
|
220
|
+
]);
|
|
221
|
+
})(),
|
|
222
|
+
headers: (() => {
|
|
223
|
+
if (getMergeProps("headers") === "onlyLocal")
|
|
224
|
+
return this.getHeadersObj(headers || {});
|
|
225
|
+
return getMergeProps("headers") === "onlyGlobal"
|
|
226
|
+
? this.getHeadersObj({ ...(this.#headers || {}) })
|
|
227
|
+
: this.getHeadersObj({
|
|
228
|
+
...(this.#headers || {}),
|
|
229
|
+
...(headers || {}),
|
|
230
|
+
});
|
|
231
|
+
})(),
|
|
232
|
+
body: (() => {
|
|
233
|
+
if (getMergeProps("body") === "onlyLocal") return body || null;
|
|
234
|
+
if (getMergeProps("body") === "onlyGlobal")
|
|
235
|
+
return this.#body || null;
|
|
236
|
+
if (
|
|
237
|
+
body &&
|
|
238
|
+
this.#body &&
|
|
239
|
+
typeof body === typeof this.#body &&
|
|
240
|
+
typeof body === "object"
|
|
241
|
+
) {
|
|
242
|
+
return Array.isArray(body)
|
|
243
|
+
? [...this.#body, ...body]
|
|
244
|
+
: { ...this.#body, ...body };
|
|
245
|
+
} else return body || this.#body || null;
|
|
246
|
+
})(),
|
|
247
|
+
options: (() => {
|
|
248
|
+
if (getMergeProps("options") === "onlyLocal")
|
|
249
|
+
return { ...(optionsRest || {}) };
|
|
250
|
+
return getMergeProps("options") === "onlyGlobal"
|
|
251
|
+
? { ...(this.#options || {}) }
|
|
252
|
+
: { ...(this.#options || {}), ...(optionsRest || {}) };
|
|
253
|
+
})(),
|
|
254
|
+
callback,
|
|
255
|
+
isSkipEveryPromiseCallback,
|
|
256
|
+
...(this.getIsResponseAsObject()
|
|
257
|
+
? { name: name && typeof name === "string" ? name : index }
|
|
258
|
+
: {}),
|
|
259
|
+
},
|
|
260
|
+
];
|
|
261
|
+
}, []);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
repeatRequest() {
|
|
266
|
+
return this.request(this.requestInput);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// ***** getters and setters *****
|
|
270
|
+
getPathPrefix() {
|
|
271
|
+
return this.#pathPrefix;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
setPathPrefix(value) {
|
|
275
|
+
if (value && typeof value !== "string")
|
|
276
|
+
throw new Error("Not valid pathPrefix value!");
|
|
277
|
+
this.#pathPrefix = value || null;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
getMethod() {
|
|
281
|
+
return this.#method;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
setMethod(value) {
|
|
285
|
+
const methods = [
|
|
286
|
+
"GET",
|
|
287
|
+
"HEAD",
|
|
288
|
+
"POST",
|
|
289
|
+
"PUT",
|
|
290
|
+
"DELETE",
|
|
291
|
+
"CONNECT",
|
|
292
|
+
"OPTIONS",
|
|
293
|
+
"TRACE",
|
|
294
|
+
"PATCH",
|
|
295
|
+
];
|
|
296
|
+
if (value && !methods.includes(value))
|
|
297
|
+
throw new Error("Not valid method value!");
|
|
298
|
+
this.#method = value || null;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
getQueryParameters() {
|
|
302
|
+
return this.#queryParameters;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// eslint-disable-next-line class-methods-use-this
|
|
306
|
+
getQueryArray(value) {
|
|
307
|
+
if (typeof value === "string")
|
|
308
|
+
return (value[0] === "?" ? value.slice(1) : value).split("&");
|
|
309
|
+
else if (Array.isArray(value)) return value;
|
|
310
|
+
else if (typeof value === "object" && value !== null) {
|
|
311
|
+
return Object.keys(value)
|
|
312
|
+
.filter((key) => Boolean(key) && Boolean(value[key]))
|
|
313
|
+
.map((key) => `${key}=${value[key]}`);
|
|
314
|
+
} else return [];
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// eslint-disable-next-line class-methods-use-this
|
|
318
|
+
getQueryString(value) {
|
|
319
|
+
if (!value) return "";
|
|
320
|
+
if (!Array.isArray(value))
|
|
321
|
+
throw new Error("Not valid query parameters value!");
|
|
322
|
+
return value.length ? `?${value.join("&")}` : "";
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
setQueryParameters(value) {
|
|
326
|
+
if (value && !Array.isArray(value))
|
|
327
|
+
throw new Error("Not valid query parameters value!");
|
|
328
|
+
this.#queryParameters = value || null;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
getHeaders() {
|
|
332
|
+
return this.#headers;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// eslint-disable-next-line class-methods-use-this
|
|
336
|
+
getHeadersObj(obj) {
|
|
337
|
+
const headers = new Headers();
|
|
338
|
+
if (!obj) return headers;
|
|
339
|
+
|
|
340
|
+
if (typeof obj !== "object" || Array.isArray(obj))
|
|
341
|
+
throw new Error("Not valid headers value!");
|
|
342
|
+
Object.keys(obj).forEach((key) => {
|
|
343
|
+
headers.append(key, obj[key]);
|
|
344
|
+
});
|
|
345
|
+
return headers;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
setHeaders(value) {
|
|
349
|
+
if (value && (typeof value !== "object" || Array.isArray(value)))
|
|
350
|
+
throw new Error("Not valid headers value!");
|
|
351
|
+
this.#headers = value || null;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
getBody() {
|
|
355
|
+
return this.#body;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
setBody(value) {
|
|
359
|
+
this.#body = value;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
getOptions() {
|
|
363
|
+
return this.#options;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
setOptions(value) {
|
|
367
|
+
if (value && (typeof value !== "object" || Array.isArray(value)))
|
|
368
|
+
throw new Error("Not valid options value!");
|
|
369
|
+
this.#options = { ...value };
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
getCallback() {
|
|
373
|
+
return this.#callback;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
setCallback(value) {
|
|
377
|
+
if (value && typeof value !== "function")
|
|
378
|
+
throw new Error("Not valid callback value!");
|
|
379
|
+
this.#callback = value || null;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
getCatchCallback() {
|
|
383
|
+
return this.#catchCallback;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
setCatchCallback(value) {
|
|
387
|
+
if (value && typeof value !== "function")
|
|
388
|
+
throw new Error("Not valid callback value!");
|
|
389
|
+
this.#catchCallback = value || null;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
getEveryPromiseCallback() {
|
|
393
|
+
return this.#everyPromiseCallback;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
setEveryPromiseCallback(value) {
|
|
397
|
+
if (value && typeof value !== "function")
|
|
398
|
+
throw new Error("Not valid callback value!");
|
|
399
|
+
this.#everyPromiseCallback = value || null;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
getIsResponseAsObject() {
|
|
403
|
+
return this.#isResponseAsObject;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
setIsResponseAsObject(value) {
|
|
407
|
+
this.#isResponseAsObject =
|
|
408
|
+
typeof value !== "boolean" && value !== "always" ? Boolean(value) : value;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
getProps() {
|
|
412
|
+
return {
|
|
413
|
+
pathPrefix: this.getPathPrefix() || null,
|
|
414
|
+
method: this.getMethod() || null,
|
|
415
|
+
queryParameters: this.getQueryParameters() || null,
|
|
416
|
+
headers: this.getHeaders() || null,
|
|
417
|
+
body: this.getBody() || null,
|
|
418
|
+
options: this.getOptions() || null,
|
|
419
|
+
callback: this.getCallback() || null,
|
|
420
|
+
everyPromiseCallback: this.getEveryPromiseCallback(),
|
|
421
|
+
// isAnywayRunCallback: this.getIsAnywayRunCallback(),
|
|
422
|
+
isResponseAsObject: this.getIsResponseAsObject(),
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
setProps(input) {
|
|
427
|
+
const {
|
|
428
|
+
pathPrefix,
|
|
429
|
+
method,
|
|
430
|
+
queryParameters,
|
|
431
|
+
headers,
|
|
432
|
+
body,
|
|
433
|
+
options,
|
|
434
|
+
callback,
|
|
435
|
+
catchCallback,
|
|
436
|
+
everyPromiseCallback,
|
|
437
|
+
// isAnywayRunCallback,
|
|
438
|
+
isResponseAsObject,
|
|
439
|
+
} = input;
|
|
440
|
+
if (pathPrefix) this.setPathPrefix(pathPrefix);
|
|
441
|
+
if (method) this.setMethod(method);
|
|
442
|
+
if (queryParameters)
|
|
443
|
+
this.setQueryParameters(this.getQueryArray(queryParameters));
|
|
444
|
+
if (headers) this.setHeaders(headers);
|
|
445
|
+
if (body) this.setBody(body);
|
|
446
|
+
if (options) this.setOptions(options);
|
|
447
|
+
if (callback) this.setCallback(callback);
|
|
448
|
+
if (catchCallback) this.setCatchCallback(catchCallback);
|
|
449
|
+
if (everyPromiseCallback)
|
|
450
|
+
this.setEveryPromiseCallback(everyPromiseCallback);
|
|
451
|
+
// if (isAnywayRunCallback) this.setIsAnywayRunCallback(isAnywayRunCallback);
|
|
452
|
+
if (isResponseAsObject !== undefined)
|
|
453
|
+
this.setIsResponseAsObject(isResponseAsObject);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
export default AbortableFetch;
|
|
@@ -1 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
import ApiRequestCreators from "./ApiRequestCreators";
|
|
2
|
+
class ApiBase extends ApiRequestCreators {
|
|
3
|
+
constructor(settings) {
|
|
4
|
+
super(settings);
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
API_PATH,
|
|
8
|
+
|
|
9
|
+
BAD_REQUEST_DATA_TEXT = "Bad request data",
|
|
10
|
+
DEFAULT_SUCCESS_MESSAGE = "Success",
|
|
11
|
+
DEFAULT_ERROR_MESSAGE = "Something wrong, try again",
|
|
12
|
+
NO_INET = "Please check your network connection and reload page",
|
|
13
|
+
|
|
14
|
+
REJECT_CODES = [],
|
|
15
|
+
|
|
16
|
+
...customConstants
|
|
17
|
+
} = settings.constants || {};
|
|
18
|
+
|
|
19
|
+
if (typeof API_PATH !== "string")
|
|
20
|
+
throw new Error("No API_PATH [ApiBase constructor]");
|
|
21
|
+
|
|
22
|
+
if (
|
|
23
|
+
typeof BAD_REQUEST_DATA_TEXT !== "string" ||
|
|
24
|
+
typeof DEFAULT_SUCCESS_MESSAGE !== "string" ||
|
|
25
|
+
typeof DEFAULT_ERROR_MESSAGE !== "string" ||
|
|
26
|
+
typeof NO_INET !== "string" ||
|
|
27
|
+
!Array.isArray(REJECT_CODES) ||
|
|
28
|
+
!REJECT_CODES.every((i) => typeof i === "number")
|
|
29
|
+
) {
|
|
30
|
+
throw new Error("Bad input data [ApiBase constructor]");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
this.API_PATH = API_PATH;
|
|
34
|
+
|
|
35
|
+
this.BAD_REQUEST_DATA_TEXT = BAD_REQUEST_DATA_TEXT;
|
|
36
|
+
this.DEFAULT_SUCCESS_MESSAGE = DEFAULT_SUCCESS_MESSAGE;
|
|
37
|
+
this.DEFAULT_ERROR_MESSAGE = DEFAULT_ERROR_MESSAGE;
|
|
38
|
+
this.NO_INET = NO_INET;
|
|
39
|
+
|
|
40
|
+
this.REJECT_CODES = REJECT_CODES;
|
|
41
|
+
|
|
42
|
+
Object.keys(customConstants).forEach((key) => {
|
|
43
|
+
this[key] = customConstants[key];
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default ApiBase;
|
|
@@ -1 +1,112 @@
|
|
|
1
|
-
|
|
1
|
+
import ApiUtils from "./ApiUtils";
|
|
2
|
+
import {
|
|
3
|
+
addCustomMethods,
|
|
4
|
+
getIsOnlyAnObject,
|
|
5
|
+
getResponseClone,
|
|
6
|
+
omitKeys,
|
|
7
|
+
} from "./_utils";
|
|
8
|
+
|
|
9
|
+
//? Префикс createRequest_ добавляется к крейтерам с целью разгрузить пространство имен
|
|
10
|
+
const PREFIX_OF_CLASS_UTILS = "createRequest_";
|
|
11
|
+
class ApiRequestCreators extends ApiUtils {
|
|
12
|
+
constructor(settings) {
|
|
13
|
+
super(settings);
|
|
14
|
+
const { requestsCreators } = settings || {};
|
|
15
|
+
|
|
16
|
+
if (getIsOnlyAnObject(requestsCreators))
|
|
17
|
+
addCustomMethods.call(this, requestsCreators, PREFIX_OF_CLASS_UTILS);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//? При типе toJson пользовательский callback на вход получит тело ответа реализованное методом Response.json()
|
|
21
|
+
//? независимо от насторойки isGetBody
|
|
22
|
+
async createRequest_toJson(props, variant) {
|
|
23
|
+
const safelyProps = omitKeys(props, ['getBodyAs']);
|
|
24
|
+
|
|
25
|
+
return this.splitProperties(
|
|
26
|
+
{
|
|
27
|
+
...safelyProps,
|
|
28
|
+
isGetBody: false,
|
|
29
|
+
callback: async (res) => {
|
|
30
|
+
const output = await this.getResponseBody(res, 'json');
|
|
31
|
+
return await (safelyProps.callback?.(output) ?? output);
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
variant,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//? При типе toJsonAdvanced пользовательский callback на вход получит структуру { response, result },
|
|
39
|
+
//? где response - объект Response, result - тело ответа реализованное методом Response.json()
|
|
40
|
+
//? независимо от насторойки isGetBody
|
|
41
|
+
async createRequest_toJsonAdvanced(props, variant) {
|
|
42
|
+
const safelyProps = omitKeys(props, ['getBodyAs']);
|
|
43
|
+
|
|
44
|
+
return this.splitProperties(
|
|
45
|
+
{
|
|
46
|
+
...safelyProps,
|
|
47
|
+
isGetBody: false,
|
|
48
|
+
callback: async (res) => {
|
|
49
|
+
const output = {
|
|
50
|
+
response: res,
|
|
51
|
+
result: await this.getResponseBody(await getResponseClone(res), 'json'),
|
|
52
|
+
};
|
|
53
|
+
return await (safelyProps.callback?.(output) ?? output);
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
variant,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//? При типе blob пользовательский callback на вход получит тело ответа реализованное методом Response.blob(),
|
|
61
|
+
//? независимо от насторойки isGetBody
|
|
62
|
+
async createRequest_blob(props, variant) {
|
|
63
|
+
const safelyProps = omitKeys(props, ['getBodyAs']);
|
|
64
|
+
|
|
65
|
+
return this.splitProperties(
|
|
66
|
+
{
|
|
67
|
+
...safelyProps,
|
|
68
|
+
isGetBody: false,
|
|
69
|
+
callback: async (res) => {
|
|
70
|
+
const output = await this.getResponseBody(await getResponseClone(res), 'blob')
|
|
71
|
+
return await (safelyProps.callback?.(output) ?? output);
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
variant,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//? При типе testBadResponse пользовательский callback на вход получит объект Response в 401-м статусе
|
|
79
|
+
//? независимо независимо вообще ни от чего
|
|
80
|
+
async createRequest_testBadResponse(props, variant) {
|
|
81
|
+
return this.splitProperties(
|
|
82
|
+
{
|
|
83
|
+
...props,
|
|
84
|
+
callback: async () =>
|
|
85
|
+
Promise.resolve(
|
|
86
|
+
new Response(
|
|
87
|
+
JSON.stringify({ errors: [{ message: "test bad Response" }] }),
|
|
88
|
+
{
|
|
89
|
+
status: 401,
|
|
90
|
+
statusText: "test bad Response",
|
|
91
|
+
headers: (() => {
|
|
92
|
+
const headers = new Headers();
|
|
93
|
+
headers.append("content-type", "application/json");
|
|
94
|
+
return headers;
|
|
95
|
+
})(),
|
|
96
|
+
},
|
|
97
|
+
),
|
|
98
|
+
).then((res) => props.callback?.(res) ?? res),
|
|
99
|
+
},
|
|
100
|
+
variant,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//? По умолчанию пользовательский callback на вход получит
|
|
105
|
+
//? - либо объект Response
|
|
106
|
+
//? - либо тело ответа (в случае isGetBody: 'first') полученное методом getResponseBody (смотри класс ApiUtils)
|
|
107
|
+
async createRequest_default(props, variant) {
|
|
108
|
+
return this.splitProperties(props, variant);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default ApiRequestCreators;
|