Skip to content

Commit 0edbc02

Browse files
Copilothotlong
andcommitted
Fix critical documentation inconsistencies
Co-authored-by: hotlong <[email protected]>
1 parent c1c6f2b commit 0edbc02

File tree

8 files changed

+71
-8
lines changed

8 files changed

+71
-8
lines changed

content/docs/getting-started/index.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ fields:
5555
searchable: true
5656
completed:
5757
type: boolean
58-
default: false
58+
defaultValue: false
5959
priority:
6060
type: select
6161
options: [low, medium, high]
62-
default: medium
62+
defaultValue: medium
6363
```
6464
6565
### 4. Run the Project
@@ -173,12 +173,12 @@ ObjectQL shines when you need to add logic.
173173
Triggers logic automatically when data changes.
174174

175175
```typescript
176-
app.on('beforeCreate', 'todo', async (ctx) => {
177-
if (ctx.doc.title === 'Sleep') {
176+
app.on('before:create', 'todo', async (ctx) => {
177+
if (ctx.data.title === 'Sleep') {
178178
throw new Error("Cannot sleep yet!");
179179
}
180180
// Auto-tagging
181-
ctx.doc.title = `[Task] ${ctx.doc.title}`;
181+
ctx.data.title = `[Task] ${ctx.data.title}`;
182182
});
183183
```
184184

content/docs/logic/actions.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ The `params` section in YAML supports the same types as Object Fields. This allo
139139
params:
140140
assign_to:
141141
type: lookup
142-
reference: user
142+
reference_to: user
143143
label: Assign To Staff
144144
```
145145

content/docs/reference/spec/action.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,32 @@ Unlike Hooks (which trigger automatically), Actions are explicitly invoked by th
1919
### 1.2 Schema-First Inputs
2020
Input parameters (`params`) are defined using the same `FieldConfig` schema as object fields. This gives you free validation, type coercion, and UI generation.
2121

22+
### 1.3 AI Context Support
23+
Actions support the `ai_context` property to provide semantic information for AI-assisted development and code generation.
24+
25+
```yaml
26+
# File: order.object.yml
27+
actions:
28+
approve_order:
29+
type: record
30+
label: Approve Order
31+
ai_context:
32+
intent: "Approve a pending order after verifying inventory and payment"
33+
business_rules:
34+
- "Only orders in 'Pending' status can be approved"
35+
- "Must verify sufficient inventory before approval"
36+
- "Payment must be confirmed"
37+
examples:
38+
- "Approve order #12345 after payment verification"
39+
- "Batch approve all paid orders"
40+
```
41+
42+
| Property | Type | Description |
43+
| :--- | :--- | :--- |
44+
| `intent` | `string` | Brief description of the action's business purpose. |
45+
| `business_rules` | `string[]` | Key constraints or validation requirements. |
46+
| `examples` | `string[]` | Typical use cases or invocation scenarios. |
47+
2248
## 2. Configuration (YAML)
2349

2450
Actions are declared in your object definition file (`<object_name>.object.yml`).

content/docs/reference/spec/hook.mdx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,37 @@ Unlike traditional ORMs that provide generic contexts, ObjectQL hooks are **Type
2222
* **Separation of Concerns**: `before` hooks focus on validation/mutation; `after` hooks focus on side-effects.
2323
* **Change Tracking**: Built-in helpers like `isModified()` simplify "diff" logic.
2424

25+
### AI Context Support
26+
27+
While hooks are implemented in TypeScript files, you can document their business logic using `ai_context` in your object definition or validation rules for AI-assisted development.
28+
29+
```yaml
30+
# File: project.object.yml
31+
label: Project
32+
description: "Project management with status tracking"
33+
34+
ai_context:
35+
intent: "Manage projects with automatic owner assignment and state validation"
36+
business_rules:
37+
- "Owner is auto-assigned on creation from current user"
38+
- "Completed projects cannot be reopened"
39+
- "Status changes trigger notifications"
40+
hooks_description:
41+
- "beforeCreate: Auto-assign owner and validate unique name"
42+
- "beforeUpdate: Prevent reopening completed projects"
43+
- "afterUpdate: Send notification when project completes"
44+
45+
fields:
46+
# ... field definitions
47+
```
48+
49+
| Property | Type | Description |
50+
| :--- | :--- | :--- |
51+
| `hooks_description` | `string[]` | Documentation of hook behavior for AI understanding. |
52+
| `business_rules` | `string[]` | Key validation rules enforced by hooks. |
53+
54+
**Note:** This ai_context goes in the object definition file, not the hook implementation file.
55+
2556
## 2. Supported Hooks
2657

2758
| Hook | Operation | Context Properties | Purpose |

content/docs/reference/spec/object.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ fields:
565565
status:
566566
type: select
567567
required: true
568-
default: planning
568+
defaultValue: planning
569569
options:
570570
- value: planning
571571
label: Planning

content/docs/reference/spec/query-language.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ export interface UnifiedQuery {
102102

103103
The `filters` property is a recursive array structure that eliminates the need for SQL strings.
104104

105+
**Note:** This array-based syntax ([field, operator, value]) is used for **runtime queries**. For **validation rules** in YAML metadata, an object-based syntax (field/operator/value) is used instead. See [Validation Rules](./validation.mdx) for details.
106+
105107
### 3.1 Single Criterion
106108
A criterion is a tuple of `[Field, Operator, Value]`.
107109

content/docs/reference/spec/validation.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ The filename (without the `.validation.yml` extension) automatically identifies
2525

2626
## 2. Root Structure
2727

28+
**Important:** Validation rules use an **object-based syntax** (field/operator/value) while the [Query Language](./query-language.mdx) uses an **array-based syntax** ([field, operator, value]). This distinction exists because:
29+
- **Validation rules** are declarative metadata (YAML) optimized for readability and AI generation
30+
- **Query filters** are runtime AST (JSON) optimized for parsing and logical precedence
31+
2832
```yaml
2933
# File: project.validation.yml
3034
# Object "project" is inferred from filename!

content/docs/server/microservices.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ It must expose the metadata API (default in `@objectql/server`).
2121
```typescript
2222
// user-service/index.ts
2323
const app = new ObjectQL({
24-
source: './src/objects', // Defines 'user', 'role'
24+
modules: ['./src/objects'], // Defines 'user', 'role'
2525
datasources: { ... }
2626
});
2727
// Exposes http://user-service:3000/api/metadata/objects

0 commit comments

Comments
 (0)