@oyolincc/create 0.4.0 → 0.5.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/package.json +2 -2
- package/templates/hono-fullstack/.codegraph/.gitignore +5 -0
- package/templates/hono-fullstack/README.md +22 -1
- package/templates/hono-fullstack/_gitignore +1 -0
- package/templates/hono-fullstack/apps/server/package.json +7 -2
- package/templates/hono-fullstack/apps/server/src/adapters/cloudflare/entry.ts +4 -30
- package/templates/hono-fullstack/apps/server/src/adapters/nodejs/bootstrap.ts +20 -12
- package/templates/hono-fullstack/apps/server/src/adapters/nodejs/entry.ts +7 -57
- package/templates/hono-fullstack/apps/server/src/app.ts +37 -21
- package/templates/hono-fullstack/apps/server/src/config.ts +1 -1
- package/templates/hono-fullstack/apps/server/src/di-container.ts +51 -0
- package/templates/hono-fullstack/apps/server/src/infra/logger/getter.ts +1 -1
- package/templates/hono-fullstack/apps/server/src/infra/logger/pino.ts +21 -34
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/errors.ts +22 -0
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/pass-through/runner.ts +28 -22
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/piscina/runner.ts +11 -34
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/{example → piscina}/worker-entry.ts +6 -2
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/types.ts +2 -16
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/utils/business-error.ts +10 -5
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/utils/message.ts +5 -17
- package/templates/hono-fullstack/apps/server/src/middlewares/cors.ts +16 -22
- package/templates/hono-fullstack/apps/server/src/middlewares/logger.ts +34 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/module.ts +8 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/queries.ts +8 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/routes.ts +74 -68
- package/templates/hono-fullstack/apps/server/src/modules/example/service.test.ts +53 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/service.ts +54 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/types.ts +12 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/work-task/tasks.test.ts +9 -35
- package/templates/hono-fullstack/apps/server/src/modules/example/work-task/tasks.ts +15 -46
- package/templates/hono-fullstack/apps/server/src/shared/errors/defs/index.ts +6 -1
- package/templates/hono-fullstack/apps/server/src/shared/errors/handler.ts +1 -1
- package/templates/hono-fullstack/apps/server/src/shared/network/openapi/index.ts +1 -1
- package/templates/hono-fullstack/apps/server/src/shared/types/app.ts +51 -0
- package/templates/hono-fullstack/apps/server/src/shared/types/db.ts +126 -0
- package/templates/hono-fullstack/apps/server/src/shared/utils/data-access/check.ts +19 -0
- package/templates/hono-fullstack/apps/server/src/shared/utils/data-access/model.ts +47 -0
- package/templates/hono-fullstack/apps/server/src/shared/utils/data-access/params.ts +105 -0
- package/templates/hono-fullstack/apps/server/src/shared/utils/data-access/query.test.ts +139 -0
- package/templates/hono-fullstack/apps/server/src/shared/utils/data-access/query.ts +236 -0
- package/templates/hono-fullstack/apps/server/vite.config.ts +2 -2
- package/templates/hono-fullstack/apps/server/wrangler.jsonc +1 -1
- package/templates/hono-fullstack/apps/stack/frontend/assets/styles.css +6 -0
- package/templates/hono-fullstack/apps/stack/frontend/components/general/ErrorMessage.tsx +3 -1
- package/templates/hono-fullstack/apps/stack/frontend/components/layouts/AppLayout.tsx +2 -1
- package/templates/hono-fullstack/apps/stack/frontend/components/layouts/Header.tsx +14 -2
- package/templates/hono-fullstack/apps/stack/frontend/components/layouts/Page.tsx +2 -1
- package/templates/hono-fullstack/apps/stack/frontend/components/layouts/PageContainer.tsx +4 -1
- package/templates/hono-fullstack/apps/stack/frontend/modules/example/api.ts +16 -9
- package/templates/hono-fullstack/apps/stack/frontend/modules/example/components/ExampleForm.tsx +25 -12
- package/templates/hono-fullstack/apps/stack/frontend/modules/example/components/ExampleList.tsx +13 -4
- package/templates/hono-fullstack/apps/stack/frontend/modules/example/hooks/api-hooks.ts +3 -3
- package/templates/hono-fullstack/apps/stack/frontend/routes/__root.tsx +1 -1
- package/templates/hono-fullstack/apps/stack/frontend/routes/index.tsx +16 -4
- package/templates/hono-fullstack/apps/stack/package.json +9 -4
- package/templates/hono-fullstack/apps/stack/panda.config.ts +31 -0
- package/templates/hono-fullstack/apps/stack/tsconfig.json +1 -0
- package/templates/hono-fullstack/apps/stack/turbo.json +20 -0
- package/templates/hono-fullstack/apps/stack/vite.config.ts +48 -12
- package/templates/hono-fullstack/apps/stack/wrangler.jsonc +1 -1
- package/templates/hono-fullstack/envs/.env.example.sqlite-d1 +1 -0
- package/templates/hono-fullstack/libs/db/drizzle-kit/sqlite-d1.config.ts +29 -10
- package/templates/hono-fullstack/libs/db/package.json +1 -0
- package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/columns.ts +1 -1
- package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/modules/examples/examples.ts +6 -3
- package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/vo.ts +7 -1
- package/templates/hono-fullstack/libs/definition/README.md +81 -0
- package/templates/hono-fullstack/libs/definition/package.json +3 -1
- package/templates/hono-fullstack/libs/definition/src/constants/index.ts +1 -0
- package/templates/hono-fullstack/libs/definition/src/constants/pagination.ts +3 -0
- package/templates/hono-fullstack/libs/definition/src/modules/common-contracts.ts +24 -0
- package/templates/hono-fullstack/libs/definition/src/modules/example/contracts.ts +34 -0
- package/templates/hono-fullstack/libs/definition/src/modules/example/index.ts +1 -16
- package/templates/hono-fullstack/libs/definition/src/modules/index.ts +2 -0
- package/templates/hono-fullstack/libs/definition/src/modules/vo-generated-types.ts +12 -0
- package/templates/hono-fullstack/libs/ui/.storybook/main.ts +32 -0
- package/templates/hono-fullstack/libs/ui/.storybook/panda.config.ts +22 -0
- package/templates/hono-fullstack/libs/ui/.storybook/preview.tsx +79 -0
- package/templates/hono-fullstack/libs/ui/.storybook/styles.css +1 -0
- package/templates/hono-fullstack/libs/ui/.storybook/vite.config.ts +37 -0
- package/templates/hono-fullstack/libs/ui/components.json +15 -0
- package/templates/hono-fullstack/libs/ui/package.json +114 -0
- package/templates/hono-fullstack/libs/ui/panda.config.ts +41 -0
- package/templates/hono-fullstack/libs/ui/src/Tooltip.tsx +47 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/buttons/Button.tsx +80 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/buttons/CloseButton.tsx +15 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/buttons/IconButton.tsx +10 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/collections/Combobox.tsx +91 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/collections/Select.tsx +88 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/collections/TreeView.tsx +142 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/data-display/Avatar.tsx +64 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/data-display/Badge.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/data-display/Card.tsx +23 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/data-display/Clipboard.tsx +77 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/data-display/Icon.tsx +9 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/data-display/Table.tsx +51 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/data-display/Tag.tsx +23 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/data-display/Timeline.tsx +33 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/date-and-time/DatePicker.tsx +255 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/disclosure/Accordion.tsx +48 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/disclosure/Breadcrumb.tsx +50 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/disclosure/Collapsible.tsx +34 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/disclosure/Pagination.tsx +74 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/disclosure/Steps.tsx +91 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/disclosure/Tabs.tsx +37 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/feedback/Alert.tsx +52 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/feedback/Progress.tsx +41 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/feedback/ProgressCircle.tsx +40 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/feedback/Skeleton.tsx +37 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/feedback/Spinner.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/feedback/Toast.tsx +99 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/Checkbox.tsx +95 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/ColorPicker.tsx +148 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/Editable.tsx +44 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/Field.tsx +36 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/Fieldset.tsx +34 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/FileUpload.tsx +143 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/Input.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/InputAddon.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/InputGroup.tsx +61 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/NativeSelect.tsx +81 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/NumberInput.tsx +63 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/PasswordInput.tsx +76 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/PinInput.tsx +36 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/RadioCard.tsx +96 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/RadioGroup.tsx +61 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/RatingGroup.tsx +106 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/SegmentGroup.tsx +68 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/Slider.tsx +87 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/Switch.tsx +74 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/TagsInput.tsx +77 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/forms/Textarea.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/index.ts +98 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/internal/AbsoluteCenter.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/internal/Loader.tsx +69 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/internal/Span.tsx +5 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/internal/create-layout.ts +18 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/layout/Float.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/layout/Grid.tsx +17 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/layout/Group.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/layout/ScrollArea.tsx +46 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/layout/Separator.tsx +26 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/layout/Stack.tsx +54 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/overlays/Dialog.tsx +69 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/overlays/Drawer.tsx +49 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/overlays/HoverCard.tsx +37 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/overlays/Menu.tsx +74 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/overlays/OverlayManager.test.ts +124 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/overlays/OverlayManager.tsx +189 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/overlays/Popover.tsx +57 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/overlays/Tooltip.tsx +37 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/typography/Heading.tsx +6 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/typography/Link.tsx +7 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/typography/LinkOverlay.tsx +21 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/typography/Text.tsx +6 -0
- package/templates/hono-fullstack/libs/ui/src/components/atoms/utilities/VisuallyHidden.tsx +13 -0
- package/templates/hono-fullstack/libs/ui/src/hooks.ts +242 -0
- package/templates/hono-fullstack/libs/ui/src/index.ts +19 -0
- package/templates/hono-fullstack/libs/ui/src/theme/animation-styles.ts +50 -0
- package/templates/hono-fullstack/libs/ui/src/theme/breakpoints.ts +7 -0
- package/templates/hono-fullstack/libs/ui/src/theme/conditions.ts +12 -0
- package/templates/hono-fullstack/libs/ui/src/theme/containers.ts +16 -0
- package/templates/hono-fullstack/libs/ui/src/theme/global-css.ts +12 -0
- package/templates/hono-fullstack/libs/ui/src/theme/keyframes.ts +157 -0
- package/templates/hono-fullstack/libs/ui/src/theme/layer-styles.ts +11 -0
- package/templates/hono-fullstack/libs/ui/src/theme/patterns/grid.ts +51 -0
- package/templates/hono-fullstack/libs/ui/src/theme/patterns/index.ts +60 -0
- package/templates/hono-fullstack/libs/ui/src/theme/patterns/stack.ts +46 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/absolute-center.ts +38 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/accordion.ts +68 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/alert.ts +83 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/avatar.ts +155 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/badge.ts +67 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/breadcrumb.ts +69 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/button.ts +149 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/card.ts +36 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/checkbox.ts +120 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/clipboard.ts +22 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/collapsible.ts +26 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/color-picker.ts +299 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/combobox.ts +141 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/date-picker.ts +302 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/dialog.ts +191 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/drawer.ts +170 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/editable.ts +64 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/field.ts +41 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/fieldset.ts +47 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/file-upload.ts +86 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/group.ts +78 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/heading.ts +24 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/hover-card.ts +47 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/icon.ts +25 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/index.ts +120 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/input-addon.ts +51 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/input-group.ts +77 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/input.ts +99 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/link.ts +36 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/menu.ts +114 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/native-select.ts +92 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/number-input.ts +91 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/pagination.ts +9 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/pin-input.ts +33 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/popover.ts +78 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/progress-circle.ts +50 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/progress.ts +112 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/radio-card.ts +223 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/radio-group.ts +78 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/rating-group.ts +98 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/scroll-area.ts +119 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/segment-group.ts +162 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/select.ts +157 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/separator.ts +25 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/skeleton.ts +65 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/slider.ts +164 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/spinner.ts +34 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/steps.ts +162 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/switch.ts +150 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/table.ts +150 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/tabs.ts +128 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/tag.ts +114 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/tags-input.ts +201 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/text.ts +7 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/textarea.ts +90 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/timeline.ts +137 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/toast.ts +52 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/tooltip.ts +44 -0
- package/templates/hono-fullstack/libs/ui/src/theme/recipes/tree-view.ts +200 -0
- package/templates/hono-fullstack/libs/ui/src/theme/semanticTokens/colors/amber.ts +91 -0
- package/templates/hono-fullstack/libs/ui/src/theme/semanticTokens/colors/gray.ts +103 -0
- package/templates/hono-fullstack/libs/ui/src/theme/semanticTokens/colors/green.ts +88 -0
- package/templates/hono-fullstack/libs/ui/src/theme/semanticTokens/colors/index.ts +14 -0
- package/templates/hono-fullstack/libs/ui/src/theme/semanticTokens/colors/lime.ts +91 -0
- package/templates/hono-fullstack/libs/ui/src/theme/semanticTokens/colors/red.ts +88 -0
- package/templates/hono-fullstack/libs/ui/src/theme/semanticTokens/index.ts +8 -0
- package/templates/hono-fullstack/libs/ui/src/theme/semanticTokens/shadows.ts +46 -0
- package/templates/hono-fullstack/libs/ui/src/theme/text-styles.ts +82 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/animations.ts +8 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/aspect-ratio.ts +6 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/borders.ts +5 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/colors.ts +35 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/durations.ts +11 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/easings.ts +9 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/index.ts +42 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/radii.ts +13 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/sizes.ts +27 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/spacing.ts +41 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/typography.ts +86 -0
- package/templates/hono-fullstack/libs/ui/src/theme/tokens/z-index.ts +43 -0
- package/templates/hono-fullstack/libs/ui/stories/README.md +107 -0
- package/templates/hono-fullstack/libs/ui/stories/actions/Button.stories.tsx +260 -0
- package/templates/hono-fullstack/libs/ui/stories/actions/Clipboard.stories.tsx +87 -0
- package/templates/hono-fullstack/libs/ui/stories/actions/IconButton.stories.tsx +33 -0
- package/templates/hono-fullstack/libs/ui/stories/collections/Combobox.stories.tsx +334 -0
- package/templates/hono-fullstack/libs/ui/stories/collections/Select.stories.tsx +342 -0
- package/templates/hono-fullstack/libs/ui/stories/collections/TreeView.stories.tsx +252 -0
- package/templates/hono-fullstack/libs/ui/stories/color/ColorPicker.stories.tsx +217 -0
- package/templates/hono-fullstack/libs/ui/stories/date/DatePicker.stories.tsx +302 -0
- package/templates/hono-fullstack/libs/ui/stories/disclosure/Accordion.stories.tsx +105 -0
- package/templates/hono-fullstack/libs/ui/stories/disclosure/Collapsible.stories.tsx +55 -0
- package/templates/hono-fullstack/libs/ui/stories/disclosure/Steps.stories.tsx +208 -0
- package/templates/hono-fullstack/libs/ui/stories/disclosure/Tabs.stories.tsx +176 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Avatar.stories.tsx +108 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Badge.stories.tsx +90 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Card.stories.tsx +121 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Heading.stories.tsx +62 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Icon.stories.tsx +51 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Table.stories.tsx +222 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Tag.stories.tsx +168 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Text.stories.tsx +32 -0
- package/templates/hono-fullstack/libs/ui/stories/display/Timeline.stories.tsx +241 -0
- package/templates/hono-fullstack/libs/ui/stories/feedback/Alert.stories.tsx +122 -0
- package/templates/hono-fullstack/libs/ui/stories/feedback/Progress.stories.tsx +163 -0
- package/templates/hono-fullstack/libs/ui/stories/feedback/ProgressCircle.stories.tsx +176 -0
- package/templates/hono-fullstack/libs/ui/stories/feedback/Skeleton.stories.tsx +75 -0
- package/templates/hono-fullstack/libs/ui/stories/feedback/Spinner.stories.tsx +49 -0
- package/templates/hono-fullstack/libs/ui/stories/feedback/Toast.stories.tsx +145 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Checkbox.stories.tsx +281 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Editable.stories.tsx +94 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Field.stories.tsx +72 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Fieldset.stories.tsx +109 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/FileUpload.stories.tsx +115 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Form.stories.tsx +120 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Input.stories.tsx +155 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/InputGroup.stories.tsx +79 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/NativeSelect.stories.tsx +160 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/NumberInput.stories.tsx +149 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/PasswordInput.stories.tsx +141 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/PinInput.stories.tsx +155 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/RadioCard.stories.tsx +265 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/RadioGroup.stories.tsx +109 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/RatingGroup.stories.tsx +123 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/SegmentGroup.stories.tsx +130 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Slider.stories.tsx +190 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Switch.stories.tsx +124 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/TagsInput.stories.tsx +154 -0
- package/templates/hono-fullstack/libs/ui/stories/forms/Textarea.stories.tsx +148 -0
- package/templates/hono-fullstack/libs/ui/stories/layout/Grid.stories.tsx +60 -0
- package/templates/hono-fullstack/libs/ui/stories/layout/Positioning.stories.tsx +90 -0
- package/templates/hono-fullstack/libs/ui/stories/layout/ScrollArea.stories.tsx +68 -0
- package/templates/hono-fullstack/libs/ui/stories/layout/Stack.stories.tsx +87 -0
- package/templates/hono-fullstack/libs/ui/stories/navigation/Breadcrumb.stories.tsx +104 -0
- package/templates/hono-fullstack/libs/ui/stories/navigation/Link.stories.tsx +62 -0
- package/templates/hono-fullstack/libs/ui/stories/navigation/LinkBox.stories.tsx +45 -0
- package/templates/hono-fullstack/libs/ui/stories/navigation/Pagination.stories.tsx +74 -0
- package/templates/hono-fullstack/libs/ui/stories/overlays/Dialog.stories.tsx +255 -0
- package/templates/hono-fullstack/libs/ui/stories/overlays/Drawer.stories.tsx +114 -0
- package/templates/hono-fullstack/libs/ui/stories/overlays/HoverCard.stories.tsx +47 -0
- package/templates/hono-fullstack/libs/ui/stories/overlays/Menu.stories.tsx +133 -0
- package/templates/hono-fullstack/libs/ui/stories/overlays/OverlayManager.stories.tsx +206 -0
- package/templates/hono-fullstack/libs/ui/stories/overlays/Popover.stories.tsx +73 -0
- package/templates/hono-fullstack/libs/ui/stories/overlays/Tooltip.stories.tsx +114 -0
- package/templates/hono-fullstack/libs/ui/stories/tsconfig.json +14 -0
- package/templates/hono-fullstack/libs/ui/tsconfig.build.json +5 -0
- package/templates/hono-fullstack/libs/ui/tsconfig.json +13 -0
- package/templates/hono-fullstack/libs/ui/turbo.json +28 -0
- package/templates/hono-fullstack/libs/ui/vite.config.ts +33 -0
- package/templates/hono-fullstack/oyo.config.json +30 -4
- package/templates/hono-fullstack/package.json +1 -0
- package/templates/hono-fullstack/pnpm-workspace.yaml +20 -10
- package/templates/hono-fullstack/turbo.json +10 -0
- package/templates/hono-server/.codegraph/.gitignore +5 -0
- package/templates/hono-server/README.md +9 -1
- package/templates/hono-server/_gitignore +1 -0
- package/templates/hono-server/apps/server/package.json +7 -2
- package/templates/hono-server/apps/server/src/adapters/cloudflare/entry.ts +4 -30
- package/templates/hono-server/apps/server/src/adapters/nodejs/bootstrap.ts +20 -12
- package/templates/hono-server/apps/server/src/adapters/nodejs/entry.ts +7 -57
- package/templates/hono-server/apps/server/src/app.ts +37 -21
- package/templates/hono-server/apps/server/src/config.ts +1 -1
- package/templates/hono-server/apps/server/src/di-container.ts +51 -0
- package/templates/hono-server/apps/server/src/infra/logger/getter.ts +1 -1
- package/templates/hono-server/apps/server/src/infra/logger/pino.ts +21 -34
- package/templates/hono-server/apps/server/src/infra/work-runner/errors.ts +22 -0
- package/templates/hono-server/apps/server/src/infra/work-runner/pass-through/runner.ts +28 -22
- package/templates/hono-server/apps/server/src/infra/work-runner/piscina/runner.ts +11 -34
- package/templates/hono-server/apps/server/src/infra/work-runner/{example → piscina}/worker-entry.ts +6 -2
- package/templates/hono-server/apps/server/src/infra/work-runner/types.ts +2 -16
- package/templates/hono-server/apps/server/src/infra/work-runner/utils/business-error.ts +10 -5
- package/templates/hono-server/apps/server/src/infra/work-runner/utils/message.ts +5 -17
- package/templates/hono-server/apps/server/src/middlewares/cors.ts +16 -22
- package/templates/hono-server/apps/server/src/middlewares/logger.ts +34 -0
- package/templates/hono-server/apps/server/src/modules/example/module.ts +8 -0
- package/templates/hono-server/apps/server/src/modules/example/queries.ts +8 -0
- package/templates/hono-server/apps/server/src/modules/example/routes.ts +74 -68
- package/templates/hono-server/apps/server/src/modules/example/service.test.ts +53 -0
- package/templates/hono-server/apps/server/src/modules/example/service.ts +54 -0
- package/templates/hono-server/apps/server/src/modules/example/types.ts +12 -0
- package/templates/hono-server/apps/server/src/modules/example/work-task/tasks.test.ts +9 -35
- package/templates/hono-server/apps/server/src/modules/example/work-task/tasks.ts +15 -46
- package/templates/hono-server/apps/server/src/shared/errors/defs/index.ts +6 -1
- package/templates/hono-server/apps/server/src/shared/errors/handler.ts +1 -1
- package/templates/hono-server/apps/server/src/shared/network/openapi/index.ts +1 -1
- package/templates/hono-server/apps/server/src/shared/types/app.ts +51 -0
- package/templates/hono-server/apps/server/src/shared/types/db.ts +126 -0
- package/templates/hono-server/apps/server/src/shared/utils/data-access/check.ts +19 -0
- package/templates/hono-server/apps/server/src/shared/utils/data-access/model.ts +47 -0
- package/templates/hono-server/apps/server/src/shared/utils/data-access/params.ts +105 -0
- package/templates/hono-server/apps/server/src/shared/utils/data-access/query.test.ts +139 -0
- package/templates/hono-server/apps/server/src/shared/utils/data-access/query.ts +236 -0
- package/templates/hono-server/apps/server/vite.config.ts +2 -2
- package/templates/hono-server/apps/server/wrangler.jsonc +1 -1
- package/templates/hono-server/docker/README.md +1 -1
- package/templates/hono-server/envs/.env.example.sqlite-d1 +1 -0
- package/templates/hono-server/libs/db/drizzle-kit/sqlite-d1.config.ts +29 -10
- package/templates/hono-server/libs/db/package.json +1 -0
- package/templates/hono-server/libs/db/src/dialects/sqlite/schema/columns.ts +1 -1
- package/templates/hono-server/libs/db/src/dialects/sqlite/schema/modules/examples/examples.ts +6 -3
- package/templates/hono-server/libs/db/src/dialects/sqlite/schema/vo.ts +7 -1
- package/templates/hono-server/libs/definition/README.md +81 -0
- package/templates/hono-server/libs/definition/package.json +3 -1
- package/templates/hono-server/libs/definition/src/constants/index.ts +1 -0
- package/templates/hono-server/libs/definition/src/constants/pagination.ts +3 -0
- package/templates/hono-server/libs/definition/src/modules/common-contracts.ts +24 -0
- package/templates/hono-server/libs/definition/src/modules/example/contracts.ts +34 -0
- package/templates/hono-server/libs/definition/src/modules/example/index.ts +1 -16
- package/templates/hono-server/libs/definition/src/modules/index.ts +2 -0
- package/templates/hono-server/libs/definition/src/modules/vo-generated-types.ts +12 -0
- package/templates/hono-server/oyo.config.json +30 -4
- package/templates/hono-server/package.json +1 -0
- package/templates/hono-server/pnpm-workspace.yaml +9 -7
- package/templates/hono-server/turbo.json +10 -0
- package/templates/monorepo/.codegraph/.gitignore +5 -0
- package/templates/monorepo/_gitignore +1 -0
- package/templates/monorepo/oyo.config.json +6 -4
- package/templates/monorepo/pnpm-workspace.yaml +4 -4
- package/templates/monorepo/turbo.json +10 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/contracts.ts +0 -9
- package/templates/hono-fullstack/apps/server/src/shared/app/types.ts +0 -44
- package/templates/hono-fullstack/apps/stack/frontend/styles.css +0 -23
- package/templates/hono-server/apps/server/src/modules/example/contracts.ts +0 -9
- package/templates/hono-server/apps/server/src/shared/app/types.ts +0 -44
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { relations, type SqliteTableType, type SqliteColType } from '@repo/db/sqlite/schema'
|
|
2
|
+
import { count, getColumns, sql, type DBQueryConfig } from 'drizzle-orm'
|
|
3
|
+
import type { SQLiteInsertValue, SQLiteUpdateSetSource } from 'drizzle-orm/sqlite-core'
|
|
4
|
+
import type {
|
|
5
|
+
Result,
|
|
6
|
+
SQLiteAsyncRelationalQueryHKT,
|
|
7
|
+
SQLiteSyncRelationalQuery,
|
|
8
|
+
} from 'drizzle-orm/sqlite-core/async'
|
|
9
|
+
import type { RelationalQueryBuilder } from 'drizzle-orm/sqlite-core/query-builders/query'
|
|
10
|
+
import type {
|
|
11
|
+
DeleteOptions,
|
|
12
|
+
DeleteResults,
|
|
13
|
+
InsertOptions,
|
|
14
|
+
InsertResults,
|
|
15
|
+
QueryDB,
|
|
16
|
+
QueryOneOptions,
|
|
17
|
+
QueryOptions,
|
|
18
|
+
QueryPageOptions,
|
|
19
|
+
QueryResultKind,
|
|
20
|
+
QueryResults,
|
|
21
|
+
QueryRow,
|
|
22
|
+
UpdateOptions,
|
|
23
|
+
UpdateResults,
|
|
24
|
+
VOsMap,
|
|
25
|
+
} from '@/shared/types/db'
|
|
26
|
+
import type { Model } from './model'
|
|
27
|
+
import {
|
|
28
|
+
objectWhereToSQL,
|
|
29
|
+
parseDeleteOptions,
|
|
30
|
+
parseDrizzleQueryOptions,
|
|
31
|
+
parseUpdateOptions,
|
|
32
|
+
} from './params'
|
|
33
|
+
|
|
34
|
+
type TableConfig<T extends SqliteTableType> = {
|
|
35
|
+
table: T
|
|
36
|
+
name: string
|
|
37
|
+
relations: Record<never, never>
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type TableReader<K extends QueryResultKind, T extends SqliteTableType> = RelationalQueryBuilder<
|
|
41
|
+
K,
|
|
42
|
+
typeof relations,
|
|
43
|
+
TableConfig<T>,
|
|
44
|
+
SQLiteAsyncRelationalQueryHKT
|
|
45
|
+
>
|
|
46
|
+
|
|
47
|
+
type TotalInfo = { total: number } | undefined
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 为固定查询创建按 db/tx 实例隔离的预编译缓存。
|
|
51
|
+
* 在领域 queries.ts 顶层调用一次,每个模块持有自己的 WeakMap;此时无需提供 db。
|
|
52
|
+
* 返回的函数首次收到某个 db/tx 时同步 prepare,后续复用同一组 statement。
|
|
53
|
+
* 初始化入口也可调用它提前准备;prepare 回调只创建语句,不执行查询。
|
|
54
|
+
* 准备失败不写入缓存,后续允许重试;数据库连接的关闭仍由调用方负责。
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* // queries.ts 顶层定义,只创建缓存,不准备语句。
|
|
58
|
+
* export const prepareQueries = createPreparedQueries((db) => ({
|
|
59
|
+
* findByTitle: db.select().from(sources)
|
|
60
|
+
* .where(eq(sources.title, sql.placeholder('title'))).prepare(),
|
|
61
|
+
* }))
|
|
62
|
+
*
|
|
63
|
+
* // 查询函数仍接受 db/tx;也可在初始化入口直接调用 prepareQueries(db) 预热。
|
|
64
|
+
* export function findByTitle(db: QueryDB, title: string) {
|
|
65
|
+
* return prepareQueries(db).findByTitle.get({ title })
|
|
66
|
+
* }
|
|
67
|
+
*/
|
|
68
|
+
export function createPreparedQueries<T extends Record<string, object>>(
|
|
69
|
+
prepare: (db: QueryDB) => T,
|
|
70
|
+
) {
|
|
71
|
+
const cache = new WeakMap<QueryDB, T>()
|
|
72
|
+
|
|
73
|
+
return (db: QueryDB): T => {
|
|
74
|
+
let queries = cache.get(db)
|
|
75
|
+
if (queries === undefined) {
|
|
76
|
+
queries = prepare(db)
|
|
77
|
+
cache.set(db, queries)
|
|
78
|
+
}
|
|
79
|
+
return queries
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 绑定领域的表与 VO,生成可直接导出的通用查询函数;不创建事务,db 或 tx 由调用方传入。
|
|
85
|
+
* 返回值沿用驱动行为:better-sqlite3 直接返回结果,D1 返回 Promise。
|
|
86
|
+
* 通过 Drizzle 自带的 db._.resultKind 判断驱动,避免同步 SQLite 事务被改成异步执行。
|
|
87
|
+
*/
|
|
88
|
+
export function createQueries<T extends SqliteTableType, VOs extends VOsMap>(
|
|
89
|
+
model: Model<T, VOs>,
|
|
90
|
+
defaults: Pick<QueryOptions<T, keyof VOs & string>, 'orderBy'> = {},
|
|
91
|
+
) {
|
|
92
|
+
type M = Model<T, VOs>
|
|
93
|
+
type VT = keyof VOs & string
|
|
94
|
+
|
|
95
|
+
const relation = Object.entries(relations).find(
|
|
96
|
+
([, relation]) => (relation.table as SqliteTableType) === model.table,
|
|
97
|
+
)
|
|
98
|
+
if (!relation) throw new Error(`Table is not registered in relations: ${model.tableName}`)
|
|
99
|
+
const tableKey = relation[0] as keyof typeof relations
|
|
100
|
+
const { orderBy } = defaults
|
|
101
|
+
|
|
102
|
+
/** 按条件读取多条记录;voType 选择字段,limit 控制分页,withTotal 决定是否另查总数。 */
|
|
103
|
+
function query<K extends QueryResultKind, Q extends QueryOptions<T, VT> = {}>(
|
|
104
|
+
db: QueryDB<K>,
|
|
105
|
+
options: Q = {} as Q,
|
|
106
|
+
): Result<K, QueryResults<M, Q>> {
|
|
107
|
+
const { selectFields, where, orderByObj, offset, limit, withTotal } = parseDrizzleQueryOptions(
|
|
108
|
+
model,
|
|
109
|
+
options,
|
|
110
|
+
)
|
|
111
|
+
// 表与 VO 在工厂创建时绑定;动态表名的类型适配只留在公共层。
|
|
112
|
+
const reader = db.query[tableKey] as unknown as TableReader<K, T>
|
|
113
|
+
const statement = reader.findMany({
|
|
114
|
+
columns: selectFields,
|
|
115
|
+
where: where || {},
|
|
116
|
+
orderBy: orderByObj || orderBy,
|
|
117
|
+
...(limit === undefined ? {} : { offset, limit }),
|
|
118
|
+
} as DBQueryConfig<'many', typeof relations, TableConfig<T>>)
|
|
119
|
+
const totalInfo: TotalInfo | Promise<TotalInfo> = withTotal
|
|
120
|
+
? db
|
|
121
|
+
.select({ total: count() })
|
|
122
|
+
.from(model.table)
|
|
123
|
+
.where(objectWhereToSQL(model.table, where))
|
|
124
|
+
.get()
|
|
125
|
+
: undefined
|
|
126
|
+
|
|
127
|
+
// 动态 VO 选择的运行时分支在这里统一对应到 schema 推断的公开结果类型。
|
|
128
|
+
const finish = (results: unknown[], total?: { total: number }) =>
|
|
129
|
+
({
|
|
130
|
+
results,
|
|
131
|
+
meta: { offset, ...(limit === undefined ? {} : { limit }), ...total },
|
|
132
|
+
}) as QueryResults<M, Q>
|
|
133
|
+
|
|
134
|
+
// 同步驱动保持同步执行,避免给同步 SQLite 事务引入异步回调。
|
|
135
|
+
if (db._.resultKind === 'sync') {
|
|
136
|
+
const results = (statement as SQLiteSyncRelationalQuery<unknown[]>).sync()
|
|
137
|
+
return finish(results, totalInfo as TotalInfo) as Result<K, QueryResults<M, Q>>
|
|
138
|
+
}
|
|
139
|
+
return Promise.all([statement.execute(), totalInfo]).then(([results, total]) =>
|
|
140
|
+
finish(results, total),
|
|
141
|
+
) as Result<K, QueryResults<M, Q>>
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// 单条读取未命中时返回 null;写入结果沿用参考项目的 result/meta、updated、deleted 结构。
|
|
145
|
+
/** 按条件读取第一条记录,未命中返回 null;需要确定顺序时传入 orderBy。 */
|
|
146
|
+
function findOne<K extends QueryResultKind, Q extends QueryOneOptions<T, VT> = {}>(
|
|
147
|
+
db: QueryDB<K>,
|
|
148
|
+
options: Q = {} as Q,
|
|
149
|
+
): Result<K, QueryRow<M, Q> | null> {
|
|
150
|
+
const result = query(db, { ...options, page: 1, limit: 1, withTotal: false as const })
|
|
151
|
+
const finish = (value: { results: unknown[] }) =>
|
|
152
|
+
(value.results[0] || null) as QueryRow<M, Q> | null
|
|
153
|
+
|
|
154
|
+
if (db._.resultKind === 'sync') {
|
|
155
|
+
return finish(result as { results: unknown[] }) as Result<K, QueryRow<M, Q> | null>
|
|
156
|
+
}
|
|
157
|
+
return Promise.resolve(result).then(finish) as Result<K, QueryRow<M, Q> | null>
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** 按页读取记录并附带总数;limit 必填,page 默认从第 1 页开始。 */
|
|
161
|
+
function findPage<K extends QueryResultKind, Q extends QueryPageOptions<T, VT>>(
|
|
162
|
+
db: QueryDB<K>,
|
|
163
|
+
options: Q,
|
|
164
|
+
) {
|
|
165
|
+
return query(db, { ...options, withTotal: true as const })
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** 插入单条或多条记录,按 VO 返回字段及写入数量;空数组返回空结果。 */
|
|
169
|
+
function insert<K extends QueryResultKind, O extends InsertOptions<T, VT>>(
|
|
170
|
+
db: QueryDB<K>,
|
|
171
|
+
options: O,
|
|
172
|
+
): Result<K, InsertResults<M, O>> {
|
|
173
|
+
// 动态 VO 在执行层统一为列映射;对外结果仍根据调用方的 voType 精确推断。
|
|
174
|
+
const fields: Record<string, SqliteColType> =
|
|
175
|
+
options.voType === undefined ? getColumns(model.table) : model.getVO(options.voType)
|
|
176
|
+
const values = Array.isArray(options.values) ? options.values : [options.values]
|
|
177
|
+
const rows: unknown[] | Promise<unknown[]> = values.length
|
|
178
|
+
? db
|
|
179
|
+
.insert(model.table)
|
|
180
|
+
.values(values as unknown as SQLiteInsertValue<T>[])
|
|
181
|
+
.returning(fields)
|
|
182
|
+
.all()
|
|
183
|
+
: []
|
|
184
|
+
const finish = (result: unknown[]) =>
|
|
185
|
+
({
|
|
186
|
+
result,
|
|
187
|
+
meta: { count: values.length, affected: result.length },
|
|
188
|
+
}) as InsertResults<M, O>
|
|
189
|
+
|
|
190
|
+
if (db._.resultKind === 'sync') {
|
|
191
|
+
return finish(rows as unknown[]) as Result<K, InsertResults<M, O>>
|
|
192
|
+
}
|
|
193
|
+
return Promise.resolve(rows).then(finish) as Result<K, InsertResults<M, O>>
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** 按条件更新记录并返回 updated 数量;空更新字段、无条件更新均抛出异常。 */
|
|
197
|
+
function update<K extends QueryResultKind>(
|
|
198
|
+
db: QueryDB<K>,
|
|
199
|
+
options: UpdateOptions<T>,
|
|
200
|
+
): Result<K, UpdateResults> {
|
|
201
|
+
const { value, conditions } = parseUpdateOptions(model, options)
|
|
202
|
+
const rows: unknown[] | Promise<unknown[]> = db
|
|
203
|
+
.update(model.table)
|
|
204
|
+
.set(value as SQLiteUpdateSetSource<T>)
|
|
205
|
+
.where(conditions)
|
|
206
|
+
.returning({ affected: sql<number>`1` })
|
|
207
|
+
.all()
|
|
208
|
+
const finish = (result: unknown[]): UpdateResults => ({ updated: result.length })
|
|
209
|
+
|
|
210
|
+
if (db._.resultKind === 'sync') {
|
|
211
|
+
return finish(rows as unknown[]) as Result<K, UpdateResults>
|
|
212
|
+
}
|
|
213
|
+
return Promise.resolve(rows).then(finish) as Result<K, UpdateResults>
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** 按条件删除记录并返回 deleted 数量;无条件删除抛出异常。 */
|
|
217
|
+
function deleteRecords<K extends QueryResultKind>(
|
|
218
|
+
db: QueryDB<K>,
|
|
219
|
+
options: DeleteOptions<T>,
|
|
220
|
+
): Result<K, DeleteResults> {
|
|
221
|
+
const { conditions } = parseDeleteOptions(model, options)
|
|
222
|
+
const rows: unknown[] | Promise<unknown[]> = db
|
|
223
|
+
.delete(model.table)
|
|
224
|
+
.where(conditions)
|
|
225
|
+
.returning({ affected: sql<number>`1` })
|
|
226
|
+
.all()
|
|
227
|
+
const finish = (result: unknown[]): DeleteResults => ({ deleted: result.length })
|
|
228
|
+
|
|
229
|
+
if (db._.resultKind === 'sync') {
|
|
230
|
+
return finish(rows as unknown[]) as Result<K, DeleteResults>
|
|
231
|
+
}
|
|
232
|
+
return Promise.resolve(rows).then(finish) as Result<K, DeleteResults>
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return { query, findOne, findPage, insert, update, deleteRecords }
|
|
236
|
+
}
|
|
@@ -66,8 +66,8 @@ export default defineConfig(() => {
|
|
|
66
66
|
}),
|
|
67
67
|
nodejsEntry: './src/adapters/nodejs/entry.ts',
|
|
68
68
|
cloudflareEntry: './src/adapters/cloudflare/entry.ts',
|
|
69
|
-
// Enable this entry together with PiscinaWorkRunner in
|
|
70
|
-
// 'workers/
|
|
69
|
+
// Enable this entry together with PiscinaWorkRunner in di-container.ts.
|
|
70
|
+
// 'workers/piscina-worker': './src/infra/work-runner/piscina/worker-entry.ts',
|
|
71
71
|
},
|
|
72
72
|
// deps: {
|
|
73
73
|
// neverBundle: [...builtinModules],
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ReactNode } from 'react'
|
|
2
|
+
import { css } from 'styled-system/css'
|
|
2
3
|
import { Header } from './Header'
|
|
3
4
|
|
|
4
5
|
export function AppLayout({ children }: { children: ReactNode }) {
|
|
5
6
|
return (
|
|
6
|
-
<div className=
|
|
7
|
+
<div className={css({ minHeight: 'screen', bg: 'gray.bg.page', color: 'gray.fg.default' })}>
|
|
7
8
|
<Header />
|
|
8
9
|
{children}
|
|
9
10
|
</div>
|
|
@@ -1,7 +1,19 @@
|
|
|
1
|
+
import { Text } from '@repo/ui'
|
|
2
|
+
import { css } from 'styled-system/css'
|
|
3
|
+
|
|
1
4
|
export function Header() {
|
|
2
5
|
return (
|
|
3
|
-
<header
|
|
4
|
-
|
|
6
|
+
<header
|
|
7
|
+
className={css({
|
|
8
|
+
bg: 'gray.bg.surface',
|
|
9
|
+
borderBottomWidth: 'px',
|
|
10
|
+
borderColor: 'gray.border.subtle',
|
|
11
|
+
px: '8',
|
|
12
|
+
py: '4',
|
|
13
|
+
})}>
|
|
14
|
+
<Text as="strong" fontWeight="semibold">
|
|
15
|
+
Hono fullstack
|
|
16
|
+
</Text>
|
|
5
17
|
</header>
|
|
6
18
|
)
|
|
7
19
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react'
|
|
2
|
+
import { vstack } from 'styled-system/patterns'
|
|
2
3
|
|
|
3
4
|
export function Page({ children }: { children: ReactNode }) {
|
|
4
|
-
return <section className=
|
|
5
|
+
return <section className={vstack({ gap: '6', alignItems: 'stretch' })}>{children}</section>
|
|
5
6
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from 'react'
|
|
2
|
+
import { css } from 'styled-system/css'
|
|
2
3
|
|
|
3
4
|
export function PageContainer({ children }: { children: ReactNode }) {
|
|
4
|
-
return
|
|
5
|
+
return (
|
|
6
|
+
<main className={css({ mx: 'auto', maxW: '2xl', p: { base: '4', md: '8' } })}>{children}</main>
|
|
7
|
+
)
|
|
5
8
|
}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
IExampleCreateOne,
|
|
3
|
+
IExamplesListVO,
|
|
4
|
+
IExampleProcess,
|
|
5
|
+
IExampleProcessResult,
|
|
6
|
+
IExamplesIdVO,
|
|
6
7
|
} from '@repo/definition/frontend'
|
|
7
8
|
import { request } from '#/shared/network/client'
|
|
8
9
|
|
|
9
|
-
export const apiExampleFindMany = () =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
export const apiExampleFindMany = () =>
|
|
11
|
+
request<{ results: IExamplesListVO[]; meta: { offset: number; limit: number; total: number } }>(
|
|
12
|
+
'examples',
|
|
13
|
+
)
|
|
14
|
+
export const apiExampleCreateOne = (input: IExampleCreateOne) =>
|
|
15
|
+
request<{ result: IExamplesIdVO[]; meta: { count: number; affected: number } }>('examples', {
|
|
16
|
+
method: 'post',
|
|
17
|
+
json: input,
|
|
18
|
+
})
|
|
19
|
+
export const apiExampleProcess = (input: IExampleProcess) =>
|
|
20
|
+
request<IExampleProcessResult>('examples/process', { method: 'post', json: input })
|
package/templates/hono-fullstack/apps/stack/frontend/modules/example/components/ExampleForm.tsx
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Button, Field, Input } from '@repo/ui'
|
|
1
2
|
import type { FormEvent } from 'react'
|
|
3
|
+
import { css } from 'styled-system/css'
|
|
2
4
|
|
|
3
5
|
interface ExampleFormProps {
|
|
4
6
|
message: string
|
|
@@ -23,23 +25,34 @@ export function ExampleForm({
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
return (
|
|
26
|
-
<form
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
<form
|
|
29
|
+
className={css({ display: 'flex', flexWrap: 'wrap', alignItems: 'flex-end', gap: '3' })}
|
|
30
|
+
onSubmit={submit}>
|
|
31
|
+
<Field.Root
|
|
32
|
+
className={css({
|
|
33
|
+
flex: '1',
|
|
34
|
+
minW: '0',
|
|
35
|
+
width: { base: 'full', sm: 'auto' },
|
|
36
|
+
flexBasis: { base: 'full', sm: '0' },
|
|
37
|
+
})}>
|
|
38
|
+
<Field.Label>Message</Field.Label>
|
|
39
|
+
<Input
|
|
40
|
+
value={message}
|
|
41
|
+
onChange={(event) => onMessageChange(event.target.value)}
|
|
42
|
+
placeholder="Message"
|
|
43
|
+
/>
|
|
44
|
+
</Field.Root>
|
|
45
|
+
<Button type="submit" variant="solid" loading={saving} disabled={!message.trim() || saving}>
|
|
34
46
|
Save
|
|
35
|
-
</
|
|
36
|
-
<
|
|
37
|
-
className="rounded bg-emerald-600 px-4 py-2"
|
|
47
|
+
</Button>
|
|
48
|
+
<Button
|
|
38
49
|
type="button"
|
|
50
|
+
variant="outline"
|
|
51
|
+
loading={processing}
|
|
39
52
|
disabled={!message.trim() || processing}
|
|
40
53
|
onClick={onProcess}>
|
|
41
54
|
Process
|
|
42
|
-
</
|
|
55
|
+
</Button>
|
|
43
56
|
</form>
|
|
44
57
|
)
|
|
45
58
|
}
|
package/templates/hono-fullstack/apps/stack/frontend/modules/example/components/ExampleList.tsx
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { css } from 'styled-system/css'
|
|
2
|
+
import type { IExamplesListVO } from '@repo/definition/frontend'
|
|
2
3
|
|
|
3
|
-
export function ExampleList({ examples }: { examples?:
|
|
4
|
+
export function ExampleList({ examples }: { examples?: IExamplesListVO[] }) {
|
|
4
5
|
return (
|
|
5
|
-
<ul className=
|
|
6
|
+
<ul className={css({ display: 'grid', gap: '2' })}>
|
|
6
7
|
{examples?.map((example) => (
|
|
7
|
-
<li
|
|
8
|
+
<li
|
|
9
|
+
className={css({
|
|
10
|
+
bg: 'gray.bg.surface',
|
|
11
|
+
borderRadius: 'md',
|
|
12
|
+
borderWidth: 'px',
|
|
13
|
+
borderColor: 'gray.border.subtle',
|
|
14
|
+
p: '3',
|
|
15
|
+
})}
|
|
16
|
+
key={example.id}>
|
|
8
17
|
{example.message}
|
|
9
18
|
</li>
|
|
10
19
|
))}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IExampleCreateOne, IExampleProcess } from '@repo/definition/frontend'
|
|
2
2
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
3
3
|
import { defineMutationHook, defineQueryHook } from '#/shared/network/query-hooks'
|
|
4
4
|
import { apiExampleCreateOne, apiExampleFindMany, apiExampleProcess } from '../api'
|
|
@@ -17,11 +17,11 @@ export const useExamplesQuery = defineQueryHook(() =>
|
|
|
17
17
|
export const useCreateExampleMutation = defineMutationHook(() => {
|
|
18
18
|
const queryClient = useQueryClient()
|
|
19
19
|
return useMutation({
|
|
20
|
-
mutationFn: (input:
|
|
20
|
+
mutationFn: (input: IExampleCreateOne) => apiExampleCreateOne(input),
|
|
21
21
|
onSuccess: () => queryClient.invalidateQueries({ queryKey: exampleQueryKeys.all }),
|
|
22
22
|
})
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
export const useProcessExampleMutation = defineMutationHook(() =>
|
|
26
|
-
useMutation({ mutationFn: (input:
|
|
26
|
+
useMutation({ mutationFn: (input: IExampleProcess) => apiExampleProcess(input) }),
|
|
27
27
|
)
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from '@tanstack/react-router'
|
|
11
11
|
import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
|
|
12
12
|
import { Provider as JotaiProvider, type createStore } from 'jotai'
|
|
13
|
-
import appCss from '../styles.css?url'
|
|
13
|
+
import appCss from '../assets/styles.css?url'
|
|
14
14
|
|
|
15
15
|
export const Route = createRootRouteWithContext<{
|
|
16
16
|
queryClient: QueryClient
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Heading, Text } from '@repo/ui'
|
|
2
|
+
import { css } from 'styled-system/css'
|
|
1
3
|
import { createFileRoute } from '@tanstack/react-router'
|
|
2
4
|
import { useAtom } from 'jotai'
|
|
3
5
|
import { ErrorMessage } from '#/components/general/ErrorMessage'
|
|
@@ -36,8 +38,10 @@ function Home() {
|
|
|
36
38
|
<PageContainer>
|
|
37
39
|
<Page>
|
|
38
40
|
<header>
|
|
39
|
-
<h1
|
|
40
|
-
|
|
41
|
+
<Heading as="h1" size="3xl">
|
|
42
|
+
Example workspace
|
|
43
|
+
</Heading>
|
|
44
|
+
<Text color="gray.fg.muted">Nitro mounts the independent Hono server under /api.</Text>
|
|
41
45
|
</header>
|
|
42
46
|
<ExampleForm
|
|
43
47
|
message={message}
|
|
@@ -48,12 +52,20 @@ function Home() {
|
|
|
48
52
|
onProcess={() => processExample({ message })}
|
|
49
53
|
/>
|
|
50
54
|
{processedExample && (
|
|
51
|
-
<pre
|
|
55
|
+
<pre
|
|
56
|
+
className={css({
|
|
57
|
+
borderRadius: 'md',
|
|
58
|
+
bg: 'gray.bg.surface',
|
|
59
|
+
color: 'gray.fg.muted',
|
|
60
|
+
boxShadow: 'inset 0 0 0 1px token(colors.gray.border.subtle)',
|
|
61
|
+
p: '4',
|
|
62
|
+
overflowX: 'auto',
|
|
63
|
+
})}>
|
|
52
64
|
{JSON.stringify(processedExample, null, 2)}
|
|
53
65
|
</pre>
|
|
54
66
|
)}
|
|
55
67
|
<ErrorMessage error={create.error || processError || examplesError} />
|
|
56
|
-
<ExampleList examples={examples} />
|
|
68
|
+
<ExampleList examples={examples?.results} />
|
|
57
69
|
</Page>
|
|
58
70
|
</PageContainer>
|
|
59
71
|
</AppLayout>
|
|
@@ -19,15 +19,18 @@
|
|
|
19
19
|
"preview:cloudflare": "DEPLOY_TARGET=cloudflare vp preview",
|
|
20
20
|
"deploy:cloudflare": "pnpm build:cloudflare-chain && wrangler deploy",
|
|
21
21
|
"db:migrate:cloudflare:local": "wrangler d1 migrations apply DB --local --config wrangler.jsonc --persist-to ../../.wrangler/state",
|
|
22
|
+
"db:warmup:cloudflare:local": "wrangler d1 execute DB --local --config wrangler.jsonc --persist-to ../../.wrangler/state --command \"SELECT 1\"",
|
|
22
23
|
"cf:typegen": "wrangler types",
|
|
23
24
|
"cf:typecheck": "wrangler types --check",
|
|
24
25
|
"generate-routes": "tsr generate",
|
|
25
26
|
"test": "vp test",
|
|
26
|
-
"check": "vp check"
|
|
27
|
+
"check": "pnpm codegen && vp check",
|
|
28
|
+
"codegen": "panda codegen"
|
|
27
29
|
},
|
|
28
30
|
"dependencies": {
|
|
29
31
|
"@repo/definition": "workspace:*",
|
|
30
32
|
"@repo/server": "workspace:*",
|
|
33
|
+
"@repo/ui": "workspace:*",
|
|
31
34
|
"@tanstack/react-query": "catalog:frontend",
|
|
32
35
|
"@tanstack/react-router": "catalog:frontend",
|
|
33
36
|
"@tanstack/react-start": "catalog:frontend",
|
|
@@ -41,17 +44,19 @@
|
|
|
41
44
|
"@cloudflare/vite-plugin": "catalog:",
|
|
42
45
|
"@oyolincc/cli": "catalog:",
|
|
43
46
|
"@oyolincc/dev-config": "catalog:",
|
|
47
|
+
"@pandacss/dev": "catalog:frontend",
|
|
48
|
+
"@pandacss/preset-base": "catalog:frontend",
|
|
49
|
+
"@pandacss/preset-panda": "catalog:frontend",
|
|
50
|
+
"@pandacss/vite": "catalog:frontend",
|
|
44
51
|
"@rollup/pluginutils": "catalog:",
|
|
45
|
-
"@tailwindcss/vite": "catalog:frontend",
|
|
46
52
|
"@tanstack/react-query-devtools": "catalog:frontend",
|
|
47
53
|
"@tanstack/react-router-devtools": "catalog:frontend",
|
|
48
54
|
"@tanstack/router-cli": "catalog:frontend",
|
|
49
55
|
"@types/node": "catalog:",
|
|
50
56
|
"@types/react": "catalog:frontend",
|
|
51
57
|
"@types/react-dom": "catalog:frontend",
|
|
52
|
-
"@vitejs/plugin-react": "catalog:",
|
|
58
|
+
"@vitejs/plugin-react": "catalog:frontend",
|
|
53
59
|
"fast-glob": "catalog:",
|
|
54
|
-
"tailwindcss": "catalog:frontend",
|
|
55
60
|
"typescript": "catalog:",
|
|
56
61
|
"vite-plus": "catalog:",
|
|
57
62
|
"wrangler": "catalog:"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineConfig } from '@pandacss/dev'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
designSystem: '@repo/ui',
|
|
5
|
+
// designSystem 自动注册样式入口;不要把 UI 组件入口映射为 Panda JSX,
|
|
6
|
+
// 否则启用源码转换时会将 Stack 等带行为的组件内联成原生元素。
|
|
7
|
+
// Stack 使用 UI 设计系统;应用侧负责 reset 与文档全局样式。
|
|
8
|
+
// Panda preflight 替代原有 reset,组件状态样式由 UI 配方提供。
|
|
9
|
+
preflight: true,
|
|
10
|
+
prefix: {
|
|
11
|
+
className: '',
|
|
12
|
+
},
|
|
13
|
+
globalCss: {
|
|
14
|
+
extend: {
|
|
15
|
+
'html, body': { minHeight: 'full', margin: '0' },
|
|
16
|
+
html: {
|
|
17
|
+
colorPalette: 'gray',
|
|
18
|
+
},
|
|
19
|
+
'html.dark': { colorScheme: 'dark' },
|
|
20
|
+
body: {
|
|
21
|
+
fontFamily: 'sans',
|
|
22
|
+
background: 'gray.bg.page',
|
|
23
|
+
color: 'gray.fg.default',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
jsxFramework: 'react',
|
|
28
|
+
include: ['./frontend/**/*.{js,jsx,ts,tsx}'],
|
|
29
|
+
exclude: [],
|
|
30
|
+
outdir: 'styled-system',
|
|
31
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["//"],
|
|
3
|
+
"tasks": {
|
|
4
|
+
"dev:node": {
|
|
5
|
+
"dependsOn": ["^build:dev"]
|
|
6
|
+
},
|
|
7
|
+
"dev:cloudflare": {
|
|
8
|
+
"dependsOn": ["^build:dev"]
|
|
9
|
+
},
|
|
10
|
+
"build": {
|
|
11
|
+
"inputs": ["$TURBO_EXTENDS$"]
|
|
12
|
+
},
|
|
13
|
+
"build:node": {
|
|
14
|
+
"inputs": ["$TURBO_EXTENDS$"]
|
|
15
|
+
},
|
|
16
|
+
"build:cloudflare": {
|
|
17
|
+
"inputs": ["$TURBO_EXTENDS$"]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|