|
| 1 | +import { ObjectSchema, Field } from '@objectstack/spec/data'; |
| 2 | + |
| 3 | +export const KitchenSinkObject = ObjectSchema.create({ |
| 4 | + name: 'kitchen_sink', |
| 5 | + label: 'Kitchen Sink', |
| 6 | + description: 'Shows all available field types for testing', |
| 7 | + fields: { |
| 8 | + // Basic Text |
| 9 | + name: Field.text({ label: 'Text (Name)', required: true, searchable: true }), |
| 10 | + description: Field.textarea({ label: 'Text Area' }), |
| 11 | + code: Field.code('json', { label: 'Code' }), |
| 12 | + password: Field.password({ label: 'Password' }), |
| 13 | + |
| 14 | + // Numbers |
| 15 | + amount: Field.number({ label: 'Number (Int)', scale: 0 }), |
| 16 | + price: Field.currency({ label: 'Currency', scale: 2 }), |
| 17 | + percent: Field.percent({ label: 'Percentage', scale: 2 }), |
| 18 | + rating: Field.rating(5, { label: 'Rating' }), |
| 19 | + |
| 20 | + // Date & Time |
| 21 | + due_date: Field.date({ label: 'Date' }), |
| 22 | + event_time: Field.datetime({ label: 'Date Time' }), |
| 23 | + |
| 24 | + // Boolean |
| 25 | + is_active: Field.boolean({ label: 'Boolean (Switch)', defaultValue: true }), |
| 26 | + |
| 27 | + // Selection |
| 28 | + category: Field.select({ |
| 29 | + options: [ |
| 30 | + { label: 'Option A', value: 'opt_a' }, |
| 31 | + { label: 'Option B', value: 'opt_b' }, |
| 32 | + { label: 'Option C', value: 'opt_c' } |
| 33 | + ], |
| 34 | + label: 'Select (Dropdown)' |
| 35 | + }), |
| 36 | + tags: Field.select({ |
| 37 | + options: [ |
| 38 | + { label: 'Red', value: 'col_red' }, |
| 39 | + { label: 'Green', value: 'col_green' }, |
| 40 | + { label: 'Blue', value: 'col_blue' } |
| 41 | + ], |
| 42 | + multiple: true, |
| 43 | + label: 'Multi Select' |
| 44 | + }), |
| 45 | + |
| 46 | + // Contact & specialized |
| 47 | + email: Field.email({ label: 'Email' }), |
| 48 | + url: Field.url({ label: 'URL' }), |
| 49 | + phone: Field.phone({ label: 'Phone' }), |
| 50 | + avatar: Field.avatar({ label: 'Avatar' }), |
| 51 | + color: Field.color({ label: 'Color Picker' }), |
| 52 | + |
| 53 | + // Rich Content |
| 54 | + rich_text: Field.richtext({ label: 'Rich Text' }), |
| 55 | + image: Field.image({ label: 'Image Upload' }), |
| 56 | + file: Field.file({ label: 'File Upload' }), |
| 57 | + signature: Field.signature({ label: 'Signature' }), |
| 58 | + |
| 59 | + // Relationships |
| 60 | + // For these to work, 'account' must exist in the schema. |
| 61 | + // Since this is now isolated, we might need a mock 'account' object or rely on dynamic binding. |
| 62 | + // For now, we will assume 'account' might be present in the runtime environment or just leave it. |
| 63 | + // However, validation might fail if 'account' object isn't in scope of THIS stack. |
| 64 | + // Let's keep it but knowing we might need to add a dummy account object to this stack too for compilation. |
| 65 | + account: Field.lookup('account', { label: 'Lookup (Account)' }), |
| 66 | + |
| 67 | + // Location |
| 68 | + location: Field.location({ label: 'Location' }), |
| 69 | + |
| 70 | + // System/Readonly |
| 71 | + formula_field: Field.formula({ |
| 72 | + expression: '{amount} * {price}', |
| 73 | + label: 'Formula (Amount * Price)' |
| 74 | + }), |
| 75 | + auto_number: Field.autonumber({ label: 'Auto Number' }), |
| 76 | + } |
| 77 | +}); |
0 commit comments