Skip to content

Commit 79805dc

Browse files
committed
Add enterprise structure object and type definitions
Introduces auto-generated TypeScript interfaces for core, CRM, HR, finance, and project modules in the enterprise-structure scenario. Refactors the main index.ts to export all object definitions directly, and updates codegen output path in package.json to generate types in a dedicated directory.
1 parent dcea041 commit 79805dc

45 files changed

Lines changed: 2072 additions & 127 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/scenarios/enterprise-structure/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"dist"
1717
],
1818
"scripts": {
19-
"codegen": "objectql generate -s src -o src",
19+
"codegen": "objectql generate -s src -o src/types",
2020
"build": "npm run codegen && tsc",
2121
"test": "echo \"No tests specified\" && exit 0"
2222
},
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Auto-generated by ObjectQL. DO NOT EDIT.
2+
import { ObjectDoc } from '@objectql/types';
3+
4+
export interface Attachment extends ObjectDoc {
5+
/**
6+
* File Name
7+
*/
8+
name: string;
9+
/**
10+
* File URL
11+
*/
12+
file_url: any;
13+
/**
14+
* File Size (bytes)
15+
*/
16+
file_size?: number;
17+
/**
18+
* MIME Type
19+
*/
20+
file_type?: string;
21+
/**
22+
* Related Object Name
23+
*/
24+
related_to?: string;
25+
/**
26+
* Related Record ID
27+
*/
28+
related_id?: string;
29+
/**
30+
* Uploaded By
31+
*/
32+
uploaded_by?: string | number;
33+
/**
34+
* Description
35+
*/
36+
description?: string;
37+
/**
38+
* Tags (comma-separated)
39+
*/
40+
tags?: string;
41+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Auto-generated by ObjectQL. DO NOT EDIT.
2+
import { ObjectDoc } from '@objectql/types';
3+
4+
export interface Organization extends ObjectDoc {
5+
/**
6+
* Organization Name
7+
*/
8+
name: string;
9+
/**
10+
* Organization Code
11+
*/
12+
code?: string;
13+
type?: string;
14+
/**
15+
* Parent Organization
16+
*/
17+
parent?: string | number;
18+
/**
19+
* Manager
20+
*/
21+
manager?: string | number;
22+
/**
23+
* Description
24+
*/
25+
description?: string;
26+
/**
27+
* Organization Logo
28+
*/
29+
logo?: any;
30+
/**
31+
* Address
32+
*/
33+
address?: string;
34+
/**
35+
* Website
36+
*/
37+
website?: string;
38+
/**
39+
* Phone Number
40+
*/
41+
phone?: string;
42+
/**
43+
* Contact Email
44+
*/
45+
email?: string;
46+
status?: string;
47+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Auto-generated by ObjectQL. DO NOT EDIT.
2+
import { ObjectDoc } from '@objectql/types';
3+
4+
export interface User extends ObjectDoc {
5+
/**
6+
* Full Name
7+
*/
8+
name: string;
9+
/**
10+
* Email Address
11+
*/
12+
email: string;
13+
/**
14+
* Username
15+
*/
16+
username?: string;
17+
/**
18+
* Mobile Phone
19+
*/
20+
mobile?: string;
21+
/**
22+
* Profile Picture
23+
*/
24+
avatar?: any;
25+
status?: string;
26+
role?: string;
27+
/**
28+
* Last Login Time
29+
*/
30+
last_login_at?: Date | string;
31+
/**
32+
* Preferred Language
33+
*/
34+
locale?: string;
35+
/**
36+
* Timezone
37+
*/
38+
timezone?: string;
39+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Auto-generated by ObjectQL. DO NOT EDIT.
2+
import { ObjectDoc } from '@objectql/types';
3+
4+
export interface User extends ObjectDoc {
5+
/**
6+
* Employee Record
7+
*/
8+
employee?: string | number;
9+
email: any;
10+
/**
11+
* Employee ID
12+
*/
13+
employee_id?: string;
14+
/**
15+
* Department
16+
*/
17+
department?: string | number;
18+
/**
19+
* Office Location
20+
*/
21+
office_location?: string;
22+
/**
23+
* Two-Factor Auth Enabled
24+
*/
25+
two_factor_enabled?: boolean;
26+
}
Lines changed: 20 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,20 @@
1-
/**
2-
* Enterprise Structure Example - Main Entry Point
3-
*
4-
* This demonstrates how to organize metadata for large-scale ObjectQL applications
5-
* using a modular, domain-driven structure.
6-
*/
7-
8-
import { ObjectQL } from '@objectql/core';
9-
import { KnexDriver } from '@objectql/driver-knex';
10-
import path from 'path';
11-
12-
/**
13-
* Initialize ObjectQL with enterprise structure
14-
*/
15-
export async function initializeApp() {
16-
const app = new ObjectQL({
17-
datasources: {
18-
default: new KnexDriver({
19-
client: 'sqlite3',
20-
connection: {
21-
filename: path.join(__dirname, '../data/enterprise.db'),
22-
},
23-
useNullAsDefault: true,
24-
}),
25-
},
26-
});
27-
28-
// Load metadata from all modules
29-
// ObjectQL will automatically discover and merge all .object.yml files
30-
await app.connect();
31-
32-
// Register objects from each module
33-
// In a real application, you might use dynamic imports or a plugin system
34-
await registerCoreObjects(app);
35-
await registerCRMModule(app);
36-
await registerHRModule(app);
37-
await registerFinanceModule(app);
38-
await registerProjectModule(app);
39-
await registerExtensions(app);
40-
41-
return app;
42-
}
43-
44-
/**
45-
* Register core objects (foundation layer)
46-
*/
47-
async function registerCoreObjects(app: ObjectQL) {
48-
// Load objects from core/objects/
49-
// user, organization, attachment
50-
}
51-
52-
/**
53-
* Register CRM module
54-
*/
55-
async function registerCRMModule(app: ObjectQL) {
56-
// Load objects from modules/crm/objects/
57-
// crm_account, crm_contact, crm_opportunity, crm_lead
58-
}
59-
60-
/**
61-
* Register HR module
62-
*/
63-
async function registerHRModule(app: ObjectQL) {
64-
// Load objects from modules/hr/objects/
65-
// hr_employee, hr_department, hr_position, hr_timesheet
66-
}
67-
68-
/**
69-
* Register Finance module
70-
*/
71-
async function registerFinanceModule(app: ObjectQL) {
72-
// Load objects from modules/finance/objects/
73-
// finance_invoice, finance_payment, finance_expense, finance_budget
74-
}
75-
76-
/**
77-
* Register Project module
78-
*/
79-
async function registerProjectModule(app: ObjectQL) {
80-
// Load objects from modules/project/objects/
81-
// project_project, project_task, project_milestone, project_timesheet_entry
82-
}
83-
84-
/**
85-
* Register extensions (override layer)
86-
*/
87-
async function registerExtensions(app: ObjectQL) {
88-
// Load extensions from extensions/
89-
// These will merge with existing objects
90-
}
91-
92-
/**
93-
* Example usage
94-
*/
95-
async function main() {
96-
const app = await initializeApp();
97-
98-
console.log('✅ ObjectQL initialized with enterprise structure');
99-
console.log('📦 Modules loaded:');
100-
console.log(' - Core (user, organization, attachment)');
101-
console.log(' - CRM (account, contact, opportunity, lead)');
102-
console.log(' - HR (employee, department, position, timesheet)');
103-
console.log(' - Finance (invoice, payment, expense, budget)');
104-
console.log(' - Project (project, task, milestone, timesheet_entry)');
105-
106-
// Example query: Get all active employees
107-
const employees = await app.find({
108-
object: 'hr_employee',
109-
filters: [['status', '=', 'active']],
110-
limit: 10,
111-
});
112-
113-
console.log(`\n👥 Found ${employees.length} active employees`);
114-
115-
await app.disconnect();
116-
}
117-
118-
// Run if executed directly
119-
if (require.main === module) {
120-
main().catch(console.error);
121-
}
122-
123-
export default initializeApp;
1+
export * from './extensions/user';
2+
export * from './core/objects/attachment';
3+
export * from './core/objects/organization';
4+
export * from './core/objects/user';
5+
export * from './modules/crm/objects/crm_account';
6+
export * from './modules/crm/objects/crm_contact';
7+
export * from './modules/crm/objects/crm_lead';
8+
export * from './modules/crm/objects/crm_opportunity';
9+
export * from './modules/finance/objects/finance_budget';
10+
export * from './modules/finance/objects/finance_expense';
11+
export * from './modules/finance/objects/finance_invoice';
12+
export * from './modules/finance/objects/finance_payment';
13+
export * from './modules/hr/objects/hr_department';
14+
export * from './modules/hr/objects/hr_employee';
15+
export * from './modules/hr/objects/hr_position';
16+
export * from './modules/hr/objects/hr_timesheet';
17+
export * from './modules/project/objects/project_milestone';
18+
export * from './modules/project/objects/project_project';
19+
export * from './modules/project/objects/project_task';
20+
export * from './modules/project/objects/project_timesheet_entry';
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Auto-generated by ObjectQL. DO NOT EDIT.
2+
import { ObjectDoc } from '@objectql/types';
3+
4+
export interface CrmAccount extends ObjectDoc {
5+
/**
6+
* Account Name
7+
*/
8+
name: string;
9+
/**
10+
* Account Number
11+
*/
12+
account_number?: string;
13+
type?: string;
14+
/**
15+
* Industry
16+
*/
17+
industry?: string;
18+
/**
19+
* Annual Revenue
20+
*/
21+
annual_revenue?: number;
22+
/**
23+
* Number of Employees
24+
*/
25+
employees?: number;
26+
/**
27+
* Website
28+
*/
29+
website?: string;
30+
/**
31+
* Phone
32+
*/
33+
phone?: string;
34+
/**
35+
* Billing Address
36+
*/
37+
billing_address?: string;
38+
/**
39+
* Shipping Address
40+
*/
41+
shipping_address?: string;
42+
/**
43+
* Account Owner
44+
*/
45+
owner?: string | number;
46+
/**
47+
* Parent Account
48+
*/
49+
parent_account?: string | number;
50+
/**
51+
* Description
52+
*/
53+
description?: string;
54+
status?: string;
55+
}

0 commit comments

Comments
 (0)