@objectql/create 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/enterprise/CHANGELOG.md +10 -0
- package/templates/enterprise/README.md +2 -2
- package/templates/enterprise/package.json +2 -2
- package/templates/enterprise/src/core/attachment.object.yml +10 -1
- package/templates/enterprise/src/core/organization.object.yml +41 -6
- package/templates/enterprise/src/core/user.object.yml +37 -12
- package/templates/enterprise/src/extensions/README.md +4 -4
- package/templates/enterprise/src/extensions/user_extension.object.yml +65 -0
- package/templates/enterprise/src/modules/crm/crm_account.object.yml +57 -13
- package/templates/enterprise/src/modules/crm/crm_contact.object.yml +42 -8
- package/templates/enterprise/src/modules/crm/crm_lead.object.yml +82 -21
- package/templates/enterprise/src/modules/crm/crm_opportunity.object.yml +65 -15
- package/templates/enterprise/src/modules/finance/finance_budget.object.yml +67 -16
- package/templates/enterprise/src/modules/finance/finance_expense.object.yml +75 -19
- package/templates/enterprise/src/modules/finance/finance_invoice.object.yml +61 -16
- package/templates/enterprise/src/modules/finance/finance_payment.object.yml +65 -16
- package/templates/enterprise/src/modules/hr/hr_department.object.yml +29 -2
- package/templates/enterprise/src/modules/hr/hr_employee.object.yml +50 -8
- package/templates/enterprise/src/modules/hr/hr_position.object.yml +46 -10
- package/templates/enterprise/src/modules/hr/hr_timesheet.object.yml +44 -8
- package/templates/enterprise/src/modules/project/project_milestone.object.yml +36 -4
- package/templates/enterprise/src/modules/project/project_project.object.yml +64 -13
- package/templates/enterprise/src/modules/project/project_task.object.yml +70 -9
- package/templates/enterprise/src/modules/project/project_timesheet_entry.object.yml +39 -4
- package/templates/enterprise/src/plugins/audit/note.object.yml +17 -0
- package/templates/enterprise/tsconfig.tsbuildinfo +1 -1
- package/templates/hello-world/CHANGELOG.md +8 -0
- package/templates/hello-world/README.md +73 -10
- package/templates/hello-world/package.json +1 -1
- package/templates/hello-world/src/index.ts +17 -5
- package/templates/starter/CHANGELOG.md +10 -0
- package/templates/starter/package.json +1 -1
- package/templates/starter/src/modules/projects/projects.object.yml +65 -6
- package/templates/starter/src/modules/projects/projects.validation.yml +13 -4
- package/templates/starter/src/seed.ts +1 -1
- package/templates/starter/tsconfig.tsbuildinfo +1 -1
- package/templates/enterprise/src/extensions/user.extension.object.yml +0 -42
|
@@ -1,11 +1,51 @@
|
|
|
1
1
|
# Hello ObjectQL
|
|
2
2
|
|
|
3
|
-
This is the simplest possible example of **ObjectQL
|
|
3
|
+
This is the simplest possible example of **ObjectQL** following the **latest ObjectStack specification** (v4.0+).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
## What it demonstrates
|
|
6
|
+
|
|
7
|
+
1. **Zero Config:** No YAML files or server setup required
|
|
8
|
+
2. **In-Memory SQL:** Uses SQLite in memory, so no database installation is needed
|
|
9
|
+
3. **Inline Schema:** Defines the data model directly in code using programmatic API
|
|
10
|
+
4. **Latest Spec Compliance:**
|
|
11
|
+
- Label/value format for select options
|
|
12
|
+
- Explicit field labels for AI-friendly metadata
|
|
13
|
+
- Proper field type declarations
|
|
14
|
+
|
|
15
|
+
## Key Concepts
|
|
16
|
+
|
|
17
|
+
### Metadata Definition Approaches
|
|
18
|
+
|
|
19
|
+
**Programmatic (This Example):**
|
|
20
|
+
```typescript
|
|
21
|
+
app.registerObject({
|
|
22
|
+
name: 'deal', // Required when using code
|
|
23
|
+
fields: {
|
|
24
|
+
stage: {
|
|
25
|
+
type: 'select',
|
|
26
|
+
options: [
|
|
27
|
+
{ label: 'New', value: 'new' }, // ✅ Latest spec format
|
|
28
|
+
{ label: 'Negotiation', value: 'negotiation' }
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**YAML-based (Recommended for Production):**
|
|
36
|
+
```yaml
|
|
37
|
+
# File: deal.object.yml
|
|
38
|
+
# NO 'name:' field needed - inferred from filename! ✅
|
|
39
|
+
label: Deal
|
|
40
|
+
fields:
|
|
41
|
+
stage:
|
|
42
|
+
type: select
|
|
43
|
+
options:
|
|
44
|
+
- label: New
|
|
45
|
+
value: new
|
|
46
|
+
- label: Negotiation
|
|
47
|
+
value: negotiation
|
|
48
|
+
```
|
|
9
49
|
|
|
10
50
|
## How to Run
|
|
11
51
|
|
|
@@ -16,14 +56,37 @@ Since you are in the monorepo, simply run:
|
|
|
16
56
|
pnpm install
|
|
17
57
|
|
|
18
58
|
# Run the script
|
|
19
|
-
cd examples/
|
|
59
|
+
cd examples/quickstart/hello-world
|
|
20
60
|
pnpm start
|
|
21
61
|
```
|
|
22
62
|
|
|
23
63
|
## What you see
|
|
24
64
|
|
|
25
65
|
The script will:
|
|
26
|
-
1. Initialize the ObjectQL engine
|
|
27
|
-
2. Create a `deal` object definition
|
|
28
|
-
3. Insert a record into the
|
|
29
|
-
4. Query it back and print the result
|
|
66
|
+
1. Initialize the ObjectQL engine with an in-memory SQLite driver
|
|
67
|
+
2. Create a `deal` object definition programmatically
|
|
68
|
+
3. Insert a record into the database
|
|
69
|
+
4. Query it back and print the result
|
|
70
|
+
|
|
71
|
+
## Expected Output
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
🚀 Starting ObjectQL Hello World...
|
|
75
|
+
Creating a new Deal...
|
|
76
|
+
✅ Deals found in database: [
|
|
77
|
+
{
|
|
78
|
+
_id: '...',
|
|
79
|
+
title: 'Enterprise Contract',
|
|
80
|
+
amount: 50000,
|
|
81
|
+
stage: 'new',
|
|
82
|
+
created_at: '...',
|
|
83
|
+
updated_at: '...'
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Next Steps
|
|
89
|
+
|
|
90
|
+
- See [Project Tracker Example](../../showcase/project-tracker/) for YAML-based metadata
|
|
91
|
+
- Read the [Metadata Standard Spec](https://protocol.objectstack.ai) from @objectstack/spec
|
|
92
|
+
- Explore the [ObjectQL Documentation](../../../content/docs/)
|
|
@@ -26,14 +26,26 @@ async function main() {
|
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
// 3. Define Metadata Inline
|
|
29
|
+
// 3. Define Metadata Inline (Following Latest ObjectStack Specification)
|
|
30
|
+
// Note: When using registerObject(), the 'name' is required in code
|
|
31
|
+
// When using YAML files, the name is inferred from filename (e.g., deal.object.yml)
|
|
30
32
|
app.registerObject({
|
|
31
|
-
name: 'deal',
|
|
33
|
+
name: 'deal', // Required for programmatic registration
|
|
34
|
+
label: 'Deal', // Human-readable label
|
|
32
35
|
fields: {
|
|
33
|
-
title: {
|
|
34
|
-
|
|
36
|
+
title: {
|
|
37
|
+
type: 'text',
|
|
38
|
+
required: true,
|
|
39
|
+
label: 'Deal Title'
|
|
40
|
+
},
|
|
41
|
+
amount: {
|
|
42
|
+
type: 'currency',
|
|
43
|
+
label: 'Deal Amount'
|
|
44
|
+
},
|
|
35
45
|
stage: {
|
|
36
|
-
type: 'select',
|
|
46
|
+
type: 'select',
|
|
47
|
+
label: 'Deal Stage',
|
|
48
|
+
// Options use label/value format (ObjectStack spec v4.0+)
|
|
37
49
|
options: [
|
|
38
50
|
{ label: 'New', value: 'new' },
|
|
39
51
|
{ label: 'Negotiation', value: 'negotiation' },
|
|
@@ -1,49 +1,108 @@
|
|
|
1
|
+
# File: projects.object.yml
|
|
2
|
+
# Object name is inferred from filename as 'projects'
|
|
1
3
|
label: Project
|
|
2
4
|
icon: building-line
|
|
5
|
+
|
|
6
|
+
ai_context:
|
|
7
|
+
intent: "Track and manage software development projects"
|
|
8
|
+
domain: project_management
|
|
9
|
+
aliases: [project, initiative]
|
|
10
|
+
common_queries:
|
|
11
|
+
- "Find active projects"
|
|
12
|
+
- "Show projects by priority"
|
|
13
|
+
- "List projects with high budget"
|
|
14
|
+
|
|
3
15
|
fields:
|
|
4
16
|
name:
|
|
5
17
|
type: text
|
|
6
18
|
required: true
|
|
19
|
+
label: Project Name
|
|
7
20
|
index: true # Field-level index
|
|
21
|
+
ai_context:
|
|
22
|
+
intent: "Primary identifier for the project"
|
|
23
|
+
examples: ["Website Redesign", "Mobile App v2.0"]
|
|
8
24
|
|
|
9
25
|
status:
|
|
26
|
+
type: select
|
|
27
|
+
label: Project Status
|
|
10
28
|
options:
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
-
|
|
29
|
+
- label: Planned
|
|
30
|
+
value: planned
|
|
31
|
+
- label: In Progress
|
|
32
|
+
value: in_progress
|
|
33
|
+
- label: Completed
|
|
34
|
+
value: completed
|
|
14
35
|
defaultValue: planned
|
|
15
36
|
index: true
|
|
37
|
+
ai_context:
|
|
38
|
+
intent: "Track project lifecycle stage"
|
|
39
|
+
is_state_machine: true
|
|
40
|
+
transitions:
|
|
41
|
+
planned: [in_progress, completed]
|
|
42
|
+
in_progress: [completed, planned]
|
|
43
|
+
completed: []
|
|
16
44
|
|
|
17
45
|
priority:
|
|
46
|
+
type: select
|
|
47
|
+
label: Priority Level
|
|
18
48
|
options:
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
-
|
|
49
|
+
- label: Low
|
|
50
|
+
value: low
|
|
51
|
+
- label: Normal
|
|
52
|
+
value: normal
|
|
53
|
+
- label: High
|
|
54
|
+
value: high
|
|
22
55
|
defaultValue: normal
|
|
56
|
+
ai_context:
|
|
57
|
+
intent: "Prioritize project execution order"
|
|
58
|
+
selection_guidance: "High priority for urgent or critical projects"
|
|
23
59
|
|
|
24
60
|
description:
|
|
25
61
|
type: textarea
|
|
62
|
+
label: Project Description
|
|
63
|
+
ai_context:
|
|
64
|
+
intent: "Detailed project overview and objectives"
|
|
26
65
|
|
|
27
66
|
owner:
|
|
28
67
|
type: text
|
|
68
|
+
label: Project Owner
|
|
69
|
+
ai_context:
|
|
70
|
+
intent: "Person responsible for project success"
|
|
71
|
+
semantic_type: ownership
|
|
29
72
|
|
|
30
73
|
budget:
|
|
31
74
|
type: currency
|
|
75
|
+
label: Project Budget
|
|
76
|
+
ai_context:
|
|
77
|
+
intent: "Allocated financial resources"
|
|
78
|
+
validation_notes: "Must be non-negative; >$10k requires detailed description"
|
|
32
79
|
|
|
33
80
|
start_date:
|
|
34
81
|
type: date
|
|
82
|
+
label: Start Date
|
|
83
|
+
ai_context:
|
|
84
|
+
intent: "Project commencement date"
|
|
35
85
|
|
|
36
86
|
end_date:
|
|
37
87
|
type: date
|
|
88
|
+
label: End Date
|
|
89
|
+
ai_context:
|
|
90
|
+
intent: "Target completion date"
|
|
91
|
+
validation_notes: "Must be on or after start_date"
|
|
38
92
|
|
|
39
93
|
approved_by:
|
|
40
94
|
type: text
|
|
95
|
+
label: Approved By
|
|
96
|
+
ai_context:
|
|
97
|
+
intent: "Approver identity for audit trail"
|
|
41
98
|
|
|
42
99
|
approved_at:
|
|
43
100
|
type: datetime
|
|
101
|
+
label: Approval Timestamp
|
|
44
102
|
|
|
45
103
|
approval_comment:
|
|
46
104
|
type: textarea
|
|
105
|
+
label: Approval Comment
|
|
47
106
|
|
|
48
107
|
indexes:
|
|
49
108
|
# Composite index for reporting
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# File: projects.validation.yml
|
|
2
|
+
# Object is inferred from filename as 'projects'
|
|
3
3
|
description: "Validation rules for Projects"
|
|
4
4
|
|
|
5
5
|
rules:
|
|
@@ -8,25 +8,33 @@ rules:
|
|
|
8
8
|
ai_context:
|
|
9
9
|
intent: "Ensure project timeline is valid"
|
|
10
10
|
business_rule: "Projects cannot end before they start"
|
|
11
|
+
rationale: "Maintaining data integrity for project scheduling"
|
|
11
12
|
rule:
|
|
12
13
|
field: end_date
|
|
13
14
|
operator: ">="
|
|
14
15
|
compare_to: start_date
|
|
15
|
-
message: "End Date must be after Start Date"
|
|
16
|
+
message: "End Date must be on or after Start Date"
|
|
17
|
+
error_code: "INVALID_DATE_RANGE"
|
|
16
18
|
|
|
17
19
|
- name: positive_budget
|
|
18
20
|
type: field
|
|
21
|
+
ai_context:
|
|
22
|
+
intent: "Prevent negative budget values"
|
|
23
|
+
business_rule: "Project budget must be zero or positive"
|
|
19
24
|
rule:
|
|
20
25
|
field: budget
|
|
21
26
|
operator: ">="
|
|
22
27
|
value: 0
|
|
23
28
|
message: "Budget cannot be negative"
|
|
29
|
+
error_code: "NEGATIVE_BUDGET"
|
|
24
30
|
|
|
25
31
|
- name: comment_required_if_high_budget
|
|
26
32
|
type: conditional
|
|
27
33
|
description: "Description is required for high budget projects"
|
|
28
34
|
ai_context:
|
|
29
|
-
|
|
35
|
+
intent: "Ensure governance for high-value projects"
|
|
36
|
+
business_rule: "High value projects (>$10k) must have a detailed description for stakeholder transparency"
|
|
37
|
+
rationale: "Projects over $10,000 require executive oversight and clear documentation"
|
|
30
38
|
condition:
|
|
31
39
|
field: budget
|
|
32
40
|
operator: ">"
|
|
@@ -35,3 +43,4 @@ rules:
|
|
|
35
43
|
field: description
|
|
36
44
|
operator: "not_empty"
|
|
37
45
|
message: "Description is required for high budget projects (> $10,000)"
|
|
46
|
+
error_code: "HIGH_BUDGET_REQUIRES_DESCRIPTION"
|
|
@@ -50,7 +50,7 @@ async function main() {
|
|
|
50
50
|
|
|
51
51
|
console.log("Querying Tasks...");
|
|
52
52
|
const tasks = await ctx.object('tasks').find({
|
|
53
|
-
|
|
53
|
+
where: { project: projectId }
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
console.log("📊 Project Report:", JSON.stringify({ project, tasks }, null, 2));
|