@idealyst/cli 1.0.41 → 1.0.44

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.
Files changed (78) hide show
  1. package/dist/generators/api.js +1 -2
  2. package/dist/generators/api.js.map +1 -1
  3. package/dist/generators/database.js +1 -2
  4. package/dist/generators/database.js.map +1 -1
  5. package/dist/generators/fullstack.js +371 -0
  6. package/dist/generators/fullstack.js.map +1 -0
  7. package/dist/generators/index.js +5 -0
  8. package/dist/generators/index.js.map +1 -1
  9. package/dist/generators/native.js +2 -1
  10. package/dist/generators/native.js.map +1 -1
  11. package/dist/generators/shared.js +1 -2
  12. package/dist/generators/shared.js.map +1 -1
  13. package/dist/generators/utils.js +71 -7
  14. package/dist/generators/utils.js.map +1 -1
  15. package/dist/generators/web.js +1 -2
  16. package/dist/generators/web.js.map +1 -1
  17. package/dist/generators/workspace.js +56 -2
  18. package/dist/generators/workspace.js.map +1 -1
  19. package/dist/index.js +50 -2
  20. package/dist/index.js.map +1 -1
  21. package/dist/templates/database/.env.example +1 -8
  22. package/dist/templates/database/README.md +29 -74
  23. package/dist/templates/database/package.json +20 -34
  24. package/dist/templates/database/prisma/seed.ts +11 -11
  25. package/dist/templates/database/schema.prisma +97 -0
  26. package/dist/templates/database/src/index.ts +12 -8
  27. package/dist/templates/database/tsconfig.json +9 -23
  28. package/dist/templates/native/src/App-with-trpc-and-shared.tsx +266 -0
  29. package/dist/templates/shared/package.json +28 -3
  30. package/dist/templates/shared/src/components/index.ts +392 -0
  31. package/dist/templates/shared/src/index.ts +59 -1
  32. package/dist/templates/shared/src/types/index.ts +148 -0
  33. package/dist/templates/shared/src/utils/index.ts +278 -0
  34. package/dist/templates/web/package.json +2 -2
  35. package/dist/templates/web/src/App-with-trpc-and-shared.tsx +304 -0
  36. package/dist/templates/workspace/.devcontainer/Dockerfile +1 -1
  37. package/dist/templates/workspace/.devcontainer/devcontainer.json +7 -2
  38. package/dist/templates/workspace/.devcontainer/docker-compose.yml +14 -0
  39. package/dist/templates/workspace/.devcontainer/figma-mcp.sh +32 -0
  40. package/dist/templates/workspace/.devcontainer/setup.sh +3 -0
  41. package/dist/templates/workspace/setup.sh +22 -197
  42. package/dist/templates/workspace/tsconfig.json +32 -0
  43. package/dist/types/generators/fullstack.d.ts +2 -0
  44. package/dist/types/generators/index.d.ts +1 -0
  45. package/dist/types/generators/utils.d.ts +4 -1
  46. package/dist/types/types.d.ts +3 -1
  47. package/package.json +1 -1
  48. package/templates/database/.env.example +1 -0
  49. package/templates/database/README.md +48 -0
  50. package/templates/database/package.json +21 -2
  51. package/templates/database/prisma/seed.ts +28 -0
  52. package/templates/database/schema.prisma +85 -9
  53. package/templates/database/src/index.ts +7 -7
  54. package/templates/database/src/validators.ts +10 -0
  55. package/templates/native/src/App-with-trpc-and-shared.tsx +266 -0
  56. package/templates/shared/package.json +28 -3
  57. package/templates/shared/src/components/index.ts +392 -0
  58. package/templates/shared/src/index.ts +59 -1
  59. package/templates/shared/src/types/index.ts +148 -0
  60. package/templates/shared/src/utils/index.ts +278 -0
  61. package/templates/web/package.json +1 -1
  62. package/templates/web/src/App-with-trpc-and-shared.tsx +304 -0
  63. package/templates/workspace/.devcontainer/devcontainer.json +7 -2
  64. package/templates/workspace/.devcontainer/docker-compose.yml +14 -0
  65. package/templates/workspace/.devcontainer/figma-mcp.sh +32 -0
  66. package/templates/workspace/.devcontainer/setup.sh +3 -0
  67. package/templates/workspace/setup.sh +30 -0
  68. package/templates/workspace/tsconfig.json +32 -0
  69. package/dist/templates/database/__tests__/database.test.ts +0 -14
  70. package/dist/templates/database/jest.config.js +0 -19
  71. package/dist/templates/database/jest.setup.js +0 -11
  72. package/dist/templates/database/prisma/schema.prisma +0 -21
  73. package/dist/templates/database/src/client.ts +0 -18
  74. package/dist/templates/database/src/schemas.ts +0 -26
  75. package/dist/templates/workspace/scripts/docker/db-backup.sh +0 -230
  76. package/dist/templates/workspace/scripts/docker/deploy.sh +0 -212
  77. package/dist/templates/workspace/scripts/test-runner.js +0 -120
  78. /package/{templates/database/src/validatgors.ts → dist/templates/database/src/validators.ts} +0 -0
@@ -1,205 +1,30 @@
1
1
  #!/bin/bash
2
2
 
3
- # Quick setup script for Idealyst workspace
4
- # Usage: ./setup.sh [development|production]
3
+ # Idealyst Framework Workspace Setup Script
4
+ # This script sets up the development environment for your workspace
5
5
 
6
- set -e
6
+ echo "🏗️ Setting up Idealyst Framework workspace..."
7
7
 
8
- ENVIRONMENT=${1:-development}
9
- PROJECT_NAME="{{packageName}}"
8
+ # Install dependencies
9
+ echo "📦 Installing dependencies..."
10
+ yarn install
10
11
 
11
- echo "🚀 Setting up Idealyst workspace..."
12
- echo "Environment: $ENVIRONMENT"
13
- echo "Project: $PROJECT_NAME"
14
- echo ""
15
-
16
- # Function to generate random password
17
- generate_password() {
18
- openssl rand -base64 32 | tr -d "=+/" | cut -c1-25
19
- }
20
-
21
- # Function to generate JWT secret
22
- generate_jwt_secret() {
23
- openssl rand -base64 64 | tr -d "=+/" | cut -c1-50
24
- }
25
-
26
- # Function to setup development environment
27
- setup_development() {
28
- echo "🔧 Setting up development environment..."
29
-
30
- if [ ! -f ".env" ]; then
31
- echo "📝 Creating .env from template..."
32
- cp .env.example .env
33
- echo "✅ Created .env file"
34
- else
35
- echo "⚠️ .env file already exists, skipping..."
36
- fi
37
-
38
- echo ""
39
- echo "🐳 Starting development containers..."
40
- if command -v docker-compose &> /dev/null; then
41
- docker-compose up -d postgres redis
42
- echo "✅ Database and Redis started"
43
-
44
- echo "⏳ Waiting for services to be ready..."
45
- sleep 10
46
-
47
- echo "🚀 Starting development environment..."
48
- echo "💡 You can now:"
49
- echo " - Run 'docker-compose up -d dev' for full dev container"
50
- echo " - Run 'yarn dev' for local development"
51
- echo " - Open in VS Code and select 'Reopen in Container'"
52
- else
53
- echo "❌ Docker Compose not found. Please install Docker and Docker Compose."
54
- exit 1
55
- fi
56
- }
57
-
58
- # Function to setup production environment
59
- setup_production() {
60
- echo "🏭 Setting up production environment..."
61
-
62
- if [ ! -f ".env" ]; then
63
- echo "📝 Creating .env from production template..."
64
- cp .env.production .env
65
-
66
- # Generate secure passwords and secrets
67
- echo "🔐 Generating secure credentials..."
68
-
69
- DB_PASSWORD=$(generate_password)
70
- JWT_SECRET=$(generate_jwt_secret)
71
- SESSION_SECRET=$(generate_jwt_secret)
72
- ENCRYPTION_KEY=$(openssl rand -base64 32 | cut -c1-32)
73
- GRAFANA_PASSWORD=$(generate_password)
74
-
75
- # Replace placeholders in .env file
76
- sed -i "s/CHANGE_THIS_STRONG_PASSWORD/$DB_PASSWORD/g" .env
77
- sed -i "s/CHANGE_THIS_VERY_STRONG_JWT_SECRET_MINIMUM_32_CHARACTERS/$JWT_SECRET/g" .env
78
- sed -i "s/CHANGE_THIS_VERY_STRONG_SESSION_SECRET/$SESSION_SECRET/g" .env
79
- sed -i "s/CHANGE_THIS_32_CHARACTER_ENCRYPTION_KEY/$ENCRYPTION_KEY/g" .env
80
- sed -i "s/CHANGE_THIS_STRONG_PASSWORD/$GRAFANA_PASSWORD/g" .env
81
-
82
- echo "✅ Created .env with secure credentials"
83
- echo ""
84
- echo "🔐 Generated Credentials (save these securely!):"
85
- echo " Database Password: $DB_PASSWORD"
86
- echo " JWT Secret: $JWT_SECRET"
87
- echo " Grafana Password: $GRAFANA_PASSWORD"
88
- echo ""
89
- echo "⚠️ IMPORTANT: Edit .env to configure your domain and other settings!"
90
-
91
- else
92
- echo "⚠️ .env file already exists. Please verify production settings."
93
- fi
94
-
95
- echo ""
96
- echo "📋 Production Checklist:"
97
- echo " [ ] Edit .env with your domain name"
98
- echo " [ ] Configure SSL certificates"
99
- echo " [ ] Set up DNS records"
100
- echo " [ ] Configure firewall rules"
101
- echo " [ ] Set up monitoring (optional)"
102
- echo ""
103
- echo "🚀 Deploy with: ./scripts/docker/deploy.sh production"
104
- }
12
+ # Build all packages
13
+ echo "🔨 Building packages..."
14
+ yarn build:packages
105
15
 
106
- # Function to check prerequisites
107
- check_prerequisites() {
108
- echo "🔍 Checking prerequisites..."
109
-
110
- # Check Docker
111
- if ! command -v docker &> /dev/null; then
112
- echo "❌ Docker not found. Please install Docker."
113
- exit 1
114
- fi
115
-
116
- # Check Docker Compose
117
- if ! command -v docker-compose &> /dev/null; then
118
- echo "❌ Docker Compose not found. Please install Docker Compose."
119
- exit 1
120
- fi
121
-
122
- # Check if Docker is running
123
- if ! docker info &> /dev/null; then
124
- echo "❌ Docker is not running. Please start Docker."
125
- exit 1
126
- fi
127
-
128
- echo "✅ Prerequisites check passed"
129
- echo ""
130
- }
131
-
132
- # Function to show post-setup instructions
133
- show_instructions() {
134
- echo ""
135
- echo "🎉 Setup complete!"
136
- echo ""
137
- echo "Next steps:"
138
-
139
- if [ "$ENVIRONMENT" = "development" ]; then
140
- echo " 1. Install dependencies: yarn install"
141
- echo " 2. Start development:"
142
- echo " - Full container: docker-compose up -d dev"
143
- echo " - VS Code: Open in Container"
144
- echo " - Local: yarn dev"
145
- echo " 3. Access your app:"
146
- echo " - Web: http://localhost:3000"
147
- echo " - API: http://localhost:3001"
148
- echo " - Database: postgresql://postgres:postgres@localhost:5432/idealyst_db"
149
- else
150
- echo " 1. Edit .env with your production settings"
151
- echo " 2. Configure SSL certificates"
152
- echo " 3. Deploy: ./scripts/docker/deploy.sh production"
153
- echo " 4. Set up monitoring (optional)"
154
- fi
155
-
156
- echo ""
157
- echo "📚 Documentation:"
158
- echo " - DOCKER.md - Complete Docker guide"
159
- echo " - TESTING.md - Testing documentation"
160
- echo " - README.md - General workspace info"
161
- echo ""
162
- echo "🆘 Need help? Check the documentation or run:"
163
- echo " ./scripts/docker/deploy.sh --help"
164
- }
165
-
166
- # Main setup process
167
- main() {
168
- check_prerequisites
169
-
170
- case $ENVIRONMENT in
171
- "development"|"dev")
172
- setup_development
173
- ;;
174
- "production"|"prod")
175
- setup_production
176
- ;;
177
- *)
178
- echo "❌ Invalid environment. Use 'development' or 'production'"
179
- echo "Usage: $0 [development|production]"
180
- exit 1
181
- ;;
182
- esac
183
-
184
- show_instructions
185
- }
186
-
187
- # Handle help
188
- if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "help" ]]; then
189
- echo "Idealyst Workspace Setup Script"
190
- echo ""
191
- echo "Usage: $0 [environment]"
192
- echo ""
193
- echo "Environments:"
194
- echo " development (default) - Set up for local development"
195
- echo " production - Set up for production deployment"
196
- echo ""
197
- echo "Examples:"
198
- echo " $0 # Development setup"
199
- echo " $0 development # Development setup"
200
- echo " $0 production # Production setup"
201
- echo ""
202
- exit 0
16
+ # Set up git hooks (if using husky)
17
+ if [ -f "package.json" ] && grep -q "husky" package.json; then
18
+ echo "🪝 Setting up git hooks..."
19
+ yarn prepare
203
20
  fi
204
21
 
205
- main
22
+ echo "✅ Workspace setup complete!"
23
+ echo ""
24
+ echo "🚀 Quick start:"
25
+ echo " • Run 'yarn dev' to start development mode"
26
+ echo " • Run 'yarn build' to build all packages"
27
+ echo " • Run 'yarn test' to run tests"
28
+ echo " • Use 'idealyst create <type> <name>' to add new projects"
29
+ echo ""
30
+ echo "📚 Check README.md and DOCKER.md for more information."
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "lib": ["ES2020"],
5
+ "module": "commonjs",
6
+ "moduleResolution": "node",
7
+ "esModuleInterop": true,
8
+ "allowSyntheticDefaultImports": true,
9
+ "strict": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "declaration": true,
13
+ "declarationMap": true,
14
+ "sourceMap": true,
15
+ "outDir": "./dist",
16
+ "rootDir": "./src"
17
+ },
18
+ "include": [
19
+ "packages/*/src/**/*"
20
+ ],
21
+ "exclude": [
22
+ "node_modules",
23
+ "dist",
24
+ "**/*.test.ts",
25
+ "**/*.spec.ts"
26
+ ],
27
+ "references": [
28
+ {
29
+ "path": "./packages/*"
30
+ }
31
+ ]
32
+ }
@@ -0,0 +1,2 @@
1
+ import { GenerateProjectOptions } from '../types';
2
+ export declare function generateFullStackWorkspace(options: GenerateProjectOptions): Promise<void>;
@@ -6,3 +6,4 @@ export * from './shared';
6
6
  export * from './workspace';
7
7
  export * from './api';
8
8
  export * from './database';
9
+ export * from './fullstack';
@@ -1,5 +1,6 @@
1
1
  import { TemplateData } from '../types';
2
2
  export declare function validateProjectName(name: string): boolean;
3
+ export declare function getTemplatePath(templateName: string): string;
3
4
  export declare function createPackageName(name: string): string;
4
5
  export declare function updateWorkspacePackageJson(workspacePath: string, directory: string): Promise<void>;
5
6
  export declare function copyTemplate(templatePath: string, destPath: string, data: TemplateData): Promise<void>;
@@ -16,7 +17,8 @@ export declare function getTemplateData(projectName: string, description?: strin
16
17
  */
17
18
  export declare function isWorkspaceRoot(directory: string): Promise<boolean>;
18
19
  /**
19
- * Gets the workspace name from the workspace root's package.json
20
+ * Gets the workspace scope from the workspace root's package.json
21
+ * Extracts just the scope name (without @) from scoped package names
20
22
  */
21
23
  export declare function getWorkspaceName(directory: string): Promise<string | null>;
22
24
  /**
@@ -38,5 +40,6 @@ export declare function promptForAppName(projectName: string): Promise<string>;
38
40
  export declare function promptForTrpcIntegration(): Promise<boolean>;
39
41
  export declare function copyTrpcFiles(templatePath: string, projectPath: string, data: TemplateData): Promise<void>;
40
42
  export declare function copyTrpcAppComponent(templatePath: string, projectPath: string, data: TemplateData): Promise<void>;
43
+ export declare function addTrpcDependencies(projectPath: string): Promise<void>;
41
44
  export declare function removeTrpcDependencies(projectPath: string): Promise<void>;
42
45
  export declare function configureAndroidVectorIcons(projectPath: string): Promise<void>;
@@ -1,4 +1,4 @@
1
- export type ProjectType = 'native' | 'web' | 'shared' | 'workspace' | 'api' | 'database';
1
+ export type ProjectType = 'native' | 'web' | 'shared' | 'workspace' | 'api' | 'database' | 'fullstack';
2
2
  export interface GenerateProjectOptions {
3
3
  name: string;
4
4
  type: ProjectType;
@@ -6,6 +6,7 @@ export interface GenerateProjectOptions {
6
6
  skipInstall: boolean;
7
7
  appName?: string;
8
8
  withTrpc?: boolean;
9
+ figmaToken?: string;
9
10
  }
10
11
  export interface TemplateData {
11
12
  projectName: string;
@@ -13,4 +14,5 @@ export interface TemplateData {
13
14
  version: string;
14
15
  description: string;
15
16
  appName?: string;
17
+ workspaceScope?: string;
16
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idealyst/cli",
3
- "version": "1.0.41",
3
+ "version": "1.0.44",
4
4
  "description": "CLI tool for generating Idealyst Framework projects",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -0,0 +1 @@
1
+ DATABASE_URL="sqlite:./dev.db"
@@ -0,0 +1,48 @@
1
+ # Database Package
2
+
3
+ This package provides database access and validation schemas for the workspace.
4
+
5
+ ## Setup
6
+
7
+ 1. Install dependencies:
8
+ ```bash
9
+ yarn install
10
+ ```
11
+
12
+ 2. Set up your environment:
13
+ ```bash
14
+ cp .env.example .env
15
+ # Edit .env with your database URL
16
+ ```
17
+
18
+ 3. Generate the Prisma client:
19
+ ```bash
20
+ yarn db:generate
21
+ ```
22
+
23
+ 4. Push the schema to your database:
24
+ ```bash
25
+ yarn db:push
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ```typescript
31
+ import { prisma, User, TestValidator } from '@{{workspaceScope}}/{{name}}';
32
+
33
+ // Use the database client
34
+ const users = await prisma.user.findMany();
35
+
36
+ // Use validators
37
+ const validatedData = TestValidator.parse(userData);
38
+ ```
39
+
40
+ ## Scripts
41
+
42
+ - `yarn db:generate` - Generate Prisma client
43
+ - `yarn db:push` - Push schema to database
44
+ - `yarn db:migrate` - Create and run migrations
45
+ - `yarn db:studio` - Open Prisma Studio
46
+ - `yarn db:reset` - Reset the database
47
+ - `yarn build` - Build the package
48
+ - `yarn dev` - Build in watch mode
@@ -4,6 +4,23 @@
4
4
  "description": "Database layer with Prisma",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.js"
12
+ },
13
+ "./client": {
14
+ "types": "./generated/client/index.d.ts",
15
+ "import": "./generated/client/index.js",
16
+ "require": "./generated/client/index.js"
17
+ },
18
+ "./schemas": {
19
+ "types": "./dist/validators.d.ts",
20
+ "import": "./dist/validators.js",
21
+ "require": "./dist/validators.js"
22
+ }
23
+ },
7
24
  "scripts": {
8
25
  "build": "tsc",
9
26
  "dev": "tsc --watch",
@@ -14,7 +31,8 @@
14
31
  "db:reset": "prisma migrate reset"
15
32
  },
16
33
  "dependencies": {
17
- "@prisma/client": "^5.19.1"
34
+ "@prisma/client": "^5.19.1",
35
+ "zod": "^3.22.4"
18
36
  },
19
37
  "devDependencies": {
20
38
  "@types/node": "^20.10.0",
@@ -23,6 +41,7 @@
23
41
  },
24
42
  "files": [
25
43
  "dist/**/*",
26
- "prisma/**/*"
44
+ "prisma/**/*",
45
+ "generated/**/*"
27
46
  ]
28
47
  }
@@ -0,0 +1,28 @@
1
+ import { PrismaClient } from '../generated/client';
2
+
3
+ const prisma = new PrismaClient();
4
+
5
+ async function main() {
6
+ // Add your seed data here
7
+ console.log('🌱 Seeding database...');
8
+
9
+ // Example seed data
10
+ // const user = await prisma.user.create({
11
+ // data: {
12
+ // email: 'admin@example.com',
13
+ // name: 'Admin User',
14
+ // },
15
+ // });
16
+
17
+ console.log('✅ Seeding completed');
18
+ }
19
+
20
+ main()
21
+ .then(async () => {
22
+ await prisma.$disconnect();
23
+ })
24
+ .catch(async (e) => {
25
+ console.error(e);
26
+ await prisma.$disconnect();
27
+ process.exit(1);
28
+ });
@@ -3,6 +3,7 @@
3
3
 
4
4
  generator client {
5
5
  provider = "prisma-client-js"
6
+ output = "./generated/client"
6
7
  }
7
8
 
8
9
  datasource db {
@@ -10,12 +11,87 @@ datasource db {
10
11
  url = env("DATABASE_URL")
11
12
  }
12
13
 
13
- // Add your models here
14
- // Example:
15
- // model User {
16
- // id String @id @default(cuid())
17
- // email String @unique
18
- // name String?
19
- // createdAt DateTime @default(now())
20
- // updatedAt DateTime @updatedAt
21
- // }
14
+ // Demo User model with profile information
15
+ model User {
16
+ id String @id @default(cuid())
17
+ email String @unique
18
+ name String?
19
+ avatar String? // URL to profile image
20
+ bio String? // User biography
21
+ location String? // User location
22
+ website String? // Personal website
23
+
24
+ // Posts created by this user
25
+ posts Post[]
26
+
27
+ // Comments made by this user
28
+ comments Comment[]
29
+
30
+ // User preferences and settings
31
+ settings UserSettings?
32
+
33
+ createdAt DateTime @default(now())
34
+ updatedAt DateTime @updatedAt
35
+ }
36
+
37
+ // Demo Post model for a simple blog/social feed
38
+ model Post {
39
+ id String @id @default(cuid())
40
+ title String
41
+ content String
42
+ excerpt String? // Short description
43
+ published Boolean @default(false)
44
+ tags String? // Comma-separated tag strings
45
+
46
+ // Author relationship
47
+ author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
48
+ authorId String
49
+
50
+ // Comments on this post
51
+ comments Comment[]
52
+
53
+ // Post metadata
54
+ views Int @default(0)
55
+ likes Int @default(0)
56
+
57
+ createdAt DateTime @default(now())
58
+ updatedAt DateTime @updatedAt
59
+ }
60
+
61
+ // Demo Comment model
62
+ model Comment {
63
+ id String @id @default(cuid())
64
+ content String
65
+
66
+ // Author relationship
67
+ author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
68
+ authorId String
69
+
70
+ // Post relationship
71
+ post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
72
+ postId String
73
+
74
+ // Parent comment for nested threading
75
+ parent Comment? @relation("CommentThread", fields: [parentId], references: [id])
76
+ parentId String?
77
+ children Comment[] @relation("CommentThread")
78
+
79
+ createdAt DateTime @default(now())
80
+ updatedAt DateTime @updatedAt
81
+ }
82
+
83
+ // User settings and preferences
84
+ model UserSettings {
85
+ id String @id @default(cuid())
86
+ theme String @default("auto") // "light", "dark", "auto"
87
+ notifications Boolean @default(true)
88
+ emailUpdates Boolean @default(false)
89
+ publicProfile Boolean @default(true)
90
+
91
+ // User relationship (one-to-one)
92
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
93
+ userId String @unique
94
+
95
+ createdAt DateTime @default(now())
96
+ updatedAt DateTime @updatedAt
97
+ }
@@ -1,15 +1,15 @@
1
- import { PrismaClient } from '@prisma/client'
1
+ import { PrismaClient } from '../generated/client';
2
2
 
3
3
  declare global {
4
- var __prisma: PrismaClient | undefined
4
+ var __prisma: PrismaClient | undefined;
5
5
  }
6
6
 
7
- export const prisma = globalThis.__prisma || new PrismaClient()
7
+ export const prisma = globalThis.__prisma || new PrismaClient();
8
8
 
9
9
  if (process.env.NODE_ENV !== 'production') {
10
- globalThis.__prisma = prisma
10
+ globalThis.__prisma = prisma;
11
11
  }
12
12
 
13
- export * from '@prisma/client'
14
- export * from './validators'
15
- export default prisma
13
+ export * from './validators';
14
+ export * from '../generated/client';
15
+ export default prisma;
@@ -0,0 +1,10 @@
1
+ // Create model validators for each model defined in the Prisma schema using Zod
2
+ // E.g
3
+ import { z } from 'zod';
4
+
5
+ export const TestValidator = z.object({
6
+ id: z.string().uuid(),
7
+ email: z.string().email(),
8
+ name: z.string().min(2).max(100),
9
+ age: z.number().min(0).optional()
10
+ });