@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,13 @@
|
|
|
1
|
+
import { Entity, ProcessBuilder as PB } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { {{entityNames.pascal}}Service } from '@entity/{{entityNames.kebab}}/{{entityNames.kebab}}.service';
|
|
4
|
+
|
|
5
|
+
@Entity.Decorators.Service()
|
|
6
|
+
export class {{feature.pascal}}SearchService {
|
|
7
|
+
constructor(private {{entityNames.camel}}Service: {{entityNames.pascal}}Service) {}
|
|
8
|
+
|
|
9
|
+
search = (title: string) => PB.process.flow(PB.step(async (_, { signal }) => {
|
|
10
|
+
this.{{entityNames.camel}}Service.setQuery('search', { title });
|
|
11
|
+
await this.{{entityNames.camel}}Service.fetchList('search', { signal, mode: 'replace' });
|
|
12
|
+
})).concurrent('abort');
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{{#if (includes screens "list")}}export { default } from '@feature/{{feature.kebab}}/list/{{feature.pascal}}.List.Screen';
|
|
2
|
+
{{else}}import React from 'react';
|
|
3
|
+
import { Grid, Screen, Text } from '@components';
|
|
4
|
+
|
|
5
|
+
export default function {{feature.pascal}}Tab() {
|
|
6
|
+
return <Screen><Screen.Content><Grid mh-s mt-l><Text body-m>{{feature.pascal}}</Text></Grid></Screen.Content></Screen>;
|
|
7
|
+
}
|
|
8
|
+
{{/if}}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { AuthService } from '@entity/auth/auth.service';
|
|
4
|
+
import { AuthSessionStore } from '@entity/auth/auth.session.store';
|
|
5
|
+
import { Navigation } from '@navigation';
|
|
6
|
+
import utils from '@utils';
|
|
7
|
+
|
|
8
|
+
@Entity.Decorators.Controller()
|
|
9
|
+
export class AppController {
|
|
10
|
+
constructor(
|
|
11
|
+
private navigation: Navigation,
|
|
12
|
+
private authService: AuthService,
|
|
13
|
+
private authSessionStore: AuthSessionStore,
|
|
14
|
+
) {}
|
|
15
|
+
|
|
16
|
+
async startApp() {
|
|
17
|
+
this.navigation.app.goToSplash();
|
|
18
|
+
|
|
19
|
+
await utils.sleep(500);
|
|
20
|
+
|
|
21
|
+
const session = await this.authService.restoreSession();
|
|
22
|
+
|
|
23
|
+
if (session === 'restored') {
|
|
24
|
+
this.navigation.tabs.goToTabs();
|
|
25
|
+
} else if (session === 'expired') {
|
|
26
|
+
this.navigation.app.goToSignIn();
|
|
27
|
+
} else {
|
|
28
|
+
this.navigation.app.goToOnboarding();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
this.authSessionStore.subscribe(
|
|
32
|
+
'sessionId',
|
|
33
|
+
({ sessionId }) => {
|
|
34
|
+
if (!sessionId) {
|
|
35
|
+
this.navigation.app.goToOnboarding();
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{ omitInitialCall: true },
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class AppError extends Error {}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { StorePersistent } from '@utils';
|
|
4
|
+
|
|
5
|
+
export type AppStorePersistentState = Record<string, never>;
|
|
6
|
+
|
|
7
|
+
@Entity.Decorators.Store()
|
|
8
|
+
export class AppStorePersistent extends StorePersistent<AppStorePersistentState> {
|
|
9
|
+
constructor() {
|
|
10
|
+
super({});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EffiJS, Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { AppController } from '@app/app.controller';
|
|
4
|
+
import { AppStorePersistent } from '@app/app.store';
|
|
5
|
+
import { ThemeService } from '@theme/theme.service';
|
|
6
|
+
|
|
7
|
+
@Entity.Decorators.Module()
|
|
8
|
+
export class App {
|
|
9
|
+
constructor(
|
|
10
|
+
private storePersistent: AppStorePersistent,
|
|
11
|
+
private themeService: ThemeService,
|
|
12
|
+
private controller: AppController,
|
|
13
|
+
) {
|
|
14
|
+
themeService.init();
|
|
15
|
+
controller.startApp();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
EffiJS.create(App, 'App');
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Button, Grid, Screen, Text } from '@components';
|
|
4
|
+
import { useNavigation } from '@navigation/navigation.hooks';
|
|
5
|
+
|
|
6
|
+
export default function OnboardingScreen() {
|
|
7
|
+
const navigation = useNavigation();
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<Screen>
|
|
11
|
+
<Screen.Content sa-t sa-b>
|
|
12
|
+
<Grid flex={1} center mh-s>
|
|
13
|
+
<Text title-m color="primary" weight={600} center mb-l>
|
|
14
|
+
Welcome
|
|
15
|
+
</Text>
|
|
16
|
+
<Text body-m color="primary" center mb-xl>
|
|
17
|
+
Create an account or sign in to continue.
|
|
18
|
+
</Text>
|
|
19
|
+
</Grid>
|
|
20
|
+
<Grid gap-xs mt-l mh-s>
|
|
21
|
+
<Button type="filled" onPress={navigation.app.goToSignUp}>
|
|
22
|
+
Create Account
|
|
23
|
+
</Button>
|
|
24
|
+
<Button type="text" color="secondary" mt-xs onPress={navigation.app.goToSignIn}>
|
|
25
|
+
Already have an account? Sign In
|
|
26
|
+
</Button>
|
|
27
|
+
</Grid>
|
|
28
|
+
</Screen.Content>
|
|
29
|
+
</Screen>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Image } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { Grid, Screen } from '@components';
|
|
5
|
+
|
|
6
|
+
export default function SplashScreen() {
|
|
7
|
+
return (
|
|
8
|
+
<Screen>
|
|
9
|
+
<Grid flex={1} center>
|
|
10
|
+
<Image source={require('@icons/logo.png')} style={{ width: 160, height: 160 }} />
|
|
11
|
+
</Grid>
|
|
12
|
+
</Screen>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Grid, Screen, Text } from '@components';
|
|
4
|
+
|
|
5
|
+
export default function HomeTab() {
|
|
6
|
+
return (
|
|
7
|
+
<Screen>
|
|
8
|
+
<Screen.HeaderTab>
|
|
9
|
+
<Grid mh-s row align-center>
|
|
10
|
+
<Text title-l color="outline" weight={600}>
|
|
11
|
+
Home
|
|
12
|
+
</Text>
|
|
13
|
+
</Grid>
|
|
14
|
+
</Screen.HeaderTab>
|
|
15
|
+
<Screen.Content sa-b>
|
|
16
|
+
<Grid mh-s mt-l>
|
|
17
|
+
<Text body-m color="onSurfaceVariant">
|
|
18
|
+
Home
|
|
19
|
+
</Text>
|
|
20
|
+
</Grid>
|
|
21
|
+
</Screen.Content>
|
|
22
|
+
</Screen>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@feature/profile/Profile.Screen';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { HttpBase } from '@services/http/http.base';
|
|
4
|
+
|
|
5
|
+
import { AuthProfile, AuthTokens } from './auth.dto';
|
|
6
|
+
|
|
7
|
+
export interface RegisterPayload {
|
|
8
|
+
name: string;
|
|
9
|
+
email: string;
|
|
10
|
+
password: string;
|
|
11
|
+
avatar: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@Entity.Decorators.ApiService()
|
|
15
|
+
export class AuthApi extends HttpBase {
|
|
16
|
+
protected url = 'auth';
|
|
17
|
+
|
|
18
|
+
async login(data: { email: string; password: string }) {
|
|
19
|
+
return this.request({ url: 'login', method: 'post', data }, { response: raw => AuthTokens.transform(raw) });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async profile() {
|
|
23
|
+
return this.request({ url: 'profile', method: 'get' }, { response: raw => AuthProfile.transform(raw) });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async refreshToken(data: { refreshToken: string }) {
|
|
27
|
+
return this.request(
|
|
28
|
+
{ url: 'refresh-token', method: 'post', data, withoutMiddlewares: true },
|
|
29
|
+
{ response: raw => AuthTokens.transform(raw) },
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
register(data: RegisterPayload) {
|
|
34
|
+
return this.request({ url: '', method: 'post', data, resource: 'users' });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Transform } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
export class AuthTokens extends Transform.WithTransform {
|
|
4
|
+
@Transform.Decorators.Property()
|
|
5
|
+
access_token!: string;
|
|
6
|
+
|
|
7
|
+
@Transform.Decorators.Property()
|
|
8
|
+
refresh_token!: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class AuthProfile extends Transform.WithTransform {
|
|
12
|
+
@Transform.Decorators.Property()
|
|
13
|
+
id!: number;
|
|
14
|
+
|
|
15
|
+
@Transform.Decorators.Property()
|
|
16
|
+
email!: string;
|
|
17
|
+
|
|
18
|
+
@Transform.Decorators.Property()
|
|
19
|
+
name!: string;
|
|
20
|
+
|
|
21
|
+
@Transform.Decorators.Property()
|
|
22
|
+
role!: string;
|
|
23
|
+
|
|
24
|
+
@Transform.Decorators.Property()
|
|
25
|
+
avatar!: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { StorePersistentSessionBased, StoreRegistry } from '@utils';
|
|
4
|
+
|
|
5
|
+
import { AuthApi, RegisterPayload } from './auth.api';
|
|
6
|
+
import { AuthSessionStore } from './auth.session.store';
|
|
7
|
+
import { AuthStore } from './auth.store';
|
|
8
|
+
|
|
9
|
+
export type AuthSessionStatus = 'restored' | 'anonymous' | 'expired';
|
|
10
|
+
|
|
11
|
+
@Entity.Decorators.Service()
|
|
12
|
+
export class AuthService {
|
|
13
|
+
constructor(
|
|
14
|
+
private store: AuthStore,
|
|
15
|
+
private sessionStore: AuthSessionStore,
|
|
16
|
+
private api: AuthApi,
|
|
17
|
+
private registry: StoreRegistry,
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
get accessToken() {
|
|
21
|
+
return this.store.getByPath('accessToken');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async restoreSession(): Promise<AuthSessionStatus> {
|
|
25
|
+
const sessionId = this.sessionStore.getByPath('sessionId');
|
|
26
|
+
if (!sessionId) {
|
|
27
|
+
return 'anonymous';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
StorePersistentSessionBased.loadFor(sessionId);
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
await this.fetchProfile();
|
|
34
|
+
return 'restored';
|
|
35
|
+
} catch {
|
|
36
|
+
// 401: TokenMiddleware already called logout, so sessionId is gone.
|
|
37
|
+
// Any other error leaves sessionId and tokens in place.
|
|
38
|
+
return 'expired';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async signIn(credentials: { email: string; password: string }) {
|
|
43
|
+
const { data: tokens } = await this.api.login(credentials);
|
|
44
|
+
this.store.set('accessToken', tokens.access_token);
|
|
45
|
+
this.store.set('refreshToken', tokens.refresh_token);
|
|
46
|
+
|
|
47
|
+
const profile = await this.fetchProfile();
|
|
48
|
+
const sessionId = String(profile.id);
|
|
49
|
+
|
|
50
|
+
this.sessionStore.set('sessionId', sessionId);
|
|
51
|
+
StorePersistentSessionBased.loadFor(sessionId);
|
|
52
|
+
this.store.set('profile', profile);
|
|
53
|
+
this.store.set('accessToken', tokens.access_token);
|
|
54
|
+
this.store.set('refreshToken', tokens.refresh_token);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
signUp(data: RegisterPayload) {
|
|
58
|
+
return this.api.register(data);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async fetchProfile() {
|
|
62
|
+
const { data } = await this.api.profile();
|
|
63
|
+
this.store.set('profile', data);
|
|
64
|
+
return data;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async refresh() {
|
|
68
|
+
const refreshToken = this.store.getByPath('refreshToken');
|
|
69
|
+
if (!refreshToken) {
|
|
70
|
+
throw new Error('Missing refresh token');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const response = await this.api.refreshToken({ refreshToken });
|
|
74
|
+
const accessToken = response.data?.access_token;
|
|
75
|
+
const nextRefreshToken = response.data?.refresh_token;
|
|
76
|
+
|
|
77
|
+
if (response.status >= 200 && response.status < 300 && accessToken) {
|
|
78
|
+
this.store.set('accessToken', accessToken);
|
|
79
|
+
if (nextRefreshToken) {
|
|
80
|
+
this.store.set('refreshToken', nextRefreshToken);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return response;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
logout() {
|
|
88
|
+
this.store.delete('accessToken');
|
|
89
|
+
this.store.delete('refreshToken');
|
|
90
|
+
this.sessionStore.delete('sessionId');
|
|
91
|
+
StorePersistentSessionBased.destroy();
|
|
92
|
+
this.registry.clear();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { StorePersistent } from '@utils';
|
|
4
|
+
|
|
5
|
+
export type AuthSessionStoreState = {
|
|
6
|
+
sessionId?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
@Entity.Decorators.Store()
|
|
10
|
+
export class AuthSessionStore extends StorePersistent<AuthSessionStoreState> {
|
|
11
|
+
constructor() {
|
|
12
|
+
super({});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { SchemaName } from '@theme/theme';
|
|
4
|
+
import { StorePersistentSessionBased } from '@utils';
|
|
5
|
+
|
|
6
|
+
export type AuthStoreState = {
|
|
7
|
+
accessToken?: string;
|
|
8
|
+
refreshToken?: string;
|
|
9
|
+
profile?: {
|
|
10
|
+
id: number;
|
|
11
|
+
email: string;
|
|
12
|
+
name: string;
|
|
13
|
+
role: string;
|
|
14
|
+
avatar: string;
|
|
15
|
+
};
|
|
16
|
+
theme?: SchemaName;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
@Entity.Decorators.Store()
|
|
20
|
+
export class AuthStore extends StorePersistentSessionBased<AuthStoreState> {}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Entity, EffiJS } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { AuthService } from '@entity/auth/auth.service';
|
|
4
|
+
|
|
5
|
+
@Entity.Decorators.Feature()
|
|
6
|
+
export class AuthFeature {
|
|
7
|
+
constructor(readonly service: AuthService) {}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
EffiJS.createFeature(AuthFeature, 'AuthFeature');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './auth.feature';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { Screen, Form, Button, Grid, Text } from '@components';
|
|
5
|
+
|
|
6
|
+
import { SignInService } from './signIn.service';
|
|
7
|
+
|
|
8
|
+
export default function SignInScreen() {
|
|
9
|
+
const service = Form.useFormService(SignInService, {
|
|
10
|
+
email: 'john@mail.com',
|
|
11
|
+
password: 'changeme',
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<Screen>
|
|
16
|
+
<Screen.Content sa-t sa-b pt-m={Platform.OS === 'android'}>
|
|
17
|
+
<Text display-s color="primary" center mb-l>
|
|
18
|
+
Sign In
|
|
19
|
+
</Text>
|
|
20
|
+
<Grid mh-s mt-l>
|
|
21
|
+
<Form service={service}>
|
|
22
|
+
<Form.Item name="email">
|
|
23
|
+
<Form.Element.Input autoComplete="email" label="Email Address" autoCapitalize="none" />
|
|
24
|
+
</Form.Item>
|
|
25
|
+
<Form.Item name="password">
|
|
26
|
+
<Form.Element.Input autoComplete="password" label="Password" autoCapitalize="none" secure />
|
|
27
|
+
</Form.Item>
|
|
28
|
+
<Button type="filled" color="primary" mt-l onPress={() => service.onSignIn().id('auth.signIn').run()}>
|
|
29
|
+
Sign In
|
|
30
|
+
</Button>
|
|
31
|
+
<Button type="text" color="secondary" mt-s onPress={service.handleSignUp}>
|
|
32
|
+
Don't have an account? Sign Up
|
|
33
|
+
</Button>
|
|
34
|
+
</Form>
|
|
35
|
+
</Grid>
|
|
36
|
+
</Screen.Content>
|
|
37
|
+
</Screen>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { FormStore, Validator, ProcessBuilder as PB, Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { FormError } from '@components/Form/form.error';
|
|
4
|
+
import { AuthService } from '@entity/auth/auth.service';
|
|
5
|
+
import { Navigation } from '@navigation';
|
|
6
|
+
import { HttpError } from '@services/http/http.error';
|
|
7
|
+
|
|
8
|
+
@Validator.Decorators.Options({ skipMissingProperties: true })
|
|
9
|
+
class SignInData extends Validator.WithValidator {
|
|
10
|
+
@Validator.Decorators.IsDefined('Enter email')
|
|
11
|
+
email!: string;
|
|
12
|
+
|
|
13
|
+
@Validator.Decorators.IsDefined('Enter password')
|
|
14
|
+
password!: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Entity.Decorators.Service()
|
|
18
|
+
export class SignInService extends FormStore.FormStoreService<SignInData> {
|
|
19
|
+
constructor(
|
|
20
|
+
private readonly navigation: Navigation,
|
|
21
|
+
private readonly authService: AuthService,
|
|
22
|
+
) {
|
|
23
|
+
super();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
handleSignUp = () => this.navigation.app.goToSignUp();
|
|
27
|
+
|
|
28
|
+
onSignIn = () =>
|
|
29
|
+
PB.process
|
|
30
|
+
.flow(
|
|
31
|
+
PB.step(() => {
|
|
32
|
+
const { error, data } = this.validate((raw, options) => SignInData.validate(raw, options));
|
|
33
|
+
if (error) {
|
|
34
|
+
throw new FormError('Please fill required fields', error);
|
|
35
|
+
}
|
|
36
|
+
return { formData: data };
|
|
37
|
+
}),
|
|
38
|
+
PB.step(async ({ formData }) => {
|
|
39
|
+
await this.authService.signIn(formData);
|
|
40
|
+
this.navigation.tabs.goToTabs();
|
|
41
|
+
}),
|
|
42
|
+
)
|
|
43
|
+
.onError(({ error }) => {
|
|
44
|
+
if (error instanceof HttpError) {
|
|
45
|
+
this.catchFormError(error);
|
|
46
|
+
}
|
|
47
|
+
if (error?.message) {
|
|
48
|
+
this.navigation.widgets.showToast({
|
|
49
|
+
type: 'message',
|
|
50
|
+
title: error?.message,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Linking, Platform } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { Screen, Form, Button, Grid, Text } from '@components';
|
|
5
|
+
import configs from '@configs';
|
|
6
|
+
import { useNavigation } from '@navigation/navigation.hooks';
|
|
7
|
+
|
|
8
|
+
import { SignUpService } from './signUp.service';
|
|
9
|
+
|
|
10
|
+
export default function SignUpScreen() {
|
|
11
|
+
const navigation = useNavigation();
|
|
12
|
+
const service = Form.useFormService(SignUpService, {
|
|
13
|
+
privacy_policy: false,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Screen>
|
|
18
|
+
<Screen.Content sa-t sa-b pt-m={Platform.OS === 'android'}>
|
|
19
|
+
<Text display-s color="primary" center mb-l>
|
|
20
|
+
Sign Up
|
|
21
|
+
</Text>
|
|
22
|
+
<Grid mh-s mb-m>
|
|
23
|
+
<Form service={service}>
|
|
24
|
+
<Form.Item name="name">
|
|
25
|
+
<Form.Element.Input label="Your Name" />
|
|
26
|
+
</Form.Item>
|
|
27
|
+
<Form.Item name="email">
|
|
28
|
+
<Form.Element.Input label="Email" autoCapitalize="none" />
|
|
29
|
+
</Form.Item>
|
|
30
|
+
<Form.Item name="password">
|
|
31
|
+
<Form.Element.Input label="Password" autoCapitalize="none" secure />
|
|
32
|
+
</Form.Item>
|
|
33
|
+
<Form.Item name="confirm_password">
|
|
34
|
+
<Form.Element.Input label="Confirm Password" autoCapitalize="none" secure />
|
|
35
|
+
</Form.Item>
|
|
36
|
+
<Form.Item name="privacy_policy">
|
|
37
|
+
<Form.Element.Checkbox
|
|
38
|
+
type="text"
|
|
39
|
+
label={
|
|
40
|
+
<Text>
|
|
41
|
+
I agree to the{' '}
|
|
42
|
+
<Text underline color="outline" onPress={() => Linking.openURL(configs.PRIVACY_URL)}>
|
|
43
|
+
Privacy Policy
|
|
44
|
+
</Text>{' '}
|
|
45
|
+
and{' '}
|
|
46
|
+
<Text underline color="outline" onPress={() => Linking.openURL(configs.TERMS_URL)}>
|
|
47
|
+
Terms of Use
|
|
48
|
+
</Text>
|
|
49
|
+
</Text>
|
|
50
|
+
}
|
|
51
|
+
/>
|
|
52
|
+
</Form.Item>
|
|
53
|
+
<Button type="filled" color="primary" onPress={() => service.signUp().id('auth.signUp').run()}>
|
|
54
|
+
Create Account
|
|
55
|
+
</Button>
|
|
56
|
+
<Button type="text" color="secondary" mt-xs onPress={navigation.app.goToSignIn}>
|
|
57
|
+
Already have an account? Sign In
|
|
58
|
+
</Button>
|
|
59
|
+
</Form>
|
|
60
|
+
</Grid>
|
|
61
|
+
</Screen.Content>
|
|
62
|
+
</Screen>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { FormStore, Validator, ProcessBuilder as PB, Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { FormError } from '@components/Form/form.error';
|
|
4
|
+
import { AuthService } from '@entity/auth/auth.service';
|
|
5
|
+
import { Navigation } from '@navigation';
|
|
6
|
+
import { HttpError } from '@services/http/http.error';
|
|
7
|
+
|
|
8
|
+
@Validator.Decorators.Options({ skipMissingProperties: true })
|
|
9
|
+
class SignUpData extends Validator.WithValidator {
|
|
10
|
+
@Validator.Decorators.IsDefined('Enter name')
|
|
11
|
+
name!: string;
|
|
12
|
+
|
|
13
|
+
@Validator.Decorators.IsDefined('Enter email')
|
|
14
|
+
email!: string;
|
|
15
|
+
|
|
16
|
+
@Validator.Decorators.IsDefined('Enter password')
|
|
17
|
+
password!: string;
|
|
18
|
+
|
|
19
|
+
@Validator.Decorators.IsDefined('Enter confirm password')
|
|
20
|
+
@Validator.Decorators.Validator((value, data) => value === data.password, 'Passwords do not match')
|
|
21
|
+
confirm_password!: string;
|
|
22
|
+
|
|
23
|
+
@Validator.Decorators.Validator(value => value === true, 'Accept privacy policy')
|
|
24
|
+
privacy_policy!: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@Entity.Decorators.Service()
|
|
28
|
+
export class SignUpService extends FormStore.FormStoreService<SignUpData> {
|
|
29
|
+
constructor(
|
|
30
|
+
private readonly navigation: Navigation,
|
|
31
|
+
private readonly authService: AuthService,
|
|
32
|
+
) {
|
|
33
|
+
super();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
signUp = () =>
|
|
37
|
+
PB.process
|
|
38
|
+
.flow(
|
|
39
|
+
PB.step(() => {
|
|
40
|
+
const { error, data } = this.validate((raw, options) => SignUpData.validate(raw, options));
|
|
41
|
+
if (error) {
|
|
42
|
+
throw new FormError('Please fill required fields', error);
|
|
43
|
+
}
|
|
44
|
+
return { formData: data };
|
|
45
|
+
}),
|
|
46
|
+
PB.step(async ({ formData }) => {
|
|
47
|
+
await this.authService.signUp({
|
|
48
|
+
name: formData.name,
|
|
49
|
+
email: formData.email,
|
|
50
|
+
password: formData.password,
|
|
51
|
+
avatar: 'https://picsum.photos/800',
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
await this.authService.signIn({
|
|
55
|
+
email: formData.email,
|
|
56
|
+
password: formData.password,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
this.navigation.tabs.goToTabs();
|
|
60
|
+
}),
|
|
61
|
+
)
|
|
62
|
+
.onError(({ error }) => {
|
|
63
|
+
if (error instanceof HttpError) {
|
|
64
|
+
this.catchFormError(error);
|
|
65
|
+
}
|
|
66
|
+
if (error?.message) {
|
|
67
|
+
this.navigation.widgets.showToast({
|
|
68
|
+
type: 'message',
|
|
69
|
+
title: error?.message,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|