anhedral 0.13.0 → 0.16.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/README.md +23 -229
- package/assets/patches/audit-deps.mjs +12 -2
- package/assets/stack/ai-schema.ts.txt +5 -0
- package/assets/stack/ai.ts.txt +30 -0
- package/assets/stack/api-index.ts.txt +15 -0
- package/assets/stack/auth-features.ts.txt +4 -0
- package/assets/stack/auth-journal.json.txt +13 -0
- package/assets/stack/auth-migration.sql.txt +53 -0
- package/assets/stack/auth-routes.ts.txt +11 -0
- package/assets/stack/auth-schema.ts.txt +64 -0
- package/assets/stack/auth-snapshot.json.txt +346 -0
- package/assets/stack/auth.ts.txt +32 -0
- package/assets/stack/billing-mode.ts.txt +8 -0
- package/assets/stack/billing-schema.ts.txt +11 -0
- package/assets/stack/desktop.rs.txt +21 -0
- package/assets/stack/entitlement-guard.ts.txt +32 -0
- package/assets/stack/entitlements.ts.txt +8 -0
- package/assets/stack/events-schema.ts.txt +12 -0
- package/assets/stack/events.ts.txt +59 -0
- package/assets/stack/mobile-auth.ts.txt +25 -0
- package/assets/stack/mobile-billing.tsx.txt +63 -0
- package/assets/stack/mobile-session.tsx.txt +83 -0
- package/assets/stack/native-button.tsx.txt +108 -0
- package/assets/stack/native-global.css.txt +4 -0
- package/assets/stack/native-lib-utils.ts.txt +5 -0
- package/assets/stack/native-metro.config.js.txt +6 -0
- package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
- package/assets/stack/native-tailwind.config.js.txt +73 -0
- package/assets/stack/native-text.tsx.txt +89 -0
- package/assets/stack/purchases.ts.txt +65 -0
- package/assets/stack/revenuecat.ts.txt +88 -0
- package/assets/stack/rtc-schema.ts.txt +10 -0
- package/assets/stack/rtc.ts.txt +122 -0
- package/assets/stack/security.ts.txt +31 -0
- package/assets/stack/storage.ts.txt +36 -0
- package/assets/stack/stripe.ts.txt +126 -0
- package/assets/stack/web-sign-in.tsx.txt +51 -0
- package/assets/ui/LICENSE.react-native-reusables +21 -0
- package/assets/ui/LICENSE.shadcn +21 -0
- package/assets/ui/UPSTREAM.json +39 -0
- package/assets/ui/catalog.json +891 -0
- package/assets/ui/extensions/registry.json +6 -0
- package/assets/ui/native/_controls.tsx +521 -0
- package/assets/ui/native/_core.tsx +118 -0
- package/assets/ui/native/_data.tsx +200 -0
- package/assets/ui/native/_display.tsx +453 -0
- package/assets/ui/native/_feedback.tsx +242 -0
- package/assets/ui/native/_legacy-dialog.tsx +38 -0
- package/assets/ui/native/_motion.tsx +520 -0
- package/assets/ui/native/_overlay.tsx +402 -0
- package/assets/ui/native/_selection.tsx +366 -0
- package/assets/ui/native/accordion.tsx +1 -0
- package/assets/ui/native/alert-dialog.tsx +11 -0
- package/assets/ui/native/alert.tsx +1 -0
- package/assets/ui/native/aspect-ratio.tsx +1 -0
- package/assets/ui/native/attachment.tsx +8 -0
- package/assets/ui/native/avatar.tsx +8 -0
- package/assets/ui/native/badge.tsx +1 -0
- package/assets/ui/native/breadcrumb.tsx +9 -0
- package/assets/ui/native/bubble.tsx +1 -0
- package/assets/ui/native/button-group.tsx +1 -0
- package/assets/ui/native/button.tsx +86 -0
- package/assets/ui/native/calendar.tsx +170 -0
- package/assets/ui/native/card.tsx +44 -0
- package/assets/ui/native/carousel.tsx +1 -0
- package/assets/ui/native/chart.tsx +193 -0
- package/assets/ui/native/checkbox.tsx +1 -0
- package/assets/ui/native/code-block.tsx +137 -0
- package/assets/ui/native/collapsible.tsx +1 -0
- package/assets/ui/native/combobox.tsx +1 -0
- package/assets/ui/native/command.tsx +11 -0
- package/assets/ui/native/context-menu.tsx +16 -0
- package/assets/ui/native/data-table.tsx +1 -0
- package/assets/ui/native/date-picker.tsx +43 -0
- package/assets/ui/native/dialog.tsx +15 -0
- package/assets/ui/native/direction.tsx +1 -0
- package/assets/ui/native/drawer.tsx +10 -0
- package/assets/ui/native/dropdown-menu.tsx +16 -0
- package/assets/ui/native/empty.tsx +8 -0
- package/assets/ui/native/field.tsx +13 -0
- package/assets/ui/native/hover-card.tsx +1 -0
- package/assets/ui/native/input-group.tsx +8 -0
- package/assets/ui/native/input-otp.tsx +1 -0
- package/assets/ui/native/input.tsx +28 -0
- package/assets/ui/native/item.tsx +12 -0
- package/assets/ui/native/kbd.tsx +1 -0
- package/assets/ui/native/label.tsx +4 -0
- package/assets/ui/native/layout.tsx +26 -0
- package/assets/ui/native/marker.tsx +1 -0
- package/assets/ui/native/menubar.tsx +17 -0
- package/assets/ui/native/message-scroller.tsx +6 -0
- package/assets/ui/native/message.tsx +10 -0
- package/assets/ui/native/native-select.tsx +1 -0
- package/assets/ui/native/navigation-menu.tsx +10 -0
- package/assets/ui/native/pagination.tsx +9 -0
- package/assets/ui/native/popover.tsx +1 -0
- package/assets/ui/native/progress.tsx +1 -0
- package/assets/ui/native/questionnaire.tsx +130 -0
- package/assets/ui/native/radio-group.tsx +1 -0
- package/assets/ui/native/registry.json +1103 -0
- package/assets/ui/native/resizable.tsx +1 -0
- package/assets/ui/native/scroll-area.tsx +1 -0
- package/assets/ui/native/select.tsx +11 -0
- package/assets/ui/native/separator.tsx +1 -0
- package/assets/ui/native/sheet.tsx +10 -0
- package/assets/ui/native/sidebar.tsx +22 -0
- package/assets/ui/native/skeleton.tsx +1 -0
- package/assets/ui/native/slider.tsx +1 -0
- package/assets/ui/native/spinner.tsx +1 -0
- package/assets/ui/native/switch.tsx +1 -0
- package/assets/ui/native/table.tsx +10 -0
- package/assets/ui/native/tabs.tsx +1 -0
- package/assets/ui/native/text.tsx +20 -0
- package/assets/ui/native/textarea.tsx +1 -0
- package/assets/ui/native/theme-switcher.tsx +22 -0
- package/assets/ui/native/toast.tsx +11 -0
- package/assets/ui/native/toggle-group.tsx +1 -0
- package/assets/ui/native/toggle.tsx +1 -0
- package/assets/ui/native/tooltip.tsx +1 -0
- package/assets/ui/native/trace.tsx +20 -0
- package/assets/ui/native/typography.tsx +15 -0
- package/assets/ui/theme-storage.ts +25 -0
- package/assets/ui/theme.tsx +66 -0
- package/assets/ui/web/button.tsx +59 -0
- package/assets/ui/web/input.tsx +21 -0
- package/assets/ui/web/label.tsx +19 -0
- package/dist/bin.js +7 -12
- package/dist/capabilities.d.ts +4 -33
- package/dist/capabilities.js +2 -84
- package/dist/capability-catalog.d.ts +83 -0
- package/dist/capability-catalog.js +121 -0
- package/dist/capability-command.d.ts +3 -0
- package/dist/capability-command.js +188 -0
- package/dist/capability-editor.d.ts +17 -0
- package/dist/capability-editor.js +97 -0
- package/dist/capability-recipes.d.ts +4 -0
- package/dist/capability-recipes.js +520 -0
- package/dist/capability-references.d.ts +4 -0
- package/dist/capability-references.js +7 -0
- package/dist/cli-commands.d.ts +1 -2
- package/dist/cli-commands.js +10 -104
- package/dist/cli-output.d.ts +1 -2
- package/dist/cli-output.js +6 -251
- package/dist/command-schema.js +40 -374
- package/dist/dependencies.d.ts +34 -62
- package/dist/dependencies.js +112 -199
- package/dist/index.d.ts +1 -45
- package/dist/index.js +1 -30
- package/dist/platforms/mobile.js +29 -139
- package/dist/platforms/web.d.ts +3 -0
- package/dist/platforms/web.js +251 -0
- package/dist/project-config.d.ts +2 -13
- package/dist/project-config.js +10 -83
- package/dist/registry/context.js +0 -1
- package/dist/registry/options.js +6 -40
- package/dist/registry/resolve.d.ts +3 -4
- package/dist/registry/resolve.js +18 -108
- package/dist/registry/types.d.ts +1 -7
- package/dist/registry/usage.js +3 -9
- package/dist/runtime-policy.d.ts +0 -2
- package/dist/runtime-policy.js +0 -16
- package/dist/scaffold/backend.d.ts +0 -4
- package/dist/scaffold/backend.js +1 -189
- package/dist/scaffold/bootstrap.d.ts +2 -3
- package/dist/scaffold/bootstrap.js +37 -43
- package/dist/scaffold/compose.js +2 -14
- package/dist/scaffold/database.d.ts +1 -1
- package/dist/scaffold/database.js +19 -126
- package/dist/scaffold/documentation.d.ts +0 -1
- package/dist/scaffold/documentation.js +82 -84
- package/dist/scaffold/expo-runtime.d.ts +2 -2
- package/dist/scaffold/expo-runtime.js +9 -101
- package/dist/scaffold/native-ui.d.ts +2 -0
- package/dist/scaffold/native-ui.js +74 -0
- package/dist/scaffold/stack-documentation.d.ts +0 -1
- package/dist/scaffold/stack-documentation.js +3 -49
- package/dist/scaffold/storage.d.ts +2 -0
- package/dist/scaffold/storage.js +21 -0
- package/dist/scaffold/styling.d.ts +1 -1
- package/dist/scaffold/styling.js +20 -28
- package/dist/scaffold/workspace.js +63 -199
- package/dist/stack-registry.d.ts +2 -58
- package/dist/stack-registry.js +22 -446
- package/dist/standard.js +7 -24
- package/dist/ui-catalog.d.ts +26 -0
- package/dist/ui-catalog.js +31 -0
- package/dist/ui-command.d.ts +3 -0
- package/dist/ui-command.js +219 -0
- package/dist/ui-project.d.ts +22 -0
- package/dist/ui-project.js +110 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/anhedral-stack.md +4 -119
- package/docs/capabilities.md +110 -0
- package/docs/native-ui.md +102 -0
- package/docs/software-factory.md +16 -577
- package/docs/stack-standard.md +11 -307
- package/docs/ui.md +33 -0
- package/docs/verification.md +511 -0
- package/package.json +26 -27
- package/dist/access.d.ts +0 -10
- package/dist/access.js +0 -93
- package/dist/auth-schema-snapshot.d.ts +0 -346
- package/dist/auth-schema-snapshot.js +0 -347
- package/dist/auth-schema.d.ts +0 -1
- package/dist/auth-schema.js +0 -57
- package/dist/capability-contract.d.ts +0 -47
- package/dist/capability-contract.js +0 -168
- package/dist/catalog-model.d.ts +0 -24
- package/dist/catalog-model.js +0 -1
- package/dist/catalog-registration.d.ts +0 -16
- package/dist/catalog-registration.js +0 -22
- package/dist/catalog-snapshot.d.ts +0 -5
- package/dist/catalog-snapshot.js +0 -97
- package/dist/cli-delivery.d.ts +0 -3
- package/dist/cli-delivery.js +0 -172
- package/dist/cloudflare.d.ts +0 -25
- package/dist/cloudflare.js +0 -226
- package/dist/delivery-evidence.d.ts +0 -62
- package/dist/delivery-evidence.js +0 -186
- package/dist/delivery.d.ts +0 -88
- package/dist/delivery.js +0 -570
- package/dist/inspector-model.d.ts +0 -123
- package/dist/inspector-model.js +0 -1
- package/dist/integration-service-readers.d.ts +0 -13
- package/dist/integration-service-readers.js +0 -173
- package/dist/lifecycle-model.d.ts +0 -15
- package/dist/lifecycle-model.js +0 -20
- package/dist/lifecycle.d.ts +0 -11
- package/dist/lifecycle.js +0 -91
- package/dist/management.d.ts +0 -3
- package/dist/management.js +0 -47
- package/dist/mobile-delivery.d.ts +0 -77
- package/dist/mobile-delivery.js +0 -366
- package/dist/neon-service-data.d.ts +0 -8
- package/dist/neon-service-data.js +0 -117
- package/dist/platforms/desktop.d.ts +0 -2
- package/dist/platforms/desktop.js +0 -415
- package/dist/platforms/extension.d.ts +0 -2
- package/dist/platforms/extension.js +0 -328
- package/dist/project-catalog.d.ts +0 -41
- package/dist/project-catalog.js +0 -288
- package/dist/project-inspector.d.ts +0 -4
- package/dist/project-inspector.js +0 -702
- package/dist/project-lifecycle.d.ts +0 -25
- package/dist/project-lifecycle.js +0 -57
- package/dist/project-state.d.ts +0 -49
- package/dist/project-state.js +0 -563
- package/dist/provider-auth.d.ts +0 -41
- package/dist/provider-auth.js +0 -215
- package/dist/provider-readiness.d.ts +0 -30
- package/dist/provider-readiness.js +0 -104
- package/dist/providers/adapters.d.ts +0 -17
- package/dist/providers/adapters.js +0 -278
- package/dist/providers/api.d.ts +0 -29
- package/dist/providers/api.js +0 -253
- package/dist/providers/config.d.ts +0 -15
- package/dist/providers/config.js +0 -182
- package/dist/providers/definitions.d.ts +0 -318
- package/dist/providers/definitions.js +0 -127
- package/dist/providers/provision.d.ts +0 -24
- package/dist/providers/provision.js +0 -76
- package/dist/providers/receipts.d.ts +0 -20
- package/dist/providers/receipts.js +0 -66
- package/dist/providers/recovery-verification.d.ts +0 -7
- package/dist/providers/recovery-verification.js +0 -112
- package/dist/providers/recovery.d.ts +0 -30
- package/dist/providers/recovery.js +0 -34
- package/dist/providers/runtime.d.ts +0 -10
- package/dist/providers/runtime.js +0 -265
- package/dist/providers/schema.d.ts +0 -28
- package/dist/providers/schema.js +0 -49
- package/dist/providers/state.d.ts +0 -55
- package/dist/providers/state.js +0 -289
- package/dist/provision.d.ts +0 -55
- package/dist/provision.js +0 -284
- package/dist/r2-service-data.d.ts +0 -2
- package/dist/r2-service-data.js +0 -136
- package/dist/readiness.d.ts +0 -23
- package/dist/readiness.js +0 -122
- package/dist/registry/add.d.ts +0 -24
- package/dist/registry/add.js +0 -270
- package/dist/registry/bootstrap.d.ts +0 -2
- package/dist/registry/bootstrap.js +0 -14
- package/dist/registry/commands.d.ts +0 -3
- package/dist/registry/commands.js +0 -85
- package/dist/registry/presets.d.ts +0 -4
- package/dist/registry/presets.js +0 -41
- package/dist/registry/preview.d.ts +0 -11
- package/dist/registry/preview.js +0 -91
- package/dist/registry/receipt.d.ts +0 -3
- package/dist/registry/receipt.js +0 -68
- package/dist/repository.d.ts +0 -24
- package/dist/repository.js +0 -96
- package/dist/scaffold/auth.d.ts +0 -3
- package/dist/scaffold/auth.js +0 -151
- package/dist/scaffold/billing-config.d.ts +0 -1
- package/dist/scaffold/billing-config.js +0 -73
- package/dist/scaffold/billing-contracts.d.ts +0 -2
- package/dist/scaffold/billing-contracts.js +0 -48
- package/dist/scaffold/billing-providers.d.ts +0 -1
- package/dist/scaffold/billing-providers.js +0 -249
- package/dist/scaffold/billing-schema.d.ts +0 -1
- package/dist/scaffold/billing-schema.js +0 -34
- package/dist/scaffold/billing-security.d.ts +0 -1
- package/dist/scaffold/billing-security.js +0 -46
- package/dist/scaffold/billing-server.d.ts +0 -1
- package/dist/scaffold/billing-server.js +0 -139
- package/dist/scaffold/billing-store.d.ts +0 -1
- package/dist/scaffold/billing-store.js +0 -72
- package/dist/scaffold/billing.d.ts +0 -2
- package/dist/scaffold/billing.js +0 -216
- package/dist/scaffold/cloudflare-services.d.ts +0 -8
- package/dist/scaffold/cloudflare-services.js +0 -198
- package/dist/scaffold/expo-auth.d.ts +0 -3
- package/dist/scaffold/expo-auth.js +0 -192
- package/dist/scaffold/expo-billing.d.ts +0 -3
- package/dist/scaffold/expo-billing.js +0 -292
- package/dist/scaffold/integrations.d.ts +0 -4
- package/dist/scaffold/integrations.js +0 -12
- package/dist/scaffold/lint.d.ts +0 -4
- package/dist/scaffold/lint.js +0 -56
- package/dist/scaffold/neon-realtime.d.ts +0 -2
- package/dist/scaffold/neon-realtime.js +0 -97
- package/dist/scaffold/services.d.ts +0 -5
- package/dist/scaffold/services.js +0 -108
- package/dist/scaffold/stream.d.ts +0 -2
- package/dist/scaffold/stream.js +0 -114
- package/dist/scaffold/void.d.ts +0 -4
- package/dist/scaffold/void.js +0 -264
- package/dist/scaffold/web.d.ts +0 -2
- package/dist/scaffold/web.js +0 -130
- package/dist/service-deletion.d.ts +0 -29
- package/dist/service-deletion.js +0 -195
- package/dist/service-descriptor.d.ts +0 -10
- package/dist/service-descriptor.js +0 -78
- package/dist/service-model.d.ts +0 -49
- package/dist/service-model.js +0 -8
- package/dist/service-operations.d.ts +0 -29
- package/dist/service-operations.js +0 -78
- package/dist/service-readers.d.ts +0 -8
- package/dist/service-readers.js +0 -247
- package/dist/services-command.d.ts +0 -39
- package/dist/services-command.js +0 -102
- package/dist/ship.d.ts +0 -348
- package/dist/ship.js +0 -239
- package/dist/vercel-project.d.ts +0 -101
- package/dist/vercel-project.js +0 -305
- package/dist/vercel.d.ts +0 -67
- package/dist/vercel.js +0 -581
- package/dist/vinext.d.ts +0 -2
- package/dist/vinext.js +0 -86
- package/dist/void-execution.d.ts +0 -10
- package/dist/void-execution.js +0 -94
- package/dist/void-migrations.d.ts +0 -6
- package/dist/void-migrations.js +0 -110
- package/dist/void-state.d.ts +0 -16
- package/dist/void-state.js +0 -65
- package/dist/void.d.ts +0 -3
- package/dist/void.js +0 -5
package/README.md
CHANGED
|
@@ -1,252 +1,46 @@
|
|
|
1
|
-
# Anhedral
|
|
1
|
+
# Anhedral CLI
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://www.npmjs.com/package/anhedral)
|
|
5
|
-
[](LICENSE)
|
|
6
|
-
|
|
7
|
-
> 🚧 **Under construction.** Anhedral is in active development; features and APIs may change.
|
|
8
|
-
|
|
9
|
-
Anhedral creates TypeScript application workspaces and helps deliver them to your own cloud accounts. Start with a minimal universal frontend, add the services your product needs, and keep the source code, infrastructure, data and billing under your control.
|
|
10
|
-
|
|
11
|
-
The default is a **minimal Expo web/iOS/Android app** with React Native Reusables using shadcn conventions, NativeWind, shared styling, TypeScript, pnpm and Turborepo. Cloudflare hosts its static web export. Add API, accounts, data, files, payments or AI when needed; the resolver supplies dependencies. `--preset full-product` selects the complete compatible product foundation without activating services.
|
|
12
|
-
|
|
13
|
-
## Start locally
|
|
14
|
-
|
|
15
|
-
Use **Node.js 24.21.0 or newer** and **pnpm 10.34.5**. Initialize on Linux, macOS or WSL.
|
|
3
|
+
Start with one Next.js application configured for OpenNext on Cloudflare Workers, with Anhedral UI included as editable source. Add architecture when a product needs it.
|
|
16
4
|
|
|
17
5
|
```sh
|
|
18
|
-
npm install --global anhedral
|
|
19
|
-
|
|
20
|
-
# Inspect the default selection; no writes or network requests.
|
|
21
|
-
anhedral init my-app --dry-run --json
|
|
22
|
-
|
|
23
|
-
# Generate source, install dependencies and start development.
|
|
24
6
|
anhedral init my-app
|
|
25
7
|
cd my-app
|
|
26
8
|
pnpm dev
|
|
27
9
|
```
|
|
28
10
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
## Progressive stack
|
|
32
|
-
|
|
33
|
-
Plain init creates only the Expo client, styling and tooling. Add capabilities for
|
|
34
|
-
real requirements, or use `--preset full-product` for the complete compatible
|
|
35
|
-
foundation. [See the concise stack page](docs/anhedral-stack.md).
|
|
36
|
-
|
|
37
|
-
```mermaid
|
|
38
|
-
%%{init: {"flowchart": {"curve": "linear", "nodeSpacing": 35, "rankSpacing": 50, "padding": 18}}}%%
|
|
39
|
-
flowchart TB
|
|
40
|
-
subgraph minimal["1 · Minimal default"]
|
|
41
|
-
client["Expo · web / iOS / Android<br/>React Native Reusables · shadcn conventions<br/>NativeWind · shared tokens"]
|
|
42
|
-
web["Cloudflare static web Worker"]
|
|
43
|
-
client -->|"web export"| web
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
subgraph optional["2 · Optional capabilities · choose independently"]
|
|
47
|
-
backend["Hono API · Cloudflare Workers<br/>Public contracts · authorization"]
|
|
48
|
-
core["Data, accounts and files<br/>Drizzle / D1 · Better Auth · private R2 · KV"]
|
|
49
|
-
compute["AI, analytics and processing<br/>Workers AI · Analytics Engine · Basin<br/>Images · Queues · Cron · Workflows"]
|
|
50
|
-
media["Realtime and video<br/>Durable Object rooms · RealtimeKit<br/>Stream live / uploaded video"]
|
|
51
|
-
payments["Payments<br/>Stripe web · RevenueCat native<br/>Shared entitlements enforced by Hono"]
|
|
52
|
-
clients["Additional client<br/>WXT browser side panel"]
|
|
53
|
-
operations["External operations<br/>Resend email · Sentry monitoring"]
|
|
54
|
-
backend -.-> core
|
|
55
|
-
backend -.-> compute
|
|
56
|
-
backend -.-> media
|
|
57
|
-
backend -.-> payments
|
|
58
|
-
backend -.-> operations
|
|
59
|
-
clients -.->|"when a backend is needed"| backend
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
web ~~~ clients
|
|
63
|
-
web -.->|"add API service binding"| backend
|
|
64
|
-
client -.->|"native HTTPS when selected"| backend
|
|
65
|
-
|
|
66
|
-
subgraph full["3 · Full-product preset · selection summary"]
|
|
67
|
-
preset["Minimal app + all capabilities above<br/>22 selected products · no provider activation"]
|
|
68
|
-
end
|
|
69
|
-
core ~~~ preset
|
|
70
|
-
compute ~~~ preset
|
|
71
|
-
media ~~~ preset
|
|
72
|
-
payments ~~~ preset
|
|
73
|
-
operations ~~~ preset
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
| Need | Selection | Added automatically |
|
|
77
|
-
| --- | --- | --- |
|
|
78
|
-
| Minimal client | Plain init / `--preset minimal` | Expo, NativeWind, shared tokens and workspace tooling |
|
|
79
|
-
| Server logic | `--expo --hono` | Hono API and public contracts |
|
|
80
|
-
| Persistence | `--d1` | Hono and Drizzle/D1 |
|
|
81
|
-
| Accounts | `--better-auth` | Hono, a database and browser/native auth |
|
|
82
|
-
| AI | `--workers-ai` | Hono and AI binding; no implicit accounts or billing |
|
|
83
|
-
| Full product | `--preset full-product` | All compatible Cloudflare layers, WXT, payments, email and monitoring |
|
|
84
|
-
|
|
85
|
-
The full preset includes Expo, WXT side panel, Hono, Better Auth, D1, R2, KV,
|
|
86
|
-
Stripe, RevenueCat, Workers AI, Analytics Engine, Basin/Pipelines, Images,
|
|
87
|
-
RealtimeKit, Durable Object rooms, uploaded/live Stream video, Queues, Cron,
|
|
88
|
-
Workflows, Resend and Sentry. Bindings and helpers still need product logic,
|
|
89
|
-
provider setup and real acceptance. Init never provisions or activates services.
|
|
90
|
-
|
|
91
|
-
```sh
|
|
92
|
-
anhedral init complete --preset full-product --dry-run --json
|
|
93
|
-
anhedral add better-auth --cwd my-app --dry-run --json
|
|
94
|
-
anhedral add workers-ai images --cwd my-app --dry-run --json
|
|
95
|
-
anhedral add stripe revenuecat --cwd my-app --dry-run --json
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Additions preserve edited source and reject conflicting regeneration or backend
|
|
99
|
-
relocation. Auth additions expose `/sign-in` and `/account` for product navigation.
|
|
100
|
-
|
|
101
|
-
## Choose the applications
|
|
102
|
-
|
|
103
|
-
Expo on Cloudflare is the minimal universal default. **Next.js on Vercel**
|
|
104
|
-
(`--next`) is the usual explicit web alternative; **Vinext on Cloudflare**
|
|
105
|
-
(`--vinext`) is also available. `--hono`, `--wxt` and `--electron` alone select
|
|
106
|
-
standalone applications; combine them with `--expo` when desired. Explicit Neon
|
|
107
|
-
or Clerk replace the full preset's D1 or Better Auth selections. OpenNext remains
|
|
108
|
-
an explicit compatibility profile (`--next --hosting=cloudflare`).
|
|
109
|
-
|
|
110
|
-
Every workspace uses pnpm and Turborepo with shared TypeScript/ESLint configuration
|
|
111
|
-
and one root lockfile. Public contracts appear with Hono; server auth, database
|
|
112
|
-
and billing packages appear only when selected. Root `pnpm dev` serves exported
|
|
113
|
-
Expo web on 3000 and Hono on 8787 when present. Native Metro uses
|
|
114
|
-
`pnpm --dir apps/mobile start`. Browser changes need a re-export; this is not HMR.
|
|
115
|
-
Keep SDK 57 pinned and provide build-time paths for static dynamic routes.
|
|
116
|
-
|
|
117
|
-
## Choose data and identity
|
|
118
|
-
|
|
119
|
-
| Selection | Generates | Selection rule |
|
|
120
|
-
| --------------- | --------------------------------------------------------------------- | ----------------------------------------------------- |
|
|
121
|
-
| `--d1` | Shared Drizzle/SQLite database package and migrations | Cloudflare runtime; alternative to Neon |
|
|
122
|
-
| `--neon` | Shared Drizzle/PostgreSQL package using Neon HTTP | Server required; separate direct migration connection |
|
|
123
|
-
| `--better-auth` | Auth factory, database schema and server auth routes | Adds D1 when no database is selected; can use Neon |
|
|
124
|
-
| `--clerk` | Managed web identity integration and/or backend authentication helper | Alternative to Better Auth; server required |
|
|
125
|
-
| `--local-data` | Device-local persistence interface | Implement platform adapters and synchronization |
|
|
126
|
-
|
|
127
|
-
Database code lives in `packages/db`, including schemas and explicit migration tooling. Browser and device clients call server endpoints. Hosting audience protection and application resource authorization are separate from selecting an identity provider.
|
|
128
|
-
|
|
129
|
-
## Choose services and integrations
|
|
130
|
-
|
|
131
|
-
Private R2 and every service below are optional; full-product selects the complete compatible set. The generated scope column distinguishes bindings and Workers from SDK factories and integration guidance.
|
|
132
|
-
|
|
133
|
-
| Selection | Purpose | Generated scope |
|
|
134
|
-
| ----------------- | --------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
135
|
-
| `--r2` | Private files | R2 Worker binding and authorization guidance |
|
|
136
|
-
| `--analytics-engine` | Custom event analytics | Dataset binding and privacy-safe server event helper |
|
|
137
|
-
| `--images` | Image processing | Images binding and private raw-byte transform helper |
|
|
138
|
-
| `--realtimekit` | Audio/video conferencing | Meeting/participant-token helpers; client SDK/UI remains product work |
|
|
139
|
-
| `--video` | Uploaded video | Private Stream upload helper; implement processing checks and signed playback |
|
|
140
|
-
| `--kv` | Cache/configuration | Eventually consistent Worker binding |
|
|
141
|
-
| `--realtime` | WebSocket rooms | Separate Durable Object Worker; implement room authorization |
|
|
142
|
-
| `--neon-realtime` | Live PostgreSQL query results | Server/client factories and Drizzle adapter; adds Neon; manual branch activation |
|
|
143
|
-
| `--stream` | One-to-many live video | Cloudflare Stream WHIP/WHEP; server management factory; manual activation and product UI |
|
|
144
|
-
| `--queues` | Background jobs | Producer, consumer and dead-letter configuration; implement processing/idempotency |
|
|
145
|
-
| `--cron` | Scheduled work | Separate Worker with an hourly starter schedule |
|
|
146
|
-
| `--workflows` | Durable multi-step work | Separate Worker with a starter validation step |
|
|
147
|
-
| `--workers-ai` | Cloudflare inference | Worker AI binding; implement model calls |
|
|
148
|
-
| `--openai` | Direct OpenAI integration | Server SDK factory in `packages/ai` |
|
|
149
|
-
| `--ai-sdk` | AI streaming/provider abstraction | AI SDK exports with an OpenAI provider; alternative to `--openai` |
|
|
150
|
-
| `--resend` | Transactional email | Server SDK factory in `packages/email` |
|
|
151
|
-
| `--stripe` | Payments/subscriptions | Hono Checkout/portal/webhooks, DB projection and server entitlement guard |
|
|
152
|
-
| `--revenuecat` | Cross-store entitlements | Native purchase/restore/manage plus Hono webhooks and shared entitlement projection |
|
|
153
|
-
| `--sentry` | Error/crash monitoring | Integration boundary and redaction fields; initialize platform SDKs |
|
|
154
|
-
| `--posthog` | Product analytics | Server analytics factory |
|
|
155
|
-
| `--basin` | Cloudflare analytical events | Private stream binding and event helper |
|
|
156
|
-
| `--styling` | Shared design tokens | Light/dark tokens and Tailwind preset; automatically included with Expo/WXT |
|
|
157
|
-
|
|
158
|
-
Live video (`--stream`), room messaging (`--realtime`) and live SQL (`--neon-realtime`) can coexist. See [live video setup and limits](docs/stack-standard.md#live-video-with-cloudflare-stream). PostHog and Basin can coexist with separate packages. Workers AI can accompany either AI SDK choice. Provider setup supports selected resources for Neon, Clerk, Resend, Stripe, RevenueCat, Sentry, PostHog and OpenAI; credentials, permissions and remaining owner steps are described in the [provider reference](docs/software-factory.md#provider-configuration).
|
|
159
|
-
|
|
160
|
-
### Composition rules
|
|
161
|
-
|
|
162
|
-
- Choose one web framework, one database and one identity provider; D1 and Better Auth are the defaults when data/identity is needed. `--openai` and `--ai-sdk` are alternatives.
|
|
163
|
-
- Database/auth, Stream and Neon Realtime selections need a compatible server. For mobile with PostgreSQL, use `--expo --hono --neon`.
|
|
164
|
-
- New server capabilities introduce Hono on Cloudflare, including for Next.js/Vercel. Existing apps retain runtime ownership during `add`.
|
|
165
|
-
- New Expo workspaces, explicit OpenNext, Queues, Basin, Images and Analytics Engine use Wrangler for the Cloudflare workspace. Other supported Cloudflare selections use Void. `add` rejects changes that switch an existing engine or relocate runtime source.
|
|
166
|
-
- Neon Realtime requires Neon and manual Realtime configuration. Stripe and RevenueCat are independently optional; WXT is an optional browser-extension interface.
|
|
167
|
-
|
|
168
|
-
Examples:
|
|
169
|
-
|
|
170
|
-
```sh
|
|
171
|
-
# Web with database-backed identity; Better Auth adds D1.
|
|
172
|
-
anhedral init my-app --better-auth
|
|
173
|
-
|
|
174
|
-
# Universal web/iOS/Android, shared API and PostgreSQL.
|
|
175
|
-
anhedral init my-app --expo --neon
|
|
176
|
-
|
|
177
|
-
# Vercel web with a Cloudflare API and private files.
|
|
178
|
-
anhedral init my-app --next --r2
|
|
179
|
-
|
|
180
|
-
# Live broadcasts with independent room messaging and SQL subscriptions.
|
|
181
|
-
anhedral init my-app --stream --neon-realtime --realtime
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
Inspect the full catalog and preview later additions:
|
|
185
|
-
|
|
186
|
-
```sh
|
|
187
|
-
anhedral registry list
|
|
188
|
-
anhedral registry view resend --json
|
|
189
|
-
anhedral add resend --cwd my-app --dry-run --json
|
|
190
|
-
anhedral add resend --cwd my-app
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
Generated entry points live in `apps/*`, shared code in `packages/*`, and Anhedral configuration in one root `anhedral.json`. Read the [source-only full-stack example](https://github.com/anhedral/anhedral-cli/tree/main/examples/full-stack) to see a larger project without creating services.
|
|
194
|
-
|
|
195
|
-
## Build and deliver
|
|
196
|
-
|
|
197
|
-
Implement the product, configure selected integrations and review database migrations. Then use the [software factory](docs/software-factory.md) to check provider access, connect the intended account and audience, commit source, ship and verify real user flows.
|
|
11
|
+
Init creates only `apps/web` plus shared tooling and tokens. It includes three reviewed web starter components (Button, Input and Label), official shadcn configuration and Anhedral UI metadata. It creates no Expo app, API, database, authentication or cloud resources.
|
|
198
12
|
|
|
199
13
|
```sh
|
|
200
|
-
anhedral
|
|
201
|
-
anhedral
|
|
202
|
-
|
|
203
|
-
anhedral
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
anhedral ship --dry-run --json
|
|
207
|
-
anhedral ship --json
|
|
208
|
-
anhedral verify --json
|
|
14
|
+
anhedral init my-app --dry-run --json
|
|
15
|
+
anhedral init my-app --skip-install --no-git
|
|
16
|
+
anhedral ui list
|
|
17
|
+
anhedral ui add card --web
|
|
18
|
+
anhedral ui diff card --web
|
|
19
|
+
anhedral ui doctor --web
|
|
209
20
|
```
|
|
210
21
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
Cloudflare and Vercel have automated delivery and provider evidence checks. Mixed delivery runs Cloudflare before Vercel and can partially succeed. Expo native shipping with an explicit platform returns verified EAS build artifacts; store submission is separate. Electron and extension projects include local build/package tooling, with signing and distribution handled through their platform workflows.
|
|
22
|
+
Anhedral UI is a small catalog and CLI over official shadcn on web and React Native Reusables on native. Components are copied into your application. Native resolution prefers a reviewed Anhedral extension when one exists, then RNR; unsupported components are reported. The extension registry starts empty. There is no Anhedral component runtime, whole-library fork or automatic source replacement.
|
|
214
23
|
|
|
215
|
-
|
|
24
|
+
For an existing Expo app, complete the upstream React Native Reusables NativeWind 4 setup first, then use `anhedral ui init --native`. Ambiguous workspaces require `--web`, `--native`, `--all` or an application-specific `--cwd`. UI installation does not require Hono, a database or authentication.
|
|
216
25
|
|
|
217
|
-
|
|
26
|
+
Add the rest strategically through the CLI:
|
|
218
27
|
|
|
219
28
|
```sh
|
|
220
|
-
|
|
221
|
-
|
|
29
|
+
anhedral stack list
|
|
30
|
+
anhedral add hono
|
|
31
|
+
anhedral add database-auth
|
|
32
|
+
anhedral add expo native-ui --dry-run --json
|
|
33
|
+
anhedral add side-panel --with-dependencies --dry-run --json
|
|
222
34
|
```
|
|
223
35
|
|
|
224
|
-
|
|
36
|
+
The catalog includes private R2, Stripe, events, RTC, AI, Expo, native UI, RevenueCat, WXT, Side Panel and GPUI. Missing prerequisites require an explicit selection or `--with-dependencies`. “If needed” decisions remain open. Additions preserve edited source and do not provision providers, install credentials, migrate databases or deploy. Anhedral Platform remains a separate managed product; no Platform account is required.
|
|
225
37
|
|
|
226
|
-
|
|
38
|
+
See [stack standard](docs/stack-standard.md), [workflow](docs/software-factory.md) and [UI commands](docs/ui.md) and [stack additions](docs/capabilities.md).
|
|
227
39
|
|
|
228
|
-
|
|
40
|
+
## Compatibility
|
|
229
41
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
| Document | Use it to answer |
|
|
233
|
-
| -------------------------------------------- | ------------------------------------------------------------------------ |
|
|
234
|
-
| [Stack standard](docs/stack-standard.md) | What should the application contain, and how should it fit together? |
|
|
235
|
-
| [Software factory](docs/software-factory.md) | How do I turn a brief into a tested, delivered and maintainable product? |
|
|
236
|
-
|
|
237
|
-
The [verification record](docs/verification.md) keeps dated code reviews, provider evidence and remaining acceptance gaps together. Provider setup, CLI behavior, dashboard development and the release process are sections of the software factory.
|
|
238
|
-
|
|
239
|
-
Use `anhedral --help` and `anhedral help <command>` for command options. `--cwd` selects the project; `--json` produces structured output. Use its [provider configuration](docs/software-factory.md#provider-configuration), [CLI behavior](docs/software-factory.md#cli-behavior), [Codex dashboard](docs/software-factory.md#project-dashboard) and [release process](docs/software-factory.md#maintain-and-release-the-cli) sections for details.
|
|
240
|
-
|
|
241
|
-
## Work on the CLI
|
|
242
|
-
|
|
243
|
-
```sh
|
|
244
|
-
pnpm install --frozen-lockfile
|
|
245
|
-
pnpm build
|
|
246
|
-
node dist/bin.js init ../my-test-app --dry-run --json
|
|
247
|
-
pnpm test:all
|
|
248
|
-
```
|
|
42
|
+
This changes the default generated layout. Existing applications, Platform runtime images and installed plugins keep their reviewed pins until explicitly upgraded. The retained legacy native source and full-stack recipes are compatibility material; new init does not copy them. Publishing does not update an existing application or installed plugin.
|
|
249
43
|
|
|
250
|
-
|
|
44
|
+
For source development, run `pnpm install --frozen-lockfile && pnpm build`, then `node dist/bin.js init my-app`.
|
|
251
45
|
|
|
252
|
-
|
|
46
|
+
Apache-2.0. Generated applications are editable source that consumers may customize and license for their own products. Retain the applicable MIT notices for copied upstream UI source.
|
|
@@ -63,8 +63,18 @@ export function verifyAuditReport(report, { status, patchedCoordinates = [] } =
|
|
|
63
63
|
)
|
|
64
64
|
)
|
|
65
65
|
fail('Incomplete advisory details; no advisory exception was applied.');
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
// pnpm emits separate peer/workspace instances with the same version.
|
|
67
|
+
// Keep every instance in severity counts; only an identical version/path
|
|
68
|
+
// repeated within this advisory is ambiguous report data.
|
|
69
|
+
const affectedPaths = new Set();
|
|
70
|
+
for (const item of finding.findings) {
|
|
71
|
+
for (const dependencyPath of item.paths) {
|
|
72
|
+
const coordinate = JSON.stringify([item.version, dependencyPath]);
|
|
73
|
+
if (affectedPaths.has(coordinate))
|
|
74
|
+
fail('Duplicate affected version/path in advisory details.');
|
|
75
|
+
affectedPaths.add(coordinate);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
68
78
|
counts[finding.severity] += finding.findings.length;
|
|
69
79
|
}
|
|
70
80
|
for (const severity of severities) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { requireSession } from '../security';
|
|
4
|
+
import type { AppEnv } from '../environment';
|
|
5
|
+
export const aiRoutes = new Hono<AppEnv>();
|
|
6
|
+
const configuration = z.object({
|
|
7
|
+
AI_MODEL: z.string().min(1),
|
|
8
|
+
AI_DAILY_LIMIT: z.coerce.number().int().min(1).max(1000),
|
|
9
|
+
});
|
|
10
|
+
const input = z.object({ prompt: z.string().trim().min(1).max(4000) });
|
|
11
|
+
aiRoutes.post('/ai/generate', requireSession, async (c) => {
|
|
12
|
+
const config = configuration.safeParse(c.env);
|
|
13
|
+
if (!config.success)
|
|
14
|
+
return c.json({ error: 'Choose a model and a daily limit from 1 to 1000' }, 503);
|
|
15
|
+
const body = input.safeParse(await c.req.json().catch(() => null));
|
|
16
|
+
if (!body.success) return c.json({ error: 'Prompt must contain 1–4000 characters' }, 400);
|
|
17
|
+
const key = c.get('userId') + ':' + new Date().toISOString().slice(0, 10);
|
|
18
|
+
const quota = await c.env.DB.prepare(
|
|
19
|
+
'INSERT INTO ai_usage(id,count) VALUES (?,1) ON CONFLICT(id) DO UPDATE SET count = count + 1 WHERE count < ? RETURNING count',
|
|
20
|
+
)
|
|
21
|
+
.bind(key, config.data.AI_DAILY_LIMIT)
|
|
22
|
+
.first();
|
|
23
|
+
if (!quota) return c.json({ error: 'Daily AI limit reached' }, 429);
|
|
24
|
+
// Failed provider calls consume quota as well; retrying cannot bypass the limit.
|
|
25
|
+
const result = await c.env.AI.run(config.data.AI_MODEL as Parameters<Ai['run']>[0], {
|
|
26
|
+
messages: [{ role: 'user', content: body.data.prompt }],
|
|
27
|
+
max_tokens: 512,
|
|
28
|
+
});
|
|
29
|
+
return c.json({ result });
|
|
30
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { bodyLimit } from 'hono/body-limit';
|
|
3
|
+
import { capabilities } from './capabilities';
|
|
4
|
+
import type { AppEnv } from './environment';
|
|
5
|
+
|
|
6
|
+
const app = new Hono<AppEnv>();
|
|
7
|
+
app.use('/api/*', bodyLimit({ maxSize: 1024 * 1024 }));
|
|
8
|
+
app.use('/api/*', async (c, next) => {
|
|
9
|
+
await next();
|
|
10
|
+
c.header('Cache-Control', 'private, no-store');
|
|
11
|
+
});
|
|
12
|
+
app.get('/api/health', (c) => c.json({ ok: true }));
|
|
13
|
+
app.route('/api', capabilities);
|
|
14
|
+
app.onError((_error, c) => c.json({ error: 'Application request failed' }, 500));
|
|
15
|
+
export default app;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Enable methods deliberately after configuring credentials, email and policies.
|
|
2
|
+
// OAuth, passkeys, MFA and organizations each need their matching provider/plugin,
|
|
3
|
+
// schema generation, reviewed migrations and client configuration before use.
|
|
4
|
+
export const authFeatures = { emailPassword: false };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
CREATE TABLE `account` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`account_id` text NOT NULL,
|
|
4
|
+
`provider_id` text NOT NULL,
|
|
5
|
+
`user_id` text NOT NULL,
|
|
6
|
+
`access_token` text,
|
|
7
|
+
`refresh_token` text,
|
|
8
|
+
`id_token` text,
|
|
9
|
+
`access_token_expires_at` integer,
|
|
10
|
+
`refresh_token_expires_at` integer,
|
|
11
|
+
`scope` text,
|
|
12
|
+
`password` text,
|
|
13
|
+
`created_at` integer NOT NULL,
|
|
14
|
+
`updated_at` integer NOT NULL,
|
|
15
|
+
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
|
16
|
+
);
|
|
17
|
+
--> statement-breakpoint
|
|
18
|
+
CREATE INDEX `account_user_id_idx` ON `account` (`user_id`);--> statement-breakpoint
|
|
19
|
+
CREATE TABLE `session` (
|
|
20
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
21
|
+
`expires_at` integer NOT NULL,
|
|
22
|
+
`token` text NOT NULL,
|
|
23
|
+
`created_at` integer NOT NULL,
|
|
24
|
+
`updated_at` integer NOT NULL,
|
|
25
|
+
`ip_address` text,
|
|
26
|
+
`user_agent` text,
|
|
27
|
+
`user_id` text NOT NULL,
|
|
28
|
+
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
|
29
|
+
);
|
|
30
|
+
--> statement-breakpoint
|
|
31
|
+
CREATE UNIQUE INDEX `session_token_unique` ON `session` (`token`);--> statement-breakpoint
|
|
32
|
+
CREATE INDEX `session_user_id_idx` ON `session` (`user_id`);--> statement-breakpoint
|
|
33
|
+
CREATE TABLE `user` (
|
|
34
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
35
|
+
`name` text NOT NULL,
|
|
36
|
+
`email` text NOT NULL,
|
|
37
|
+
`email_verified` integer DEFAULT false NOT NULL,
|
|
38
|
+
`image` text,
|
|
39
|
+
`created_at` integer NOT NULL,
|
|
40
|
+
`updated_at` integer NOT NULL
|
|
41
|
+
);
|
|
42
|
+
--> statement-breakpoint
|
|
43
|
+
CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);--> statement-breakpoint
|
|
44
|
+
CREATE TABLE `verification` (
|
|
45
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
46
|
+
`identifier` text NOT NULL,
|
|
47
|
+
`value` text NOT NULL,
|
|
48
|
+
`expires_at` integer NOT NULL,
|
|
49
|
+
`created_at` integer NOT NULL,
|
|
50
|
+
`updated_at` integer NOT NULL
|
|
51
|
+
);
|
|
52
|
+
--> statement-breakpoint
|
|
53
|
+
CREATE INDEX `verification_identifier_idx` ON `verification` (`identifier`);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { createAuth, authConfiguration } from '../auth';
|
|
3
|
+
import { requireSession } from '../security';
|
|
4
|
+
import type { AppEnv } from '../environment';
|
|
5
|
+
export const authRoutes = new Hono<AppEnv>();
|
|
6
|
+
authRoutes.on(['GET', 'POST'], '/auth/*', (c) => {
|
|
7
|
+
if (!authConfiguration.safeParse(c.env).success)
|
|
8
|
+
return c.json({ error: 'Authentication needs configuration' }, 503);
|
|
9
|
+
return createAuth(c.env).handler(c.req.raw);
|
|
10
|
+
});
|
|
11
|
+
authRoutes.get('/session', requireSession, (c) => c.json({ userId: c.get('userId') }));
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { index, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';
|
|
2
|
+
const timestamps = () => ({
|
|
3
|
+
createdAt: integer('created_at', { mode: 'timestamp_ms' })
|
|
4
|
+
.notNull()
|
|
5
|
+
.$defaultFn(() => new Date()),
|
|
6
|
+
updatedAt: integer('updated_at', { mode: 'timestamp_ms' })
|
|
7
|
+
.notNull()
|
|
8
|
+
.$defaultFn(() => new Date())
|
|
9
|
+
.$onUpdate(() => new Date()),
|
|
10
|
+
});
|
|
11
|
+
export const user = sqliteTable('user', {
|
|
12
|
+
id: text('id').primaryKey(),
|
|
13
|
+
name: text('name').notNull(),
|
|
14
|
+
email: text('email').notNull().unique(),
|
|
15
|
+
emailVerified: integer('email_verified', { mode: 'boolean' }).notNull().default(false),
|
|
16
|
+
image: text('image'),
|
|
17
|
+
...timestamps(),
|
|
18
|
+
});
|
|
19
|
+
export const session = sqliteTable(
|
|
20
|
+
'session',
|
|
21
|
+
{
|
|
22
|
+
id: text('id').primaryKey(),
|
|
23
|
+
expiresAt: integer('expires_at', { mode: 'timestamp_ms' }).notNull(),
|
|
24
|
+
token: text('token').notNull().unique(),
|
|
25
|
+
...timestamps(),
|
|
26
|
+
ipAddress: text('ip_address'),
|
|
27
|
+
userAgent: text('user_agent'),
|
|
28
|
+
userId: text('user_id')
|
|
29
|
+
.notNull()
|
|
30
|
+
.references(() => user.id, { onDelete: 'cascade' }),
|
|
31
|
+
},
|
|
32
|
+
(t) => [index('session_user_id_idx').on(t.userId)],
|
|
33
|
+
);
|
|
34
|
+
export const account = sqliteTable(
|
|
35
|
+
'account',
|
|
36
|
+
{
|
|
37
|
+
id: text('id').primaryKey(),
|
|
38
|
+
accountId: text('account_id').notNull(),
|
|
39
|
+
providerId: text('provider_id').notNull(),
|
|
40
|
+
userId: text('user_id')
|
|
41
|
+
.notNull()
|
|
42
|
+
.references(() => user.id, { onDelete: 'cascade' }),
|
|
43
|
+
accessToken: text('access_token'),
|
|
44
|
+
refreshToken: text('refresh_token'),
|
|
45
|
+
idToken: text('id_token'),
|
|
46
|
+
accessTokenExpiresAt: integer('access_token_expires_at', { mode: 'timestamp_ms' }),
|
|
47
|
+
refreshTokenExpiresAt: integer('refresh_token_expires_at', { mode: 'timestamp_ms' }),
|
|
48
|
+
scope: text('scope'),
|
|
49
|
+
password: text('password'),
|
|
50
|
+
...timestamps(),
|
|
51
|
+
},
|
|
52
|
+
(t) => [index('account_user_id_idx').on(t.userId)],
|
|
53
|
+
);
|
|
54
|
+
export const verification = sqliteTable(
|
|
55
|
+
'verification',
|
|
56
|
+
{
|
|
57
|
+
id: text('id').primaryKey(),
|
|
58
|
+
identifier: text('identifier').notNull(),
|
|
59
|
+
value: text('value').notNull(),
|
|
60
|
+
expiresAt: integer('expires_at', { mode: 'timestamp_ms' }).notNull(),
|
|
61
|
+
...timestamps(),
|
|
62
|
+
},
|
|
63
|
+
(t) => [index('verification_identifier_idx').on(t.identifier)],
|
|
64
|
+
);
|