Skip to content

Commit 8356056

Browse files
Add comprehensive quick start guide for VSCode extension
Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
1 parent e30e298 commit 8356056

File tree

1 file changed

+290
-0
lines changed

1 file changed

+290
-0
lines changed
Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
# ObjectQL VSCode Extension - Quick Start Guide
2+
3+
## 🚀 Installation
4+
5+
### Option 1: Install from VSIX
6+
```bash
7+
cd packages/tools/vscode-objectql
8+
code --install-extension vscode-objectql-0.1.0.vsix
9+
```
10+
11+
### Option 2: Build from Source
12+
```bash
13+
cd packages/tools/vscode-objectql
14+
npm install
15+
npm run compile
16+
npm run package
17+
code --install-extension vscode-objectql-0.1.0.vsix
18+
```
19+
20+
## 📋 What You Get
21+
22+
### 1. Smart Auto-Completion
23+
When editing `.object.yml` files, you get intelligent suggestions:
24+
25+
**Field Types:**
26+
- `text`, `textarea`, `markdown`, `html`
27+
- `number`, `currency`, `percent`
28+
- `date`, `datetime`, `time`
29+
- `select`, `lookup`, `master_detail`
30+
- `boolean`, `email`, `phone`, `url`
31+
- `file`, `image`, `location`
32+
- `formula`, `summary`, `auto_number`
33+
- `object`, `vector`, `grid`
34+
35+
**Validation Operators:**
36+
- `=`, `!=`, `>`, `>=`, `<`, `<=`
37+
- `in`, `not_in`, `contains`, `not_contains`
38+
- `starts_with`, `ends_with`
39+
40+
### 2. Code Snippets
41+
42+
Type these prefixes and press Tab:
43+
44+
#### Object & Field Snippets
45+
```yaml
46+
oql-object # Complete object definition
47+
oql-field-text # Text field
48+
oql-field-number # Number field
49+
oql-field-select # Select with options
50+
oql-field-lookup # Relationship field
51+
oql-field-datetime # DateTime field
52+
oql-field-email # Email field
53+
oql-field-currency # Currency field
54+
oql-field-file # File attachment
55+
oql-field-image # Image field
56+
oql-index # Database index
57+
oql-ai-search # AI semantic search
58+
```
59+
60+
#### Validation Snippets
61+
```yaml
62+
oql-validation-cross-field # Cross-field validation
63+
oql-validation-unique # Uniqueness validation
64+
oql-validation-business # Business rule
65+
oql-validation-state # State machine
66+
```
67+
68+
#### TypeScript Snippets
69+
```typescript
70+
oql-hook-beforeCreate // Before create hook
71+
oql-hook-afterCreate // After create hook
72+
oql-hook-beforeUpdate // Before update hook
73+
oql-hook-afterUpdate // After update hook
74+
oql-hook-beforeDelete // Before delete hook
75+
oql-hook-afterDelete // After delete hook
76+
oql-action-record // Record-level action
77+
oql-action-global // Global action
78+
oql-query // Repository query
79+
oql-create // Create record
80+
oql-update // Update record
81+
oql-error // ObjectQL error
82+
```
83+
84+
### 3. Quick Commands
85+
86+
Press `Ctrl+Shift+P` (or `Cmd+Shift+P`) and type "ObjectQL":
87+
88+
- **ObjectQL: New Object Definition** - Create new object with template
89+
- **ObjectQL: New Validation Rules** - Create validation file
90+
- **ObjectQL: New Permission Rules** - Create permission file
91+
- **ObjectQL: New Application Config** - Create app config
92+
- **ObjectQL: Validate Current File** - Validate against schema
93+
94+
### 4. Real-Time Validation
95+
96+
The extension validates your YAML files in real-time:
97+
98+
**Valid Syntax:**
99+
```yaml
100+
name: product
101+
label: Product
102+
fields:
103+
name:
104+
type: text
105+
required: true
106+
```
107+
108+
❌ **Invalid Syntax:**
109+
```yaml
110+
name: product
111+
fields:
112+
name:
113+
type: invalid_type # Error: Invalid field type
114+
required: "yes" # Error: Should be boolean
115+
```
116+
117+
Errors appear:
118+
- Underlined in red in the editor
119+
- Listed in the Problems panel (`Ctrl+Shift+M`)
120+
- With helpful error messages on hover
121+
122+
### 5. File Icons
123+
124+
ObjectQL files get custom icons in the Explorer:
125+
- 📊 `.object.yml` - Database table icon
126+
- ✅ `.validation.yml` - Checkmark icon
127+
- 🔒 `.permission.yml` - Lock icon
128+
- 📱 `.app.yml` - Application icon
129+
130+
## 💡 Usage Examples
131+
132+
### Example 1: Create a Product Object
133+
134+
1. Press `Ctrl+Shift+P`
135+
2. Type "ObjectQL: New Object"
136+
3. Enter "product"
137+
4. Edit the generated template:
138+
139+
```yaml
140+
name: product
141+
label: Product
142+
description: "Product catalog item"
143+
144+
fields:
145+
name:
146+
type: text
147+
label: Product Name
148+
required: true
149+
searchable: true
150+
151+
price:
152+
type: currency
153+
label: Price
154+
required: true
155+
min: 0
156+
157+
category:
158+
type: select
159+
label: Category
160+
options:
161+
- label: Electronics
162+
value: electronics
163+
- label: Clothing
164+
value: clothing
165+
```
166+
167+
### Example 2: Add Field with Snippet
168+
169+
1. In an `.object.yml` file, type `oql-field-select`
170+
2. Press Tab
171+
3. Fill in the placeholders:
172+
- Field name: `status`
173+
- Label: `Status`
174+
- Options: `Draft`, `Published`, `Archived`
175+
176+
Result:
177+
```yaml
178+
status:
179+
type: select
180+
label: Status
181+
options:
182+
- label: Draft
183+
value: draft
184+
- label: Published
185+
value: published
186+
defaultValue: draft
187+
```
188+
189+
### Example 3: Add Validation
190+
191+
1. Type `oql-validation-cross-field`
192+
2. Press Tab
193+
3. Configure the rule:
194+
195+
```yaml
196+
validation:
197+
rules:
198+
- name: price_positive
199+
type: cross_field
200+
message: "Price must be greater than 0"
201+
rule:
202+
field: price
203+
operator: ">"
204+
value: 0
205+
trigger: [create, update]
206+
severity: error
207+
```
208+
209+
### Example 4: Create a Hook
210+
211+
1. Create `product.hook.ts`
212+
2. Type `oql-hook-beforeCreate`
213+
3. Press Tab
214+
4. Implement your logic:
215+
216+
```typescript
217+
import { HookContext, ObjectQLError } from '@objectql/types';
218+
219+
export async function beforeCreate(ctx: HookContext): Promise<void> {
220+
const { doc } = ctx;
221+
222+
// Auto-generate SKU
223+
if (!doc.sku) {
224+
doc.sku = `PRD-${Date.now()}`;
225+
}
226+
227+
// Set timestamps
228+
doc.created_at = new Date();
229+
}
230+
```
231+
232+
## ⚙️ Configuration
233+
234+
Add to your VS Code settings (`.vscode/settings.json`):
235+
236+
```json
237+
{
238+
"objectql.validation.enabled": true,
239+
"objectql.completion.enabled": true,
240+
"objectql.diagnostics.enabled": true,
241+
242+
"yaml.schemas": {
243+
"./packages/tools/vscode-objectql/schemas/object.schema.json": "*.object.yml",
244+
"./packages/tools/vscode-objectql/schemas/app.schema.json": "*.app.yml"
245+
}
246+
}
247+
```
248+
249+
## 🎯 Pro Tips
250+
251+
1. **Use Tab Navigation**: After inserting a snippet, press Tab to jump between placeholders
252+
2. **Check Problems Panel**: Always check the Problems panel for validation errors
253+
3. **Hover for Help**: Hover over field names to see documentation
254+
4. **Command Palette**: Use `Ctrl+Shift+P` for quick access to all commands
255+
5. **Auto-Save**: Enable auto-save to see validation in real-time
256+
257+
## 🐛 Troubleshooting
258+
259+
**Snippets not appearing?**
260+
- Make sure you're in a YAML or TypeScript file
261+
- Check that `objectql.completion.enabled` is true
262+
- Try reloading the window (`Developer: Reload Window`)
263+
264+
**Validation not working?**
265+
- Install the Red Hat YAML extension
266+
- Check that the file extension is correct (`.object.yml`, not `.object.yaml`)
267+
- Verify `objectql.validation.enabled` is true
268+
269+
**Extension not activating?**
270+
- Open a folder/workspace (not just a file)
271+
- Create or open an ObjectQL file (`.object.yml`)
272+
- Check the Output panel → Extension Host for errors
273+
274+
## 📚 Next Steps
275+
276+
- Read the [complete README](README.md) for all features
277+
- Check [INSTALL.md](INSTALL.md) for detailed installation
278+
- See [CONTRIBUTING.md](CONTRIBUTING.md) to contribute
279+
- Review [IMPLEMENTATION-SUMMARY.md](IMPLEMENTATION-SUMMARY.md) for technical details
280+
281+
## 🎉 You're Ready!
282+
283+
Start creating ObjectQL metadata files with full IDE support:
284+
- ✅ IntelliSense
285+
- ✅ Validation
286+
- ✅ Snippets
287+
- ✅ Quick commands
288+
- ✅ File icons
289+
290+
Happy coding! 🚀

0 commit comments

Comments
 (0)