@effijs/templates 0.0.0-stage → 1.0.0-alpha.0
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/CONTRIBUTING.md +27 -0
- package/LICENSE +22 -0
- package/README.md +32 -2
- package/ai/SETUP.md +5 -0
- package/docs/catalog.md +85 -0
- package/forge.manifest.js +75 -0
- package/lib/compat.js +40 -0
- package/lib/docs/build.js +146 -0
- package/lib/install.js +51 -0
- package/lib/journal.js +40 -0
- package/lib/jsonConfig.js +33 -0
- package/lib/migration.js +35 -0
- package/lib/names.js +42 -0
- package/lib/patch.js +62 -0
- package/lib/paths.js +12 -0
- package/lib/project.js +48 -0
- package/lib/registry.js +99 -0
- package/package.json +46 -4
- package/platforms/react-native/CATALOG.md +391 -0
- package/platforms/react-native/ORIGIN.md +42 -0
- package/platforms/react-native/README.md +78 -0
- package/platforms/react-native/ai/AGENTS.md.hbs +36 -0
- package/platforms/react-native/ai/SETUP.md +89 -0
- package/platforms/react-native/compat/matrix.js +150 -0
- package/platforms/react-native/configs/babel.js +63 -0
- package/platforms/react-native/configs/forgeConfig.js +35 -0
- package/platforms/react-native/configs/jsConfigs.js +96 -0
- package/platforms/react-native/configs/metro.js +86 -0
- package/platforms/react-native/generators/add/generator.js +12 -0
- package/platforms/react-native/generators/add/run.js +64 -0
- package/platforms/react-native/generators/component/generator.js +75 -0
- package/platforms/react-native/generators/component/render.js +69 -0
- package/platforms/react-native/generators/component/templates/Common.tsx.hbs +13 -0
- package/platforms/react-native/generators/component/templates/index.ts.hbs +13 -0
- package/platforms/react-native/generators/component/templates/pm.ts.hbs +7 -0
- package/platforms/react-native/generators/component/templates/types.ts.hbs +3 -0
- package/platforms/react-native/generators/demo/files/api/app.http +8 -0
- package/platforms/react-native/generators/demo/files/api/environment/http-client.env.json +5 -0
- package/platforms/react-native/generators/demo/files/entity/category/category.api.ts +18 -0
- package/platforms/react-native/generators/demo/files/entity/category/category.dto.ts +15 -0
- package/platforms/react-native/generators/demo/files/entity/category/category.service.ts +42 -0
- package/platforms/react-native/generators/demo/files/entity/category/category.store.ts +26 -0
- package/platforms/react-native/generators/demo/files/entity/category/index.ts +2 -0
- package/platforms/react-native/generators/demo/files/entity/product/index.ts +2 -0
- package/platforms/react-native/generators/demo/files/entity/product/product.api.ts +49 -0
- package/platforms/react-native/generators/demo/files/entity/product/product.dto.ts +120 -0
- package/platforms/react-native/generators/demo/files/entity/product/product.service.ts +139 -0
- package/platforms/react-native/generators/demo/files/entity/product/product.store.ts +37 -0
- package/platforms/react-native/generators/demo/files/feature/product/components/Product.CategorySelect.tsx +36 -0
- package/platforms/react-native/generators/demo/files/feature/product/detail/Product.Detail.Screen.tsx +100 -0
- package/platforms/react-native/generators/demo/files/feature/product/detail/product.detail.service.ts +33 -0
- package/platforms/react-native/generators/demo/files/feature/product/filter/Product.Filter.Screen.tsx +59 -0
- package/platforms/react-native/generators/demo/files/feature/product/filter/product.filter.service.ts +78 -0
- package/platforms/react-native/generators/demo/files/feature/product/form/Product.Form.Screen.tsx +71 -0
- package/platforms/react-native/generators/demo/files/feature/product/form/product.form.service.ts +142 -0
- package/platforms/react-native/generators/demo/files/feature/product/index.ts +7 -0
- package/platforms/react-native/generators/demo/files/feature/product/list/Product.List.Item.tsx +34 -0
- package/platforms/react-native/generators/demo/files/feature/product/list/Product.List.Screen.tsx +106 -0
- package/platforms/react-native/generators/demo/files/feature/product/list/product.list.service.ts +47 -0
- package/platforms/react-native/generators/demo/files/feature/product/product.feature.ts +29 -0
- package/platforms/react-native/generators/demo/files/feature/product/product.hooks.ts +7 -0
- package/platforms/react-native/generators/demo/files/feature/product/search/Product.Search.Screen.tsx +82 -0
- package/platforms/react-native/generators/demo/files/feature/product/search/product.search.service.ts +97 -0
- package/platforms/react-native/generators/demo/files/navigation/navigation.product.ts +46 -0
- package/platforms/react-native/generators/demo/generator.js +93 -0
- package/platforms/react-native/generators/entity/generator.js +68 -0
- package/platforms/react-native/generators/feature/generator.js +224 -0
- package/platforms/react-native/generators/feature/render.js +163 -0
- package/platforms/react-native/generators/feature/templates/detail.screen.tsx.hbs +25 -0
- package/platforms/react-native/generators/feature/templates/detail.service.ts.hbs +14 -0
- package/platforms/react-native/generators/feature/templates/feature.ts.hbs +18 -0
- package/platforms/react-native/generators/feature/templates/filter.screen.tsx.hbs +17 -0
- package/platforms/react-native/generators/feature/templates/filter.service.ts.hbs +14 -0
- package/platforms/react-native/generators/feature/templates/form.screen.tsx.hbs +21 -0
- package/platforms/react-native/generators/feature/templates/form.service.ts.hbs +37 -0
- package/platforms/react-native/generators/feature/templates/hooks.ts.hbs +7 -0
- package/platforms/react-native/generators/feature/templates/index.ts.hbs +2 -0
- package/platforms/react-native/generators/feature/templates/list.item.tsx.hbs +16 -0
- package/platforms/react-native/generators/feature/templates/list.screen.tsx.hbs +34 -0
- package/platforms/react-native/generators/feature/templates/list.service.ts.hbs +15 -0
- package/platforms/react-native/generators/feature/templates/navigation.ts.hbs +12 -0
- package/platforms/react-native/generators/feature/templates/search.screen.tsx.hbs +24 -0
- package/platforms/react-native/generators/feature/templates/search.service.ts.hbs +13 -0
- package/platforms/react-native/generators/feature/templates/tab.tsx.hbs +8 -0
- package/platforms/react-native/generators/init/files/app/app.controller.ts +41 -0
- package/platforms/react-native/generators/init/files/app/app.error.ts +1 -0
- package/platforms/react-native/generators/init/files/app/app.store.ts +12 -0
- package/platforms/react-native/generators/init/files/app/index.ts +19 -0
- package/platforms/react-native/generators/init/files/app/splash/Onboarding.Screen.tsx +31 -0
- package/platforms/react-native/generators/init/files/app/splash/Splash.Screen.tsx +14 -0
- package/platforms/react-native/generators/init/files/app/tabs/home/Home.tab.tsx +24 -0
- package/platforms/react-native/generators/init/files/app/tabs/profile/Profile.tab.tsx +1 -0
- package/platforms/react-native/generators/init/files/configs/dev.ts.hbs +5 -0
- package/platforms/react-native/generators/init/files/configs/index.ts +4 -0
- package/platforms/react-native/generators/init/files/configs/prod.ts.hbs +5 -0
- package/platforms/react-native/generators/init/files/entity/auth/auth.api.ts +36 -0
- package/platforms/react-native/generators/init/files/entity/auth/auth.dto.ts +26 -0
- package/platforms/react-native/generators/init/files/entity/auth/auth.service.ts +94 -0
- package/platforms/react-native/generators/init/files/entity/auth/auth.session.store.ts +14 -0
- package/platforms/react-native/generators/init/files/entity/auth/auth.store.ts +20 -0
- package/platforms/react-native/generators/init/files/entity/auth/index.ts +2 -0
- package/platforms/react-native/generators/init/files/entity/index.ts +2 -0
- package/platforms/react-native/generators/init/files/feature/auth/auth.feature.ts +10 -0
- package/platforms/react-native/generators/init/files/feature/auth/auth.hooks.ts +7 -0
- package/platforms/react-native/generators/init/files/feature/auth/index.ts +1 -0
- package/platforms/react-native/generators/init/files/feature/auth/sign-in/SignIn.Screen.tsx +39 -0
- package/platforms/react-native/generators/init/files/feature/auth/sign-in/signIn.service.ts +54 -0
- package/platforms/react-native/generators/init/files/feature/auth/sign-up/SignUp.Screen.tsx +64 -0
- package/platforms/react-native/generators/init/files/feature/auth/sign-up/signUp.service.ts +73 -0
- package/platforms/react-native/generators/init/files/feature/feature.hooks.ts +15 -0
- package/platforms/react-native/generators/init/files/feature/index.ts +3 -0
- package/platforms/react-native/generators/init/files/feature/profile/Profile.Screen.tsx +52 -0
- package/platforms/react-native/generators/init/files/feature/profile/index.ts +1 -0
- package/platforms/react-native/generators/init/files/feature/profile/profile.feature.ts +18 -0
- package/platforms/react-native/generators/init/files/feature/profile/profile.hooks.ts +7 -0
- package/platforms/react-native/generators/init/files/index.ts +16 -0
- package/platforms/react-native/generators/init/files/navigation/index.ts +18 -0
- package/platforms/react-native/generators/init/files/navigation/navigation.app.ts +58 -0
- package/platforms/react-native/generators/init/files/navigation/navigation.features.ts +9 -0
- package/platforms/react-native/generators/init/files/navigation/navigation.hooks.ts +5 -0
- package/platforms/react-native/generators/init/files/navigation/navigation.tabs.ts +55 -0
- package/platforms/react-native/generators/init/files/navigation/navigation.widgets.ts +23 -0
- package/platforms/react-native/generators/init/files/services/http/http.base.ts +69 -0
- package/platforms/react-native/generators/init/files/services/http/http.error.ts +10 -0
- package/platforms/react-native/generators/init/files/services/http/http.service.ts +24 -0
- package/platforms/react-native/generators/init/files/services/http/middleware/index.ts +12 -0
- package/platforms/react-native/generators/init/files/services/http/middleware/middleware.error.ts +36 -0
- package/platforms/react-native/generators/init/files/services/http/middleware/middleware.registry.ts +3 -0
- package/platforms/react-native/generators/init/files/services/http/middleware/middleware.token.ts +97 -0
- package/platforms/react-native/generators/init/files/services/index.ts +15 -0
- package/platforms/react-native/generators/init/files/ui/components/Box/Common.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Box/box.pm.ts +111 -0
- package/platforms/react-native/generators/init/files/ui/components/Box/box.types.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/components/Box/index.ts +13 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/Common.tsx +50 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/Touchable.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/button.pm.ts +197 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/button.types.ts +22 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/button.utils.ts +16 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/index.ts +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/Colours.tsx +50 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/Common.tsx +38 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/ErrorText.tsx +11 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/Input.tsx +115 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/InputArea.tsx +70 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/Label.tsx +18 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/Select.tsx +86 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/components/SecureTextEntry.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/form.error.ts +18 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/form.pm.ts +134 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/form.types.ts +59 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/index.ts +67 -0
- package/platforms/react-native/generators/init/files/ui/components/Grid/Common.tsx +11 -0
- package/platforms/react-native/generators/init/files/ui/components/Grid/grid.pm.ts +93 -0
- package/platforms/react-native/generators/init/files/ui/components/Grid/grid.types.ts +79 -0
- package/platforms/react-native/generators/init/files/ui/components/Grid/index.ts +13 -0
- package/platforms/react-native/generators/init/files/ui/components/Icon/Common.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Icon/icons.pm.ts +74 -0
- package/platforms/react-native/generators/init/files/ui/components/Icon/icons.types.ts +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Icon/index.ts +3 -0
- package/platforms/react-native/generators/init/files/ui/components/Loading/Loading.tsx +10 -0
- package/platforms/react-native/generators/init/files/ui/components/Loading/loading.hook.ts +5 -0
- package/platforms/react-native/generators/init/files/ui/components/Loading/loading.service.ts +22 -0
- package/platforms/react-native/generators/init/files/ui/components/Loading/loading.store.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/Common.tsx +87 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/Content.tsx +77 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/Header.tsx +80 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/HeaderTab.tsx +17 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/SafeAreaHOC.tsx +9 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/index.ts +22 -0
- package/platforms/react-native/generators/init/files/ui/components/Text/Common.tsx +20 -0
- package/platforms/react-native/generators/init/files/ui/components/Text/index.ts +13 -0
- package/platforms/react-native/generators/init/files/ui/components/Text/text.pm.ts +55 -0
- package/platforms/react-native/generators/init/files/ui/components/Text/text.types.ts +27 -0
- package/platforms/react-native/generators/init/files/ui/components/TextInput/Common.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/components/TextInput/index.ts +15 -0
- package/platforms/react-native/generators/init/files/ui/components/TextInput/textInput.pm.ts +65 -0
- package/platforms/react-native/generators/init/files/ui/components/TextInput/textInput.types.ts +16 -0
- package/platforms/react-native/generators/init/files/ui/components/ThemePicker/ThemePicker.tsx +92 -0
- package/platforms/react-native/generators/init/files/ui/components/ThemePicker/index.ts +1 -0
- package/platforms/react-native/generators/init/files/ui/components/index.ts +27 -0
- package/platforms/react-native/generators/init/files/ui/components/utils/color.ts +19 -0
- package/platforms/react-native/generators/init/files/ui/components/utils/index.ts +3 -0
- package/platforms/react-native/generators/init/files/ui/components/utils/useLoading.hook.spec.tsx +202 -0
- package/platforms/react-native/generators/init/files/ui/components/utils/useLoading.hook.ts +172 -0
- package/platforms/react-native/generators/init/files/ui/components/utils/useStore.ts +34 -0
- package/platforms/react-native/generators/init/files/ui/fonts/font-icons.ttf +0 -0
- package/platforms/react-native/generators/init/files/ui/icons/font-icons.json +53 -0
- package/platforms/react-native/generators/init/files/ui/icons/logo.png +0 -0
- package/platforms/react-native/generators/init/files/ui/icons/logo.svg +304 -0
- package/platforms/react-native/generators/init/files/ui/icons/tabs/icon-1.png +0 -0
- package/platforms/react-native/generators/init/files/ui/icons/tabs/icon-2.png +0 -0
- package/platforms/react-native/generators/init/files/ui/theme/black/black.color.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/theme/black/index.ts +10 -0
- package/platforms/react-native/generators/init/files/ui/theme/blue/blue.color.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/theme/blue/index.ts +10 -0
- package/platforms/react-native/generators/init/files/ui/theme/green/green.color.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/theme/green/index.ts +10 -0
- package/platforms/react-native/generators/init/files/ui/theme/index.ts +11 -0
- package/platforms/react-native/generators/init/files/ui/theme/pink/index.ts +10 -0
- package/platforms/react-native/generators/init/files/ui/theme/pink/pink.color.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/index.ts +23 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.color.ts +139 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.radius.ts +21 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.spacing.ts +24 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.ts +25 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.typography.ts +98 -0
- package/platforms/react-native/generators/init/files/ui/theme/shared/index.ts +4 -0
- package/platforms/react-native/generators/init/files/ui/theme/shared/shared.color.base.ts +79 -0
- package/platforms/react-native/generators/init/files/ui/theme/shared/shared.radius.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/theme/shared/shared.spacing.ts +9 -0
- package/platforms/react-native/generators/init/files/ui/theme/shared/shared.typography.ts +105 -0
- package/platforms/react-native/generators/init/files/ui/theme/theme.hooks.ts +7 -0
- package/platforms/react-native/generators/init/files/ui/theme/theme.meta.ts +10 -0
- package/platforms/react-native/generators/init/files/ui/theme/theme.provider.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/theme/theme.service.ts +36 -0
- package/platforms/react-native/generators/init/files/ui/theme/theme.ts +27 -0
- package/platforms/react-native/generators/init/files/ui/widgets/index.ts +1 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/Toast.Item.tsx +175 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/Toast.Overlay.tsx +46 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/Toast.Stack.tsx +75 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/index.ts +7 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/toast.hooks.ts +18 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/toast.service.ts +39 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/toast.store.ts +59 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/toast.types.ts +18 -0
- package/platforms/react-native/generators/init/files/ui/widgets/widgets.feature.ts +14 -0
- package/platforms/react-native/generators/init/files/utils/date.ts +11 -0
- package/platforms/react-native/generators/init/files/utils/index.ts +12 -0
- package/platforms/react-native/generators/init/files/utils/store.persistent.ts +103 -0
- package/platforms/react-native/generators/init/files/utils/store.registry.ts +14 -0
- package/platforms/react-native/generators/init/files/utils/string.ts +100 -0
- package/platforms/react-native/generators/init/generator.js +86 -0
- package/platforms/react-native/generators/init/kit.js +23 -0
- package/platforms/react-native/generators/init/navigators/expo-router/index.ts +18 -0
- package/platforms/react-native/generators/init/navigators/expo-router/navigation.app.ts +8 -0
- package/platforms/react-native/generators/init/navigators/expo-router/navigation.features.ts +9 -0
- package/platforms/react-native/generators/init/navigators/expo-router/navigation.hooks.ts +5 -0
- package/platforms/react-native/generators/init/navigators/expo-router/navigation.tabs.ts +7 -0
- package/platforms/react-native/generators/init/navigators/expo-router/navigation.widgets.ts +5 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/index.ts +18 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/navigation.app.ts +8 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/navigation.features.ts +9 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/navigation.hooks.ts +5 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/navigation.tabs.ts +7 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/navigation.widgets.ts +5 -0
- package/platforms/react-native/generators/setup/generator.js +225 -0
- package/platforms/react-native/generators/util/generator.js +12 -0
- package/platforms/react-native/platform.js +32 -0
- package/platforms/react-native/runtime.js +57 -0
- package/platforms/react-native/solutions/components/BottomSheet/README.md +29 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/Common.tsx +120 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/Content.tsx +57 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/Context.tsx +22 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/FlatList.tsx +50 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/Header.tsx +57 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/Search.tsx +24 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/bottomSheet.constants.ts +13 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/bottomSheet.types.ts +31 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/index.ts +33 -0
- package/platforms/react-native/solutions/components/BottomSheet/solution.js +38 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/README.md +29 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/files/SelectPicker.tsx +47 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/files/bottomSheet/Content.BottomSheet.tsx +22 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/files/bottomSheet/DateTimePicker.BottomSheet.tsx +74 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/files/bottomSheet/List.BottomSheet.tsx +62 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/solution.js +49 -0
- package/platforms/react-native/solutions/components/Calendar/README.md +29 -0
- package/platforms/react-native/solutions/components/Calendar/files/Common.tsx +16 -0
- package/platforms/react-native/solutions/components/Calendar/files/Context.tsx +466 -0
- package/platforms/react-native/solutions/components/Calendar/files/DayCell.tsx +89 -0
- package/platforms/react-native/solutions/components/Calendar/files/MonthView.tsx +41 -0
- package/platforms/react-native/solutions/components/Calendar/files/MonthYearOverlay.tsx +51 -0
- package/platforms/react-native/solutions/components/Calendar/files/SwipeablePeriod.tsx +44 -0
- package/platforms/react-native/solutions/components/Calendar/files/WeekDayTitles.tsx +31 -0
- package/platforms/react-native/solutions/components/Calendar/files/WeekView.tsx +40 -0
- package/platforms/react-native/solutions/components/Calendar/files/calendar.styles.ts +142 -0
- package/platforms/react-native/solutions/components/Calendar/files/calendar.types.ts +126 -0
- package/platforms/react-native/solutions/components/Calendar/files/calendar.utils.ts +143 -0
- package/platforms/react-native/solutions/components/Calendar/files/index.ts +40 -0
- package/platforms/react-native/solutions/components/Calendar/solution.js +38 -0
- package/platforms/react-native/solutions/components/Chart/README.md +29 -0
- package/platforms/react-native/solutions/components/Chart/files/Cilcular.tsx +140 -0
- package/platforms/react-native/solutions/components/Chart/files/index.ts +3 -0
- package/platforms/react-native/solutions/components/Chart/solution.js +38 -0
- package/platforms/react-native/solutions/components/CheckBox/README.md +29 -0
- package/platforms/react-native/solutions/components/CheckBox/files/Common.tsx +55 -0
- package/platforms/react-native/solutions/components/CheckBox/files/checkbox.pm.ts +71 -0
- package/platforms/react-native/solutions/components/CheckBox/files/index.ts +9 -0
- package/platforms/react-native/solutions/components/CheckBox/form/Checkbox.tsx +22 -0
- package/platforms/react-native/solutions/components/CheckBox/solution.js +57 -0
- package/platforms/react-native/solutions/components/DateTimePicker/README.md +29 -0
- package/platforms/react-native/solutions/components/DateTimePicker/files/DateTimePicker.tsx +44 -0
- package/platforms/react-native/solutions/components/DateTimePicker/solution.js +45 -0
- package/platforms/react-native/solutions/components/Image/README.md +29 -0
- package/platforms/react-native/solutions/components/Image/files/SVG.tsx +74 -0
- package/platforms/react-native/solutions/components/Image/files/image.pm.ts +25 -0
- package/platforms/react-native/solutions/components/Image/files/image.utils.ts +35 -0
- package/platforms/react-native/solutions/components/Image/files/index.ts +5 -0
- package/platforms/react-native/solutions/components/Image/solution.js +40 -0
- package/platforms/react-native/solutions/components/InputSecurity/README.md +29 -0
- package/platforms/react-native/solutions/components/InputSecurity/files/InputSecurity.ts +142 -0
- package/platforms/react-native/solutions/components/InputSecurity/solution.js +28 -0
- package/platforms/react-native/solutions/components/OTP/README.md +29 -0
- package/platforms/react-native/solutions/components/OTP/files/Item.tsx +16 -0
- package/platforms/react-native/solutions/components/OTP/files/Items.tsx +33 -0
- package/platforms/react-native/solutions/components/OTP/files/index.tsx +120 -0
- package/platforms/react-native/solutions/components/OTP/files/otp.pm.ts +30 -0
- package/platforms/react-native/solutions/components/OTP/solution.js +38 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/README.md +29 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/files/Circular.tsx +154 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/files/Linear.tsx +133 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/files/circular.pm.ts +34 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/files/index.ts +16 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/solution.js +39 -0
- package/platforms/react-native/solutions/components/Ruler/README.md +29 -0
- package/platforms/react-native/solutions/components/Ruler/files/Common.tsx +44 -0
- package/platforms/react-native/solutions/components/Ruler/files/Context.tsx +210 -0
- package/platforms/react-native/solutions/components/Ruler/files/Track.tsx +686 -0
- package/platforms/react-native/solutions/components/Ruler/files/Value.tsx +60 -0
- package/platforms/react-native/solutions/components/Ruler/files/index.ts +23 -0
- package/platforms/react-native/solutions/components/Ruler/files/ruler.constants.ts +70 -0
- package/platforms/react-native/solutions/components/Ruler/files/ruler.types.ts +98 -0
- package/platforms/react-native/solutions/components/Ruler/files/ruler.utils.ts +332 -0
- package/platforms/react-native/solutions/components/Ruler/solution.js +38 -0
- package/platforms/react-native/solutions/components/Section/README.md +29 -0
- package/platforms/react-native/solutions/components/Section/files/Common.tsx +144 -0
- package/platforms/react-native/solutions/components/Section/solution.js +37 -0
- package/platforms/react-native/solutions/components/Slider/README.md +29 -0
- package/platforms/react-native/solutions/components/Slider/files/Container.tsx +5 -0
- package/platforms/react-native/solutions/components/Slider/files/Content.tsx +44 -0
- package/platforms/react-native/solutions/components/Slider/files/Context.tsx +30 -0
- package/platforms/react-native/solutions/components/Slider/files/Pagination.Dot.tsx +61 -0
- package/platforms/react-native/solutions/components/Slider/files/index.ts +22 -0
- package/platforms/react-native/solutions/components/Slider/solution.js +38 -0
- package/platforms/react-native/solutions/components/Switch/README.md +29 -0
- package/platforms/react-native/solutions/components/Switch/files/Common.tsx +38 -0
- package/platforms/react-native/solutions/components/Switch/files/index.ts +9 -0
- package/platforms/react-native/solutions/components/Switch/files/switch.pm.ts +53 -0
- package/platforms/react-native/solutions/components/Switch/solution.js +38 -0
- package/platforms/react-native/solutions/install.js +97 -0
- package/platforms/react-native/solutions/services/firebase-core/README.md +31 -0
- package/platforms/react-native/solutions/services/firebase-core/files/index.ts +5 -0
- package/platforms/react-native/solutions/services/firebase-core/solution.js +39 -0
- package/platforms/react-native/solutions/services/firebase-messaging/README.md +31 -0
- package/platforms/react-native/solutions/services/firebase-messaging/files/index.ts +20 -0
- package/platforms/react-native/solutions/services/firebase-messaging/solution.js +42 -0
- package/platforms/react-native/solutions/utils/permissions/README.md +29 -0
- package/platforms/react-native/solutions/utils/permissions/files/permissions.ts +10 -0
- package/platforms/react-native/solutions/utils/permissions/solution.js +32 -0
- package/presets/react-native-fsd/index.js +25 -0
- package/shared/generators/entity/render.js +88 -0
- package/shared/generators/entity/templates/crud/api.ts.hbs +36 -0
- package/shared/generators/entity/templates/crud/dto.ts.hbs +36 -0
- package/shared/generators/entity/templates/crud/service.ts.hbs +73 -0
- package/shared/generators/entity/templates/crud/store.ts.hbs +27 -0
- package/shared/generators/entity/templates/index.ts.hbs +2 -0
- package/shared/generators/entity/templates/simple/api.ts.hbs +16 -0
- package/shared/generators/entity/templates/simple/dto.ts.hbs +5 -0
- package/shared/generators/entity/templates/simple/service.ts.hbs +26 -0
- package/shared/generators/entity/templates/simple/store.ts.hbs +18 -0
- package/shared/solutions/utils/date/README.md +29 -0
- package/shared/solutions/utils/date/files/date.ts +11 -0
- package/shared/solutions/utils/date/solution.js +27 -0
- package/shared/solutions/utils/string/README.md +29 -0
- package/shared/solutions/utils/string/files/string.ts +100 -0
- package/shared/solutions/utils/string/solution.js +27 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EffiJS, ProcessBuilder } from '@effijs/common';
|
|
2
|
+
import { useEffect, useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
import { useStore } from '@components';
|
|
5
|
+
|
|
6
|
+
function useFeature<T>(name: string): T {
|
|
7
|
+
useEffect(() => () => EffiJS.unlink(name));
|
|
8
|
+
return useMemo(() => EffiJS.resolve<T>(name), [name]);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function useProcess(id: string) {
|
|
12
|
+
return useStore(ProcessBuilder.processRegistryStore, id as never) as ProcessBuilder.ProcessRecord | undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { useFeature, useProcess };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Image, StyleSheet } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { Button, Form, Grid, Screen, Text, ThemePicker, useStore } from '@components';
|
|
5
|
+
import { useProfileFeature } from '@feature/profile/profile.hooks';
|
|
6
|
+
|
|
7
|
+
export default function ProfileScreen() {
|
|
8
|
+
const feature = useProfileFeature();
|
|
9
|
+
const profile = useStore(feature.store, 'profile');
|
|
10
|
+
const theme = useStore(feature.store, 'theme');
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Screen>
|
|
14
|
+
<Screen.HeaderTab>
|
|
15
|
+
<Grid mh-s row align-center>
|
|
16
|
+
<Text title-l color="outline" weight={600}>
|
|
17
|
+
Profile
|
|
18
|
+
</Text>
|
|
19
|
+
</Grid>
|
|
20
|
+
</Screen.HeaderTab>
|
|
21
|
+
<Screen.Content sa-b>
|
|
22
|
+
<Grid mh-s mt-l gap-m>
|
|
23
|
+
{profile?.avatar ? <Image source={{ uri: profile.avatar }} style={styles.avatar} /> : null}
|
|
24
|
+
{profile?.name ? (
|
|
25
|
+
<Text display-s color="outline">
|
|
26
|
+
{profile?.name}
|
|
27
|
+
</Text>
|
|
28
|
+
) : null}
|
|
29
|
+
{profile?.email ? (
|
|
30
|
+
<Text body-m color="onSurfaceVariant">
|
|
31
|
+
{profile?.email}
|
|
32
|
+
</Text>
|
|
33
|
+
) : null}
|
|
34
|
+
{profile?.role ? (
|
|
35
|
+
<Text body-s color="onSurfaceVariant">
|
|
36
|
+
{profile?.role}
|
|
37
|
+
</Text>
|
|
38
|
+
) : null}
|
|
39
|
+
<Form.Element.Label>Theme</Form.Element.Label>
|
|
40
|
+
<ThemePicker value={theme} />
|
|
41
|
+
<Button type="filled" color="error" leadingIcon="log-out" mt-l onPress={() => feature.logout()}>
|
|
42
|
+
Logout
|
|
43
|
+
</Button>
|
|
44
|
+
</Grid>
|
|
45
|
+
</Screen.Content>
|
|
46
|
+
</Screen>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const styles = StyleSheet.create({
|
|
51
|
+
avatar: { width: 96, height: 96, borderRadius: 48 },
|
|
52
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './profile.feature';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Entity, EffiJS } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { AuthService } from '@entity/auth/auth.service';
|
|
4
|
+
import { AuthStore } from '@entity/auth/auth.store';
|
|
5
|
+
|
|
6
|
+
@Entity.Decorators.Feature()
|
|
7
|
+
export class ProfileFeature {
|
|
8
|
+
constructor(
|
|
9
|
+
readonly store: AuthStore,
|
|
10
|
+
private authService: AuthService,
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
logout() {
|
|
14
|
+
return this.authService.logout();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
EffiJS.createFeature(ProfileFeature, 'ProfileFeature');
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PropertyManager } from '@effijs/props-manager';
|
|
2
|
+
|
|
3
|
+
import { theme } from '@theme';
|
|
4
|
+
|
|
5
|
+
import '@widgets';
|
|
6
|
+
import '@navigation';
|
|
7
|
+
import '@services';
|
|
8
|
+
import '@entity';
|
|
9
|
+
import '@feature';
|
|
10
|
+
import '@app';
|
|
11
|
+
|
|
12
|
+
PropertyManager.registerProvider(
|
|
13
|
+
'theme',
|
|
14
|
+
() => theme,
|
|
15
|
+
listener => theme.subscribe(listener),
|
|
16
|
+
);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EffiJS, Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { NavigationApp } from './navigation.app';
|
|
4
|
+
import { NavigationFeatures } from './navigation.features';
|
|
5
|
+
import { NavigationTabs } from './navigation.tabs';
|
|
6
|
+
import { NavigationWidgets } from './navigation.widgets';
|
|
7
|
+
|
|
8
|
+
@Entity.Decorators.Module()
|
|
9
|
+
export class Navigation {
|
|
10
|
+
constructor(
|
|
11
|
+
public app: NavigationApp,
|
|
12
|
+
public features: NavigationFeatures,
|
|
13
|
+
public tabs: NavigationTabs,
|
|
14
|
+
public widgets: NavigationWidgets,
|
|
15
|
+
) {}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
EffiJS.create(Navigation, 'Navigation');
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Navigation, Decorators } from '@effijs/navigation-react-native';
|
|
2
|
+
import { Options } from 'react-native-navigation';
|
|
3
|
+
|
|
4
|
+
import OnboardingScreen from '@app/splash/Onboarding.Screen';
|
|
5
|
+
import SplashScreen from '@app/splash/Splash.Screen';
|
|
6
|
+
import SignInScreen from '@feature/auth/sign-in/SignIn.Screen';
|
|
7
|
+
import SignUpScreen from '@feature/auth/sign-up/SignUp.Screen';
|
|
8
|
+
import { theme } from '@theme';
|
|
9
|
+
|
|
10
|
+
const navigationScreenOptions = {
|
|
11
|
+
modalPresentationStyle: 'overFullScreen',
|
|
12
|
+
modalTransitionStyle: 'crossDissolve',
|
|
13
|
+
blurOnUnmount: true,
|
|
14
|
+
topBar: { visible: false },
|
|
15
|
+
popGesture: true,
|
|
16
|
+
layout: {
|
|
17
|
+
orientation: ['portrait'],
|
|
18
|
+
componentBackgroundColor: theme.color.background,
|
|
19
|
+
},
|
|
20
|
+
bottomTabs: {
|
|
21
|
+
preferLargeIcons: true,
|
|
22
|
+
titleDisplayMode: 'alwaysShow',
|
|
23
|
+
backgroundColor: 'rgb(255,255,255)',
|
|
24
|
+
},
|
|
25
|
+
bottomTab: {
|
|
26
|
+
iconHeight: 32,
|
|
27
|
+
iconWidth: 32,
|
|
28
|
+
iconColor: theme.color.primary,
|
|
29
|
+
selectedIconColor: theme.color.outline,
|
|
30
|
+
},
|
|
31
|
+
} as Options;
|
|
32
|
+
|
|
33
|
+
@Decorators.Navigation('App')
|
|
34
|
+
export class NavigationApp extends Navigation {
|
|
35
|
+
@Decorators.AppLaunch(navigationScreenOptions)
|
|
36
|
+
@Decorators.Register('Splash', SplashScreen)
|
|
37
|
+
goToSplash() {
|
|
38
|
+
return super.root('Splash', 'component');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Decorators.Register('Onboarding', OnboardingScreen)
|
|
42
|
+
goToOnboarding() {
|
|
43
|
+
return super.root('Onboarding', 'component');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Decorators.Register('SignIn', SignInScreen)
|
|
47
|
+
private handleSignIn() {
|
|
48
|
+
return super.root('SignIn', 'stack');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Decorators.Register('SignUp', SignUpScreen)
|
|
52
|
+
private handleSignUp() {
|
|
53
|
+
return super.root('SignUp', 'stack');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
goToSignIn = () => this.handleSignIn();
|
|
57
|
+
goToSignUp = () => this.handleSignUp();
|
|
58
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Navigation, Decorators } from '@effijs/navigation-react-native';
|
|
2
|
+
import { Navigation as RNNavigation } from 'react-native-navigation';
|
|
3
|
+
|
|
4
|
+
import HomeTab from '@app/tabs/home/Home.tab';
|
|
5
|
+
import ProfileTab from '@app/tabs/profile/Profile.tab';
|
|
6
|
+
import theme from '@theme/theme';
|
|
7
|
+
|
|
8
|
+
@Decorators.Navigation('Tabs')
|
|
9
|
+
export class NavigationTabs extends Navigation {
|
|
10
|
+
@Decorators.Register('Home', HomeTab)
|
|
11
|
+
homeTab() {}
|
|
12
|
+
|
|
13
|
+
@Decorators.Register('Profile', ProfileTab)
|
|
14
|
+
profileTab() {}
|
|
15
|
+
|
|
16
|
+
// forge:navigation-tabs-register
|
|
17
|
+
|
|
18
|
+
goToTabs = () => {
|
|
19
|
+
RNNavigation.setRoot({
|
|
20
|
+
root: {
|
|
21
|
+
bottomTabs: {
|
|
22
|
+
children: [
|
|
23
|
+
{
|
|
24
|
+
stack: {
|
|
25
|
+
children: [{ component: { name: 'Tabs.Home', id: 'Tabs.Home' } }],
|
|
26
|
+
options: {
|
|
27
|
+
bottomTab: {
|
|
28
|
+
text: 'Home',
|
|
29
|
+
icon: require('@icons/tabs/icon-1.png'),
|
|
30
|
+
iconColor: theme.color.outline,
|
|
31
|
+
selectedIconColor: theme.color.primary,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
stack: {
|
|
38
|
+
children: [{ component: { name: 'Tabs.Profile', id: 'Tabs.Profile' } }],
|
|
39
|
+
options: {
|
|
40
|
+
bottomTab: {
|
|
41
|
+
text: 'Profile',
|
|
42
|
+
icon: require('@icons/tabs/icon-2.png'),
|
|
43
|
+
iconColor: theme.color.outline,
|
|
44
|
+
selectedIconColor: theme.color.primary,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
// forge:navigation-tabs
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Navigation, Decorators } from '@effijs/navigation-react-native';
|
|
2
|
+
|
|
3
|
+
import SafeAreaHOC from '@components/Screen/SafeAreaHOC';
|
|
4
|
+
import { ToastOverlay, ToastService, type IToastShowOptions } from '@widgets/toast';
|
|
5
|
+
|
|
6
|
+
@Decorators.Navigation('Widgets')
|
|
7
|
+
export class NavigationWidgets extends Navigation {
|
|
8
|
+
constructor(private toastService: ToastService) {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@Decorators.Register('Toast', SafeAreaHOC(ToastOverlay))
|
|
13
|
+
openToastOverlay() {
|
|
14
|
+
super.navigate('Toast').overlay({});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
showToast(options: IToastShowOptions) {
|
|
18
|
+
const shouldOpenOverlay = this.toastService.show(options);
|
|
19
|
+
if (shouldOpenOverlay) {
|
|
20
|
+
this.openToastOverlay();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Http, Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { HttpService } from './http.service';
|
|
4
|
+
|
|
5
|
+
export abstract class HttpBase {
|
|
6
|
+
protected abstract url: string;
|
|
7
|
+
protected version: string = 'v1';
|
|
8
|
+
|
|
9
|
+
constructor(@Entity.Decorators.Inject() protected httpService: HttpService) {}
|
|
10
|
+
|
|
11
|
+
protected async request<R extends (data: unknown) => unknown>(
|
|
12
|
+
options: Http.IOptions & { version?: string; resource?: string; withoutMiddlewares?: boolean },
|
|
13
|
+
dto: {
|
|
14
|
+
response: R;
|
|
15
|
+
params?: (data: unknown) => Record<string, any>;
|
|
16
|
+
data?: (data: unknown) => unknown;
|
|
17
|
+
},
|
|
18
|
+
): Promise<Http.IResponse<ReturnType<R>>>;
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
21
|
+
protected async request<T = any>(
|
|
22
|
+
options: Http.IOptions & { version?: string; resource?: string; withoutMiddlewares?: boolean },
|
|
23
|
+
dto?: {
|
|
24
|
+
response?: undefined;
|
|
25
|
+
params?: (data: unknown) => Record<string, any>;
|
|
26
|
+
data?: (data: unknown) => unknown;
|
|
27
|
+
},
|
|
28
|
+
): Promise<Http.IResponse<T>>;
|
|
29
|
+
|
|
30
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
31
|
+
protected async request<T = any, R extends (data: unknown) => unknown = (data: unknown) => unknown>(
|
|
32
|
+
{
|
|
33
|
+
url,
|
|
34
|
+
version,
|
|
35
|
+
resource,
|
|
36
|
+
withoutMiddlewares,
|
|
37
|
+
...options
|
|
38
|
+
}: Http.IOptions & { version?: string; resource?: string; withoutMiddlewares?: boolean },
|
|
39
|
+
dto?: {
|
|
40
|
+
response?: R;
|
|
41
|
+
params?: (data: unknown) => Record<string, any>;
|
|
42
|
+
data?: (data: unknown) => unknown;
|
|
43
|
+
},
|
|
44
|
+
): Promise<ReturnType<R> | Http.IResponse<T>> {
|
|
45
|
+
if (dto?.params && options.params) {
|
|
46
|
+
options.params = dto.params(options.params);
|
|
47
|
+
}
|
|
48
|
+
if (dto?.data && options.data) {
|
|
49
|
+
options.data = dto.data(options.data);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const request = withoutMiddlewares
|
|
53
|
+
? this.httpService.fetch.bind(this.httpService)
|
|
54
|
+
: this.httpService.request.bind(this.httpService);
|
|
55
|
+
|
|
56
|
+
const response = await request({
|
|
57
|
+
url: [version || this.version, resource !== undefined ? resource : this.url, url].filter(u => u).join('/'),
|
|
58
|
+
...options,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
if (dto?.response) {
|
|
62
|
+
// console.log('response <<<', JSON.stringify(response.data, null, 2));
|
|
63
|
+
response.data = dto.response(response.data);
|
|
64
|
+
// console.log('response >>>', JSON.stringify(response.data, null, 2));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return response;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Http, AbortService, Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import configs from '@configs';
|
|
4
|
+
import { MiddlewareRegistry } from '@services/http/middleware/middleware.registry';
|
|
5
|
+
|
|
6
|
+
@Entity.Decorators.Service()
|
|
7
|
+
export class HttpService<O extends Http.IOptions = any> extends Http.Common {
|
|
8
|
+
private readonly withMiddleware;
|
|
9
|
+
|
|
10
|
+
constructor(
|
|
11
|
+
@Entity.Decorators.Inject() protected abortService: AbortService,
|
|
12
|
+
@Entity.Decorators.Inject() private middlewareRegistry: MiddlewareRegistry<O, any>,
|
|
13
|
+
) {
|
|
14
|
+
super(configs.API_URL);
|
|
15
|
+
|
|
16
|
+
middlewareRegistry.assertRegistered('error', 'token');
|
|
17
|
+
|
|
18
|
+
this.withMiddleware = this.middlewareRegistry.with('error', 'token')(options => super.request(options));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
request<R = any>(options: O): Promise<Http.IResponse<R>> {
|
|
22
|
+
return this.withMiddleware(options);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { HttpErrorMiddleware } from './middleware.error';
|
|
4
|
+
import { TokenMiddleware } from './middleware.token';
|
|
5
|
+
|
|
6
|
+
@Entity.Decorators.Service()
|
|
7
|
+
export class Middlewares {
|
|
8
|
+
constructor(
|
|
9
|
+
private readonly error: HttpErrorMiddleware,
|
|
10
|
+
private readonly token: TokenMiddleware,
|
|
11
|
+
) {}
|
|
12
|
+
}
|
package/platforms/react-native/generators/init/files/services/http/middleware/middleware.error.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Middleware, Http, Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { HttpError } from '@services/http/http.error';
|
|
4
|
+
|
|
5
|
+
import { MiddlewareRegistry } from './middleware.registry';
|
|
6
|
+
|
|
7
|
+
function readMessage(payload: any): string | undefined {
|
|
8
|
+
const message = payload?.data?.message ?? payload?.message;
|
|
9
|
+
if (Array.isArray(message)) {
|
|
10
|
+
return message[0];
|
|
11
|
+
}
|
|
12
|
+
return message;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Entity.Decorators.Service()
|
|
16
|
+
export class HttpErrorMiddleware<
|
|
17
|
+
T extends Http.IOptions = Http.IOptions,
|
|
18
|
+
R extends Http.IResponse = Http.IResponse,
|
|
19
|
+
> extends Middleware.AsMiddleware<T, R> {
|
|
20
|
+
constructor(@Entity.Decorators.Inject() registry: MiddlewareRegistry<T, R>) {
|
|
21
|
+
super('error', registry);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async middleware(data: T, next: Middleware.NextFn<T, R>) {
|
|
25
|
+
const res = await next(data);
|
|
26
|
+
|
|
27
|
+
if (res.status >= 300) {
|
|
28
|
+
throw new HttpError(
|
|
29
|
+
readMessage(res.data) || 'Something went wrong',
|
|
30
|
+
res?.data?.data?.errors || res?.data?.errors,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return res;
|
|
35
|
+
}
|
|
36
|
+
}
|
package/platforms/react-native/generators/init/files/services/http/middleware/middleware.token.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Middleware, Http, Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { AuthService } from '@entity/auth/auth.service';
|
|
4
|
+
|
|
5
|
+
import { MiddlewareRegistry } from './middleware.registry';
|
|
6
|
+
|
|
7
|
+
const RETRIED = Symbol('token-retried');
|
|
8
|
+
|
|
9
|
+
type TokenRequest = Http.IOptions & { [RETRIED]?: boolean };
|
|
10
|
+
|
|
11
|
+
@Entity.Decorators.Service()
|
|
12
|
+
export class TokenMiddleware<
|
|
13
|
+
T extends Http.IOptions = Http.IOptions,
|
|
14
|
+
R extends Http.IResponse = Http.IResponse,
|
|
15
|
+
> extends Middleware.AsMiddleware<T, R> {
|
|
16
|
+
private refreshPromise?: Promise<boolean>;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
@Entity.Decorators.Inject() private registry: MiddlewareRegistry<T, R>,
|
|
20
|
+
@Entity.Decorators.Inject(Entity.Decorators.forwardRef(() => AuthService)) private authService: AuthService,
|
|
21
|
+
) {
|
|
22
|
+
super('token', registry);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async middleware(data: T, next: Middleware.NextFn<T, R>) {
|
|
26
|
+
const request = data as T & TokenRequest;
|
|
27
|
+
const isAuth = this.isLoginRequest(request.url) || this.isRefreshRequest(request.url);
|
|
28
|
+
|
|
29
|
+
if (!isAuth && this.token) {
|
|
30
|
+
request.headers = {
|
|
31
|
+
...request.headers,
|
|
32
|
+
Authorization: `Bearer ${this.token}`,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const res = await next(request);
|
|
37
|
+
|
|
38
|
+
if (res.status === 401) {
|
|
39
|
+
if (!this.skipRefresh(request.url) && !request[RETRIED]) {
|
|
40
|
+
const refreshed = await this.refreshAccessToken();
|
|
41
|
+
if (refreshed && this.token) {
|
|
42
|
+
request[RETRIED] = true;
|
|
43
|
+
request.headers = {
|
|
44
|
+
...request.headers,
|
|
45
|
+
Authorization: `Bearer ${this.token}`,
|
|
46
|
+
};
|
|
47
|
+
return next(request);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!isAuth) {
|
|
52
|
+
await this.logout();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return res;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private get token() {
|
|
60
|
+
return this.authService.accessToken;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private isLoginRequest = (url: string) => url.includes('login') && !url.includes('refresh-token');
|
|
64
|
+
|
|
65
|
+
private isRefreshRequest = (url: string) => url.includes('refresh-token');
|
|
66
|
+
|
|
67
|
+
private skipRefresh = (url: string) => this.isLoginRequest(url) || this.isRefreshRequest(url);
|
|
68
|
+
|
|
69
|
+
private logout = async () => {
|
|
70
|
+
this.authService.logout();
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
private refreshAccessToken = async () => {
|
|
74
|
+
if (this.refreshPromise) {
|
|
75
|
+
return this.refreshPromise;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
this.refreshPromise = (async () => {
|
|
79
|
+
try {
|
|
80
|
+
const response = await this.authService.refresh();
|
|
81
|
+
const accessToken = response.data?.access_token;
|
|
82
|
+
|
|
83
|
+
if (response.status < 200 || response.status >= 300 || !accessToken) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return true;
|
|
88
|
+
} catch {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
})().finally(() => {
|
|
92
|
+
this.refreshPromise = undefined;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
return this.refreshPromise;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EffiJS, Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { HttpService } from '@services/http/http.service';
|
|
4
|
+
import { Middlewares } from '@services/http/middleware';
|
|
5
|
+
// forge:services
|
|
6
|
+
|
|
7
|
+
@Entity.Decorators.Module()
|
|
8
|
+
export class Services {
|
|
9
|
+
constructor(
|
|
10
|
+
private middlewares: Middlewares,
|
|
11
|
+
private http: HttpService,
|
|
12
|
+
) {}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
EffiJS.create(Services, 'Services');
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { useTheme, TThemeColor } from '@theme';
|
|
5
|
+
|
|
6
|
+
import { type TGridProps } from '../Grid/grid.types';
|
|
7
|
+
|
|
8
|
+
import { BoxPM } from './box.pm';
|
|
9
|
+
import { type TBoxProps } from './box.types';
|
|
10
|
+
|
|
11
|
+
export default function BoxCommon<TSpacing>({
|
|
12
|
+
children,
|
|
13
|
+
...commonProps
|
|
14
|
+
}: TBoxProps<TThemeColor, TSpacing> & TGridProps & ViewProps) {
|
|
15
|
+
const theme = useTheme();
|
|
16
|
+
const { container } = BoxPM.get({ theme, ...commonProps } as Record<string, unknown>);
|
|
17
|
+
|
|
18
|
+
return <View {...container} children={children} />;
|
|
19
|
+
}
|