schemock 0.0.4-alpha.1 → 0.0.4-alpha.3
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 +247 -0
- package/dist/cli/index.d.mts +127 -1
- package/dist/cli/index.d.ts +127 -1
- package/dist/cli/index.js +655 -15
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +651 -17
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli.js +769 -35
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -23,6 +23,11 @@ npm install schemock
|
|
|
23
23
|
npx schemock init
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
This creates:
|
|
27
|
+
- `src/schemas/user.ts` - Example schema with User, Post, Comment
|
|
28
|
+
- `schemock.config.ts` - Configuration file
|
|
29
|
+
- `CLAUDE.md` - AI tool configuration (helps Claude Code, Cursor, etc.)
|
|
30
|
+
|
|
26
31
|
Define your schema:
|
|
27
32
|
|
|
28
33
|
```typescript
|
|
@@ -87,6 +92,7 @@ schemock <command> [options]
|
|
|
87
92
|
| `generate:sql` | Generate PostgreSQL schema with RLS |
|
|
88
93
|
| `generate:openapi` | Generate OpenAPI 3.0 specification |
|
|
89
94
|
| `generate:postman` | Generate Postman collection |
|
|
95
|
+
| `setup:ai` | Generate CLAUDE.md for AI tool integration |
|
|
90
96
|
|
|
91
97
|
### Generate Options
|
|
92
98
|
|
|
@@ -98,6 +104,7 @@ npx schemock generate [options]
|
|
|
98
104
|
--config, -c <file> Config file path
|
|
99
105
|
--only <entities> Only generate for these entities (comma-separated)
|
|
100
106
|
--exclude <entities> Exclude these entities (comma-separated)
|
|
107
|
+
--with-form-schemas Generate Zod validation, form defaults, and table columns
|
|
101
108
|
--watch, -w Watch mode - regenerate on changes
|
|
102
109
|
--dry-run Preview without writing files
|
|
103
110
|
--verbose, -v Verbose output
|
|
@@ -115,6 +122,100 @@ npx schemock generate --exclude audit
|
|
|
115
122
|
npx schemock generate --adapter supabase --only user,post --verbose
|
|
116
123
|
```
|
|
117
124
|
|
|
125
|
+
### Form Schema Generation
|
|
126
|
+
|
|
127
|
+
Add `--with-form-schemas` to generate Zod validation schemas, form defaults, and table column metadata:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
npx schemock generate --with-form-schemas
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
This appends the following to `types.ts` for each entity:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
// Zod validation schema with constraints from field definitions
|
|
137
|
+
export const UserFormSchema = z.object({
|
|
138
|
+
name: z.string().min(1, 'Name is required'),
|
|
139
|
+
email: z.string().email().min(1, 'Email is required'),
|
|
140
|
+
role: z.enum(['admin', 'user', 'guest']),
|
|
141
|
+
bio: z.string().max(500).nullable(),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Default values for form initialization
|
|
145
|
+
export const UserFormDefaults: z.input<typeof UserFormSchema> = {
|
|
146
|
+
name: '',
|
|
147
|
+
email: '',
|
|
148
|
+
role: 'user',
|
|
149
|
+
bio: null,
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// Inferred TypeScript type
|
|
153
|
+
export type UserFormData = z.infer<typeof UserFormSchema>;
|
|
154
|
+
|
|
155
|
+
// Table column metadata for building data tables
|
|
156
|
+
export const UserTableColumns: ColumnDef[] = [
|
|
157
|
+
{ key: 'name', label: 'Name', type: 'text', sortable: true, filterable: true },
|
|
158
|
+
{ key: 'email', label: 'Email', type: 'email', sortable: true, filterable: true },
|
|
159
|
+
{ key: 'role', label: 'Role', type: 'enum', sortable: true, filterable: true },
|
|
160
|
+
{ key: 'createdAt', label: 'Created At', type: 'date', sortable: true, filterable: true, hidden: true },
|
|
161
|
+
];
|
|
162
|
+
|
|
163
|
+
// Union type of valid column keys
|
|
164
|
+
export type UserColumnKey = 'name' | 'email' | 'role' | 'createdAt' | ...;
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Use with react-hook-form:**
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
import { useForm } from 'react-hook-form';
|
|
171
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
172
|
+
import { UserFormSchema, UserFormDefaults, UserFormData } from './generated';
|
|
173
|
+
|
|
174
|
+
function UserForm() {
|
|
175
|
+
const form = useForm<UserFormData>({
|
|
176
|
+
resolver: zodResolver(UserFormSchema),
|
|
177
|
+
defaultValues: UserFormDefaults,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<form onSubmit={form.handleSubmit(onSubmit)}>
|
|
182
|
+
<input {...form.register('name')} />
|
|
183
|
+
{form.formState.errors.name && <span>{form.formState.errors.name.message}</span>}
|
|
184
|
+
{/* ... */}
|
|
185
|
+
</form>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Use table columns with any table library:**
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
import { UserTableColumns } from './generated';
|
|
194
|
+
|
|
195
|
+
// With TanStack Table
|
|
196
|
+
const columns = UserTableColumns.filter(col => !col.hidden).map(col => ({
|
|
197
|
+
accessorKey: col.key,
|
|
198
|
+
header: col.label,
|
|
199
|
+
enableSorting: col.sortable,
|
|
200
|
+
}));
|
|
201
|
+
|
|
202
|
+
// With any custom table
|
|
203
|
+
function UserTable({ users }) {
|
|
204
|
+
return (
|
|
205
|
+
<table>
|
|
206
|
+
<thead>
|
|
207
|
+
<tr>
|
|
208
|
+
{UserTableColumns.filter(c => !c.hidden).map(col => (
|
|
209
|
+
<th key={col.key}>{col.label}</th>
|
|
210
|
+
))}
|
|
211
|
+
</tr>
|
|
212
|
+
</thead>
|
|
213
|
+
{/* ... */}
|
|
214
|
+
</table>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
118
219
|
### SQL Generation
|
|
119
220
|
|
|
120
221
|
```bash
|
|
@@ -127,6 +228,49 @@ npx schemock generate:sql [options]
|
|
|
127
228
|
--readme Generate README documentation
|
|
128
229
|
```
|
|
129
230
|
|
|
231
|
+
### AI Tool Integration
|
|
232
|
+
|
|
233
|
+
Schemock can generate configuration files that help AI coding assistants (like Claude Code, Cursor, etc.) understand your project and avoid modifying auto-generated code.
|
|
234
|
+
|
|
235
|
+
**Automatic setup (recommended):**
|
|
236
|
+
|
|
237
|
+
When you run `schemock init`, a `CLAUDE.md` file is automatically created with:
|
|
238
|
+
- List of generated directories that AI should not modify
|
|
239
|
+
- Schema DSL reference for AI assistance
|
|
240
|
+
- Common tasks and CLI commands
|
|
241
|
+
|
|
242
|
+
**Manual setup for existing projects:**
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
# Generate/update CLAUDE.md
|
|
246
|
+
npx schemock setup:ai
|
|
247
|
+
|
|
248
|
+
# Also generate .cursorrules for Cursor IDE
|
|
249
|
+
npx schemock setup:ai --cursor
|
|
250
|
+
|
|
251
|
+
# Preview without writing files
|
|
252
|
+
npx schemock setup:ai --dry-run
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
**What the AI configuration includes:**
|
|
256
|
+
- **Generated files warning** - Tells AI which directories contain auto-generated code
|
|
257
|
+
- **Schema DSL reference** - Helps AI write correct schema definitions
|
|
258
|
+
- **Common tasks** - Guides AI on how to add fields, entities, relations
|
|
259
|
+
- **CLI commands** - Reference for generation commands
|
|
260
|
+
|
|
261
|
+
**Safe merging:** If you already have a `CLAUDE.md`, Schemock appends its section without overwriting your existing content. Clear markers (`<!-- SCHEMOCK:START -->` / `<!-- SCHEMOCK:END -->`) identify the auto-generated portion.
|
|
262
|
+
|
|
263
|
+
**Options:**
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
npx schemock setup:ai [options]
|
|
267
|
+
|
|
268
|
+
--cursor Also generate .cursorrules for Cursor IDE
|
|
269
|
+
--force Overwrite existing .cursorrules even if not created by Schemock
|
|
270
|
+
--dry-run Preview without writing files
|
|
271
|
+
--output, -o <dir> Output directory (default: current directory)
|
|
272
|
+
```
|
|
273
|
+
|
|
130
274
|
## Schema DSL
|
|
131
275
|
|
|
132
276
|
### Field Types
|
|
@@ -562,6 +706,109 @@ export default defineConfig({
|
|
|
562
706
|
});
|
|
563
707
|
```
|
|
564
708
|
|
|
709
|
+
## File Organization
|
|
710
|
+
|
|
711
|
+
Schemock supports organizing schemas across multiple files and directories. The CLI discovers all schemas via glob patterns and merges them before generation - **no code changes needed**.
|
|
712
|
+
|
|
713
|
+
### Recommended Structure
|
|
714
|
+
|
|
715
|
+
```
|
|
716
|
+
src/schemas/
|
|
717
|
+
├── entities/ # Entity definitions (defineData)
|
|
718
|
+
│ ├── user.ts
|
|
719
|
+
│ ├── post.ts
|
|
720
|
+
│ └── comment.ts
|
|
721
|
+
├── endpoints/ # Custom API endpoints (defineEndpoint)
|
|
722
|
+
│ ├── search.ts
|
|
723
|
+
│ └── bulk-operations.ts
|
|
724
|
+
├── views/ # Composite views (defineView)
|
|
725
|
+
│ └── user-profile.ts
|
|
726
|
+
└── index.ts # Optional barrel exports
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
Or organize by domain:
|
|
730
|
+
|
|
731
|
+
```
|
|
732
|
+
src/schemas/
|
|
733
|
+
├── auth/
|
|
734
|
+
│ ├── user.ts
|
|
735
|
+
│ ├── session.ts
|
|
736
|
+
│ └── auth-endpoints.ts
|
|
737
|
+
├── content/
|
|
738
|
+
│ ├── post.ts
|
|
739
|
+
│ ├── comment.ts
|
|
740
|
+
│ └── search-endpoint.ts
|
|
741
|
+
└── billing/
|
|
742
|
+
├── subscription.ts
|
|
743
|
+
└── payment.ts
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
### How It Works
|
|
747
|
+
|
|
748
|
+
1. **Discovery is file-agnostic** - The glob pattern `./src/schemas/**/*.ts` catches all files
|
|
749
|
+
2. **References are string-based** - Relations use entity names, not imports:
|
|
750
|
+
```typescript
|
|
751
|
+
// entities/post.ts
|
|
752
|
+
belongsTo('user') // References 'user' by name, not import
|
|
753
|
+
field.ref('user') // Same - string reference
|
|
754
|
+
```
|
|
755
|
+
3. **Merging happens before analysis** - All schemas are combined, so cross-file references resolve correctly
|
|
756
|
+
4. **Endpoints access all entities** - `mockResolver` receives `db` with every entity:
|
|
757
|
+
```typescript
|
|
758
|
+
// endpoints/search.ts
|
|
759
|
+
mockResolver: async ({ db }) => {
|
|
760
|
+
const users = db.user.findMany(...); // Works!
|
|
761
|
+
const posts = db.post.findMany(...); // Works!
|
|
762
|
+
}
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
### Configuration
|
|
766
|
+
|
|
767
|
+
A single glob pattern discovers everything:
|
|
768
|
+
|
|
769
|
+
```typescript
|
|
770
|
+
// schemock.config.ts
|
|
771
|
+
export default {
|
|
772
|
+
schemas: './src/schemas/**/*.ts', // Catches all subdirectories
|
|
773
|
+
output: './src/generated',
|
|
774
|
+
// ...
|
|
775
|
+
};
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
### Cross-File Example
|
|
779
|
+
|
|
780
|
+
```typescript
|
|
781
|
+
// entities/user.ts
|
|
782
|
+
export const User = defineData('user', {
|
|
783
|
+
id: field.uuid(),
|
|
784
|
+
name: field.string(),
|
|
785
|
+
}, {
|
|
786
|
+
relations: {
|
|
787
|
+
posts: hasMany('post'), // String reference to Post
|
|
788
|
+
},
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
// entities/post.ts (separate file)
|
|
792
|
+
export const Post = defineData('post', {
|
|
793
|
+
id: field.uuid(),
|
|
794
|
+
authorId: field.ref('user'), // String reference to User
|
|
795
|
+
}, {
|
|
796
|
+
relations: {
|
|
797
|
+
author: belongsTo('user'), // String reference to User
|
|
798
|
+
},
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
// endpoints/stats.ts (separate file)
|
|
802
|
+
export const StatsEndpoint = defineEndpoint('/api/stats', {
|
|
803
|
+
mockResolver: async ({ db }) => ({
|
|
804
|
+
userCount: db.user.count(), // Access User entity
|
|
805
|
+
postCount: db.post.count(), // Access Post entity
|
|
806
|
+
}),
|
|
807
|
+
});
|
|
808
|
+
```
|
|
809
|
+
|
|
810
|
+
All three files are discovered, merged, and work together seamlessly.
|
|
811
|
+
|
|
565
812
|
## Multi-Target Generation
|
|
566
813
|
|
|
567
814
|
Generate multiple outputs from a single schema - client SDKs, API routes, and server handlers all at once:
|
package/dist/cli/index.d.mts
CHANGED
|
@@ -452,6 +452,8 @@ interface GenerateOptions {
|
|
|
452
452
|
only?: string[];
|
|
453
453
|
/** Exclude these entities (applies to all targets) */
|
|
454
454
|
exclude?: string[];
|
|
455
|
+
/** Generate form schemas (Zod validation, defaults, column metadata) */
|
|
456
|
+
withFormSchemas?: boolean;
|
|
455
457
|
}
|
|
456
458
|
/**
|
|
457
459
|
* Options for the generate:sql command
|
|
@@ -598,6 +600,115 @@ declare function analyzeSchemas(schemas: EntitySchema[], config: SchemockConfig)
|
|
|
598
600
|
*/
|
|
599
601
|
declare function generate(options: GenerateOptions): Promise<void>;
|
|
600
602
|
|
|
603
|
+
/**
|
|
604
|
+
* CLAUDE.md generator for Schemock
|
|
605
|
+
*
|
|
606
|
+
* Generates AI-friendly documentation that helps Claude Code understand
|
|
607
|
+
* how to work with Schemock projects without corrupting user content.
|
|
608
|
+
*
|
|
609
|
+
* @module cli/generators/claude-md
|
|
610
|
+
* @category CLI
|
|
611
|
+
*/
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Result of CLAUDE.md generation
|
|
615
|
+
*/
|
|
616
|
+
interface ClaudeMdResult {
|
|
617
|
+
/** Whether CLAUDE.md was created (vs updated) */
|
|
618
|
+
created: boolean;
|
|
619
|
+
/** Whether the file was modified */
|
|
620
|
+
modified: boolean;
|
|
621
|
+
/** The final content */
|
|
622
|
+
content: string;
|
|
623
|
+
/** Path to the file */
|
|
624
|
+
path: string;
|
|
625
|
+
/** Warning messages if any */
|
|
626
|
+
warnings: string[];
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Generate the Schemock section content based on config
|
|
630
|
+
*
|
|
631
|
+
* @param config - Schemock configuration
|
|
632
|
+
* @returns Markdown content for the Schemock section
|
|
633
|
+
*/
|
|
634
|
+
declare function generateSchemockSection(config: SchemockConfig): string;
|
|
635
|
+
/**
|
|
636
|
+
* Merge Schemock section into existing CLAUDE.md content
|
|
637
|
+
*
|
|
638
|
+
* This function is careful to:
|
|
639
|
+
* 1. Preserve all user content outside the Schemock section
|
|
640
|
+
* 2. Replace existing Schemock section if present
|
|
641
|
+
* 3. Append new section if not present
|
|
642
|
+
* 4. Not corrupt any existing formatting
|
|
643
|
+
*
|
|
644
|
+
* @param existingContent - Current CLAUDE.md content (or empty string)
|
|
645
|
+
* @param schemockSection - The Schemock section to insert
|
|
646
|
+
* @returns Updated content with Schemock section
|
|
647
|
+
*/
|
|
648
|
+
declare function mergeClaudeMdContent(existingContent: string, schemockSection: string): {
|
|
649
|
+
content: string;
|
|
650
|
+
wasUpdated: boolean;
|
|
651
|
+
};
|
|
652
|
+
/**
|
|
653
|
+
* Generate the complete CLAUDE.md content
|
|
654
|
+
*
|
|
655
|
+
* @param config - Schemock configuration
|
|
656
|
+
* @param existingContent - Existing CLAUDE.md content (if any)
|
|
657
|
+
* @returns Generated/merged content and metadata
|
|
658
|
+
*/
|
|
659
|
+
declare function generateClaudeMd(config: SchemockConfig, existingContent?: string): ClaudeMdResult;
|
|
660
|
+
/**
|
|
661
|
+
* Generate .cursorrules content (Cursor IDE equivalent)
|
|
662
|
+
*
|
|
663
|
+
* @param config - Schemock configuration
|
|
664
|
+
* @returns Content for .cursorrules file
|
|
665
|
+
*/
|
|
666
|
+
declare function generateCursorRules(config: SchemockConfig): string;
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* Setup AI configuration command for Schemock CLI
|
|
670
|
+
*
|
|
671
|
+
* Generates CLAUDE.md and optionally .cursorrules to help AI tools
|
|
672
|
+
* understand how to work with Schemock projects.
|
|
673
|
+
*
|
|
674
|
+
* @module cli/commands/setup-ai
|
|
675
|
+
* @category CLI
|
|
676
|
+
*/
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Options for setup:ai command
|
|
680
|
+
*/
|
|
681
|
+
interface SetupAIOptions {
|
|
682
|
+
/** Config file path */
|
|
683
|
+
config?: string;
|
|
684
|
+
/** Also generate .cursorrules */
|
|
685
|
+
cursor?: boolean;
|
|
686
|
+
/** Dry run - show what would be generated */
|
|
687
|
+
dryRun?: boolean;
|
|
688
|
+
/** Force overwrite without checking for existing content */
|
|
689
|
+
force?: boolean;
|
|
690
|
+
/** Output directory (defaults to current directory) */
|
|
691
|
+
output?: string;
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Result of setup:ai command
|
|
695
|
+
*/
|
|
696
|
+
interface SetupAIResult {
|
|
697
|
+
claudeMd: ClaudeMdResult;
|
|
698
|
+
cursorRules?: {
|
|
699
|
+
created: boolean;
|
|
700
|
+
modified: boolean;
|
|
701
|
+
path: string;
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Main setup:ai command
|
|
706
|
+
*
|
|
707
|
+
* @param options - Command options
|
|
708
|
+
* @returns Result of the operation
|
|
709
|
+
*/
|
|
710
|
+
declare function setupAI(options?: SetupAIOptions): Promise<SetupAIResult>;
|
|
711
|
+
|
|
601
712
|
/**
|
|
602
713
|
* Pluralization utility for entity names
|
|
603
714
|
*
|
|
@@ -910,4 +1021,19 @@ declare function generateFirebaseClient(schemas: AnalyzedSchema[], config: Fireb
|
|
|
910
1021
|
*/
|
|
911
1022
|
declare function generateFetchClient(schemas: AnalyzedSchema[], config: FetchAdapterConfig): string;
|
|
912
1023
|
|
|
913
|
-
|
|
1024
|
+
/**
|
|
1025
|
+
* Form schema generator - generates Zod validation schemas, form defaults, and table column metadata
|
|
1026
|
+
*
|
|
1027
|
+
* @module cli/generators/form-schemas
|
|
1028
|
+
* @category CLI
|
|
1029
|
+
*/
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* Generate form-related schemas and metadata for all entities
|
|
1033
|
+
*
|
|
1034
|
+
* @param schemas - Analyzed schemas
|
|
1035
|
+
* @returns Generated TypeScript code
|
|
1036
|
+
*/
|
|
1037
|
+
declare function generateFormSchemas(schemas: AnalyzedSchema[]): string;
|
|
1038
|
+
|
|
1039
|
+
export { type AnalyzedComputed, type AnalyzedEndpoint, type AnalyzedEndpointField, type AnalyzedField, type AnalyzedIndex, type AnalyzedRLS, type AnalyzedRPC, type AnalyzedRelation, type AnalyzedSchema, type AuthProviderConfig, CodeBuilder, type FakerMapping, type FetchAdapterConfig, type FirebaseAdapterConfig, type GenerateOptions, type GenerateSQLOptions, type GenerationTarget, type GraphQLAdapterConfig, type MockAdapterConfig, type PGliteAdapterConfig, type PluralizeConfig, RLSBypass, RLSConfig, RLSScopeMapping, type SQLGeneratorResult, type SchemockConfig, type SupabaseAdapterConfig, type TargetMiddlewareConfig, type TargetType, analyzeSchemas, defineConfig, discoverSchemas, fieldToFakerCall, fieldToTsType, generate, generateClaudeMd, generateCursorRules, generateFetchClient, generateFirebaseClient, generateFormSchemas, generateHooks, generateMockClient, generateMockDb, generateMockHandlers, generateSchemockSection, generateSeed, generateSupabaseClient, generateTypes, getDefaultConfig, getRelativePath, loadConfig, mergeClaudeMdContent, pluralize, primitiveToTs, setupAI, toCamelCase, toPascalCase };
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -452,6 +452,8 @@ interface GenerateOptions {
|
|
|
452
452
|
only?: string[];
|
|
453
453
|
/** Exclude these entities (applies to all targets) */
|
|
454
454
|
exclude?: string[];
|
|
455
|
+
/** Generate form schemas (Zod validation, defaults, column metadata) */
|
|
456
|
+
withFormSchemas?: boolean;
|
|
455
457
|
}
|
|
456
458
|
/**
|
|
457
459
|
* Options for the generate:sql command
|
|
@@ -598,6 +600,115 @@ declare function analyzeSchemas(schemas: EntitySchema[], config: SchemockConfig)
|
|
|
598
600
|
*/
|
|
599
601
|
declare function generate(options: GenerateOptions): Promise<void>;
|
|
600
602
|
|
|
603
|
+
/**
|
|
604
|
+
* CLAUDE.md generator for Schemock
|
|
605
|
+
*
|
|
606
|
+
* Generates AI-friendly documentation that helps Claude Code understand
|
|
607
|
+
* how to work with Schemock projects without corrupting user content.
|
|
608
|
+
*
|
|
609
|
+
* @module cli/generators/claude-md
|
|
610
|
+
* @category CLI
|
|
611
|
+
*/
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Result of CLAUDE.md generation
|
|
615
|
+
*/
|
|
616
|
+
interface ClaudeMdResult {
|
|
617
|
+
/** Whether CLAUDE.md was created (vs updated) */
|
|
618
|
+
created: boolean;
|
|
619
|
+
/** Whether the file was modified */
|
|
620
|
+
modified: boolean;
|
|
621
|
+
/** The final content */
|
|
622
|
+
content: string;
|
|
623
|
+
/** Path to the file */
|
|
624
|
+
path: string;
|
|
625
|
+
/** Warning messages if any */
|
|
626
|
+
warnings: string[];
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Generate the Schemock section content based on config
|
|
630
|
+
*
|
|
631
|
+
* @param config - Schemock configuration
|
|
632
|
+
* @returns Markdown content for the Schemock section
|
|
633
|
+
*/
|
|
634
|
+
declare function generateSchemockSection(config: SchemockConfig): string;
|
|
635
|
+
/**
|
|
636
|
+
* Merge Schemock section into existing CLAUDE.md content
|
|
637
|
+
*
|
|
638
|
+
* This function is careful to:
|
|
639
|
+
* 1. Preserve all user content outside the Schemock section
|
|
640
|
+
* 2. Replace existing Schemock section if present
|
|
641
|
+
* 3. Append new section if not present
|
|
642
|
+
* 4. Not corrupt any existing formatting
|
|
643
|
+
*
|
|
644
|
+
* @param existingContent - Current CLAUDE.md content (or empty string)
|
|
645
|
+
* @param schemockSection - The Schemock section to insert
|
|
646
|
+
* @returns Updated content with Schemock section
|
|
647
|
+
*/
|
|
648
|
+
declare function mergeClaudeMdContent(existingContent: string, schemockSection: string): {
|
|
649
|
+
content: string;
|
|
650
|
+
wasUpdated: boolean;
|
|
651
|
+
};
|
|
652
|
+
/**
|
|
653
|
+
* Generate the complete CLAUDE.md content
|
|
654
|
+
*
|
|
655
|
+
* @param config - Schemock configuration
|
|
656
|
+
* @param existingContent - Existing CLAUDE.md content (if any)
|
|
657
|
+
* @returns Generated/merged content and metadata
|
|
658
|
+
*/
|
|
659
|
+
declare function generateClaudeMd(config: SchemockConfig, existingContent?: string): ClaudeMdResult;
|
|
660
|
+
/**
|
|
661
|
+
* Generate .cursorrules content (Cursor IDE equivalent)
|
|
662
|
+
*
|
|
663
|
+
* @param config - Schemock configuration
|
|
664
|
+
* @returns Content for .cursorrules file
|
|
665
|
+
*/
|
|
666
|
+
declare function generateCursorRules(config: SchemockConfig): string;
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* Setup AI configuration command for Schemock CLI
|
|
670
|
+
*
|
|
671
|
+
* Generates CLAUDE.md and optionally .cursorrules to help AI tools
|
|
672
|
+
* understand how to work with Schemock projects.
|
|
673
|
+
*
|
|
674
|
+
* @module cli/commands/setup-ai
|
|
675
|
+
* @category CLI
|
|
676
|
+
*/
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Options for setup:ai command
|
|
680
|
+
*/
|
|
681
|
+
interface SetupAIOptions {
|
|
682
|
+
/** Config file path */
|
|
683
|
+
config?: string;
|
|
684
|
+
/** Also generate .cursorrules */
|
|
685
|
+
cursor?: boolean;
|
|
686
|
+
/** Dry run - show what would be generated */
|
|
687
|
+
dryRun?: boolean;
|
|
688
|
+
/** Force overwrite without checking for existing content */
|
|
689
|
+
force?: boolean;
|
|
690
|
+
/** Output directory (defaults to current directory) */
|
|
691
|
+
output?: string;
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Result of setup:ai command
|
|
695
|
+
*/
|
|
696
|
+
interface SetupAIResult {
|
|
697
|
+
claudeMd: ClaudeMdResult;
|
|
698
|
+
cursorRules?: {
|
|
699
|
+
created: boolean;
|
|
700
|
+
modified: boolean;
|
|
701
|
+
path: string;
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Main setup:ai command
|
|
706
|
+
*
|
|
707
|
+
* @param options - Command options
|
|
708
|
+
* @returns Result of the operation
|
|
709
|
+
*/
|
|
710
|
+
declare function setupAI(options?: SetupAIOptions): Promise<SetupAIResult>;
|
|
711
|
+
|
|
601
712
|
/**
|
|
602
713
|
* Pluralization utility for entity names
|
|
603
714
|
*
|
|
@@ -910,4 +1021,19 @@ declare function generateFirebaseClient(schemas: AnalyzedSchema[], config: Fireb
|
|
|
910
1021
|
*/
|
|
911
1022
|
declare function generateFetchClient(schemas: AnalyzedSchema[], config: FetchAdapterConfig): string;
|
|
912
1023
|
|
|
913
|
-
|
|
1024
|
+
/**
|
|
1025
|
+
* Form schema generator - generates Zod validation schemas, form defaults, and table column metadata
|
|
1026
|
+
*
|
|
1027
|
+
* @module cli/generators/form-schemas
|
|
1028
|
+
* @category CLI
|
|
1029
|
+
*/
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* Generate form-related schemas and metadata for all entities
|
|
1033
|
+
*
|
|
1034
|
+
* @param schemas - Analyzed schemas
|
|
1035
|
+
* @returns Generated TypeScript code
|
|
1036
|
+
*/
|
|
1037
|
+
declare function generateFormSchemas(schemas: AnalyzedSchema[]): string;
|
|
1038
|
+
|
|
1039
|
+
export { type AnalyzedComputed, type AnalyzedEndpoint, type AnalyzedEndpointField, type AnalyzedField, type AnalyzedIndex, type AnalyzedRLS, type AnalyzedRPC, type AnalyzedRelation, type AnalyzedSchema, type AuthProviderConfig, CodeBuilder, type FakerMapping, type FetchAdapterConfig, type FirebaseAdapterConfig, type GenerateOptions, type GenerateSQLOptions, type GenerationTarget, type GraphQLAdapterConfig, type MockAdapterConfig, type PGliteAdapterConfig, type PluralizeConfig, RLSBypass, RLSConfig, RLSScopeMapping, type SQLGeneratorResult, type SchemockConfig, type SupabaseAdapterConfig, type TargetMiddlewareConfig, type TargetType, analyzeSchemas, defineConfig, discoverSchemas, fieldToFakerCall, fieldToTsType, generate, generateClaudeMd, generateCursorRules, generateFetchClient, generateFirebaseClient, generateFormSchemas, generateHooks, generateMockClient, generateMockDb, generateMockHandlers, generateSchemockSection, generateSeed, generateSupabaseClient, generateTypes, getDefaultConfig, getRelativePath, loadConfig, mergeClaudeMdContent, pluralize, primitiveToTs, setupAI, toCamelCase, toPascalCase };
|