Skip to content

Commit f36982a

Browse files
Copilothotlong
andcommitted
Add working example demonstrating the starter template usage
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 19b48c7 commit f36982a

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ npm run type-check
3535
npm run clean
3636
```
3737

38+
### Running the Example
39+
40+
The template includes an example file demonstrating how to use the defined objects and views:
41+
42+
```bash
43+
# Build the project
44+
npm run build
45+
46+
# Run the example
47+
node dist/example.js
48+
```
49+
50+
This will show you how to import and work with the ObjectStack definitions.
51+
3852
## 📦 What's Included
3953

4054
This starter template includes:

src/example.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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

Comments
 (0)