@@ -100,3 +100,59 @@ export default {
1001001 . ** Define Data First:** Always start by creating ` .object.ts ` files before Views or Actions.
1011012 . ** Refer to Spec:** If the user asks for a feature, check if it exists in ` @objectstack/spec ` first.
1021023 . ** 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