|
| 1 | +/** |
| 2 | + * Example Usage |
| 3 | + * |
| 4 | + * This file demonstrates how to use the ObjectStack starter template. |
| 5 | + * It shows how to import and work with the defined objects and views. |
| 6 | + */ |
| 7 | + |
| 8 | +import { |
| 9 | + config, |
| 10 | + projectTaskObject, |
| 11 | + contactObject, |
| 12 | + taskListView, |
| 13 | + taskKanbanView, |
| 14 | + contactListView, |
| 15 | + mainApp |
| 16 | +} from './index.js'; |
| 17 | + |
| 18 | +import type { Data, UI } from '@objectstack/spec'; |
| 19 | + |
| 20 | +// Example 1: Access the configuration |
| 21 | +console.log('App Configuration:', config); |
| 22 | +console.log('App Name:', config.name); |
| 23 | +console.log('App Version:', config.version); |
| 24 | + |
| 25 | +// Example 2: Access object definitions |
| 26 | +console.log('\nProject Task Object:', projectTaskObject.name); |
| 27 | +console.log('Fields:', Object.keys(projectTaskObject.fields)); |
| 28 | + |
| 29 | +console.log('\nContact Object:', contactObject.name); |
| 30 | +console.log('Fields:', Object.keys(contactObject.fields)); |
| 31 | + |
| 32 | +// Example 3: Access view definitions |
| 33 | +console.log('\nTask List View:', taskListView.name); |
| 34 | +console.log('View Type:', taskListView.type); |
| 35 | +console.log('Data Provider:', taskListView.data?.provider); |
| 36 | + |
| 37 | +console.log('\nTask Kanban View:', taskKanbanView.name); |
| 38 | +console.log('View Type:', taskKanbanView.type); |
| 39 | + |
| 40 | +// Example 4: Access app definition |
| 41 | +console.log('\nMain App:', mainApp.name); |
| 42 | +console.log('App Label:', mainApp.label); |
| 43 | +console.log('Navigation Items:', mainApp.navigation?.length); |
| 44 | + |
| 45 | +// Example 5: Create a custom object using the same pattern |
| 46 | +// Note: In real usage, you would define these in separate files like the examples |
| 47 | +console.log('\nYou can create custom objects following the same pattern as the examples.'); |
| 48 | + |
| 49 | +// Example 6: Working with the spec types |
| 50 | +console.log('\nThe starter template includes TypeScript types from @objectstack/spec'); |
| 51 | +console.log('Available namespaces: Data, UI, System, AI, API'); |
| 52 | + |
| 53 | +console.log('\n✅ ObjectStack Starter Template loaded successfully!'); |
0 commit comments