@abeedoo/radish-schemas 1.7.7
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 +317 -0
- package/index.js +38 -0
- package/package.json +51 -0
- package/prompts/index.js +118 -0
- package/prompts/radish-app-generation.md +259 -0
- package/prompts/radish-components-generation.md +138 -0
- package/prompts/radish-roles-generation.md +133 -0
- package/prompts/radish-schema-generation.md +267 -0
- package/prompts/radish-theme-generation.md +138 -0
- package/prompts/radish-types-generation.md +294 -0
- package/prompts/radish-ui-generation.md +227 -0
- package/schemas/app.schema.json +289 -0
- package/schemas/components.schema.json +199 -0
- package/schemas/index.js +49 -0
- package/schemas/roles.schema.json +64 -0
- package/schemas/theme.schema.json +196 -0
- package/schemas/types.schema.json +761 -0
- package/schemas/ui.schema.json +346 -0
- package/validators/index.js +175 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# AI Schema Generation Prompt Template
|
|
2
|
+
|
|
3
|
+
You are an expert data architect. Generate JSON blueprints for a data layer based on the user's description.
|
|
4
|
+
|
|
5
|
+
## IMPORTANT: Built-in Entities Available
|
|
6
|
+
|
|
7
|
+
The following entities are already provided by the system. DO NOT recreate them - you can reference them with `ref` or extend them if needed:
|
|
8
|
+
|
|
9
|
+
### 1. User (Authentication & Identity)
|
|
10
|
+
- **Purpose**: Core user authentication account
|
|
11
|
+
- **Fields**: email, displayName, passwordHash, roles[], permissions[], registrationSource, tenantId, lastLoginAt, isActive
|
|
12
|
+
- **Usage**: Reference with `{ "type": "objectId", "ref": "User" }` for user relationships
|
|
13
|
+
- **Extend**: You can extend User with additional fields using `"extends": "User"`
|
|
14
|
+
|
|
15
|
+
### 2. Profile (User Information)
|
|
16
|
+
- **Purpose**: Extended user profile and personal information
|
|
17
|
+
- **Fields**: userId, firstName, lastName, avatarUrl, bio, street, city, region, postal, country, timezone, locale, phone, website
|
|
18
|
+
- **Usage**: Automatically linked to User, contains personal/contact information
|
|
19
|
+
|
|
20
|
+
### 3. Role (Permission Management)
|
|
21
|
+
- **Purpose**: User roles for permission management (system-owned)
|
|
22
|
+
- **Fields**: name, label, description, permissions[], isSystem, isActive
|
|
23
|
+
- **Usage**: Referenced by User.roles[], manages access control
|
|
24
|
+
|
|
25
|
+
### 4. Permission (Access Control)
|
|
26
|
+
- **Purpose**: System permissions for role-based access control (system-owned)
|
|
27
|
+
- **Fields**: key, name, description, category, isSystem
|
|
28
|
+
- **Usage**: Referenced by Role.permissions[], defines specific access rights
|
|
29
|
+
|
|
30
|
+
### 5. ApiKey (API Authentication)
|
|
31
|
+
- **Purpose**: API access keys for programmatic authentication
|
|
32
|
+
- **Fields**: name, key (secretKey), userId, scopes[], permissions[], roles[], expiresAt, lastUsedAt, isActive
|
|
33
|
+
- **Usage**: For API authentication, linked to specific users
|
|
34
|
+
|
|
35
|
+
### 6. Setting (Configuration)
|
|
36
|
+
- **Purpose**: Key-value configuration storage (system-owned)
|
|
37
|
+
- **Fields**: key, value, category, dataType, encrypted, description, scope (system/user), userId
|
|
38
|
+
- **Usage**: System and user-specific configuration storage
|
|
39
|
+
|
|
40
|
+
## Schema Requirements
|
|
41
|
+
|
|
42
|
+
1. **Return ONLY valid JSON** - No markdown, explanations, or code blocks
|
|
43
|
+
2. **Use this exact structure for types**:
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"version": 1,
|
|
47
|
+
"defaults": {
|
|
48
|
+
"owned": true,
|
|
49
|
+
"timestamps": true
|
|
50
|
+
},
|
|
51
|
+
"entities": {
|
|
52
|
+
"Project": {
|
|
53
|
+
"label": "Project",
|
|
54
|
+
"description": "A project container",
|
|
55
|
+
"plural": "projects",
|
|
56
|
+
"fields": {
|
|
57
|
+
"title": { "type": "string", "required": true, "label": "Title" },
|
|
58
|
+
"description": { "type": "string", "optional": true, "label": "Description" }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
3. **Field Types**: string, int, float, boolean, isoDate, objectId, string[], objectId[], enum, object, array, url, secretKey, encryptedKey
|
|
66
|
+
|
|
67
|
+
4. **Field Exposure** (optional): Control field visibility in generated APIs/contracts:
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"type": "string",
|
|
71
|
+
"expose": {
|
|
72
|
+
"contracts": true,
|
|
73
|
+
"create": true,
|
|
74
|
+
"update": false,
|
|
75
|
+
"read": true
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
5. **Required Entity Properties**:
|
|
81
|
+
- `label`: Human-readable name
|
|
82
|
+
- `description`: What this entity represents
|
|
83
|
+
- `plural`: Plural form for collections
|
|
84
|
+
- `fields`: Object defining all fields
|
|
85
|
+
|
|
86
|
+
6. **Relationships**: Use `{ "type": "objectId", "ref": "EntityName" }` for references
|
|
87
|
+
|
|
88
|
+
7. **Enhanced Enums**: Use key-value pairs for better UX:
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"type": "enum",
|
|
92
|
+
"values": [
|
|
93
|
+
{ "key": "ACTIVE", "label": "Active" },
|
|
94
|
+
{ "key": "INACTIVE", "label": "Inactive" }
|
|
95
|
+
],
|
|
96
|
+
"default": "ACTIVE"
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
8. **Performance**: Add `filters` array for searchable fields and `indexes` for performance
|
|
101
|
+
|
|
102
|
+
## Extension Examples
|
|
103
|
+
|
|
104
|
+
**Extend User with custom fields**:
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"User": {
|
|
108
|
+
"extends": "User",
|
|
109
|
+
"plural": "users",
|
|
110
|
+
"fields": {
|
|
111
|
+
"department": { "type": "string", "optional": true, "label": "Department" },
|
|
112
|
+
"employeeId": { "type": "string", "optional": true, "label": "Employee ID" }
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Reference builtin entities**:
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"Project": {
|
|
122
|
+
"plural": "projects",
|
|
123
|
+
"fields": {
|
|
124
|
+
"ownerId": { "type": "objectId", "ref": "User", "required": true, "label": "Owner" },
|
|
125
|
+
"assignedUsers": { "type": "objectId[]", "ref": "User", "default": [], "label": "Assigned Users" }
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## What NOT to create:
|
|
132
|
+
- User authentication/login entities (User exists)
|
|
133
|
+
- Role/permission management (Role, Permission exist)
|
|
134
|
+
- User profile/contact info (Profile exists)
|
|
135
|
+
- API key management (ApiKey exists)
|
|
136
|
+
- System settings (Setting exists)
|
|
137
|
+
|
|
138
|
+
## Focus on:
|
|
139
|
+
- Business-specific entities for your domain
|
|
140
|
+
- Domain workflows and processes
|
|
141
|
+
- Content, inventory, transactions, etc.
|
|
142
|
+
- Relationships between business entities
|
|
143
|
+
- Extending builtin entities when needed
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Roles Blueprint Format (roles.json)
|
|
148
|
+
|
|
149
|
+
The roles blueprint defines user roles with this EXACT structure:
|
|
150
|
+
|
|
151
|
+
```json
|
|
152
|
+
{
|
|
153
|
+
"version": 1,
|
|
154
|
+
"roles": {
|
|
155
|
+
"USER": {
|
|
156
|
+
"label": "Standard User",
|
|
157
|
+
"description": "Standard user with basic permissions",
|
|
158
|
+
"isSystem": true,
|
|
159
|
+
"permissions": []
|
|
160
|
+
},
|
|
161
|
+
"ADMIN": {
|
|
162
|
+
"label": "Administrator",
|
|
163
|
+
"description": "Full system access",
|
|
164
|
+
"isSystem": true,
|
|
165
|
+
"permissions": []
|
|
166
|
+
},
|
|
167
|
+
"MANAGER": {
|
|
168
|
+
"label": "Manager",
|
|
169
|
+
"description": "Can manage projects and teams",
|
|
170
|
+
"isSystem": false,
|
|
171
|
+
"permissions": [
|
|
172
|
+
"project:create",
|
|
173
|
+
"project:edit",
|
|
174
|
+
"user:manage"
|
|
175
|
+
]
|
|
176
|
+
},
|
|
177
|
+
"PROJECT_MEMBER": {
|
|
178
|
+
"label": "Project Member",
|
|
179
|
+
"description": "Can view and edit assigned projects",
|
|
180
|
+
"isSystem": false,
|
|
181
|
+
"permissions": [
|
|
182
|
+
"project:view",
|
|
183
|
+
"task:create",
|
|
184
|
+
"task:edit",
|
|
185
|
+
"comment:create"
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**IMPORTANT**:
|
|
193
|
+
- Roles must be objects with keys (like `"USER"`, `"ADMIN"`), NOT arrays
|
|
194
|
+
- Permission names use `entity:action` format (like `"project:create"`, `"userProfile:view"`, `"task-assignment:view"`)
|
|
195
|
+
- Role keys should be UPPERCASE (USER, ADMIN, MANAGER), NOT lowercase or camelCase
|
|
196
|
+
|
|
197
|
+
## Entity Requirements
|
|
198
|
+
|
|
199
|
+
**Every entity MUST have**:
|
|
200
|
+
- `plural` - The plural form (e.g., `"plural": "projects"`)
|
|
201
|
+
- `fields` - Field definitions (even if empty: `"fields": {}`)
|
|
202
|
+
|
|
203
|
+
**Entity names**:
|
|
204
|
+
- Use PascalCase (Project, Task, Comment)
|
|
205
|
+
- Must be valid identifiers (no spaces, special characters)
|
|
206
|
+
- Don't create entities for app descriptions or metadata
|
|
207
|
+
|
|
208
|
+
**CRITICAL**: ALL entities must be inside the `entities` object, including User extensions.
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
**User Description**: {{USER_DESCRIPTION}}
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Response Format
|
|
217
|
+
|
|
218
|
+
You MUST respond with ONLY a valid JSON object in this EXACT format:
|
|
219
|
+
|
|
220
|
+
```json
|
|
221
|
+
{
|
|
222
|
+
"types": {
|
|
223
|
+
"version": 1,
|
|
224
|
+
"defaults": {
|
|
225
|
+
"owned": true,
|
|
226
|
+
"timestamps": true
|
|
227
|
+
},
|
|
228
|
+
"entities": {
|
|
229
|
+
"Project": {
|
|
230
|
+
"label": "Project",
|
|
231
|
+
"description": "A project container",
|
|
232
|
+
"plural": "projects",
|
|
233
|
+
"fields": {
|
|
234
|
+
"title": { "type": "string", "required": true, "label": "Title" }
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
"roles": {
|
|
240
|
+
"version": 1,
|
|
241
|
+
"roles": {
|
|
242
|
+
"USER": {
|
|
243
|
+
"label": "Standard User",
|
|
244
|
+
"description": "Standard user with basic permissions",
|
|
245
|
+
"isSystem": true,
|
|
246
|
+
"permissions": []
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**CRITICAL REQUIREMENTS**:
|
|
254
|
+
1. Return ONLY the JSON object - no markdown code blocks, no explanations, no preamble
|
|
255
|
+
2. Both `types` and `roles` must be complete JSON objects (NOT strings)
|
|
256
|
+
3. Both must include `"version": 1`
|
|
257
|
+
4. All keys and string values must be properly quoted
|
|
258
|
+
|
|
259
|
+
**Common Mistakes to AVOID**:
|
|
260
|
+
- Wrapping response in markdown ```json...``` blocks
|
|
261
|
+
- Including explanatory text before or after the JSON
|
|
262
|
+
- Using arrays for roles (must be objects with keys)
|
|
263
|
+
- Permission names without colons (use `"entity:action"` format)
|
|
264
|
+
- Forgetting `"plural"` field on entities
|
|
265
|
+
- Putting User extensions outside the `entities` object
|
|
266
|
+
- Creating auth-related entities that already exist builtin
|
|
267
|
+
- Returning YAML strings instead of JSON objects
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# AI Theme Blueprint Generation Prompt
|
|
2
|
+
|
|
3
|
+
You are a UI/UX designer creating a DaisyUI v5 theme for a web application. Given an app description and style preferences, generate a theme.json blueprint with concrete design tokens.
|
|
4
|
+
|
|
5
|
+
**Generate ONLY the theme blueprint. Do NOT include types, roles, app, ui, or components.**
|
|
6
|
+
|
|
7
|
+
## Theme Structure
|
|
8
|
+
|
|
9
|
+
The theme must include:
|
|
10
|
+
- **name**: Short theme identifier (lowercase, no spaces, hyphens allowed)
|
|
11
|
+
- **colorScheme**: `"light"` or `"dark"`
|
|
12
|
+
- **colors**: All 11 DaisyUI color tokens as hex values
|
|
13
|
+
- **typography**: Font families for body and headings
|
|
14
|
+
- **radius**: Border radius tokens for boxes, buttons, and badges
|
|
15
|
+
- **backgrounds**: Named background definitions for page sections
|
|
16
|
+
|
|
17
|
+
## Color Token Reference
|
|
18
|
+
|
|
19
|
+
| Token | Purpose | Guidelines |
|
|
20
|
+
|-------|---------|------------|
|
|
21
|
+
| `primary` | Brand color, CTAs, active states | Should match the app's domain/tone |
|
|
22
|
+
| `secondary` | Supporting color, secondary buttons | Deeper or complementary to primary |
|
|
23
|
+
| `accent` | Contrast color, highlights | Provides visual pop against primary |
|
|
24
|
+
| `neutral` | Text, dark backgrounds, borders | Very dark color for text readability |
|
|
25
|
+
| `base100` | Main page background | White/near-white for light, dark for dark themes |
|
|
26
|
+
| `base200` | Subtle background variation | Cards, inputs, slightly different from base100 |
|
|
27
|
+
| `base300` | Strongest background variation | Borders, dividers, strongest contrast |
|
|
28
|
+
| `info` | Informational messages | Typically blue |
|
|
29
|
+
| `success` | Success states | Typically green |
|
|
30
|
+
| `warning` | Warning states | Typically yellow/amber |
|
|
31
|
+
| `error` | Error states | Typically red |
|
|
32
|
+
|
|
33
|
+
## Example
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"version": 1,
|
|
38
|
+
"theme": {
|
|
39
|
+
"name": "edu-platform",
|
|
40
|
+
"colorScheme": "light",
|
|
41
|
+
"colors": {
|
|
42
|
+
"primary": "#2563eb",
|
|
43
|
+
"secondary": "#1e40af",
|
|
44
|
+
"accent": "#f59e0b",
|
|
45
|
+
"neutral": "#1e293b",
|
|
46
|
+
"base100": "#ffffff",
|
|
47
|
+
"base200": "#f8fafc",
|
|
48
|
+
"base300": "#e2e8f0",
|
|
49
|
+
"info": "#3b82f6",
|
|
50
|
+
"success": "#22c55e",
|
|
51
|
+
"warning": "#eab308",
|
|
52
|
+
"error": "#ef4444"
|
|
53
|
+
},
|
|
54
|
+
"typography": {
|
|
55
|
+
"fontFamily": "Inter, sans-serif",
|
|
56
|
+
"headingFont": "Poppins, sans-serif"
|
|
57
|
+
},
|
|
58
|
+
"radius": {
|
|
59
|
+
"box": "0.5rem",
|
|
60
|
+
"button": "0.375rem",
|
|
61
|
+
"badge": "1rem"
|
|
62
|
+
},
|
|
63
|
+
"backgrounds": {
|
|
64
|
+
"hero": {
|
|
65
|
+
"type": "gradient",
|
|
66
|
+
"gradient": "linear-gradient(135deg, #2563eb, #1e40af)"
|
|
67
|
+
},
|
|
68
|
+
"page": {
|
|
69
|
+
"type": "solid",
|
|
70
|
+
"color": "#ffffff"
|
|
71
|
+
},
|
|
72
|
+
"card": {
|
|
73
|
+
"type": "solid",
|
|
74
|
+
"color": "#f8fafc"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Design Rules
|
|
82
|
+
|
|
83
|
+
- Colors must be valid hex codes (`#RRGGBB`)
|
|
84
|
+
- Choose colors that match the app's domain and tone
|
|
85
|
+
- Ensure sufficient contrast between text and backgrounds
|
|
86
|
+
- `primary` should be the brand color, `accent` provides contrast
|
|
87
|
+
- `base100` is the main background, `base200`/`base300` are subtle variations
|
|
88
|
+
- For dark themes: `base100` should be dark, `base300` darkest
|
|
89
|
+
- Use real Google Fonts or system font stacks for typography
|
|
90
|
+
- Background gradients should use the primary/secondary colors
|
|
91
|
+
- Keep radius values reasonable (0.25rem to 1.5rem)
|
|
92
|
+
|
|
93
|
+
## Domain Color Suggestions
|
|
94
|
+
|
|
95
|
+
- **Education**: Blues and greens (trust, growth)
|
|
96
|
+
- **E-commerce**: Bold primaries with warm accents
|
|
97
|
+
- **Healthcare**: Clean blues, soft greens
|
|
98
|
+
- **Finance**: Dark blues, professional grays
|
|
99
|
+
- **Social**: Vibrant, energetic colors
|
|
100
|
+
- **Productivity**: Minimal, high-contrast
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
**User Description**: {{USER_DESCRIPTION}}
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Response Format
|
|
109
|
+
|
|
110
|
+
You MUST respond with ONLY a valid JSON object:
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"version": 1,
|
|
115
|
+
"theme": {
|
|
116
|
+
"name": "theme-name",
|
|
117
|
+
"colorScheme": "light",
|
|
118
|
+
"colors": { ... },
|
|
119
|
+
"typography": { ... },
|
|
120
|
+
"radius": { ... },
|
|
121
|
+
"backgrounds": { ... }
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**CRITICAL REQUIREMENTS**:
|
|
127
|
+
1. Return ONLY the JSON object - no markdown code blocks, no explanations
|
|
128
|
+
2. Must include `"version": 1`
|
|
129
|
+
3. Must include `"theme"` with `name`, `colorScheme`, and `colors`
|
|
130
|
+
4. All color values must be valid `#RRGGBB` hex codes
|
|
131
|
+
5. Theme `name` must be lowercase with hyphens only
|
|
132
|
+
|
|
133
|
+
**Common Mistakes to AVOID**:
|
|
134
|
+
- Wrapping response in markdown ```json...``` blocks
|
|
135
|
+
- Using color names instead of hex values (use `"#22c55e"` not `"green"`)
|
|
136
|
+
- Using RGB/HSL format instead of hex
|
|
137
|
+
- Insufficient contrast between base100 and text colors
|
|
138
|
+
- Missing required color tokens
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
# AI Types Blueprint Generation Prompt
|
|
2
|
+
|
|
3
|
+
You are an expert data architect. Generate a JSON types blueprint for a data layer based on the user's description.
|
|
4
|
+
|
|
5
|
+
**Generate ONLY the types blueprint. Do NOT include roles.**
|
|
6
|
+
|
|
7
|
+
## IMPORTANT: Built-in Entities Available
|
|
8
|
+
|
|
9
|
+
The following entities are already provided by the system. DO NOT recreate them - you can reference them with `ref` or extend them if needed:
|
|
10
|
+
|
|
11
|
+
### 1. User (Authentication & Identity)
|
|
12
|
+
- **Purpose**: Core user authentication account
|
|
13
|
+
- **Fields**: email, displayName, passwordHash, roles[], permissions[], registrationSource, tenantId, lastLoginAt, isActive
|
|
14
|
+
- **Usage**: Reference with `{ "type": "objectId", "ref": "User" }` for user relationships
|
|
15
|
+
- **Extend**: You can extend User with additional fields using `"extends": "User"`
|
|
16
|
+
|
|
17
|
+
### 2. Profile (User Information)
|
|
18
|
+
- **Purpose**: Extended user profile and personal information
|
|
19
|
+
- **Fields**: userId, firstName, lastName, avatarUrl, bio, street, city, region, postal, country, timezone, locale, phone, website
|
|
20
|
+
- **Usage**: Automatically linked to User, contains personal/contact information
|
|
21
|
+
|
|
22
|
+
### 3. Role (Permission Management)
|
|
23
|
+
- **Purpose**: User roles for permission management (system-owned)
|
|
24
|
+
- **Fields**: name, label, description, permissions[], isSystem, isActive
|
|
25
|
+
- **Usage**: Referenced by User.roles[], manages access control
|
|
26
|
+
|
|
27
|
+
### 4. Permission (Access Control)
|
|
28
|
+
- **Purpose**: System permissions for role-based access control (system-owned)
|
|
29
|
+
- **Fields**: key, name, description, category, isSystem
|
|
30
|
+
- **Usage**: Referenced by Role.permissions[], defines specific access rights
|
|
31
|
+
|
|
32
|
+
### 5. ApiKey (API Authentication)
|
|
33
|
+
- **Purpose**: API access keys for programmatic authentication
|
|
34
|
+
- **Fields**: name, key (secretKey), userId, scopes[], permissions[], roles[], expiresAt, lastUsedAt, isActive
|
|
35
|
+
- **Usage**: For API authentication, linked to specific users
|
|
36
|
+
|
|
37
|
+
### 6. Setting (Configuration)
|
|
38
|
+
- **Purpose**: Key-value configuration storage (system-owned)
|
|
39
|
+
- **Fields**: key, value, category, dataType, encrypted, description, scope (system/user), userId
|
|
40
|
+
- **Usage**: System and user-specific configuration storage
|
|
41
|
+
|
|
42
|
+
## Schema Requirements
|
|
43
|
+
|
|
44
|
+
1. **Return ONLY valid JSON** - No markdown, explanations, or code blocks
|
|
45
|
+
2. **Use this exact structure**:
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"version": 1,
|
|
49
|
+
"defaults": {
|
|
50
|
+
"owned": true,
|
|
51
|
+
"timestamps": true
|
|
52
|
+
},
|
|
53
|
+
"entities": {
|
|
54
|
+
"Project": {
|
|
55
|
+
"label": "Project",
|
|
56
|
+
"description": "A project container",
|
|
57
|
+
"plural": "projects",
|
|
58
|
+
"fields": {
|
|
59
|
+
"title": { "type": "string", "required": true, "label": "Title" },
|
|
60
|
+
"description": { "type": "string", "optional": true, "label": "Description" }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
3. **Field Types**: string, int, float, boolean, isoDate, objectId, string[], int[], float[], boolean[], objectId[], url[], enum, object, array, url, secretKey, encryptedKey
|
|
68
|
+
|
|
69
|
+
4. **Field Exposure** (optional): Control field visibility in generated APIs/contracts:
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"type": "string",
|
|
73
|
+
"expose": {
|
|
74
|
+
"contracts": true,
|
|
75
|
+
"create": true,
|
|
76
|
+
"update": false,
|
|
77
|
+
"read": true
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
5. **Field-Level Access Control** (optional): Restrict which roles can read or write specific fields:
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"costPrice": {
|
|
86
|
+
"type": "float",
|
|
87
|
+
"access": { "read": ["ADMIN", "MANAGER"] }
|
|
88
|
+
},
|
|
89
|
+
"supplierNotes": {
|
|
90
|
+
"type": "string",
|
|
91
|
+
"access": { "read": ["ADMIN", "MANAGER"], "write": ["ADMIN"] }
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
If `access` is omitted, the field is visible/writable to anyone with entity access. ADMIN with `system:admin` bypasses all field restrictions.
|
|
96
|
+
|
|
97
|
+
6. **Required Entity Properties**:
|
|
98
|
+
- `label`: Human-readable name
|
|
99
|
+
- `description`: What this entity represents
|
|
100
|
+
- `plural`: Plural form for collections
|
|
101
|
+
- `fields`: Object defining all fields
|
|
102
|
+
|
|
103
|
+
7. **Relationships**: Use `{ "type": "objectId", "ref": "EntityName" }` for references
|
|
104
|
+
|
|
105
|
+
8. **Scope** (optional): Scoped access control with two modes:
|
|
106
|
+
|
|
107
|
+
**Through-entity** — access if user owns a related entity:
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"Subscription": {
|
|
111
|
+
"ownership": "system",
|
|
112
|
+
"scope": { "field": "appId", "through": "App", "ownerField": "ownerId" },
|
|
113
|
+
"fields": { ... }
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Direct-match** — access when record's field matches a user field (multi-tenant):
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"Invoice": {
|
|
122
|
+
"ownership": "system",
|
|
123
|
+
"scope": { "field": "orgId", "matchUserField": "orgIds" },
|
|
124
|
+
"fields": { ... }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
`matchUserField` supports array match — if `user.orgIds` is an array, checks if `record.orgId` is in that array.
|
|
129
|
+
|
|
130
|
+
9. **Enhanced Enums**: Use key-value pairs for better UX:
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"type": "enum",
|
|
134
|
+
"values": [
|
|
135
|
+
{ "key": "ACTIVE", "label": "Active" },
|
|
136
|
+
{ "key": "INACTIVE", "label": "Inactive" }
|
|
137
|
+
],
|
|
138
|
+
"default": "ACTIVE"
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
10. **Performance**: Add `filters` array for searchable fields and `indexes` for performance
|
|
143
|
+
|
|
144
|
+
11. **Nested Objects**: Use `"type": "object"` with `"fields"` for nested structures:
|
|
145
|
+
```json
|
|
146
|
+
{
|
|
147
|
+
"type": "object",
|
|
148
|
+
"label": "Location",
|
|
149
|
+
"fields": {
|
|
150
|
+
"latitude": { "type": "float" },
|
|
151
|
+
"longitude": { "type": "float" }
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
12. **Search Index** (optional): Enable full-text search with engine-specific adapters:
|
|
157
|
+
```json
|
|
158
|
+
{
|
|
159
|
+
"Product": {
|
|
160
|
+
"plural": "products",
|
|
161
|
+
"search": {
|
|
162
|
+
"enabled": true,
|
|
163
|
+
"engine": "typesense",
|
|
164
|
+
"indexName": "products",
|
|
165
|
+
"fields": {
|
|
166
|
+
"searchable": ["name", "description", "brand"],
|
|
167
|
+
"filterable": ["brand", "price", "categories"],
|
|
168
|
+
"sortable": ["price", "name", "createdAt"],
|
|
169
|
+
"facetable": ["brand", "categories"]
|
|
170
|
+
},
|
|
171
|
+
"sync": "inline",
|
|
172
|
+
"vector": {
|
|
173
|
+
"enabled": false,
|
|
174
|
+
"sourceFields": ["name", "description"]
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"fields": { ... }
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
- **engine**: `typesense`, `elastic`, `opensearch`, `meilisearch`, `mongoAtlas`
|
|
182
|
+
- **indexName**: Custom index name (defaults to entity plural)
|
|
183
|
+
- **sync**: `inline` (immediate) or `background` (via jobs)
|
|
184
|
+
- **vector**: Enable vector/embedding search with `sourceFields` to generate embeddings from
|
|
185
|
+
|
|
186
|
+
13. **Automatic Fields** (DO NOT add these manually):
|
|
187
|
+
- When `"defaults": { "timestamps": true }` is set, `createdAt` and `updatedAt` are added automatically
|
|
188
|
+
- When `"defaults": { "owned": true }` is set, `ownerId` is added automatically
|
|
189
|
+
- Adding these fields manually causes duplication
|
|
190
|
+
|
|
191
|
+
## Extension Examples
|
|
192
|
+
|
|
193
|
+
**Extend User with custom fields**:
|
|
194
|
+
```json
|
|
195
|
+
{
|
|
196
|
+
"User": {
|
|
197
|
+
"extends": "User",
|
|
198
|
+
"plural": "users",
|
|
199
|
+
"fields": {
|
|
200
|
+
"department": { "type": "string", "optional": true, "label": "Department" },
|
|
201
|
+
"employeeId": { "type": "string", "optional": true, "label": "Employee ID" }
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Reference builtin entities**:
|
|
208
|
+
```json
|
|
209
|
+
{
|
|
210
|
+
"Project": {
|
|
211
|
+
"plural": "projects",
|
|
212
|
+
"fields": {
|
|
213
|
+
"ownerId": { "type": "objectId", "ref": "User", "required": true, "label": "Owner" },
|
|
214
|
+
"assignedUsers": { "type": "objectId[]", "ref": "User", "default": [], "label": "Assigned Users" }
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## What NOT to create:
|
|
221
|
+
- User authentication/login entities (User exists)
|
|
222
|
+
- Role/permission management (Role, Permission exist)
|
|
223
|
+
- User profile/contact info (Profile exists)
|
|
224
|
+
- API key management (ApiKey exists)
|
|
225
|
+
- System settings (Setting exists)
|
|
226
|
+
|
|
227
|
+
## Focus on:
|
|
228
|
+
- Business-specific entities for your domain
|
|
229
|
+
- Domain workflows and processes
|
|
230
|
+
- Content, inventory, transactions, etc.
|
|
231
|
+
- Relationships between business entities
|
|
232
|
+
- Extending builtin entities when needed
|
|
233
|
+
|
|
234
|
+
## Entity Requirements
|
|
235
|
+
|
|
236
|
+
**Every entity MUST have**:
|
|
237
|
+
- `plural` - The plural form (e.g., `"plural": "projects"`)
|
|
238
|
+
- `fields` - Field definitions (even if empty: `"fields": {}`)
|
|
239
|
+
|
|
240
|
+
**Entity names**:
|
|
241
|
+
- Use PascalCase (Project, Task, Comment)
|
|
242
|
+
- Must be valid identifiers (no spaces, special characters)
|
|
243
|
+
- Don't create entities for app descriptions or metadata
|
|
244
|
+
|
|
245
|
+
**CRITICAL**: ALL entities must be inside the `entities` object, including User extensions.
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
**User Description**: {{USER_DESCRIPTION}}
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Response Format
|
|
254
|
+
|
|
255
|
+
You MUST respond with ONLY a valid JSON object starting with `{ "version": 1, "entities": { ... } }`.
|
|
256
|
+
|
|
257
|
+
```json
|
|
258
|
+
{
|
|
259
|
+
"version": 1,
|
|
260
|
+
"defaults": {
|
|
261
|
+
"owned": true,
|
|
262
|
+
"timestamps": true
|
|
263
|
+
},
|
|
264
|
+
"entities": {
|
|
265
|
+
"Project": {
|
|
266
|
+
"label": "Project",
|
|
267
|
+
"description": "A project container",
|
|
268
|
+
"plural": "projects",
|
|
269
|
+
"fields": {
|
|
270
|
+
"title": { "type": "string", "required": true, "label": "Title" }
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**CRITICAL REQUIREMENTS**:
|
|
278
|
+
1. Return ONLY the JSON object - no markdown code blocks, no explanations, no preamble
|
|
279
|
+
2. Must include `"version": 1`
|
|
280
|
+
3. Must include `"entities"` with at least one entity
|
|
281
|
+
4. Do NOT include roles - this is types only
|
|
282
|
+
5. All keys and string values must be properly quoted
|
|
283
|
+
|
|
284
|
+
**Common Mistakes to AVOID**:
|
|
285
|
+
- Wrapping response in markdown ```json...``` blocks
|
|
286
|
+
- Including explanatory text before or after the JSON
|
|
287
|
+
- Including a "roles" section (generate types ONLY)
|
|
288
|
+
- Forgetting `"plural"` field on entities
|
|
289
|
+
- Putting User extensions outside the `entities` object
|
|
290
|
+
- Creating auth-related entities that already exist builtin
|
|
291
|
+
- Adding `createdAt`/`updatedAt` fields when `timestamps: true` is set (they're automatic)
|
|
292
|
+
- Adding `ownerId` fields when `owned: true` is set (it's automatic)
|
|
293
|
+
- Using `"shape"` instead of `"fields"` for nested object definitions
|
|
294
|
+
- Inventing field types that don't exist (e.g., `"date"` — use `"isoDate"`)
|