@effijs/templates 0.0.0-stage → 1.0.0-alpha.1
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,12 @@
|
|
|
1
|
+
import { addPrompts, runAdd } from './run.js';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
description: 'Install a ready-made component, service, or utility',
|
|
5
|
+
prompts: addPrompts(),
|
|
6
|
+
actions: [
|
|
7
|
+
{
|
|
8
|
+
type: 'custom',
|
|
9
|
+
action: (data, forge) => runAdd(data, forge),
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { resolveRange } from '../../../../lib/compat.js';
|
|
2
|
+
import { writeSummary } from '../../../../lib/journal.js';
|
|
3
|
+
import { packageRoot } from '../../../../lib/paths.js';
|
|
4
|
+
import { detectPackageManager, detectReactNativeVersion, projectRoot } from '../../../../lib/project.js';
|
|
5
|
+
import { expandRequires, filterByPlatform, isInstalled, loadSolutions } from '../../../../lib/registry.js';
|
|
6
|
+
import platform from '../../platform.js';
|
|
7
|
+
import { isDry } from '../../runtime.js';
|
|
8
|
+
import { installSolution } from '../../solutions/install.js';
|
|
9
|
+
|
|
10
|
+
export function addPrompts(type) {
|
|
11
|
+
return async (forge) => {
|
|
12
|
+
const solutions = filterByPlatform(await loadSolutions(packageRoot()), platform.id)
|
|
13
|
+
.filter((solution) => !type || solution.type === type);
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
type: 'list',
|
|
17
|
+
name: 'id',
|
|
18
|
+
message: type === 'util' ? 'Utility:' : 'Solution:',
|
|
19
|
+
choices: solutions.map((solution) => ({
|
|
20
|
+
name: `${solution.title} — ${solution.description}`,
|
|
21
|
+
value: solution.id,
|
|
22
|
+
})),
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function runAdd(data, forge, type) {
|
|
29
|
+
if (!data.id) return { success: false, error: 'Pass --id, for example component:BottomSheet' };
|
|
30
|
+
const root = projectRoot(forge);
|
|
31
|
+
const all = filterByPlatform(await loadSolutions(packageRoot()), platform.id);
|
|
32
|
+
const target = all.find((solution) => solution.id === data.id);
|
|
33
|
+
if (!target) return { success: false, error: `Unknown solution "${data.id}"` };
|
|
34
|
+
if (type && target.type !== type) return { success: false, error: `${data.id} is not a ${type}` };
|
|
35
|
+
let selected;
|
|
36
|
+
try {
|
|
37
|
+
selected = expandRequires([data.id], all);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
return { success: false, error: error.message };
|
|
40
|
+
}
|
|
41
|
+
const version = detectReactNativeVersion(root);
|
|
42
|
+
const compat = version ? resolveRange(version, platform.matrix).entry : platform.matrix.at(-1);
|
|
43
|
+
const dryRun = isDry(data, forge);
|
|
44
|
+
const force = Boolean(data.force || forge.runOptions?.force);
|
|
45
|
+
const notes = [];
|
|
46
|
+
for (const solution of selected) {
|
|
47
|
+
if (!force && (await isInstalled(root, solution))) {
|
|
48
|
+
notes.push(`Skipped ${solution.id} (already installed)`);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const result = await installSolution(solution, {
|
|
52
|
+
forge,
|
|
53
|
+
outputDir: forge.resolveOutputDir(type === 'util' ? 'rn-fsd:util' : 'rn-fsd:add'),
|
|
54
|
+
dryRun,
|
|
55
|
+
force,
|
|
56
|
+
compat,
|
|
57
|
+
packageManager: data.packageManager || forge.config.packageManager || detectPackageManager(root),
|
|
58
|
+
});
|
|
59
|
+
if (!result.success) return result;
|
|
60
|
+
notes.push(`Installed ${solution.id}`, ...result.notes);
|
|
61
|
+
}
|
|
62
|
+
await writeSummary(root, { generator: type === 'util' ? 'util' : 'add', name: data.id, lines: notes, dryRun });
|
|
63
|
+
return { success: true };
|
|
64
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { writeSummary } from '../../../../lib/journal.js';
|
|
2
|
+
import { projectRoot } from '../../../../lib/project.js';
|
|
3
|
+
import { isDry } from '../../runtime.js';
|
|
4
|
+
import { componentPrompts, prepareComponent } from './render.js';
|
|
5
|
+
|
|
6
|
+
const uiOnly = (data) => data.location !== 'ui';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
description: 'Add a props-manager component (Common, pm, types, index)',
|
|
10
|
+
prompts: componentPrompts,
|
|
11
|
+
actions: [
|
|
12
|
+
{
|
|
13
|
+
type: 'custom',
|
|
14
|
+
action(data) {
|
|
15
|
+
const error = prepareComponent(data);
|
|
16
|
+
if (error) return { success: false, error };
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: 'add',
|
|
21
|
+
path: '{{folder}}/Common.tsx',
|
|
22
|
+
templateFile: 'component/templates/Common.tsx.hbs',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: 'add',
|
|
26
|
+
path: '{{folder}}/{{names.kebab}}.pm.ts',
|
|
27
|
+
templateFile: 'component/templates/pm.ts.hbs',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: 'add',
|
|
31
|
+
path: '{{folder}}/{{names.kebab}}.types.ts',
|
|
32
|
+
templateFile: 'component/templates/types.ts.hbs',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: 'add',
|
|
36
|
+
path: '{{folder}}/index.ts',
|
|
37
|
+
templateFile: 'component/templates/index.ts.hbs',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: 'append',
|
|
41
|
+
path: 'ui/components/index.ts',
|
|
42
|
+
pattern: /\/\/ forge:components-import$/m,
|
|
43
|
+
before: true,
|
|
44
|
+
unique: true,
|
|
45
|
+
template: "import {{names.pascal}} from './{{names.pascal}}';\n",
|
|
46
|
+
skip: uiOnly,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: 'append',
|
|
50
|
+
path: 'ui/components/index.ts',
|
|
51
|
+
pattern: / \/\/ forge:components-export$/m,
|
|
52
|
+
before: true,
|
|
53
|
+
unique: true,
|
|
54
|
+
template: ' {{names.pascal}},\n',
|
|
55
|
+
skip: uiOnly,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: 'custom',
|
|
59
|
+
action: async (data, forge) => {
|
|
60
|
+
await writeSummary(projectRoot(forge), {
|
|
61
|
+
generator: 'component',
|
|
62
|
+
name: data.name,
|
|
63
|
+
lines: [
|
|
64
|
+
`Created ${data.folder}`,
|
|
65
|
+
`Base: ${data.base}`,
|
|
66
|
+
`Extends: ${data.extend}`,
|
|
67
|
+
`Slots: ${data.slots.join(', ')}`,
|
|
68
|
+
],
|
|
69
|
+
dryRun: isDry(data, forge),
|
|
70
|
+
});
|
|
71
|
+
return { success: true };
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
|
|
3
|
+
import { namesOf } from '../../../../lib/names.js';
|
|
4
|
+
import { listDirs } from '../../../../lib/project.js';
|
|
5
|
+
|
|
6
|
+
const BASES = ['View', 'Pressable', 'Text'];
|
|
7
|
+
const EXTENDS = ['Box', 'Grid', 'Text', 'none'];
|
|
8
|
+
|
|
9
|
+
export function componentPrompts(forge) {
|
|
10
|
+
const features = listDirs(path.join(forge.resolveOutputDir('rn-fsd:component'), 'feature'));
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
type: 'input',
|
|
14
|
+
name: 'name',
|
|
15
|
+
message: 'Component name:',
|
|
16
|
+
validate: (input) => (input?.trim() ? true : 'Component name is required'),
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: 'list',
|
|
20
|
+
name: 'base',
|
|
21
|
+
message: 'Base element:',
|
|
22
|
+
choices: BASES,
|
|
23
|
+
default: 'View',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: 'list',
|
|
27
|
+
name: 'extend',
|
|
28
|
+
message: 'Extend a props-manager node:',
|
|
29
|
+
choices: EXTENDS,
|
|
30
|
+
default: 'Grid',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: 'input',
|
|
34
|
+
name: 'slots',
|
|
35
|
+
message: 'Slots (comma-separated):',
|
|
36
|
+
default: 'container',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: 'list',
|
|
40
|
+
name: 'location',
|
|
41
|
+
message: 'Location:',
|
|
42
|
+
choices: [
|
|
43
|
+
{ name: 'ui/components', value: 'ui' },
|
|
44
|
+
...features.map((feature) => ({ name: `feature/${feature}/components`, value: feature })),
|
|
45
|
+
],
|
|
46
|
+
default: 'ui',
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function prepareComponent(data) {
|
|
52
|
+
if (!data.name || !String(data.name).trim()) return 'Component name is required. Pass --name.';
|
|
53
|
+
if (!BASES.includes(data.base)) return `Base must be one of ${BASES.join(', ')}`;
|
|
54
|
+
if (!EXTENDS.includes(data.extend)) return `Extend must be one of ${EXTENDS.join(', ')}`;
|
|
55
|
+
const slots = Array.isArray(data.slots)
|
|
56
|
+
? data.slots.map((slot) => String(slot).trim()).filter(Boolean)
|
|
57
|
+
: String(data.slots ?? '').split(',').map((slot) => slot.trim()).filter(Boolean);
|
|
58
|
+
data.slots = slots.length ? slots : ['container'];
|
|
59
|
+
data.names = namesOf(data.name);
|
|
60
|
+
data.primary = data.slots[0];
|
|
61
|
+
data.rnImport = data.base === 'Text' ? 'Text as RNText' : data.base;
|
|
62
|
+
data.tag = data.base === 'Text' ? 'RNText' : data.base;
|
|
63
|
+
data.jsxOpen = `<${data.tag} {...slots.${data.primary}}>`;
|
|
64
|
+
data.jsxClose = `</${data.tag}>`;
|
|
65
|
+
data.folder = data.location === 'ui'
|
|
66
|
+
? `ui/components/${data.names.pascal}`
|
|
67
|
+
: `feature/${data.location}/components/${data.names.pascal}`;
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { {{rnImport}}, type {{base}}Props } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { useTheme } from '@theme';
|
|
5
|
+
|
|
6
|
+
import { {{names.pascal}}PM } from './{{names.kebab}}.pm';
|
|
7
|
+
import type { T{{names.pascal}}Props } from './{{names.kebab}}.types';
|
|
8
|
+
|
|
9
|
+
export default function {{names.pascal}}Common({ children, ...commonProps }: T{{names.pascal}}Props & {{base}}Props) {
|
|
10
|
+
const theme = useTheme();
|
|
11
|
+
const slots = {{names.pascal}}PM.get({ theme, ...commonProps } as Record<string, unknown>);
|
|
12
|
+
return {{{jsxOpen}}}{children}{{{jsxClose}}};
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Common from './Common';
|
|
2
|
+
import { {{names.pascal}}PM } from './{{names.kebab}}.pm';
|
|
3
|
+
|
|
4
|
+
type TCommon = typeof Common;
|
|
5
|
+
|
|
6
|
+
interface I{{names.pascal}} extends TCommon {
|
|
7
|
+
PM: typeof {{names.pascal}}PM;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const {{names.pascal}} = Common as I{{names.pascal}};
|
|
11
|
+
{{names.pascal}}.PM = {{names.pascal}}PM;
|
|
12
|
+
|
|
13
|
+
export default {{names.pascal}};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Node, Prop, PropertyManager } from '@effijs/props-manager';
|
|
2
|
+
|
|
3
|
+
export const {{names.pascal}}PM = PropertyManager.create('{{names.pascal}}'){{#each slots}}.node(
|
|
4
|
+
Node('{{this}}'){{#if (eq this ../primary)}}{{#unless (eq ../extend "none")}}
|
|
5
|
+
.extends('{{../extend}}'){{/unless}}{{/if}}
|
|
6
|
+
.keys(Prop('style', ({ style }) => style)),
|
|
7
|
+
){{/each}};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
### Get Products
|
|
2
|
+
HEAD {{api}}/products
|
|
3
|
+
Content-Type: application/json
|
|
4
|
+
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEsImlhdCI6MTc4OTA2MDMxNSwiZXhwIjoxNzkwNzg4MzE1fQ.y3eTFrMKw8dvGvMVbywbsuATtuTx6l1z_yH2-15iyhw
|
|
5
|
+
|
|
6
|
+
> {%
|
|
7
|
+
console.log('LENGTH', response.body.length)
|
|
8
|
+
%}}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { HttpBase } from '@services/http/http.base';
|
|
4
|
+
|
|
5
|
+
import { CategoryData } from './category.dto';
|
|
6
|
+
|
|
7
|
+
@Entity.Decorators.ApiService()
|
|
8
|
+
export class CategoryApi extends HttpBase {
|
|
9
|
+
protected url = 'categories';
|
|
10
|
+
|
|
11
|
+
list = (options?: { signal?: AbortSignal }) =>
|
|
12
|
+
this.request(
|
|
13
|
+
{ url: '', method: 'get', signal: options?.signal },
|
|
14
|
+
{
|
|
15
|
+
response: raw => (Array.isArray(raw) ? raw.map(item => CategoryData.transform(item)) : []),
|
|
16
|
+
},
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Transform } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
export class CategoryData extends Transform.WithTransform {
|
|
4
|
+
@Transform.Decorators.Property()
|
|
5
|
+
id!: number;
|
|
6
|
+
|
|
7
|
+
@Transform.Decorators.Property()
|
|
8
|
+
name!: string;
|
|
9
|
+
|
|
10
|
+
@Transform.Decorators.Property()
|
|
11
|
+
slug!: string;
|
|
12
|
+
|
|
13
|
+
@Transform.Decorators.Property()
|
|
14
|
+
image!: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { CategoryApi } from './category.api';
|
|
4
|
+
import { CategoryData } from './category.dto';
|
|
5
|
+
import { CategoryStore } from './category.store';
|
|
6
|
+
|
|
7
|
+
const ENTITY_KEY = 'category';
|
|
8
|
+
|
|
9
|
+
@Entity.Decorators.Service()
|
|
10
|
+
export class CategoryService {
|
|
11
|
+
constructor(
|
|
12
|
+
private api: CategoryApi,
|
|
13
|
+
readonly store: CategoryStore,
|
|
14
|
+
) {}
|
|
15
|
+
|
|
16
|
+
getById = (id: string | number) => this.store.getByPath(`${ENTITY_KEY}.${String(id)}`) as CategoryData | undefined;
|
|
17
|
+
|
|
18
|
+
getListIds = () => (this.store.getByPath('ids.list') as string[] | undefined) ?? [];
|
|
19
|
+
|
|
20
|
+
getListData = () =>
|
|
21
|
+
this.getListIds()
|
|
22
|
+
.map(id => this.getById(id))
|
|
23
|
+
.filter(Boolean) as CategoryData[];
|
|
24
|
+
|
|
25
|
+
upsertToStore = (data: CategoryData) => {
|
|
26
|
+
this.store.set(`${ENTITY_KEY}.${String(data.id)}`, data);
|
|
27
|
+
return data;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
async fetchList(options?: { signal?: AbortSignal }) {
|
|
31
|
+
const { data } = await this.api.list({ signal: options?.signal });
|
|
32
|
+
const ids: string[] = [];
|
|
33
|
+
|
|
34
|
+
for (const item of data) {
|
|
35
|
+
this.upsertToStore(item);
|
|
36
|
+
ids.push(String(item.id));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.store.set('ids.list', ids);
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Entity, Store } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { StoreRegistry } from '@utils';
|
|
4
|
+
|
|
5
|
+
import { CategoryData } from './category.dto';
|
|
6
|
+
|
|
7
|
+
export type CategoryStoreState = {
|
|
8
|
+
category: Record<string, CategoryData>;
|
|
9
|
+
ids: {
|
|
10
|
+
list: string[];
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
@Entity.Decorators.Store()
|
|
15
|
+
export class CategoryStore extends Store.Common<CategoryStoreState> {
|
|
16
|
+
constructor(private registry: StoreRegistry) {
|
|
17
|
+
super({
|
|
18
|
+
category: {},
|
|
19
|
+
ids: {
|
|
20
|
+
list: [],
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
registry.register(this);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Entity } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { HttpBase } from '@services/http/http.base';
|
|
4
|
+
|
|
5
|
+
import { ProductCreatePayload, ProductData, ProductListQueryParams, ProductUpdatePayload } from './product.dto';
|
|
6
|
+
|
|
7
|
+
@Entity.Decorators.ApiService()
|
|
8
|
+
export class ProductApi extends HttpBase {
|
|
9
|
+
protected url = 'products';
|
|
10
|
+
|
|
11
|
+
list = (
|
|
12
|
+
params?: Partial<ProductListQueryParams>,
|
|
13
|
+
options?: {
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
},
|
|
16
|
+
) =>
|
|
17
|
+
this.request(
|
|
18
|
+
{
|
|
19
|
+
url: '',
|
|
20
|
+
method: 'get',
|
|
21
|
+
params,
|
|
22
|
+
signal: options?.signal,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
params: raw => ProductListQueryParams.transform(raw).toQueryParams(),
|
|
26
|
+
response: raw => (Array.isArray(raw) ? raw.map(item => ProductData.transform(item)) : []),
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
getById = (id: string, options?: { signal?: AbortSignal }) =>
|
|
31
|
+
this.request({ url: id, method: 'get', signal: options?.signal }, { response: raw => ProductData.transform(raw) });
|
|
32
|
+
|
|
33
|
+
create = (payload: ProductCreatePayload, options?: { signal?: AbortSignal }) =>
|
|
34
|
+
this.request(
|
|
35
|
+
{ url: '', method: 'post', data: payload, signal: options?.signal },
|
|
36
|
+
{
|
|
37
|
+
data: raw => ProductCreatePayload.transform(raw),
|
|
38
|
+
response: raw => ProductData.transform(raw),
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
update = (payload: ProductUpdatePayload, options?: { signal?: AbortSignal }) =>
|
|
43
|
+
this.request(
|
|
44
|
+
{ url: `${payload.id}`, method: 'put', data: payload, signal: options?.signal },
|
|
45
|
+
{ data: raw => ProductUpdatePayload.transform(raw), response: raw => ProductData.transform(raw) },
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
delete = (id: string | number) => this.request({ url: `${id}`, method: 'delete' });
|
|
49
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Transform } from '@effijs/common';
|
|
2
|
+
|
|
3
|
+
import { CategoryData } from '@entity/category/category.dto';
|
|
4
|
+
|
|
5
|
+
export class ProductData extends Transform.WithTransform {
|
|
6
|
+
@Transform.Decorators.Property()
|
|
7
|
+
id!: number;
|
|
8
|
+
|
|
9
|
+
@Transform.Decorators.Property()
|
|
10
|
+
title!: string;
|
|
11
|
+
|
|
12
|
+
@Transform.Decorators.Property()
|
|
13
|
+
slug!: string;
|
|
14
|
+
|
|
15
|
+
@Transform.Decorators.Property()
|
|
16
|
+
price!: number;
|
|
17
|
+
|
|
18
|
+
@Transform.Decorators.Property()
|
|
19
|
+
description!: string;
|
|
20
|
+
|
|
21
|
+
@Transform.Decorators.Property()
|
|
22
|
+
@Transform.Decorators.Type(String)
|
|
23
|
+
images!: string[];
|
|
24
|
+
|
|
25
|
+
@Transform.Decorators.Property()
|
|
26
|
+
@Transform.Decorators.Type(CategoryData)
|
|
27
|
+
category!: CategoryData;
|
|
28
|
+
|
|
29
|
+
@Transform.Decorators.Property()
|
|
30
|
+
creationAt!: string;
|
|
31
|
+
|
|
32
|
+
@Transform.Decorators.Property()
|
|
33
|
+
updatedAt!: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// export type ProductListQuery = {
|
|
37
|
+
// title?: string;
|
|
38
|
+
// price?: number;
|
|
39
|
+
// price_min?: number;
|
|
40
|
+
// price_max?: number;
|
|
41
|
+
// categoryId?: number;
|
|
42
|
+
// };
|
|
43
|
+
|
|
44
|
+
export class ProductListQuery extends Transform.WithTransform {
|
|
45
|
+
@Transform.Decorators.Property()
|
|
46
|
+
@Transform.Decorators.Modify(value => value?.trim())
|
|
47
|
+
title?: string;
|
|
48
|
+
|
|
49
|
+
@Transform.Decorators.Property()
|
|
50
|
+
price?: number;
|
|
51
|
+
|
|
52
|
+
@Transform.Decorators.Property()
|
|
53
|
+
price_min?: number;
|
|
54
|
+
|
|
55
|
+
@Transform.Decorators.Property()
|
|
56
|
+
price_max?: number;
|
|
57
|
+
|
|
58
|
+
@Transform.Decorators.Property()
|
|
59
|
+
categoryId?: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class ProductListQueryParams extends Transform.WithTransform {
|
|
63
|
+
@Transform.Decorators.Property()
|
|
64
|
+
offset?: number;
|
|
65
|
+
|
|
66
|
+
@Transform.Decorators.Property()
|
|
67
|
+
limit?: number;
|
|
68
|
+
|
|
69
|
+
@Transform.Decorators.Property()
|
|
70
|
+
title?: string;
|
|
71
|
+
|
|
72
|
+
@Transform.Decorators.Property()
|
|
73
|
+
price?: number;
|
|
74
|
+
|
|
75
|
+
@Transform.Decorators.Property()
|
|
76
|
+
price_min?: number;
|
|
77
|
+
|
|
78
|
+
@Transform.Decorators.Property()
|
|
79
|
+
price_max?: number;
|
|
80
|
+
|
|
81
|
+
@Transform.Decorators.Property()
|
|
82
|
+
categoryId?: number;
|
|
83
|
+
|
|
84
|
+
toQueryParams(): Record<string, string> {
|
|
85
|
+
const params: Record<string, string> = {};
|
|
86
|
+
if (this.offset !== undefined) params.offset = String(this.offset);
|
|
87
|
+
if (this.limit !== undefined) params.limit = String(this.limit);
|
|
88
|
+
if (this.title) params.title = this.title;
|
|
89
|
+
if (this.price !== undefined) params.price = String(this.price);
|
|
90
|
+
if (this.price_min !== undefined) params.price_min = String(this.price_min);
|
|
91
|
+
if (this.price_max !== undefined) params.price_max = String(this.price_max);
|
|
92
|
+
if (this.categoryId !== undefined) params.categoryId = String(this.categoryId);
|
|
93
|
+
return params;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export class ProductCreatePayload extends Transform.WithTransform {
|
|
98
|
+
@Transform.Decorators.Property()
|
|
99
|
+
title!: string;
|
|
100
|
+
|
|
101
|
+
@Transform.Decorators.Property()
|
|
102
|
+
@Transform.Decorators.Modify((v: unknown) => Number(v))
|
|
103
|
+
price!: number;
|
|
104
|
+
|
|
105
|
+
@Transform.Decorators.Property()
|
|
106
|
+
description!: string;
|
|
107
|
+
|
|
108
|
+
@Transform.Decorators.Property()
|
|
109
|
+
@Transform.Decorators.Modify((v: unknown) => Number(v))
|
|
110
|
+
categoryId!: number;
|
|
111
|
+
|
|
112
|
+
@Transform.Decorators.Property()
|
|
113
|
+
images!: string[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export class ProductUpdatePayload extends ProductCreatePayload {
|
|
117
|
+
@Transform.Decorators.Property()
|
|
118
|
+
@Transform.Decorators.Modify((v: unknown) => Number(v))
|
|
119
|
+
id!: number;
|
|
120
|
+
}
|