create-m5kdev 0.25.2 → 0.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/create.cjs +18 -1
- package/dist/src/create.cjs.map +1 -1
- package/dist/src/fs.cjs +65 -5
- package/dist/src/fs.cjs.map +1 -1
- package/dist/src/fs.d.cts +13 -2
- package/dist/src/index.cjs +0 -0
- package/dist/src/paths.cjs +2 -2
- package/dist/src/prompts.cjs +22 -0
- package/dist/src/prompts.cjs.map +1 -1
- package/dist/src/runCli.cjs +13 -2
- package/dist/src/runCli.cjs.map +1 -1
- package/dist/src/types.d.cts +9 -1
- package/package.json +8 -6
- package/templates/minimal-app/.cursor/rules/frontend-data-guide.mdc +46 -3
- package/templates/minimal-app/.cursor/rules/module-db-guide.mdc +15 -1
- package/templates/minimal-app/.cursor/rules/module-dto-guide.mdc +60 -0
- package/templates/minimal-app/.cursor/rules/module-repository-guide.mdc +98 -193
- package/templates/minimal-app/.cursor/rules/module-schema-guide.mdc +53 -173
- package/templates/minimal-app/.cursor/rules/module-service-guide.mdc +133 -240
- package/templates/minimal-app/.cursor/rules/module-trpc-guide.mdc +71 -113
- package/templates/minimal-app/README.md.tpl +3 -3
- package/templates/minimal-app/apps/.gitignore.tpl +13 -0
- package/templates/minimal-app/apps/e2e/package.json.tpl +23 -0
- package/templates/minimal-app/apps/e2e/playwright.config.ts.tpl +39 -0
- package/templates/minimal-app/apps/e2e/playwright.expo.config.ts.tpl +38 -0
- package/templates/minimal-app/apps/e2e/servers.ts.tpl +100 -0
- package/templates/minimal-app/apps/e2e/tests/email.spec.ts.tpl +47 -0
- package/templates/minimal-app/apps/e2e/tests/expo-helpers.ts.tpl +73 -0
- package/templates/minimal-app/apps/e2e/tests/expo-standard.spec.ts.tpl +517 -0
- package/templates/minimal-app/apps/e2e/tests/expo-waitlist.spec.ts.tpl +94 -0
- package/templates/minimal-app/apps/e2e/tests/helpers.ts.tpl +289 -0
- package/templates/minimal-app/apps/e2e/tests/standard.spec.ts.tpl +516 -0
- package/templates/minimal-app/apps/e2e/tests/waitlist.spec.ts.tpl +107 -0
- package/templates/minimal-app/apps/e2e/tsconfig.json.tpl +10 -0
- package/templates/minimal-app/apps/email/package.json.tpl +34 -34
- package/templates/minimal-app/apps/email/src/emails/accountDeletionEmail.tsx.tpl +35 -34
- package/templates/minimal-app/apps/email/src/emails/organizationInviteEmail.tsx.tpl +34 -33
- package/templates/minimal-app/apps/email/src/emails/passwordResetEmail.tsx.tpl +35 -34
- package/templates/minimal-app/apps/email/src/emails/verificationEmail.tsx.tpl +37 -36
- package/templates/minimal-app/apps/email/src/emails/waitlistEmails.tsx.tpl +87 -0
- package/templates/minimal-app/apps/email/src/index.ts.tpl +72 -32
- package/templates/minimal-app/apps/email/src/resources.ts.tpl +65 -36
- package/templates/minimal-app/apps/email/tsconfig.json.tpl +16 -11
- package/templates/minimal-app/apps/expo/.gitignore.tpl +44 -0
- package/templates/minimal-app/apps/expo/.prettierignore +13 -0
- package/templates/minimal-app/apps/expo/.prettierrc.json.tpl +9 -0
- package/templates/minimal-app/apps/expo/CHANGELOG.md.tpl +156 -0
- package/templates/minimal-app/apps/expo/README.md.tpl +44 -0
- package/templates/minimal-app/apps/expo/app.json.tpl +36 -0
- package/templates/minimal-app/apps/expo/assets/images/adaptive-icon.png +0 -0
- package/templates/minimal-app/apps/expo/assets/images/favicon.png +0 -0
- package/templates/minimal-app/apps/expo/assets/images/icon.png +0 -0
- package/templates/minimal-app/apps/expo/assets/images/splash-icon.png +0 -0
- package/templates/minimal-app/apps/expo/eslint.config.js.tpl +8 -0
- package/templates/minimal-app/apps/expo/expo-env.d.ts.tpl +3 -0
- package/templates/minimal-app/apps/expo/metro.config.js.tpl +16 -0
- package/templates/minimal-app/apps/expo/package.json.tpl +59 -0
- package/templates/minimal-app/apps/expo/src/app/_layout.tsx.tpl +31 -0
- package/templates/minimal-app/apps/expo/src/app/claim-account.tsx.tpl +151 -0
- package/templates/minimal-app/apps/expo/src/app/forgot-password.tsx.tpl +53 -0
- package/templates/minimal-app/apps/expo/src/app/index.tsx.tpl +8 -0
- package/templates/minimal-app/apps/expo/src/app/login.tsx.tpl +71 -0
- package/templates/minimal-app/apps/expo/src/app/logout.tsx.tpl +19 -0
- package/templates/minimal-app/apps/expo/src/app/organization/accept-invitation.tsx.tpl +85 -0
- package/templates/minimal-app/apps/expo/src/app/posts.tsx.tpl +40 -0
- package/templates/minimal-app/apps/expo/src/app/reset-password.tsx.tpl +75 -0
- package/templates/minimal-app/apps/expo/src/app/signup.tsx.tpl +193 -0
- package/templates/minimal-app/apps/expo/src/components/AuthScaffold.tsx.tpl +34 -0
- package/templates/minimal-app/apps/expo/src/components/FormTextField.tsx.tpl +37 -0
- package/templates/minimal-app/apps/expo/src/components/LoadingScreen.tsx.tpl +10 -0
- package/templates/minimal-app/apps/expo/src/components/StatusText.tsx.tpl +22 -0
- package/templates/minimal-app/apps/expo/src/config.ts.tpl +9 -0
- package/templates/minimal-app/apps/expo/src/global.css.tpl +11 -0
- package/templates/minimal-app/apps/expo/src/lib/trpc.ts.tpl +20 -0
- package/templates/minimal-app/apps/expo/tsconfig.json.tpl +11 -0
- package/templates/minimal-app/apps/expo/uniwind-env.d.ts.tpl +1 -0
- package/templates/minimal-app/apps/expo/uniwind-types.d.ts.tpl +10 -0
- package/templates/minimal-app/apps/server/AGENTS.md.tpl +39 -39
- package/templates/minimal-app/apps/server/drizzle/0000_wealthy_absorbing_man.sql +268 -0
- package/templates/minimal-app/apps/server/drizzle/db.ts.tpl +26 -0
- package/templates/minimal-app/apps/server/drizzle/meta/0000_snapshot.json.tpl +1890 -0
- package/templates/minimal-app/apps/server/drizzle/meta/_journal.json.tpl +13 -0
- package/templates/minimal-app/apps/server/drizzle/reset.ts.tpl +33 -0
- package/templates/minimal-app/apps/server/drizzle/seed.e2e.ts.tpl +244 -0
- package/templates/minimal-app/apps/server/drizzle/seed.ts.tpl +181 -180
- package/templates/minimal-app/apps/server/drizzle/sync.ts.tpl +14 -21
- package/templates/minimal-app/apps/server/drizzle.config.ts.tpl +33 -35
- package/templates/minimal-app/apps/server/package.json.tpl +56 -52
- package/templates/minimal-app/apps/server/src/app.ts.tpl +142 -126
- package/templates/minimal-app/apps/server/src/index.ts.tpl +58 -58
- package/templates/minimal-app/apps/server/src/lib/auth.ts.tpl +12 -12
- package/templates/minimal-app/apps/server/src/modules/posts/posts.db.ts.tpl +25 -25
- package/templates/minimal-app/apps/server/src/modules/posts/posts.dto.ts.tpl +23 -0
- package/templates/minimal-app/apps/server/src/modules/posts/posts.grants.ts.tpl +30 -40
- package/templates/minimal-app/apps/server/src/modules/posts/posts.module.ts.tpl +54 -54
- package/templates/minimal-app/apps/server/src/modules/posts/posts.repository.ts.tpl +67 -112
- package/templates/minimal-app/apps/server/src/modules/posts/posts.service.ts.tpl +104 -170
- package/templates/minimal-app/apps/server/src/modules/posts/posts.trpc.ts.tpl +37 -48
- package/templates/minimal-app/apps/server/src/modules/posts/posts.utils.ts.tpl +19 -0
- package/templates/minimal-app/apps/server/src/modules/test-harness/test-harness.module.ts.tpl +279 -0
- package/templates/minimal-app/apps/server/src/schema.ts.tpl +20 -0
- package/templates/minimal-app/apps/server/src/types.ts.tpl +1 -1
- package/templates/minimal-app/apps/server/tsconfig.json.tpl +20 -14
- package/templates/minimal-app/apps/server/tsup.config.ts.tpl +9 -9
- package/templates/minimal-app/apps/shared/package.json.tpl +24 -24
- package/templates/minimal-app/apps/shared/src/modules/app/app.constants.ts.tpl +28 -2
- package/templates/minimal-app/apps/shared/src/modules/notification/notification.schema.ts.tpl +3 -3
- package/templates/minimal-app/apps/shared/src/modules/posts/posts.constants.ts.tpl +5 -5
- package/templates/minimal-app/apps/shared/src/modules/posts/posts.schema.ts.tpl +25 -76
- package/templates/minimal-app/apps/shared/tsconfig.json.tpl +16 -12
- package/templates/minimal-app/apps/webapp/index.html.tpl +22 -22
- package/templates/minimal-app/apps/webapp/package.json.tpl +53 -52
- package/templates/minimal-app/apps/webapp/public/{push-sw.js → push-sw.js.tpl} +34 -34
- package/templates/minimal-app/apps/webapp/src/App.tsx.tpl +44 -13
- package/templates/minimal-app/apps/webapp/src/Layout.tsx.tpl +18 -12
- package/templates/minimal-app/apps/webapp/src/Router.tsx.tpl +33 -40
- package/templates/minimal-app/apps/webapp/src/index.css.tpl +15 -75
- package/templates/minimal-app/apps/webapp/src/main.tsx.tpl +26 -26
- package/templates/minimal-app/apps/webapp/src/modules/posts/PostsRoute.tsx.tpl +278 -307
- package/templates/minimal-app/apps/webapp/src/modules/posts/components/PostCard.tsx.tpl +96 -138
- package/templates/minimal-app/apps/webapp/src/modules/posts/components/PostEditorModal.tsx.tpl +118 -124
- package/templates/minimal-app/apps/webapp/src/modules/posts/hooks/usePostActions.ts.tpl +108 -116
- package/templates/minimal-app/apps/webapp/src/modules/posts/hooks/usePostsList.ts.tpl +15 -9
- package/templates/minimal-app/apps/webapp/src/modules/posts/hooks/usePostsRoute.ts.tpl +13 -13
- package/templates/minimal-app/apps/webapp/src/modules/posts/posts.utils.ts.tpl +16 -16
- package/templates/minimal-app/apps/webapp/src/utils/i18n.ts.tpl +13 -13
- package/templates/minimal-app/apps/webapp/src/utils/trpc.ts.tpl +10 -6
- package/templates/minimal-app/apps/webapp/src/vite-env.d.ts.tpl +1 -1
- package/templates/minimal-app/apps/webapp/translations/{app.json.tpl → en/app.json.tpl} +7 -7
- package/templates/minimal-app/apps/webapp/translations/en/{blog-app.json.tpl → {{APP_SLUG}}.json.tpl} +135 -135
- package/templates/minimal-app/apps/webapp/tsconfig.json.tpl +17 -17
- package/templates/minimal-app/apps/webapp/vite.config.ts.tpl +31 -31
- package/templates/minimal-app/template.manifest.json +21 -0
- package/templates/minimal-app/apps/server/drizzle/generate-schema.ts.tpl +0 -31
- package/templates/minimal-app/apps/server/src/db.ts.tpl +0 -7
- package/templates/minimal-app/apps/server/src/generated/schema.ts.tpl +0 -13
- package/templates/minimal-app/apps/server/src/utils/trpc.ts.tpl +0 -8
- package/templates/minimal-app/apps/shared/src/modules/app/locale.constants.ts.tpl +0 -7
- package/templates/minimal-app/apps/shared/src/modules/app/roles.constants.ts.tpl +0 -17
- package/templates/minimal-app/apps/webapp/src/Providers.tsx.tpl +0 -36
- package/templates/minimal-app/apps/webapp/src/modules/notification/PushNotificationsPanel.tsx.tpl +0 -89
- package/templates/minimal-app/apps/webapp/src/navigation/navigation.config.tsx.tpl +0 -85
- /package/templates/minimal-app/apps/webapp/public/{logo.svg → logo.svg.tpl} +0 -0
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
# Server Module Structure Guide
|
|
2
|
-
|
|
3
|
-
Use this for modules in `apps/server/src/modules/**`.
|
|
4
|
-
|
|
5
|
-
## Preferred Module Layout
|
|
6
|
-
|
|
7
|
-
Shared contracts:
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
apps/shared/src/modules/<module>/
|
|
11
|
-
├── <module>.constants.ts
|
|
12
|
-
└── <module>.schema.ts
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
Server module:
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
apps/server/src/modules/<module>/
|
|
19
|
-
├── <module>.db.ts
|
|
20
|
-
├── <module>.repository.ts
|
|
21
|
-
├── <module>.service.ts
|
|
22
|
-
├── <module>.trpc.ts
|
|
23
|
-
└── <module>.module.ts
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Layer Boundaries
|
|
27
|
-
|
|
28
|
-
- Repositories own persistence and query construction.
|
|
29
|
-
- Services own business rules, orchestration, and context-aware defaults.
|
|
30
|
-
- tRPC files own transport only and must delegate to services.
|
|
31
|
-
- Register modules in `apps/server/src/app.ts`; use `db.ts` and `lib/auth.ts` only for scripts that need direct DB or auth access.
|
|
32
|
-
|
|
33
|
-
## Workflow, Redis, and push notifications
|
|
34
|
-
|
|
35
|
-
- `WorkflowModule` and `NotificationModule` are registered in `app.ts`. Start **Redis** locally (`REDIS_URL`) before `pnpm dev` on the server, or background jobs will not run.
|
|
36
|
-
- `index.ts` calls `builtBackendApp.start()` before listening and `builtBackendApp.shutdown()` on exit.
|
|
37
|
-
- After changing Drizzle tables, run `pnpm --filter ./apps/server sync` — do not hand-edit SQL migrations in this repo.
|
|
38
|
-
|
|
39
|
-
Push-related server env vars are documented in `apps/shared/.env.example`.
|
|
1
|
+
# Server Module Structure Guide
|
|
2
|
+
|
|
3
|
+
Use this for modules in `apps/server/src/modules/**`.
|
|
4
|
+
|
|
5
|
+
## Preferred Module Layout
|
|
6
|
+
|
|
7
|
+
Shared contracts:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
apps/shared/src/modules/<module>/
|
|
11
|
+
├── <module>.constants.ts
|
|
12
|
+
└── <module>.schema.ts
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Server module:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
apps/server/src/modules/<module>/
|
|
19
|
+
├── <module>.db.ts
|
|
20
|
+
├── <module>.repository.ts
|
|
21
|
+
├── <module>.service.ts
|
|
22
|
+
├── <module>.trpc.ts
|
|
23
|
+
└── <module>.module.ts
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Layer Boundaries
|
|
27
|
+
|
|
28
|
+
- Repositories own persistence and query construction.
|
|
29
|
+
- Services own business rules, orchestration, and context-aware defaults.
|
|
30
|
+
- tRPC files own transport only and must delegate to services.
|
|
31
|
+
- Register modules in `apps/server/src/app.ts`; use `db.ts` and `lib/auth.ts` only for scripts that need direct DB or auth access.
|
|
32
|
+
|
|
33
|
+
## Workflow, Redis, and push notifications
|
|
34
|
+
|
|
35
|
+
- `WorkflowModule` and `NotificationModule` are registered in `app.ts`. Start **Redis** locally (`REDIS_URL`) before `pnpm dev` on the server, or background jobs will not run.
|
|
36
|
+
- `index.ts` calls `builtBackendApp.start()` before listening and `builtBackendApp.shutdown()` on exit.
|
|
37
|
+
- After changing Drizzle tables, run `pnpm --filter ./apps/server sync` — do not hand-edit SQL migrations in this repo.
|
|
38
|
+
|
|
39
|
+
Push-related server env vars are documented in `apps/shared/.env.example`.
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
CREATE TABLE `account_claim_magic_links` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`claim_id` text NOT NULL,
|
|
4
|
+
`user_id` text NOT NULL,
|
|
5
|
+
`email` text NOT NULL,
|
|
6
|
+
`token` text NOT NULL,
|
|
7
|
+
`url` text NOT NULL,
|
|
8
|
+
`expires_at` integer,
|
|
9
|
+
`created_at` integer NOT NULL,
|
|
10
|
+
FOREIGN KEY (`claim_id`) REFERENCES `waitlist`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
11
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
|
|
12
|
+
);
|
|
13
|
+
--> statement-breakpoint
|
|
14
|
+
CREATE TABLE `accounts` (
|
|
15
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
16
|
+
`account_id` text NOT NULL,
|
|
17
|
+
`provider_id` text NOT NULL,
|
|
18
|
+
`user_id` text NOT NULL,
|
|
19
|
+
`access_token` text,
|
|
20
|
+
`refresh_token` text,
|
|
21
|
+
`id_token` text,
|
|
22
|
+
`access_token_expires_at` integer,
|
|
23
|
+
`refresh_token_expires_at` integer,
|
|
24
|
+
`scope` text,
|
|
25
|
+
`password` text,
|
|
26
|
+
`created_at` integer NOT NULL,
|
|
27
|
+
`updated_at` integer NOT NULL,
|
|
28
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
|
|
29
|
+
);
|
|
30
|
+
--> statement-breakpoint
|
|
31
|
+
CREATE TABLE `apikeys` (
|
|
32
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
33
|
+
`name` text,
|
|
34
|
+
`start` text,
|
|
35
|
+
`prefix` text,
|
|
36
|
+
`key` text NOT NULL,
|
|
37
|
+
`user_id` text NOT NULL,
|
|
38
|
+
`refill_interval` integer,
|
|
39
|
+
`refill_amount` integer,
|
|
40
|
+
`last_refill_at` integer,
|
|
41
|
+
`enabled` integer NOT NULL,
|
|
42
|
+
`rate_limit_enabled` integer NOT NULL,
|
|
43
|
+
`rate_limit_time_window` integer,
|
|
44
|
+
`rate_limit_max` integer,
|
|
45
|
+
`request_count` integer NOT NULL,
|
|
46
|
+
`remaining` integer,
|
|
47
|
+
`last_request` integer,
|
|
48
|
+
`expires_at` integer,
|
|
49
|
+
`created_at` integer NOT NULL,
|
|
50
|
+
`updated_at` integer NOT NULL,
|
|
51
|
+
`permissions` text,
|
|
52
|
+
`metadata` text,
|
|
53
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action
|
|
54
|
+
);
|
|
55
|
+
--> statement-breakpoint
|
|
56
|
+
CREATE TABLE `invitations` (
|
|
57
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
58
|
+
`organization_id` text NOT NULL,
|
|
59
|
+
`team_id` text,
|
|
60
|
+
`email` text NOT NULL,
|
|
61
|
+
`role` text,
|
|
62
|
+
`status` text NOT NULL,
|
|
63
|
+
`created_at` integer NOT NULL,
|
|
64
|
+
`expires_at` integer NOT NULL,
|
|
65
|
+
`inviter_id` text NOT NULL,
|
|
66
|
+
FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE no action,
|
|
67
|
+
FOREIGN KEY (`team_id`) REFERENCES `teams`(`id`) ON UPDATE no action ON DELETE no action,
|
|
68
|
+
FOREIGN KEY (`inviter_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action
|
|
69
|
+
);
|
|
70
|
+
--> statement-breakpoint
|
|
71
|
+
CREATE TABLE `members` (
|
|
72
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
73
|
+
`organization_id` text NOT NULL,
|
|
74
|
+
`user_id` text NOT NULL,
|
|
75
|
+
`role` text NOT NULL,
|
|
76
|
+
`created_at` integer NOT NULL,
|
|
77
|
+
`preferences` text DEFAULT '{}',
|
|
78
|
+
`metadata` text DEFAULT '{}',
|
|
79
|
+
`onboarding` integer,
|
|
80
|
+
`flags` text DEFAULT '[]',
|
|
81
|
+
FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE no action,
|
|
82
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action
|
|
83
|
+
);
|
|
84
|
+
--> statement-breakpoint
|
|
85
|
+
CREATE TABLE `notification_devices` (
|
|
86
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
87
|
+
`user_id` text NOT NULL,
|
|
88
|
+
`platform` text NOT NULL,
|
|
89
|
+
`endpoint` text,
|
|
90
|
+
`subscription` text,
|
|
91
|
+
`token` text,
|
|
92
|
+
`label` text,
|
|
93
|
+
`enabled` integer DEFAULT true NOT NULL,
|
|
94
|
+
`created_at` integer NOT NULL,
|
|
95
|
+
`updated_at` integer NOT NULL,
|
|
96
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
|
|
97
|
+
);
|
|
98
|
+
--> statement-breakpoint
|
|
99
|
+
CREATE UNIQUE INDEX `notification_devices_endpoint_unique` ON `notification_devices` (`endpoint`);--> statement-breakpoint
|
|
100
|
+
CREATE UNIQUE INDEX `notification_devices_token_unique` ON `notification_devices` (`token`);--> statement-breakpoint
|
|
101
|
+
CREATE TABLE `notification_send_logs` (
|
|
102
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
103
|
+
`batch_id` text NOT NULL,
|
|
104
|
+
`user_id` text NOT NULL,
|
|
105
|
+
`device_id` text NOT NULL,
|
|
106
|
+
`provider` text NOT NULL,
|
|
107
|
+
`title` text NOT NULL,
|
|
108
|
+
`body` text NOT NULL,
|
|
109
|
+
`data` text,
|
|
110
|
+
`status` text NOT NULL,
|
|
111
|
+
`error` text,
|
|
112
|
+
`job_id` text,
|
|
113
|
+
`created_at` integer NOT NULL,
|
|
114
|
+
`updated_at` integer NOT NULL,
|
|
115
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
116
|
+
FOREIGN KEY (`device_id`) REFERENCES `notification_devices`(`id`) ON UPDATE no action ON DELETE cascade
|
|
117
|
+
);
|
|
118
|
+
--> statement-breakpoint
|
|
119
|
+
CREATE TABLE `organizations` (
|
|
120
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
121
|
+
`name` text NOT NULL,
|
|
122
|
+
`slug` text,
|
|
123
|
+
`logo` text,
|
|
124
|
+
`type` text,
|
|
125
|
+
`parent_id` text,
|
|
126
|
+
`created_at` integer NOT NULL,
|
|
127
|
+
`onboarding` integer,
|
|
128
|
+
`preferences` text DEFAULT '{}',
|
|
129
|
+
`metadata` text DEFAULT '{}',
|
|
130
|
+
`flags` text DEFAULT '[]',
|
|
131
|
+
`locale` text,
|
|
132
|
+
FOREIGN KEY (`parent_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE set null
|
|
133
|
+
);
|
|
134
|
+
--> statement-breakpoint
|
|
135
|
+
CREATE UNIQUE INDEX `organizations_slug_unique` ON `organizations` (`slug`);--> statement-breakpoint
|
|
136
|
+
CREATE TABLE `posts` (
|
|
137
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
138
|
+
`author_user_id` text,
|
|
139
|
+
`organization_id` text,
|
|
140
|
+
`team_id` text,
|
|
141
|
+
`title` text NOT NULL,
|
|
142
|
+
`slug` text NOT NULL,
|
|
143
|
+
`excerpt` text,
|
|
144
|
+
`content` text NOT NULL,
|
|
145
|
+
`status` text DEFAULT 'draft' NOT NULL,
|
|
146
|
+
`published_at` integer,
|
|
147
|
+
`created_at` integer NOT NULL,
|
|
148
|
+
`updated_at` integer,
|
|
149
|
+
`deleted_at` integer,
|
|
150
|
+
FOREIGN KEY (`author_user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null,
|
|
151
|
+
FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE set null,
|
|
152
|
+
FOREIGN KEY (`team_id`) REFERENCES `teams`(`id`) ON UPDATE no action ON DELETE set null
|
|
153
|
+
);
|
|
154
|
+
--> statement-breakpoint
|
|
155
|
+
CREATE UNIQUE INDEX `posts_slug_unique` ON `posts` (`slug`);--> statement-breakpoint
|
|
156
|
+
CREATE TABLE `sessions` (
|
|
157
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
158
|
+
`expires_at` integer NOT NULL,
|
|
159
|
+
`token` text NOT NULL,
|
|
160
|
+
`created_at` integer NOT NULL,
|
|
161
|
+
`updated_at` integer NOT NULL,
|
|
162
|
+
`ip_address` text,
|
|
163
|
+
`user_agent` text,
|
|
164
|
+
`user_id` text NOT NULL,
|
|
165
|
+
`impersonated_by` text,
|
|
166
|
+
`active_organization_id` text,
|
|
167
|
+
`active_organization_member_id` text,
|
|
168
|
+
`active_organization_role` text,
|
|
169
|
+
`active_organization_type` text,
|
|
170
|
+
`active_team_id` text,
|
|
171
|
+
`active_team_role` text,
|
|
172
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
|
|
173
|
+
);
|
|
174
|
+
--> statement-breakpoint
|
|
175
|
+
CREATE UNIQUE INDEX `sessions_token_unique` ON `sessions` (`token`);--> statement-breakpoint
|
|
176
|
+
CREATE TABLE `teammembers` (
|
|
177
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
178
|
+
`team_id` text NOT NULL,
|
|
179
|
+
`user_id` text NOT NULL,
|
|
180
|
+
`role` text NOT NULL,
|
|
181
|
+
`created_at` integer NOT NULL,
|
|
182
|
+
FOREIGN KEY (`team_id`) REFERENCES `teams`(`id`) ON UPDATE no action ON DELETE no action,
|
|
183
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action
|
|
184
|
+
);
|
|
185
|
+
--> statement-breakpoint
|
|
186
|
+
CREATE TABLE `teams` (
|
|
187
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
188
|
+
`name` text NOT NULL,
|
|
189
|
+
`organization_id` text NOT NULL,
|
|
190
|
+
`created_at` integer NOT NULL,
|
|
191
|
+
`updated_at` integer,
|
|
192
|
+
FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE no action
|
|
193
|
+
);
|
|
194
|
+
--> statement-breakpoint
|
|
195
|
+
CREATE TABLE `users` (
|
|
196
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
197
|
+
`name` text NOT NULL,
|
|
198
|
+
`email` text NOT NULL,
|
|
199
|
+
`email_verified` integer NOT NULL,
|
|
200
|
+
`image` text,
|
|
201
|
+
`created_at` integer NOT NULL,
|
|
202
|
+
`updated_at` integer NOT NULL,
|
|
203
|
+
`role` text,
|
|
204
|
+
`banned` integer,
|
|
205
|
+
`ban_reason` text,
|
|
206
|
+
`ban_expires` integer,
|
|
207
|
+
`stripe_customer_id` text,
|
|
208
|
+
`payment_customer_id` text,
|
|
209
|
+
`payment_plan_tier` text,
|
|
210
|
+
`payment_plan_expires_at` integer,
|
|
211
|
+
`preferences` text DEFAULT '{}',
|
|
212
|
+
`metadata` text DEFAULT '{}',
|
|
213
|
+
`onboarding` integer,
|
|
214
|
+
`flags` text DEFAULT '[]',
|
|
215
|
+
`locale` text
|
|
216
|
+
);
|
|
217
|
+
--> statement-breakpoint
|
|
218
|
+
CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);--> statement-breakpoint
|
|
219
|
+
CREATE UNIQUE INDEX `users_stripe_customer_id_unique` ON `users` (`stripe_customer_id`);--> statement-breakpoint
|
|
220
|
+
CREATE UNIQUE INDEX `users_payment_customer_id_unique` ON `users` (`payment_customer_id`);--> statement-breakpoint
|
|
221
|
+
CREATE TABLE `verifications` (
|
|
222
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
223
|
+
`identifier` text NOT NULL,
|
|
224
|
+
`value` text NOT NULL,
|
|
225
|
+
`expires_at` integer NOT NULL,
|
|
226
|
+
`created_at` integer,
|
|
227
|
+
`updated_at` integer
|
|
228
|
+
);
|
|
229
|
+
--> statement-breakpoint
|
|
230
|
+
CREATE TABLE `waitlist` (
|
|
231
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
232
|
+
`name` text,
|
|
233
|
+
`email` text,
|
|
234
|
+
`created_at` integer NOT NULL,
|
|
235
|
+
`updated_at` integer,
|
|
236
|
+
`status` text DEFAULT 'WAITLIST' NOT NULL,
|
|
237
|
+
`type` text DEFAULT 'WAITLIST' NOT NULL,
|
|
238
|
+
`code` text,
|
|
239
|
+
`expires_at` integer,
|
|
240
|
+
`user_id` text,
|
|
241
|
+
`claim_user_id` text,
|
|
242
|
+
`claimed_at` integer,
|
|
243
|
+
`claimed_email` text,
|
|
244
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
|
|
245
|
+
FOREIGN KEY (`claim_user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action
|
|
246
|
+
);
|
|
247
|
+
--> statement-breakpoint
|
|
248
|
+
CREATE TABLE `workflows` (
|
|
249
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
250
|
+
`user_id` text,
|
|
251
|
+
`job_id` text NOT NULL,
|
|
252
|
+
`job_name` text NOT NULL,
|
|
253
|
+
`queue_name` text NOT NULL,
|
|
254
|
+
`timeout` integer,
|
|
255
|
+
`tags` text,
|
|
256
|
+
`input` text,
|
|
257
|
+
`output` text,
|
|
258
|
+
`status` text NOT NULL,
|
|
259
|
+
`error` text,
|
|
260
|
+
`retries` integer DEFAULT 0 NOT NULL,
|
|
261
|
+
`finished_at` integer,
|
|
262
|
+
`processed_at` integer,
|
|
263
|
+
`created_at` integer NOT NULL,
|
|
264
|
+
`updated_at` integer NOT NULL,
|
|
265
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
|
|
266
|
+
);
|
|
267
|
+
--> statement-breakpoint
|
|
268
|
+
CREATE UNIQUE INDEX `workflows_job_id_unique` ON `workflows` (`job_id`);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createClient } from "@libsql/client";
|
|
2
|
+
import { drizzle } from "drizzle-orm/libsql";
|
|
3
|
+
import * as schema from "../src/schema";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Standalone DB handle for scripts (seed, maintenance). Deliberately does NOT
|
|
7
|
+
* import ./app — constructing the backend app opens Redis/queue connections
|
|
8
|
+
* that keep short-lived scripts alive forever. The running server gets its own
|
|
9
|
+
* connection through createBackendApp.
|
|
10
|
+
*/
|
|
11
|
+
const databaseUrl = process.env.DATABASE_URL ?? "file:./local.db";
|
|
12
|
+
const syncUrl = process.env.TURSO_DATABASE_URL;
|
|
13
|
+
const authToken = process.env.TURSO_AUTH_TOKEN;
|
|
14
|
+
|
|
15
|
+
export const isRemote = syncUrl && authToken;
|
|
16
|
+
|
|
17
|
+
const client = createClient(
|
|
18
|
+
isRemote ? { url: databaseUrl, syncUrl, authToken } : { url: databaseUrl }
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export const orm = drizzle(client, { schema });
|
|
22
|
+
|
|
23
|
+
export type Orm = typeof orm;
|
|
24
|
+
export type Schema = typeof schema;
|
|
25
|
+
|
|
26
|
+
export { schema };
|