@_tc/template-core 0.0.1-bate.9 → 0.0.2
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/README.md +1108 -0
- package/cjs/_virtual/_rolldown/runtime.js +1 -0
- package/cjs/app/controller/base.js +1 -21
- package/cjs/app/controller/project.js +1 -50
- package/cjs/app/controller/view.js +1 -14
- package/cjs/app/data/signKey.js +1 -4
- package/cjs/app/extend/$fetch.js +1 -0
- package/cjs/app/extend/db.js +1 -12
- package/cjs/app/extend/generateErrorMessage.js +1 -14
- package/cjs/app/extend/logger.js +1 -72
- package/cjs/app/extend/parsingParamsOnUrl.js +1 -22
- package/cjs/app/extend/render-view.js +1 -21
- package/cjs/app/middleware/api-params-verify.js +1 -63
- package/cjs/app/middleware/api-sign-verify.js +1 -28
- package/cjs/app/middleware/error-handle.js +1 -33
- package/cjs/app/middleware/project-handler.js +1 -21
- package/cjs/app/middleware.js +1 -60
- package/cjs/app/router/project.js +1 -8
- package/cjs/app/router/view.js +1 -5
- package/cjs/app/router-schema/project.js +1 -33
- package/cjs/app/service/base.js +1 -0
- package/cjs/app/service/project.js +1 -42
- package/cjs/app/type.js +1 -2
- package/cjs/app/typings.js +1 -2
- package/cjs/bundler/defaultAlias.js +1 -0
- package/cjs/bundler/dev.js +1 -68
- package/cjs/bundler/index.js +1 -18
- package/cjs/bundler/prod.js +1 -19
- package/cjs/bundler/state.js +1 -0
- package/cjs/bundler/utils.js +1 -127
- package/cjs/index.js +1 -21
- package/cjs/packages/common/LRUCache.js +1 -0
- package/cjs/packages/common/array/index.js +1 -0
- package/cjs/packages/common/cache/LRUCache.js +1 -0
- package/cjs/packages/common/cache/index.js +1 -0
- package/cjs/packages/common/guards/index.js +1 -0
- package/cjs/packages/common/http/index.js +1 -0
- package/cjs/packages/common/i18n/default.js +1 -0
- package/cjs/packages/common/i18n/en-US.js +1 -0
- package/cjs/packages/common/i18n/index.js +1 -0
- package/cjs/packages/common/i18n/locales.js +1 -0
- package/cjs/packages/common/i18n/types.js +1 -0
- package/cjs/packages/common/index.js +1 -0
- package/cjs/packages/common/log/index.js +2 -0
- package/cjs/packages/common/number/index.js +1 -0
- package/cjs/packages/common/object/filterEmpty.js +1 -0
- package/cjs/packages/common/object/filtereEmpty.js +1 -0
- package/cjs/packages/common/object/index.js +1 -0
- package/cjs/packages/common/string/index.js +1 -0
- package/cjs/packages/common/types/index.js +1 -0
- package/cjs/packages/core/env.js +1 -25
- package/cjs/packages/core/index.js +1 -116
- package/cjs/packages/core/loader/config.js +1 -45
- package/cjs/packages/core/loader/controller.js +1 -40
- package/cjs/packages/core/loader/extend.js +1 -41
- package/cjs/packages/core/loader/middleware.js +1 -38
- package/cjs/packages/core/loader/model.js +1 -132
- package/cjs/packages/core/loader/router-schema.js +1 -35
- package/cjs/packages/core/loader/router.js +1 -62
- package/cjs/packages/core/loader/service.js +1 -30
- package/cjs/packages/core/paths.js +1 -10
- package/cjs/packages/core/types.js +1 -2
- package/cjs/packages/utils/getAllFilesInFolder.js +1 -45
- package/cjs/packages/utils/getAllFnReturnValue.js +1 -6
- package/cjs/packages/utils/index.js +1 -20
- package/cjs/packages/utils/loadFile.js +1 -65
- package/cjs/packages/utils/path.js +1 -64
- package/cjs/packages/utils/runFileFn.js +1 -5
- package/esm/_virtual/_rolldown/runtime.js +20 -0
- package/esm/app/controller/base.js +26 -21
- package/esm/app/controller/project.js +52 -42
- package/esm/app/controller/view.js +23 -12
- package/esm/app/data/signKey.js +8 -1
- package/esm/app/extend/$fetch.js +15 -0
- package/esm/app/extend/db.js +5 -8
- package/esm/app/extend/generateErrorMessage.js +6 -11
- package/esm/app/extend/logger.js +25 -36
- package/esm/app/extend/parsingParamsOnUrl.js +13 -19
- package/esm/app/extend/render-view.js +18 -15
- package/esm/app/middleware/api-params-verify.js +55 -57
- package/esm/app/middleware/api-sign-verify.js +17 -22
- package/esm/app/middleware/error-handle.js +23 -30
- package/esm/app/middleware/project-handler.js +14 -18
- package/esm/app/middleware.js +17 -54
- package/esm/app/router/project.js +6 -5
- package/esm/app/router/view.js +6 -2
- package/esm/app/router-schema/project.js +14 -30
- package/esm/app/service/base.js +14 -0
- package/esm/app/service/project.js +23 -34
- package/esm/app/type.js +0 -1
- package/esm/app/typings.js +0 -1
- package/esm/bundler/defaultAlias.js +4 -0
- package/esm/bundler/dev.js +11 -28
- package/esm/bundler/index.js +17 -13
- package/esm/bundler/prod.js +13 -15
- package/esm/bundler/state.js +10 -0
- package/esm/bundler/utils.js +191 -82
- package/esm/index.js +15 -12
- package/esm/packages/common/LRUCache.js +2 -0
- package/esm/packages/common/array/index.js +27 -0
- package/esm/packages/common/cache/LRUCache.js +39 -0
- package/esm/packages/common/cache/index.js +2 -0
- package/esm/packages/common/guards/index.js +8 -0
- package/esm/packages/common/http/index.js +256 -0
- package/esm/packages/common/i18n/default.js +88 -0
- package/esm/packages/common/i18n/en-US.js +88 -0
- package/esm/packages/common/i18n/index.js +91 -0
- package/esm/packages/common/i18n/locales.js +9 -0
- package/esm/packages/common/index.js +14 -0
- package/esm/packages/common/log/index.js +93 -0
- package/esm/packages/common/number/index.js +10 -0
- package/esm/packages/common/object/filterEmpty.js +23 -0
- package/esm/packages/common/object/filtereEmpty.js +2 -0
- package/esm/packages/common/object/index.js +17 -0
- package/esm/packages/common/string/index.js +4 -0
- package/esm/packages/common/types/index.js +0 -0
- package/esm/packages/core/env.js +24 -23
- package/esm/packages/core/index.js +51 -108
- package/esm/packages/core/loader/config.js +26 -42
- package/esm/packages/core/loader/controller.js +12 -37
- package/esm/packages/core/loader/extend.js +22 -38
- package/esm/packages/core/loader/middleware.js +15 -35
- package/esm/packages/core/loader/model.js +65 -124
- package/esm/packages/core/loader/router-schema.js +18 -32
- package/esm/packages/core/loader/router.js +35 -56
- package/esm/packages/core/loader/service.js +12 -27
- package/esm/packages/core/paths.js +7 -4
- package/esm/packages/core/types.js +0 -1
- package/esm/packages/utils/getAllFilesInFolder.js +8 -7
- package/esm/packages/utils/getAllFnReturnValue.js +0 -6
- package/esm/packages/utils/index.js +5 -4
- package/esm/packages/utils/loadFile.js +33 -62
- package/esm/packages/utils/path.js +14 -25
- package/esm/packages/utils/runFileFn.js +45 -1
- package/fe/frontend/apps/dash/Dashboard.d.ts +6 -0
- package/fe/frontend/apps/dash/Dashboard.js +75 -0
- package/fe/frontend/apps/dash/dash.entry.d.ts +2 -0
- package/fe/frontend/apps/dash/dash.entry.js +80 -0
- package/fe/frontend/apps/dash/types.d.ts +17 -0
- package/fe/frontend/apps/testPage/index.d.ts +3 -0
- package/fe/frontend/apps/testPage/index.js +6 -0
- package/fe/frontend/apps/testPage/testPage.entry.d.ts +2 -0
- package/fe/frontend/apps/testPage/testPage.entry.js +6 -0
- package/fe/frontend/extended/SchemaForm/data.d.ts +13 -0
- package/fe/frontend/extended/SchemaForm/data.js +8 -0
- package/fe/frontend/src/api/baseInfo.d.ts +31 -0
- package/fe/frontend/src/api/baseInfo.js +15 -0
- package/fe/frontend/src/common/CRUD/CRUD.d.ts +3 -0
- package/fe/frontend/src/common/CRUD/CRUD.js +2 -0
- package/fe/frontend/src/common/CRUD/index.d.ts +2 -0
- package/fe/frontend/src/common/CRUD/index.js +1 -0
- package/fe/frontend/src/common/auth/index.d.ts +7 -0
- package/fe/frontend/src/common/auth/index.js +20 -0
- package/fe/frontend/src/common/fetchErrorShow.d.ts +3 -0
- package/fe/frontend/src/common/fetchErrorShow.js +8 -0
- package/fe/frontend/src/common/generateMenuData.d.ts +4 -0
- package/fe/frontend/src/common/generateMenuData.js +12 -0
- package/fe/frontend/src/common/importComponent.d.ts +5 -0
- package/fe/frontend/src/common/importComponent.js +8 -0
- package/fe/frontend/src/common/language.d.ts +2 -0
- package/fe/frontend/src/common/language.js +9 -0
- package/fe/frontend/src/common/logFn/index.d.ts +5 -0
- package/fe/frontend/src/common/logFn/index.js +9 -0
- package/fe/frontend/src/common/menu.d.ts +34 -0
- package/fe/frontend/src/common/menu.js +101 -0
- package/fe/frontend/src/common/request.d.ts +37 -0
- package/fe/frontend/src/common/request.js +217 -0
- package/fe/frontend/src/components/AsyncSelect/AsyncSelect.d.ts +8 -0
- package/fe/frontend/src/components/AsyncSelect/AsyncSelect.js +32 -0
- package/fe/frontend/src/components/AsyncSelect/index.d.ts +4 -0
- package/fe/frontend/src/components/AsyncSelect/index.js +3 -0
- package/fe/frontend/src/components/BasePage/HeaderView.d.ts +9 -0
- package/fe/frontend/src/components/BasePage/HeaderView.js +14 -0
- package/fe/frontend/src/components/Router/index.d.ts +9 -0
- package/fe/frontend/src/components/Router/index.js +11 -0
- package/fe/frontend/src/components/Router/type.d.ts +2 -0
- package/fe/frontend/src/components/Router/type.js +1 -0
- package/fe/frontend/src/defaultPages/Iframe/index.d.ts +3 -0
- package/fe/frontend/src/defaultPages/Iframe/index.js +14 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/DetailPanel.d.ts +7 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/DetailPanel.js +94 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/PopFrom.d.ts +13 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/PopFrom.js +124 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/builtIn.d.ts +44 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/builtIn.js +7 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/data.d.ts +4 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/data.js +6 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaSearch/index.d.ts +3 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaSearch/index.js +63 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaTable/index.d.ts +11 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaTable/index.js +188 -0
- package/fe/frontend/src/defaultPages/SchemaPage/data/eventInfo.d.ts +8 -0
- package/fe/frontend/src/defaultPages/SchemaPage/data/eventInfo.js +6 -0
- package/fe/frontend/src/defaultPages/SchemaPage/data/index.d.ts +3 -0
- package/fe/frontend/src/defaultPages/SchemaPage/data/index.js +1 -0
- package/fe/frontend/src/defaultPages/SchemaPage/hooks/useComConfig.d.ts +10 -0
- package/fe/frontend/src/defaultPages/SchemaPage/hooks/useComConfig.js +14 -0
- package/fe/frontend/src/defaultPages/SchemaPage/index.css +167 -0
- package/fe/frontend/src/defaultPages/SchemaPage/index.d.ts +4 -0
- package/fe/frontend/src/defaultPages/SchemaPage/index.js +75 -0
- package/fe/frontend/src/defaultPages/SchemaPage/schemaType.d.ts +51 -0
- package/fe/frontend/src/defaultPages/SchemaPage/schemaType.js +4 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/permissions.d.ts +3 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/permissions.js +3 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/schemaConversion.d.ts +3 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/schemaConversion.js +115 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/validator.d.ts +7 -0
- package/fe/frontend/src/defaultPages/SchemaPage/utils/validator.js +36 -0
- package/fe/frontend/src/defaultPages/SidebarSlotPage/SidebarSlotContainer.d.ts +10 -0
- package/fe/frontend/src/defaultPages/SidebarSlotPage/SidebarSlotContainer.js +38 -0
- package/fe/frontend/src/defaultPages/SidebarSlotPage/index.d.ts +3 -0
- package/fe/frontend/src/defaultPages/SidebarSlotPage/index.js +16 -0
- package/fe/frontend/src/defaultPages/SidebarSlotPageTmp.d.ts +3 -0
- package/fe/frontend/src/defaultPages/SidebarSlotPageTmp.js +17 -0
- package/fe/frontend/src/defaultPages/SlotPage/index.d.ts +3 -0
- package/fe/frontend/src/defaultPages/SlotPage/index.js +26 -0
- package/fe/frontend/src/exportStore.d.ts +17 -0
- package/fe/frontend/src/exportStore.js +16 -0
- package/fe/frontend/src/hooks/useCurrentMenuData.d.ts +19 -0
- package/fe/frontend/src/hooks/useCurrentMenuData.js +28 -0
- package/fe/frontend/src/hooks/useRouterParams.d.ts +5 -0
- package/fe/frontend/src/hooks/useRouterParams.js +11 -0
- package/fe/frontend/src/index.d.ts +16 -0
- package/fe/frontend/src/index.js +13 -0
- package/fe/frontend/src/main.css +96 -0
- package/fe/frontend/src/main.d.ts +27 -0
- package/fe/frontend/src/main.js +72 -0
- package/fe/frontend/src/stores/apiFreezer.d.ts +93 -0
- package/fe/frontend/src/stores/apiFreezer.js +49 -0
- package/fe/frontend/src/stores/mode.d.ts +19 -0
- package/fe/frontend/src/stores/mode.js +37 -0
- package/fe/frontend/src/stores/schemaEventBus.d.ts +42 -0
- package/fe/frontend/src/stores/schemaEventBus.js +70 -0
- package/fe/frontend/src/stores/schemaStore.d.ts +47 -0
- package/fe/frontend/src/stores/schemaStore.js +26 -0
- package/fe/frontend/src/typing/scalability.d.ts +47 -0
- package/fe/frontend/src/typing/scalability.js +1 -0
- package/fe/frontend/src/typing/window.d.ts +7 -0
- package/fe/frontend/src/typing/window.js +1 -0
- package/fe/model/types/data/button.d.ts +32 -0
- package/fe/model/types/data/button.js +16 -0
- package/fe/model/types/data/component.d.ts +40 -0
- package/fe/model/types/data/component.js +11 -0
- package/fe/model/types/data/fetchInfo.d.ts +20 -0
- package/fe/model/types/data/fetchInfo.js +1 -0
- package/fe/model/types/data/schema.d.ts +98 -0
- package/fe/model/types/data/schema.js +1 -0
- package/fe/model/types/data/search.d.ts +7 -0
- package/fe/model/types/data/search.js +1 -0
- package/fe/model/types/menuType.d.ts +73 -0
- package/fe/model/types/menuType.js +1 -0
- package/fe/model/types/model.d.ts +33 -0
- package/fe/model/types/model.js +1 -0
- package/fe/packages/common/array/index.d.ts +7 -0
- package/fe/packages/common/array/index.js +40 -0
- package/fe/packages/common/cache/LRUCache.d.ts +13 -0
- package/fe/packages/common/cache/LRUCache.js +47 -0
- package/fe/packages/common/cache/index.d.ts +2 -0
- package/fe/packages/common/cache/index.js +1 -0
- package/fe/packages/common/guards/index.d.ts +9 -0
- package/fe/packages/common/guards/index.js +24 -0
- package/fe/packages/common/http/index.d.ts +90 -0
- package/fe/packages/common/http/index.js +310 -0
- package/fe/packages/common/i18n/default.d.ts +92 -0
- package/fe/packages/common/i18n/default.js +90 -0
- package/fe/packages/common/i18n/en-US.d.ts +92 -0
- package/fe/packages/common/i18n/en-US.js +90 -0
- package/fe/packages/common/i18n/index.d.ts +43 -0
- package/fe/packages/common/i18n/index.js +173 -0
- package/fe/packages/common/i18n/locales.d.ts +8 -0
- package/fe/packages/common/i18n/locales.js +10 -0
- package/fe/packages/common/i18n/types.d.ts +71 -0
- package/fe/packages/common/i18n/types.js +1 -0
- package/fe/packages/common/index.d.ts +11 -0
- package/fe/packages/common/index.js +10 -0
- package/fe/packages/common/log/index.d.ts +33 -0
- package/fe/packages/common/log/index.js +176 -0
- package/fe/packages/common/number/index.d.ts +3 -0
- package/fe/packages/common/number/index.js +10 -0
- package/fe/packages/common/object/filterEmpty.d.ts +3 -0
- package/fe/packages/common/object/filterEmpty.js +33 -0
- package/fe/packages/common/object/index.d.ts +5 -0
- package/fe/packages/common/object/index.js +25 -0
- package/fe/packages/common/string/index.d.ts +4 -0
- package/fe/packages/common/string/index.js +17 -0
- package/fe/packages/common/types/index.d.ts +4 -0
- package/fe/packages/common/types/index.js +1 -0
- package/fe/packages/ui/react/components/Button/Button.d.ts +29 -10
- package/fe/packages/ui/react/components/Button/Button.js +53 -23
- package/fe/packages/ui/react/components/Button/SumbitButton.d.ts +2 -2
- package/fe/packages/ui/react/components/Button/SumbitButton.js +3 -10
- package/fe/packages/ui/react/components/Button/index.d.ts +1 -1
- package/fe/packages/ui/react/components/Checkbox/Checkbox.d.ts +1 -1
- package/fe/packages/ui/react/components/Checkbox/Checkbox.js +5 -3
- package/fe/packages/ui/react/components/ConfirmDialog/ConfirmDialog.js +11 -0
- package/fe/packages/ui/react/components/ConfirmDialog/index.d.ts +2 -0
- package/fe/packages/ui/react/components/ConfirmDialog/index.js +1 -0
- package/fe/packages/ui/react/components/DataTable/ActionBtn.d.ts +3 -1
- package/fe/packages/ui/react/components/DataTable/ActionBtn.js +87 -4
- package/fe/packages/ui/react/components/DataTable/{data-table.d.ts → index.d.ts} +12 -4
- package/fe/packages/ui/react/components/DataTable/index.js +187 -0
- package/fe/packages/ui/react/components/Date/Calendar.js +4 -3
- package/fe/packages/ui/react/components/Date/Date.d.ts +5 -3
- package/fe/packages/ui/react/components/Date/Date.js +71 -48
- package/fe/packages/ui/react/components/Date/TimePicker.js +3 -1
- package/fe/packages/ui/react/components/Date/dropdownPositioning.d.ts +3 -0
- package/fe/packages/ui/react/components/Date/dropdownPositioning.js +12 -0
- package/fe/packages/ui/react/components/Date/locales.d.ts +1 -0
- package/fe/packages/ui/react/components/Date/locales.js +7 -38
- package/fe/packages/ui/react/components/Drawer/Drawer.d.ts +29 -0
- package/fe/packages/ui/react/components/Drawer/Drawer.js +100 -0
- package/fe/packages/ui/react/components/Drawer/index.d.ts +3 -0
- package/fe/packages/ui/react/components/Drawer/index.js +1 -0
- package/fe/packages/ui/react/components/Dropdown/Dropdown.d.ts +26 -0
- package/fe/packages/ui/react/components/Dropdown/Dropdown.js +49 -0
- package/fe/packages/ui/react/components/Dropdown/index.d.ts +2 -0
- package/fe/packages/ui/react/components/Dropdown/index.js +1 -0
- package/fe/packages/ui/react/components/Form/Form.js +1 -1
- package/fe/packages/ui/react/components/Form/FormItem.js +1 -1
- package/fe/packages/ui/react/components/Form/SchemaForm/data.d.ts +40 -0
- package/fe/packages/ui/react/components/Form/SchemaForm/data.js +18 -0
- package/fe/packages/ui/react/components/Form/{SchemeForm → SchemaForm}/index.d.ts +15 -14
- package/fe/packages/ui/react/components/Form/SchemaForm/index.js +79 -0
- package/fe/packages/ui/react/components/Form/index.d.ts +1 -1
- package/fe/packages/ui/react/components/Form/index.js +1 -1
- package/fe/packages/ui/react/components/ImagePreview/ImagePreview.js +15 -12
- package/fe/packages/ui/react/components/ImagePreview/PreviewImage.js +5 -2
- package/fe/packages/ui/react/components/Input/Input.d.ts +5 -1
- package/fe/packages/ui/react/components/Input/Input.js +5 -4
- package/fe/packages/ui/react/components/InputNumber/InputNumber.d.ts +28 -0
- package/fe/packages/ui/react/components/InputNumber/InputNumber.js +144 -0
- package/fe/packages/ui/react/components/InputNumber/index.d.ts +2 -0
- package/fe/packages/ui/react/components/InputNumber/index.js +1 -0
- package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.d.ts +30 -0
- package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.js +63 -0
- package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.test.d.ts +2 -0
- package/fe/packages/ui/react/components/InputNumber/inputNumberUtils.test.js +27 -0
- package/fe/packages/ui/react/components/Label/Label.js +2 -2
- package/fe/packages/ui/react/components/Menu/Menu.d.ts +18 -0
- package/fe/packages/ui/react/components/Menu/Menu.js +102 -0
- package/fe/packages/ui/react/components/Menu/MenuContext.d.ts +39 -0
- package/fe/packages/ui/react/components/Menu/MenuContext.js +97 -0
- package/fe/packages/ui/react/components/Menu/MenuItem.d.ts +3 -0
- package/fe/packages/ui/react/components/Menu/MenuItem.js +33 -0
- package/fe/packages/ui/react/components/Menu/SubMenu.d.ts +10 -0
- package/fe/packages/ui/react/components/Menu/SubMenu.js +169 -0
- package/fe/packages/ui/react/components/Menu/index.d.ts +9 -0
- package/fe/packages/ui/react/components/Menu/index.js +5 -0
- package/fe/packages/ui/react/components/Menu/menuTypes.d.ts +59 -0
- package/fe/packages/ui/react/components/Menu/menuTypes.js +1 -0
- package/fe/packages/ui/react/components/Menu/utils.d.ts +2 -0
- package/fe/packages/ui/react/components/Menu/utils.js +7 -0
- package/fe/packages/ui/react/components/Message/Message.js +4 -1
- package/fe/packages/ui/react/components/Modal/Modal.d.ts +3 -1
- package/fe/packages/ui/react/components/Modal/Modal.js +6 -43
- package/fe/packages/ui/react/components/Modal/ModalManager.js +4 -3
- package/fe/packages/ui/react/components/Overlay/Overlay.d.ts +23 -0
- package/fe/packages/ui/react/components/Overlay/Overlay.js +53 -0
- package/fe/packages/ui/react/components/Overlay/index.d.ts +3 -0
- package/fe/packages/ui/react/components/Overlay/index.js +1 -0
- package/fe/packages/ui/react/components/{Pagination.js → Pagination/Pagination.js} +4 -4
- package/fe/packages/ui/react/components/Pagination/index.d.ts +2 -0
- package/fe/packages/ui/react/components/Pagination/index.js +1 -0
- package/fe/packages/ui/react/components/Popup/Popup.d.ts +26 -0
- package/fe/packages/ui/react/components/Popup/Popup.js +81 -0
- package/fe/packages/ui/react/components/Popup/index.d.ts +2 -0
- package/fe/packages/ui/react/components/Popup/index.js +1 -0
- package/fe/packages/ui/react/components/Search/Search.d.ts +2 -2
- package/fe/packages/ui/react/components/Search/Search.js +3 -3
- package/fe/packages/ui/react/components/Select/Select.d.ts +5 -0
- package/fe/packages/ui/react/components/Select/Select.js +52 -109
- package/fe/packages/ui/react/components/Select/dropdownPositioning.d.ts +3 -0
- package/fe/packages/ui/react/components/Select/dropdownPositioning.js +13 -0
- package/fe/packages/ui/react/components/Skeleton/Skeleton.js +2 -2
- package/fe/packages/ui/react/components/Switch/Switch.js +3 -1
- package/fe/packages/ui/react/components/TableSearch/TableSearch.d.ts +5 -4
- package/fe/packages/ui/react/components/TableSearch/TableSearch.js +23 -21
- package/fe/packages/ui/react/components/TableSearch/lang.js +5 -14
- package/fe/packages/ui/react/components/{Textarea.d.ts → Textarea/Textarea.d.ts} +11 -3
- package/fe/packages/ui/react/components/Textarea/Textarea.js +37 -0
- package/fe/packages/ui/react/components/Textarea/index.d.ts +2 -0
- package/fe/packages/ui/react/components/Textarea/index.js +1 -0
- package/fe/packages/ui/react/components/{Tooltip.d.ts → Tooltip/Tooltip.d.ts} +2 -2
- package/fe/packages/ui/react/components/Tooltip/Tooltip.js +79 -0
- package/fe/packages/ui/react/components/Tooltip/index.d.ts +2 -0
- package/fe/packages/ui/react/components/Tooltip/index.js +1 -0
- package/fe/packages/ui/react/components/{TreeSelect.js → TreeSelect/TreeSelect.js} +9 -11
- package/fe/packages/ui/react/components/TreeSelect/index.d.ts +2 -0
- package/fe/packages/ui/react/components/TreeSelect/index.js +1 -0
- package/fe/packages/ui/react/components/Upload/ImageUpload.js +18 -6
- package/fe/packages/ui/react/components/Upload/Upload.js +2 -1
- package/fe/packages/ui/react/components/{breadcrumb.js → breadcrumb/breadcrumb.js} +15 -12
- package/fe/packages/ui/react/components/breadcrumb/index.d.ts +2 -0
- package/fe/packages/ui/react/components/breadcrumb/index.js +1 -0
- package/fe/packages/ui/react/components/hooks/useDropdownPositioning.d.ts +49 -0
- package/fe/packages/ui/react/components/hooks/useDropdownPositioning.js +137 -0
- package/fe/packages/ui/react/components/index.d.ts +7 -1
- package/fe/packages/ui/react/components/index.js +7 -1
- package/fe/packages/ui/react/components/table/index.d.ts +2 -0
- package/fe/packages/ui/react/components/table/index.js +1 -0
- package/fe/packages/ui/react/components/{table.d.ts → table/table.d.ts} +12 -2
- package/fe/packages/ui/react/components/table/table.js +116 -0
- package/fe/packages/ui/react/components/testPage/MenuTestPage.d.ts +2 -0
- package/fe/packages/ui/react/components/testPage/MenuTestPage.js +104 -0
- package/fe/packages/ui/react/components/testPage/index.js +300 -81
- package/fe/packages/ui/react/hooks/useExecuteOnce.d.ts +30 -0
- package/fe/packages/ui/react/hooks/useExecuteOnce.js +57 -0
- package/fe/packages/ui/react/hooks/useInit.d.ts +1 -1
- package/fe/packages/ui/react/hooks/useInit.js +1 -1
- package/fe/packages/ui/react/hooks/useLanguage.d.ts +1 -6
- package/fe/packages/ui/react/hooks/useRefState.d.ts +30 -0
- package/fe/packages/ui/react/hooks/useRefState.js +29 -0
- package/fe/packages/ui/react/hooks/useWatch.d.ts +23 -0
- package/fe/packages/ui/react/hooks/useWatch.js +87 -0
- package/fe/packages/ui/react/hooks/useWatch.test.d.ts +2 -0
- package/fe/packages/ui/react/hooks/useWatch.test.js +22 -0
- package/fe/packages/ui/react/i18n/I18nProvider.d.ts +31 -0
- package/fe/packages/ui/react/i18n/I18nProvider.js +25 -0
- package/fe/packages/ui/react/i18n/index.d.ts +4 -0
- package/fe/packages/ui/react/i18n/index.js +3 -0
- package/fe/packages/ui/react/i18n/useI18n.d.ts +13 -0
- package/fe/packages/ui/react/i18n/useI18n.js +18 -0
- package/fe/packages/ui/react/index.css +238 -0
- package/fe/packages/ui/react/index.d.ts +2 -0
- package/fe/packages/ui/react/index.js +2 -0
- package/fe/packages/ui/react/lib/createStoreHook.d.ts +9 -0
- package/fe/packages/ui/react/lib/createStoreHook.js +6 -0
- package/fe/packages/ui/react/lib/export.d.ts +2 -2
- package/fe/packages/ui/react/stores/language.d.ts +3 -12
- package/fe/packages/ui/react/stores/language.js +2 -51
- package/fe/typings/type.d.ts +5 -0
- package/fe/typings/type.js +1 -0
- package/model/index.d.ts +2 -0
- package/model/test.d.ts +2 -0
- package/model/types/data/button.d.ts +32 -0
- package/model/types/data/component.d.ts +40 -0
- package/model/types/data/fetchInfo.d.ts +20 -0
- package/model/types/data/schema.d.ts +98 -0
- package/model/types/data/search.d.ts +7 -0
- package/model/types/index.d.ts +3 -0
- package/model/types/menuType.d.ts +73 -0
- package/model/types/model.d.ts +33 -0
- package/package.json +36 -17
- package/{cjs → types}/app/controller/base.d.ts +4 -5
- package/types/app/controller/project.d.ts +22 -0
- package/{cjs → types}/app/controller/view.d.ts +1 -2
- package/types/app/extend/$fetch.d.ts +8 -0
- package/{cjs → types}/app/extend/db.d.ts +1 -1
- package/{cjs → types}/app/extend/logger.d.ts +1 -1
- package/{cjs → types}/app/extend/render-view.d.ts +1 -2
- package/{cjs → types}/app/middleware/api-params-verify.d.ts +1 -2
- package/{cjs → types}/app/middleware/api-sign-verify.d.ts +1 -2
- package/{esm/app/middleware/api-sign-verify.d.ts → types/app/middleware/error-handle.d.ts} +1 -3
- package/{cjs → types}/app/middleware/project-handler.d.ts +2 -2
- package/{cjs → types}/app/middleware.d.ts +0 -2
- package/{cjs/app/router/view.d.ts → types/app/router/project.d.ts} +1 -1
- package/types/app/router/view.d.ts +3 -0
- package/{cjs → types}/app/router-schema/project.d.ts +1 -1
- package/types/app/service/base.d.ts +9 -0
- package/types/app/service/project.d.ts +57 -0
- package/types/app/type.d.ts +5 -0
- package/{cjs → types}/app/typings.d.ts +17 -23
- package/types/bundler/defaultAlias.d.ts +3 -0
- package/types/bundler/index.d.ts +2 -0
- package/types/bundler/state.d.ts +18 -0
- package/types/bundler/utils.d.ts +9 -0
- package/types/config/config.default.d.ts +14 -0
- package/types/index.d.ts +28 -0
- package/types/packages/common/LRUCache.d.ts +1 -0
- package/types/packages/common/array/index.d.ts +6 -0
- package/types/packages/common/cache/LRUCache.d.ts +12 -0
- package/types/packages/common/cache/index.d.ts +1 -0
- package/types/packages/common/guards/index.d.ts +8 -0
- package/types/packages/common/http/index.d.ts +89 -0
- package/types/packages/common/i18n/default.d.ts +91 -0
- package/types/packages/common/i18n/en-US.d.ts +91 -0
- package/types/packages/common/i18n/index.d.ts +42 -0
- package/types/packages/common/i18n/locales.d.ts +7 -0
- package/types/packages/common/i18n/types.d.ts +70 -0
- package/types/packages/common/index.d.ts +10 -0
- package/types/packages/common/log/index.d.ts +32 -0
- package/types/packages/common/number/index.d.ts +2 -0
- package/types/packages/common/object/filterEmpty.d.ts +2 -0
- package/types/packages/common/object/filtereEmpty.d.ts +1 -0
- package/types/packages/common/object/index.d.ts +4 -0
- package/types/packages/common/string/index.d.ts +3 -0
- package/types/packages/common/types/index.d.ts +3 -0
- package/{cjs → types}/packages/core/index.d.ts +1 -1
- package/{cjs → types}/packages/core/loader/config.d.ts +1 -1
- package/{cjs → types}/packages/core/loader/controller.d.ts +2 -2
- package/{cjs → types}/packages/core/loader/middleware.d.ts +1 -1
- package/{esm → types}/packages/core/loader/model.d.ts +2 -3
- package/{cjs → types}/packages/core/loader/router-schema.d.ts +2 -2
- package/{cjs → types}/packages/core/loader/router.d.ts +1 -1
- package/{cjs → types}/packages/core/loader/service.d.ts +2 -2
- package/{cjs → types}/packages/core/types.d.ts +42 -3
- package/types/packages/utils/getAllFnReturnValue.d.ts +0 -0
- package/types/packages/utils/runFileFn.d.ts +7 -0
- package/types/typings/type.d.ts +4 -0
- package/cjs/app/controller/project.d.ts +0 -11
- package/cjs/app/middleware/error-handle.d.ts +0 -5
- package/cjs/app/router/project.d.ts +0 -4
- package/cjs/app/service/bese.d.ts +0 -10
- package/cjs/app/service/bese.js +0 -17
- package/cjs/app/service/project.d.ts +0 -27
- package/cjs/app/type.d.ts +0 -2
- package/cjs/bundler/index.d.ts +0 -1
- package/cjs/bundler/utils.d.ts +0 -7
- package/cjs/index.d.ts +0 -28
- package/cjs/packages/core/loader/model.d.ts +0 -36
- package/cjs/packages/utils/runFileFn.d.ts +0 -5
- package/cjs/typings/type.d.ts +0 -4
- package/cjs/typings/type.js +0 -2
- package/esm/app/controller/base.d.ts +0 -14
- package/esm/app/controller/project.d.ts +0 -12
- package/esm/app/controller/view.d.ts +0 -9
- package/esm/app/data/signKey.d.ts +0 -2
- package/esm/app/extend/db.d.ts +0 -3
- package/esm/app/extend/generateErrorMessage.d.ts +0 -8
- package/esm/app/extend/logger.d.ts +0 -12
- package/esm/app/extend/parsingParamsOnUrl.d.ts +0 -3
- package/esm/app/extend/render-view.d.ts +0 -5
- package/esm/app/middleware/api-params-verify.d.ts +0 -6
- package/esm/app/middleware/error-handle.d.ts +0 -6
- package/esm/app/middleware/project-handler.d.ts +0 -5
- package/esm/app/middleware.d.ts +0 -6
- package/esm/app/router/project.d.ts +0 -5
- package/esm/app/router/view.d.ts +0 -5
- package/esm/app/router-schema/project.d.ts +0 -4
- package/esm/app/service/bese.d.ts +0 -11
- package/esm/app/service/bese.js +0 -12
- package/esm/app/service/project.d.ts +0 -28
- package/esm/app/type.d.ts +0 -3
- package/esm/app/typings.d.ts +0 -50
- package/esm/bundler/dev.d.ts +0 -2
- package/esm/bundler/index.d.ts +0 -2
- package/esm/bundler/prod.d.ts +0 -2
- package/esm/bundler/utils.d.ts +0 -8
- package/esm/index.d.ts +0 -29
- package/esm/packages/core/env.d.ts +0 -16
- package/esm/packages/core/index.d.ts +0 -7
- package/esm/packages/core/loader/config.d.ts +0 -10
- package/esm/packages/core/loader/controller.d.ts +0 -18
- package/esm/packages/core/loader/extend.d.ts +0 -9
- package/esm/packages/core/loader/middleware.d.ts +0 -12
- package/esm/packages/core/loader/router-schema.d.ts +0 -19
- package/esm/packages/core/loader/router.d.ts +0 -9
- package/esm/packages/core/loader/service.d.ts +0 -18
- package/esm/packages/core/paths.d.ts +0 -12
- package/esm/packages/core/types.d.ts +0 -75
- package/esm/packages/utils/getAllFilesInFolder.d.ts +0 -10
- package/esm/packages/utils/getAllFnReturnValue.d.ts +0 -1
- package/esm/packages/utils/index.d.ts +0 -5
- package/esm/packages/utils/loadFile.d.ts +0 -21
- package/esm/packages/utils/path.d.ts +0 -25
- package/esm/packages/utils/runFileFn.d.ts +0 -6
- package/esm/typings/type.d.ts +0 -5
- package/fe/frontend/main.d.ts +0 -3
- package/fe/frontend/main.js +0 -6
- package/fe/packages/ui/react/components/ConfirmDialog.js +0 -9
- package/fe/packages/ui/react/components/DataTable/data-table.js +0 -141
- package/fe/packages/ui/react/components/Dropdown.d.ts +0 -16
- package/fe/packages/ui/react/components/Dropdown.js +0 -54
- package/fe/packages/ui/react/components/Form/SchemeForm/data.d.ts +0 -51
- package/fe/packages/ui/react/components/Form/SchemeForm/data.js +0 -8
- package/fe/packages/ui/react/components/Form/SchemeForm/index.js +0 -69
- package/fe/packages/ui/react/components/Textarea.js +0 -35
- package/fe/packages/ui/react/components/Tooltip.js +0 -118
- package/fe/packages/ui/react/components/table.js +0 -20
- package/fe/packages/ui/react/locales/index.d.ts +0 -8
- package/fe/packages/ui/react/locales/index.js +0 -6
- /package/{cjs/packages/utils/getAllFnReturnValue.d.ts → esm/packages/common/i18n/types.js} +0 -0
- /package/{esm/typings/type.js → fe/frontend/apps/dash/types.js} +0 -0
- /package/fe/packages/ui/react/components/{ConfirmDialog.d.ts → ConfirmDialog/ConfirmDialog.d.ts} +0 -0
- /package/fe/packages/ui/react/components/{Pagination.d.ts → Pagination/Pagination.d.ts} +0 -0
- /package/fe/packages/ui/react/components/{TreeSelect.d.ts → TreeSelect/TreeSelect.d.ts} +0 -0
- /package/fe/packages/ui/react/components/{breadcrumb.d.ts → breadcrumb/breadcrumb.d.ts} +0 -0
- /package/{cjs → types}/app/data/signKey.d.ts +0 -0
- /package/{cjs → types}/app/extend/generateErrorMessage.d.ts +0 -0
- /package/{cjs → types}/app/extend/parsingParamsOnUrl.d.ts +0 -0
- /package/{cjs → types}/bundler/dev.d.ts +0 -0
- /package/{cjs → types}/bundler/prod.d.ts +0 -0
- /package/{cjs → types}/packages/core/env.d.ts +0 -0
- /package/{cjs → types}/packages/core/loader/extend.d.ts +0 -0
- /package/{cjs → types}/packages/core/paths.d.ts +0 -0
- /package/{cjs → types}/packages/utils/getAllFilesInFolder.d.ts +0 -0
- /package/{cjs → types}/packages/utils/index.d.ts +0 -0
- /package/{cjs → types}/packages/utils/loadFile.d.ts +0 -0
- /package/{cjs → types}/packages/utils/path.d.ts +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SchemaFormAllPropsMap, FormFieldType } from '../../../packages/ui/react';
|
|
2
|
+
export type SearchOption = {
|
|
3
|
+
[K in FormFieldType]: {
|
|
4
|
+
comType: K;
|
|
5
|
+
} & (K extends keyof SchemaFormAllPropsMap ? SchemaFormAllPropsMap[K] : unknown);
|
|
6
|
+
}[FormFieldType];
|
|
7
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { SchemaDataType } from "./data/schema";
|
|
2
|
+
/**
|
|
3
|
+
* - parent menuLaout === 'top'
|
|
4
|
+
* - child menuLayout === 'top' | 'left'
|
|
5
|
+
* - parent menuLayout === 'left'
|
|
6
|
+
* - child menuLayout === 'left'
|
|
7
|
+
*/
|
|
8
|
+
export type MenuLayout = "left" | "top";
|
|
9
|
+
interface BaseMenu {
|
|
10
|
+
key: string;
|
|
11
|
+
icon?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 菜单名称
|
|
14
|
+
*/
|
|
15
|
+
name: string;
|
|
16
|
+
}
|
|
17
|
+
interface GroupMenuType<T extends MenuLayout> extends BaseMenu {
|
|
18
|
+
menuType: "group";
|
|
19
|
+
subMenu: T extends "top" ? TopMenuType[] : LeftMenuType[];
|
|
20
|
+
}
|
|
21
|
+
interface ModuleMenuType extends BaseMenu {
|
|
22
|
+
menuType: "module";
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* ----------------------------- moduletype -----------------------------
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
interface IframeModuleType {
|
|
30
|
+
moduleType: "iframe";
|
|
31
|
+
iframeConfig: {
|
|
32
|
+
/**
|
|
33
|
+
* iframe 路径
|
|
34
|
+
*/
|
|
35
|
+
path: string;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
interface CustomModuleType {
|
|
39
|
+
moduleType: "custom";
|
|
40
|
+
customConfig: {
|
|
41
|
+
/**
|
|
42
|
+
* 自定义路由路径
|
|
43
|
+
*/
|
|
44
|
+
path: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
interface SchemaModuleType {
|
|
48
|
+
moduleType: "schema";
|
|
49
|
+
schemaConfig: SchemaDataType;
|
|
50
|
+
}
|
|
51
|
+
export interface SidebarModuleType {
|
|
52
|
+
moduleType: "sidebar";
|
|
53
|
+
sidebarConfig: {
|
|
54
|
+
menu: BaseMenuType[];
|
|
55
|
+
/**
|
|
56
|
+
* 只能为left
|
|
57
|
+
*/
|
|
58
|
+
menuLayout?: "left";
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export type BasicModuleType = SchemaModuleType | CustomModuleType | IframeModuleType;
|
|
62
|
+
export type BaseMenuType = GroupMenuType<"left"> | (ModuleMenuType & BasicModuleType);
|
|
63
|
+
type ModuleType = BasicModuleType | SidebarModuleType;
|
|
64
|
+
/**
|
|
65
|
+
* top 包含所有
|
|
66
|
+
*/
|
|
67
|
+
export type TopMenuType = GroupMenuType<"top"> | (ModuleMenuType & ModuleType);
|
|
68
|
+
/**
|
|
69
|
+
* left 不包含 sidebar
|
|
70
|
+
*/
|
|
71
|
+
export type LeftMenuType = GroupMenuType<"left"> | BaseMenuType;
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=menuType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TopMenuType, LeftMenuType } from "./menuType";
|
|
2
|
+
type MTopMenuType = {
|
|
3
|
+
/**
|
|
4
|
+
* 默认为 left
|
|
5
|
+
*/
|
|
6
|
+
menuLayout: "top";
|
|
7
|
+
menu: TopMenuType[];
|
|
8
|
+
};
|
|
9
|
+
type MLeftMenuType = {
|
|
10
|
+
/**
|
|
11
|
+
* 默认为 left
|
|
12
|
+
*/
|
|
13
|
+
menuLayout?: "left";
|
|
14
|
+
menu: LeftMenuType[];
|
|
15
|
+
};
|
|
16
|
+
export type ModeMenuType = MTopMenuType | MLeftMenuType;
|
|
17
|
+
export type ModelDataType = {
|
|
18
|
+
/**
|
|
19
|
+
* - 使用哪一块的模型数据 内置 MB
|
|
20
|
+
* - MB = 管理后台
|
|
21
|
+
*/
|
|
22
|
+
mode: "MB";
|
|
23
|
+
key?: string;
|
|
24
|
+
name: string;
|
|
25
|
+
desc: string;
|
|
26
|
+
icon: string;
|
|
27
|
+
/**
|
|
28
|
+
* 首页(项目配置)
|
|
29
|
+
*/
|
|
30
|
+
homePage: string;
|
|
31
|
+
} & ModeMenuType;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function toArray<T>(value: readonly T[]): T[];
|
|
2
|
+
export declare function toArray<T>(value: T | null | undefined): T[];
|
|
3
|
+
export declare const compact: <T>(items: readonly (T | null | undefined)[]) => T[];
|
|
4
|
+
export declare const uniqueBy: <T, K extends PropertyKey>(items: readonly T[], getKey: (item: T) => K) => T[];
|
|
5
|
+
export declare const groupBy: <T, K extends PropertyKey>(items: readonly T[], getKey: (item: T) => K) => Record<K, T[]>;
|
|
6
|
+
export declare const chunk: <T>(items: readonly T[], size: number) => T[][];
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isNonNullable } from "../guards";
|
|
2
|
+
export function toArray(value) {
|
|
3
|
+
if (value === null || value === undefined)
|
|
4
|
+
return [];
|
|
5
|
+
return Array.isArray(value) ? [...value] : [value];
|
|
6
|
+
}
|
|
7
|
+
export const compact = (items) => {
|
|
8
|
+
return items.filter(isNonNullable);
|
|
9
|
+
};
|
|
10
|
+
export const uniqueBy = (items, getKey) => {
|
|
11
|
+
const keys = new Set();
|
|
12
|
+
const result = [];
|
|
13
|
+
for (const item of items) {
|
|
14
|
+
const key = getKey(item);
|
|
15
|
+
if (keys.has(key))
|
|
16
|
+
continue;
|
|
17
|
+
keys.add(key);
|
|
18
|
+
result.push(item);
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
export const groupBy = (items, getKey) => {
|
|
23
|
+
const result = {};
|
|
24
|
+
for (const item of items) {
|
|
25
|
+
const key = getKey(item);
|
|
26
|
+
result[key] = result[key] ?? [];
|
|
27
|
+
result[key].push(item);
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
export const chunk = (items, size) => {
|
|
32
|
+
if (!Number.isInteger(size) || size <= 0) {
|
|
33
|
+
throw new RangeError("chunk size must be a positive integer");
|
|
34
|
+
}
|
|
35
|
+
const result = [];
|
|
36
|
+
for (let index = 0; index < items.length; index += size) {
|
|
37
|
+
result.push(items.slice(index, index + size));
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class LRUCache<T> {
|
|
2
|
+
private readonly limit;
|
|
3
|
+
private readonly data;
|
|
4
|
+
constructor(limit: number);
|
|
5
|
+
get size(): number;
|
|
6
|
+
has(k: string): boolean;
|
|
7
|
+
get(k: string): NonNullable<T> | undefined;
|
|
8
|
+
set(k: string, v: T): void;
|
|
9
|
+
push(k: string, v: T): void;
|
|
10
|
+
private deleteFirstKey;
|
|
11
|
+
private updateSorting;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=LRUCache.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export class LRUCache {
|
|
2
|
+
limit;
|
|
3
|
+
data;
|
|
4
|
+
constructor(limit) {
|
|
5
|
+
if (!Number.isInteger(limit) || limit <= 0) {
|
|
6
|
+
throw new Error("LRUCache limit must be a positive integer");
|
|
7
|
+
}
|
|
8
|
+
this.limit = limit;
|
|
9
|
+
this.data = new Map();
|
|
10
|
+
}
|
|
11
|
+
get size() {
|
|
12
|
+
return this.data.size;
|
|
13
|
+
}
|
|
14
|
+
has(k) {
|
|
15
|
+
return this.data.has(k);
|
|
16
|
+
}
|
|
17
|
+
get(k) {
|
|
18
|
+
if (!this.data.has(k))
|
|
19
|
+
return undefined;
|
|
20
|
+
const value = this.data.get(k);
|
|
21
|
+
this.updateSorting(k, value);
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
set(k, v) {
|
|
25
|
+
if (this.data.has(k)) {
|
|
26
|
+
this.updateSorting(k, v);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (this.data.size >= this.limit) {
|
|
30
|
+
this.deleteFirstKey();
|
|
31
|
+
}
|
|
32
|
+
this.data.set(k, v);
|
|
33
|
+
}
|
|
34
|
+
push(k, v) {
|
|
35
|
+
this.set(k, v);
|
|
36
|
+
}
|
|
37
|
+
deleteFirstKey() {
|
|
38
|
+
const firstKey = this.data.keys().next().value;
|
|
39
|
+
if (firstKey !== undefined) {
|
|
40
|
+
this.data.delete(firstKey);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
updateSorting(k, v) {
|
|
44
|
+
this.data.delete(k);
|
|
45
|
+
this.data.set(k, v);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./LRUCache";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Dictionary, Maybe } from "../types";
|
|
2
|
+
export declare const isNil: <T>(value: Maybe<T>) => value is null | undefined;
|
|
3
|
+
export declare const isNonNullable: <T>(value: T) => value is NonNullable<T>;
|
|
4
|
+
export declare const isString: (value: unknown) => value is string;
|
|
5
|
+
export declare const isNumber: (value: unknown) => value is number;
|
|
6
|
+
export declare const isBoolean: (value: unknown) => value is boolean;
|
|
7
|
+
export declare const isFunction: <TArgs extends unknown[], TResult>(value: unknown) => value is (...args: TArgs) => TResult;
|
|
8
|
+
export declare const isPlainObject: (value: unknown) => value is Dictionary;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const isNil = (value) => {
|
|
2
|
+
return value === null || value === undefined;
|
|
3
|
+
};
|
|
4
|
+
export const isNonNullable = (value) => {
|
|
5
|
+
return value !== null && value !== undefined;
|
|
6
|
+
};
|
|
7
|
+
export const isString = (value) => {
|
|
8
|
+
return typeof value === "string";
|
|
9
|
+
};
|
|
10
|
+
export const isNumber = (value) => {
|
|
11
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
12
|
+
};
|
|
13
|
+
export const isBoolean = (value) => {
|
|
14
|
+
return typeof value === "boolean";
|
|
15
|
+
};
|
|
16
|
+
export const isFunction = (value) => {
|
|
17
|
+
return typeof value === "function";
|
|
18
|
+
};
|
|
19
|
+
export const isPlainObject = (value) => {
|
|
20
|
+
if (value === null || typeof value !== "object")
|
|
21
|
+
return false;
|
|
22
|
+
const prototype = Object.getPrototypeOf(value);
|
|
23
|
+
return prototype === Object.prototype || prototype === null;
|
|
24
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
2
|
+
export type HttpHeaders = Record<string, string>;
|
|
3
|
+
export type RequestCredentials = 'omit' | 'same-origin' | 'include';
|
|
4
|
+
export type RequestCache = 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload';
|
|
5
|
+
export type RequestRedirect = 'error' | 'follow' | 'manual';
|
|
6
|
+
export type ReferrerPolicy = '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
|
7
|
+
export interface HeadersLike {
|
|
8
|
+
forEach(callback: (value: string, key: string) => void): void;
|
|
9
|
+
has(name: string): boolean;
|
|
10
|
+
set(name: string, value: string): void;
|
|
11
|
+
}
|
|
12
|
+
export interface ProgressEventLike {
|
|
13
|
+
loaded?: number;
|
|
14
|
+
total?: number;
|
|
15
|
+
lengthComputable?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export type RequestBodyLike = string | ArrayBuffer | ArrayBufferView | object;
|
|
18
|
+
export interface RequestConfig<D = unknown> {
|
|
19
|
+
url?: string;
|
|
20
|
+
method?: HttpMethod;
|
|
21
|
+
baseURL?: string;
|
|
22
|
+
headers?: HttpHeaders;
|
|
23
|
+
params?: Record<string, string | number | boolean | undefined | null>;
|
|
24
|
+
data?: D;
|
|
25
|
+
timeout?: number;
|
|
26
|
+
signal?: unknown;
|
|
27
|
+
credentials?: RequestCredentials;
|
|
28
|
+
cache?: RequestCache;
|
|
29
|
+
redirect?: RequestRedirect;
|
|
30
|
+
referrer?: string;
|
|
31
|
+
referrerPolicy?: ReferrerPolicy;
|
|
32
|
+
transformRequest?: ((data: D, headers: HeadersLike) => D | RequestBodyLike) | ((data: D, headers: HeadersLike) => D | RequestBodyLike)[];
|
|
33
|
+
transformResponse?: ((data: unknown) => unknown) | ((data: unknown) => unknown)[];
|
|
34
|
+
validateStatus?: (status: number) => boolean;
|
|
35
|
+
onUploadProgress?: (progress: ProgressEventLike) => void;
|
|
36
|
+
onDownloadProgress?: (progress: ProgressEventLike) => void;
|
|
37
|
+
}
|
|
38
|
+
export interface ResponseConfig<T = unknown, D = unknown> {
|
|
39
|
+
data: T;
|
|
40
|
+
status: number;
|
|
41
|
+
statusText: string;
|
|
42
|
+
headers: HttpHeaders;
|
|
43
|
+
config: RequestConfig<D>;
|
|
44
|
+
request?: unknown;
|
|
45
|
+
}
|
|
46
|
+
export interface AxiosError<T = unknown, D = unknown> extends Error {
|
|
47
|
+
config: RequestConfig<D>;
|
|
48
|
+
code?: string;
|
|
49
|
+
request?: unknown;
|
|
50
|
+
response?: ResponseConfig<T, D>;
|
|
51
|
+
isAxiosError: boolean;
|
|
52
|
+
}
|
|
53
|
+
interface InterceptorHandler<V> {
|
|
54
|
+
fulfilled?: (value: V) => V | Promise<V>;
|
|
55
|
+
rejected?: (error: unknown) => unknown;
|
|
56
|
+
id: number;
|
|
57
|
+
}
|
|
58
|
+
declare class InterceptorManager<V> {
|
|
59
|
+
private handlers;
|
|
60
|
+
private nextId;
|
|
61
|
+
use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: unknown) => unknown): number;
|
|
62
|
+
eject(id: number): void;
|
|
63
|
+
clear(): void;
|
|
64
|
+
getHandlers(): InterceptorHandler<V>[];
|
|
65
|
+
}
|
|
66
|
+
export declare class FetchAxios {
|
|
67
|
+
defaults: RequestConfig;
|
|
68
|
+
interceptors: {
|
|
69
|
+
request: InterceptorManager<RequestConfig<unknown>>;
|
|
70
|
+
response: InterceptorManager<ResponseConfig<unknown, unknown>>;
|
|
71
|
+
};
|
|
72
|
+
constructor(config?: RequestConfig);
|
|
73
|
+
private request;
|
|
74
|
+
private applyRequestInterceptors;
|
|
75
|
+
private applyResponseInterceptors;
|
|
76
|
+
private applyResponseErrorInterceptors;
|
|
77
|
+
private _doRequest;
|
|
78
|
+
private createError;
|
|
79
|
+
get<T = unknown, D = unknown>(url: string, config?: RequestConfig<D>): Promise<ResponseConfig<T, D>>;
|
|
80
|
+
post<T = unknown, D = unknown>(url: string, data?: D, config?: RequestConfig<D>): Promise<ResponseConfig<T, D>>;
|
|
81
|
+
put<T = unknown, D = unknown>(url: string, data?: D, config?: RequestConfig<D>): Promise<ResponseConfig<T, D>>;
|
|
82
|
+
patch<T = unknown, D = unknown>(url: string, data?: D, config?: RequestConfig<D>): Promise<ResponseConfig<T, D>>;
|
|
83
|
+
delete<T = unknown, D = unknown>(url: string, config?: RequestConfig<D>): Promise<ResponseConfig<T, D>>;
|
|
84
|
+
head<T = unknown, D = unknown>(url: string, config?: RequestConfig<D>): Promise<ResponseConfig<T, D>>;
|
|
85
|
+
options<T = unknown, D = unknown>(url: string, config?: RequestConfig<D>): Promise<ResponseConfig<T, D>>;
|
|
86
|
+
}
|
|
87
|
+
export declare const axios: FetchAxios;
|
|
88
|
+
export declare const createInstance: (defaultConfig: RequestConfig) => FetchAxios;
|
|
89
|
+
export default FetchAxios;
|
|
90
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
const getGlobalValue = (key) => {
|
|
2
|
+
return globalThis[key];
|
|
3
|
+
};
|
|
4
|
+
const getTimerGlobal = () => {
|
|
5
|
+
return globalThis;
|
|
6
|
+
};
|
|
7
|
+
class FallbackHeaders {
|
|
8
|
+
headers = new Map();
|
|
9
|
+
constructor(init = {}) {
|
|
10
|
+
Object.entries(init).forEach(([key, value]) => {
|
|
11
|
+
this.set(key, value);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
forEach(callback) {
|
|
15
|
+
this.headers.forEach((value, key) => {
|
|
16
|
+
callback(value, key);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
has(name) {
|
|
20
|
+
return this.headers.has(this.normalizeName(name));
|
|
21
|
+
}
|
|
22
|
+
set(name, value) {
|
|
23
|
+
this.headers.set(this.normalizeName(name), value);
|
|
24
|
+
}
|
|
25
|
+
toRecord() {
|
|
26
|
+
return Object.fromEntries(this.headers);
|
|
27
|
+
}
|
|
28
|
+
normalizeName(name) {
|
|
29
|
+
return name.toLowerCase();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
class InterceptorManager {
|
|
33
|
+
handlers = [];
|
|
34
|
+
nextId = 0;
|
|
35
|
+
use(onFulfilled, onRejected) {
|
|
36
|
+
const id = this.nextId++;
|
|
37
|
+
this.handlers.push({ id, fulfilled: onFulfilled, rejected: onRejected });
|
|
38
|
+
return id;
|
|
39
|
+
}
|
|
40
|
+
eject(id) {
|
|
41
|
+
const idx = this.handlers.findIndex((handler) => handler.id === id);
|
|
42
|
+
if (idx !== -1)
|
|
43
|
+
this.handlers.splice(idx, 1);
|
|
44
|
+
}
|
|
45
|
+
clear() {
|
|
46
|
+
this.handlers = [];
|
|
47
|
+
}
|
|
48
|
+
getHandlers() {
|
|
49
|
+
return [...this.handlers];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function createHeaders(headers) {
|
|
53
|
+
const HeadersRef = getGlobalValue('Headers');
|
|
54
|
+
if (HeadersRef)
|
|
55
|
+
return new HeadersRef(headers);
|
|
56
|
+
return new FallbackHeaders(headers);
|
|
57
|
+
}
|
|
58
|
+
function toFetchHeaders(headers) {
|
|
59
|
+
return headers instanceof FallbackHeaders ? headers.toRecord() : headers;
|
|
60
|
+
}
|
|
61
|
+
function serializeParams(params) {
|
|
62
|
+
const URLSearchParamsRef = getGlobalValue('URLSearchParams');
|
|
63
|
+
if (URLSearchParamsRef) {
|
|
64
|
+
const searchParams = new URLSearchParamsRef();
|
|
65
|
+
for (const [key, value] of Object.entries(params)) {
|
|
66
|
+
if (value !== undefined && value !== null) {
|
|
67
|
+
searchParams.append(key, String(value));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return searchParams.toString();
|
|
71
|
+
}
|
|
72
|
+
return Object.entries(params)
|
|
73
|
+
.filter((entry) => entry[1] !== undefined && entry[1] !== null)
|
|
74
|
+
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`)
|
|
75
|
+
.join('&');
|
|
76
|
+
}
|
|
77
|
+
function buildURL(url, baseURL, params) {
|
|
78
|
+
let fullUrl = baseURL ? `${baseURL.replace(/\/+$/, '')}/${url.replace(/^\/+/, '')}` : url;
|
|
79
|
+
if (params) {
|
|
80
|
+
const query = serializeParams(params);
|
|
81
|
+
if (query) {
|
|
82
|
+
fullUrl += (fullUrl.includes('?') ? '&' : '?') + query;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return fullUrl;
|
|
86
|
+
}
|
|
87
|
+
function parseHeaders(rawHeaders) {
|
|
88
|
+
const headers = {};
|
|
89
|
+
rawHeaders.forEach((value, key) => {
|
|
90
|
+
headers[key] = value;
|
|
91
|
+
});
|
|
92
|
+
return headers;
|
|
93
|
+
}
|
|
94
|
+
function mergeConfig(primary, secondary) {
|
|
95
|
+
return {
|
|
96
|
+
...secondary,
|
|
97
|
+
...primary,
|
|
98
|
+
headers: {
|
|
99
|
+
...secondary?.headers,
|
|
100
|
+
...primary.headers,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function isObject(value) {
|
|
105
|
+
return Object.prototype.toString.call(value) === '[object Object]';
|
|
106
|
+
}
|
|
107
|
+
function isRuntimeInstance(value, ctorName) {
|
|
108
|
+
const RuntimeCtor = getGlobalValue(ctorName);
|
|
109
|
+
return typeof RuntimeCtor === 'function' && value instanceof RuntimeCtor;
|
|
110
|
+
}
|
|
111
|
+
function isBodyLike(value) {
|
|
112
|
+
if (typeof value === 'string')
|
|
113
|
+
return true;
|
|
114
|
+
if (value instanceof ArrayBuffer)
|
|
115
|
+
return true;
|
|
116
|
+
if (ArrayBuffer.isView(value))
|
|
117
|
+
return true;
|
|
118
|
+
return (isRuntimeInstance(value, 'Blob') ||
|
|
119
|
+
isRuntimeInstance(value, 'FormData') ||
|
|
120
|
+
isRuntimeInstance(value, 'URLSearchParams') ||
|
|
121
|
+
isRuntimeInstance(value, 'ReadableStream'));
|
|
122
|
+
}
|
|
123
|
+
function applyTransformers(value, transformers) {
|
|
124
|
+
if (!transformers?.length)
|
|
125
|
+
return value;
|
|
126
|
+
return transformers.reduce((acc, fn) => fn(acc), value);
|
|
127
|
+
}
|
|
128
|
+
function applyRequestTransformers(value, headers, transformers) {
|
|
129
|
+
if (!transformers)
|
|
130
|
+
return value;
|
|
131
|
+
const fns = Array.isArray(transformers) ? transformers : [transformers];
|
|
132
|
+
return fns.reduce((acc, fn) => fn(acc, headers), value);
|
|
133
|
+
}
|
|
134
|
+
function getFetch() {
|
|
135
|
+
const fetchRef = getGlobalValue('fetch');
|
|
136
|
+
if (!fetchRef) {
|
|
137
|
+
throw new Error('FetchAxios requires globalThis.fetch. Use Node.js 18+ or provide a fetch polyfill.');
|
|
138
|
+
}
|
|
139
|
+
return fetchRef;
|
|
140
|
+
}
|
|
141
|
+
function createAbortController() {
|
|
142
|
+
const AbortControllerRef = getGlobalValue('AbortController');
|
|
143
|
+
if (!AbortControllerRef)
|
|
144
|
+
return undefined;
|
|
145
|
+
return new AbortControllerRef();
|
|
146
|
+
}
|
|
147
|
+
export class FetchAxios {
|
|
148
|
+
defaults;
|
|
149
|
+
interceptors = {
|
|
150
|
+
request: new InterceptorManager(),
|
|
151
|
+
response: new InterceptorManager(),
|
|
152
|
+
};
|
|
153
|
+
constructor(config = {}) {
|
|
154
|
+
this.defaults = config;
|
|
155
|
+
}
|
|
156
|
+
async request(config) {
|
|
157
|
+
const merged = mergeConfig(this.defaults, config);
|
|
158
|
+
try {
|
|
159
|
+
const currentConfig = await this.applyRequestInterceptors(merged);
|
|
160
|
+
const response = await this._doRequest(currentConfig);
|
|
161
|
+
return this.applyResponseInterceptors(response);
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
return this.applyResponseErrorInterceptors(err);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
async applyRequestInterceptors(config) {
|
|
168
|
+
let currentConfig = config;
|
|
169
|
+
const handlers = this.interceptors.request.getHandlers().reverse();
|
|
170
|
+
for (const handler of handlers) {
|
|
171
|
+
if (!handler.fulfilled)
|
|
172
|
+
continue;
|
|
173
|
+
try {
|
|
174
|
+
currentConfig = (await handler.fulfilled(currentConfig));
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
if (!handler.rejected)
|
|
178
|
+
throw err;
|
|
179
|
+
currentConfig = (await handler.rejected(err));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return currentConfig;
|
|
183
|
+
}
|
|
184
|
+
async applyResponseInterceptors(response) {
|
|
185
|
+
let currentResponse = response;
|
|
186
|
+
for (const handler of this.interceptors.response.getHandlers()) {
|
|
187
|
+
if (!handler.fulfilled)
|
|
188
|
+
continue;
|
|
189
|
+
currentResponse = (await handler.fulfilled(currentResponse));
|
|
190
|
+
}
|
|
191
|
+
return currentResponse;
|
|
192
|
+
}
|
|
193
|
+
async applyResponseErrorInterceptors(error) {
|
|
194
|
+
let currentError = error;
|
|
195
|
+
for (const handler of this.interceptors.response.getHandlers()) {
|
|
196
|
+
if (!handler.rejected)
|
|
197
|
+
continue;
|
|
198
|
+
try {
|
|
199
|
+
return (await handler.rejected(currentError));
|
|
200
|
+
}
|
|
201
|
+
catch (err) {
|
|
202
|
+
currentError = err;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
throw currentError;
|
|
206
|
+
}
|
|
207
|
+
async _doRequest(config) {
|
|
208
|
+
const { method = 'GET', baseURL, headers: rawHeaders = {}, params, data, timeout, credentials, cache, redirect, referrer, referrerPolicy, transformRequest, transformResponse, validateStatus, } = config;
|
|
209
|
+
const url = buildURL(config.url ?? '', baseURL, params);
|
|
210
|
+
const requestHeaders = createHeaders(rawHeaders);
|
|
211
|
+
let requestData = data;
|
|
212
|
+
if (transformRequest && (method === 'POST' || method === 'PUT' || method === 'PATCH')) {
|
|
213
|
+
requestData = applyRequestTransformers(data, requestHeaders, transformRequest);
|
|
214
|
+
if ((isObject(requestData) || Array.isArray(requestData)) && !requestHeaders.has('Content-Type')) {
|
|
215
|
+
requestHeaders.set('Content-Type', 'application/json');
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const init = {
|
|
219
|
+
method,
|
|
220
|
+
headers: toFetchHeaders(requestHeaders),
|
|
221
|
+
credentials: credentials ?? 'same-origin',
|
|
222
|
+
cache,
|
|
223
|
+
redirect,
|
|
224
|
+
referrer,
|
|
225
|
+
referrerPolicy,
|
|
226
|
+
};
|
|
227
|
+
if (requestData !== undefined && method !== 'GET' && method !== 'HEAD') {
|
|
228
|
+
init.body = isBodyLike(requestData) ? requestData : JSON.stringify(requestData);
|
|
229
|
+
}
|
|
230
|
+
const controller = config.signal ? undefined : createAbortController();
|
|
231
|
+
init.signal = config.signal ?? controller?.signal;
|
|
232
|
+
let timeoutId;
|
|
233
|
+
if (timeout) {
|
|
234
|
+
if (!controller && !config.signal) {
|
|
235
|
+
throw this.createError(new Error('FetchAxios timeout requires globalThis.AbortController.'), 'ERR_ABORT_CONTROLLER_UNAVAILABLE', config);
|
|
236
|
+
}
|
|
237
|
+
const timer = getTimerGlobal();
|
|
238
|
+
if (!timer.setTimeout || !timer.clearTimeout) {
|
|
239
|
+
throw this.createError(new Error('FetchAxios timeout requires globalThis.setTimeout and globalThis.clearTimeout.'), 'ERR_TIMER_UNAVAILABLE', config);
|
|
240
|
+
}
|
|
241
|
+
timeoutId = timer.setTimeout(() => controller?.abort(), timeout);
|
|
242
|
+
}
|
|
243
|
+
let response;
|
|
244
|
+
try {
|
|
245
|
+
response = await getFetch()(url, init);
|
|
246
|
+
}
|
|
247
|
+
catch (err) {
|
|
248
|
+
if (timeoutId)
|
|
249
|
+
getTimerGlobal().clearTimeout?.(timeoutId);
|
|
250
|
+
const error = this.createError(err instanceof Error ? err : new Error(String(err)), 'ECONNABORTED', config);
|
|
251
|
+
throw error;
|
|
252
|
+
}
|
|
253
|
+
if (timeoutId)
|
|
254
|
+
getTimerGlobal().clearTimeout?.(timeoutId);
|
|
255
|
+
const responseHeaders = parseHeaders(response.headers);
|
|
256
|
+
const responseConfig = {
|
|
257
|
+
data: null,
|
|
258
|
+
status: response.status,
|
|
259
|
+
statusText: response.statusText,
|
|
260
|
+
headers: responseHeaders,
|
|
261
|
+
config,
|
|
262
|
+
};
|
|
263
|
+
if (!validateStatus || validateStatus(response.status)) {
|
|
264
|
+
const rawData = await response.text();
|
|
265
|
+
const parsed = rawData ? JSON.parse(rawData) : null;
|
|
266
|
+
const transformedData = transformResponse
|
|
267
|
+
? applyTransformers(parsed, Array.isArray(transformResponse) ? transformResponse : [transformResponse])
|
|
268
|
+
: parsed;
|
|
269
|
+
responseConfig.data = transformedData;
|
|
270
|
+
return responseConfig;
|
|
271
|
+
}
|
|
272
|
+
const rawData = response.body ? await response.text() : null;
|
|
273
|
+
responseConfig.data = rawData ? JSON.parse(rawData) : null;
|
|
274
|
+
const error = this.createError(new Error(`Request failed with status ${response.status}`), undefined, config, responseConfig);
|
|
275
|
+
throw error;
|
|
276
|
+
}
|
|
277
|
+
createError(message, code, config, response) {
|
|
278
|
+
const error = message;
|
|
279
|
+
error.config = config;
|
|
280
|
+
error.code = code;
|
|
281
|
+
error.response = response;
|
|
282
|
+
error.isAxiosError = true;
|
|
283
|
+
return error;
|
|
284
|
+
}
|
|
285
|
+
get(url, config) {
|
|
286
|
+
return this.request({ ...config, url, method: 'GET' });
|
|
287
|
+
}
|
|
288
|
+
post(url, data, config) {
|
|
289
|
+
return this.request({ ...config, url, method: 'POST', data });
|
|
290
|
+
}
|
|
291
|
+
put(url, data, config) {
|
|
292
|
+
return this.request({ ...config, url, method: 'PUT', data });
|
|
293
|
+
}
|
|
294
|
+
patch(url, data, config) {
|
|
295
|
+
return this.request({ ...config, url, method: 'PATCH', data });
|
|
296
|
+
}
|
|
297
|
+
delete(url, config) {
|
|
298
|
+
return this.request({ ...config, url, method: 'DELETE' });
|
|
299
|
+
}
|
|
300
|
+
head(url, config) {
|
|
301
|
+
return this.request({ ...config, url, method: 'HEAD' });
|
|
302
|
+
}
|
|
303
|
+
options(url, config) {
|
|
304
|
+
return this.request({ ...config, url, method: 'OPTIONS' });
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
const instance = new FetchAxios();
|
|
308
|
+
export const axios = instance;
|
|
309
|
+
export const createInstance = (defaultConfig) => new FetchAxios(defaultConfig);
|
|
310
|
+
export default FetchAxios;
|