@@ -27,19 +27,19 @@ export default defineStack({
2727 {
2828 name: ' project' ,
2929 label: ' Project' ,
30- fields: [
31- { name: ' title ' , label: ' Title' , type: ' text' , required: true , maxLength: 200 },
32- { name: ' description ' , label: ' Description' , type: ' textarea' },
33- { name: ' status ' , label: ' Status' , type: ' select' , options: [
30+ fields: {
31+ title: { label: ' Title' , type: ' text' , required: true , maxLength: 200 },
32+ description: { label: ' Description' , type: ' textarea' },
33+ status: { label: ' Status' , type: ' select' , options: [
3434 { label: ' Planning' , value: ' planning' , default: true },
3535 { label: ' Active' , value: ' active' },
3636 { label: ' Complete' , value: ' complete' },
3737 { label: ' Archived' , value: ' archived' }
3838 ]},
39- { name: ' owner ' , label: ' Owner' , type: ' lookup' , reference: ' user' },
40- { name: ' due_date ' , label: ' Due Date' , type: ' date' },
41- { name: ' budget ' , label: ' Budget' , type: ' currency' , currencyConfig: { precision: 2 , defaultCurrency: ' USD' } }
42- ]
39+ owner: { label: ' Owner' , type: ' lookup' , reference: ' user' },
40+ due_date: { label: ' Due Date' , type: ' date' },
41+ budget: { label: ' Budget' , type: ' currency' , currencyConfig: { precision: 2 , defaultCurrency: ' USD' } },
42+ }
4343 }
4444 ]
4545});
@@ -85,27 +85,27 @@ Create a parent-child relationship where child records are cascaded on delete.
8585 {
8686 name: ' order' ,
8787 label: ' Order' ,
88- fields: [
89- { name: ' order_number ' , label: ' Order #' , type: ' autonumber' , autonumberFormat: ' ORD-{0000}' },
90- { name: ' customer ' , label: ' Customer' , type: ' lookup' , reference: ' contact' },
91- { name: ' total ' , label: ' Total' , type: ' summary' , summaryOperations: [' sum' ] },
92- { name: ' status ' , label: ' Status' , type: ' select' , options: [
88+ fields: {
89+ order_number: { label: ' Order #' , type: ' autonumber' , autonumberFormat: ' ORD-{0000}' },
90+ customer: { label: ' Customer' , type: ' lookup' , reference: ' contact' },
91+ total: { label: ' Total' , type: ' summary' , summaryOperations: [' sum' ] },
92+ status: { label: ' Status' , type: ' select' , options: [
9393 { label: ' Draft' , value: ' draft' , default: true },
9494 { label: ' Submitted' , value: ' submitted' },
9595 { label: ' Fulfilled' , value: ' fulfilled' }
96- ]}
97- ]
96+ ]},
97+ }
9898 },
9999 {
100100 name: ' order_line' ,
101101 label: ' Order Line' ,
102- fields: [
103- { name: ' order ' , label: ' Order' , type: ' master_detail' , reference: ' order' },
104- { name: ' product ' , label: ' Product' , type: ' lookup' , reference: ' product' },
105- { name: ' quantity ' , label: ' Qty' , type: ' number' , min: 1 , required: true },
106- { name: ' unit_price ' , label: ' Unit Price' , type: ' currency' },
107- { name: ' line_total ' , label: ' Line Total' , type: ' formula' , expression: ' quantity * unit_price' }
108- ]
102+ fields: {
103+ order: { label: ' Order' , type: ' master_detail' , reference: ' order' },
104+ product: { label: ' Product' , type: ' lookup' , reference: ' product' },
105+ quantity: { label: ' Qty' , type: ' number' , min: 1 , required: true },
106+ unit_price: { label: ' Unit Price' , type: ' currency' },
107+ line_total: { label: ' Line Total' , type: ' formula' , expression: ' quantity * unit_price' },
108+ }
109109 }
110110 ]
111111}
@@ -257,18 +257,18 @@ Define a multi-step approval process for records.
257257 objects : [{
258258 name: ' expense_report' ,
259259 label: ' Expense Report' ,
260- fields: [
261- { name: ' title ' , label: ' Title' , type: ' text' , required: true },
262- { name: ' amount ' , label: ' Amount' , type: ' currency' },
263- { name: ' status ' , label: ' Status' , type: ' select' , options: [
260+ fields: {
261+ title: { label: ' Title' , type: ' text' , required: true },
262+ amount: { label: ' Amount' , type: ' currency' },
263+ status: { label: ' Status' , type: ' select' , options: [
264264 { label: ' Draft' , value: ' draft' , default: true },
265265 { label: ' Submitted' , value: ' submitted' },
266266 { label: ' Approved' , value: ' approved' },
267267 { label: ' Rejected' , value: ' rejected' }
268268 ]},
269- { name: ' submitted_by ' , label: ' Submitted By' , type: ' lookup' , reference: ' user' },
270- { name: ' approved_by ' , label: ' Approved By' , type: ' lookup' , reference: ' user' }
271- ] ,
269+ submitted_by: { label: ' Submitted By' , type: ' lookup' , reference: ' user' },
270+ approved_by: { label: ' Approved By' , type: ' lookup' , reference: ' user' },
271+ } ,
272272 enable: {
273273 trackHistory: true ,
274274 apiEnabled: true
@@ -397,19 +397,19 @@ Restrict field visibility and editability based on user profiles.
397397 objects : [{
398398 name: ' employee' ,
399399 label: ' Employee' ,
400- fields: [
401- { name: ' name ' , label: ' Name' , type: ' text' , required: true },
402- { name: ' email ' , label: ' Email' , type: ' email' , required: true },
403- { name: ' department ' , label: ' Department' , type: ' lookup' , reference: ' department' },
400+ fields: {
401+ name: { label: ' Name' , type: ' text' , required: true },
402+ email: { label: ' Email' , type: ' email' , required: true },
403+ department: { label: ' Department' , type: ' lookup' , reference: ' department' },
404404 // Sensitive fields with encryption
405- { name: ' salary ' , label: ' Salary' , type: ' currency' ,
405+ salary: { label: ' Salary' , type: ' currency' ,
406406 hidden: true , // Hidden from default views
407407 encryptionConfig: {
408408 algorithm: ' aes-256-gcm' ,
409409 keyRotation: true
410410 }
411411 },
412- { name: ' ssn ' , label: ' SSN' , type: ' text' ,
412+ ssn: { label: ' SSN' , type: ' text' ,
413413 hidden: true ,
414414 maskingRule: {
415415 strategy: ' partial' ,
@@ -421,8 +421,8 @@ Restrict field visibility and editability based on user profiles.
421421 algorithm: ' aes-256-gcm' ,
422422 keyRotation: true
423423 }
424- }
425- ]
424+ },
425+ }
426426 }]
427427}
428428```
@@ -441,9 +441,9 @@ import { defineStack } from '@objectstack/spec';
441441export default defineStack ({
442442 objects: [
443443 // Pattern 1: CRUD objects
444- { name: ' project' , label: ' Project' , fields: [ /* ... */ ] },
444+ { name: ' project' , label: ' Project' , fields: { /* ... */ } },
445445 // Pattern 2: Master-detail
446- { name: ' task' , label: ' Task' , fields: [ /* ... */ ] },
446+ { name: ' task' , label: ' Task' , fields: { /* ... */ } },
447447 ],
448448 views: [
449449 // Pattern 3: List views
0 commit comments