Skip to content

Commit 8ccfdfb

Browse files
committed
feat(metadata): add protocol reference snippets for view and action definitions
1 parent a24e9bd commit 8ccfdfb

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

content/prompts/plugin/metadata.prompt.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,59 @@ export default {
100100
1. **Define Data First:** Always start by creating `.object.ts` files before Views or Actions.
101101
2. **Refer to Spec:** If the user asks for a feature, check if it exists in `@objectstack/spec` first.
102102
3. **Validation:** Ensure generated code satisfies the Zod Schema constraints (e.g., regex patterns for names).
103+
104+
## 4. Protocol Reference Snippets
105+
106+
### **A. View Definition (`*.view.ts`)**
107+
108+
**Key Pattern:** Decouple Interaction (Navigation/Actions) from Data Config.
109+
110+
```typescript
111+
import type { View } from '@objectstack/spec/ui';
112+
113+
export const MyListView: View = {
114+
list: {
115+
type: 'grid',
116+
columns: [
117+
{
118+
field: 'name',
119+
link: true, // Primary Navigation Link
120+
width: 300
121+
},
122+
{
123+
field: 'status',
124+
width: 120
125+
},
126+
{
127+
field: 'phone_number',
128+
action: 'call_customer' // Triggers 'call_customer' action
129+
}
130+
],
131+
// Explicit Navigation Configuration
132+
navigation: {
133+
mode: 'drawer', // Opens details in a side drawer
134+
view: 'summary_form', // Uses specific form view
135+
width: '600px'
136+
},
137+
filter: [['status', '=', 'active']]
138+
}
139+
};
140+
export default MyListView;
141+
```
142+
143+
### **B. Action Definition (`*.action.ts`)**
144+
145+
```typescript
146+
import { Action } from '@objectstack/spec/ui';
147+
148+
export default Action.create({
149+
name: 'call_customer',
150+
label: 'Call',
151+
icon: 'phone',
152+
type: 'script', // or 'flow', 'api'
153+
locations: ['list_item', 'record_header'],
154+
params: [
155+
{ name: 'phone', type: 'text', label: 'Number' } // Context param
156+
]
157+
});
158+
```

0 commit comments

Comments
 (0)