Skip to content

Commit 8ae3d92

Browse files
Copilothotlong
andcommitted
Add README documentation for categorized JSON schema structure
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent cfd12a1 commit 8ae3d92

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# JSON Schema Directory
2+
3+
This directory contains auto-generated JSON schemas for all ObjectStack protocols, organized by category.
4+
5+
## Directory Structure
6+
7+
The schemas are organized into the following categories matching the protocol structure:
8+
9+
```
10+
json-schema/
11+
├── data/ # Data Protocol - Business Logic & Data Modeling (74 schemas)
12+
├── ui/ # UI Protocol - Presentation & Interaction (39 schemas)
13+
├── system/ # System Protocol - Runtime Configuration & Security (112 schemas)
14+
├── ai/ # AI Protocol - AI/ML Capabilities (86 schemas)
15+
└── api/ # API Protocol - API Contracts & Envelopes (12 schemas)
16+
```
17+
18+
## Categories
19+
20+
### 📊 Data Protocol (`data/`)
21+
Core business logic and data modeling schemas:
22+
- Object, Field, Validation
23+
- Query (AST), Mapping (ETL)
24+
- Permission, Sharing, Flow, Workflow
25+
26+
**Example schemas:** `Field.json`, `Object.json`, `Query.json`, `ValidationRule.json`
27+
28+
### 🎨 UI Protocol (`ui/`)
29+
Presentation and interaction schemas:
30+
- App, Page, View (Grid/Kanban/Calendar/Gantt)
31+
- Dashboard (Widgets), Report
32+
- Action (Triggers), Theme
33+
34+
**Example schemas:** `App.json`, `View.json`, `Dashboard.json`, `Theme.json`
35+
36+
### ⚙️ System Protocol (`system/`)
37+
Runtime configuration and security schemas:
38+
- Manifest (Config), Datasource, Driver
39+
- Role (Hierarchy), Identity (Auth)
40+
- Webhook (Integration), Policy (Compliance)
41+
- Plugin Architecture, Audit, Tenant Management
42+
43+
**Example schemas:** `Manifest.json`, `AuthConfig.json`, `Datasource.json`, `AuditEvent.json`
44+
45+
### 🤖 AI Protocol (`ai/`)
46+
AI/ML capabilities schemas:
47+
- Agent Configuration
48+
- Model Registry & Selection
49+
- RAG Pipeline, NLQ (Natural Language Query)
50+
- Workflow Automation, Predictive Analytics
51+
- Conversation Memory & Token Management
52+
- Cost Tracking & Budget Management
53+
54+
**Example schemas:** `Agent.json`, `ModelRegistry.json`, `RAGPipelineConfig.json`, `NLQRequest.json`
55+
56+
### 🔌 API Protocol (`api/`)
57+
API contracts and envelopes:
58+
- Request/Response schemas
59+
- Error handling
60+
- Bulk operations
61+
62+
**Example schemas:** `ApiEndpoint.json`, `BaseResponse.json`, `BulkRequest.json`
63+
64+
## Generation
65+
66+
These schemas are automatically generated from Zod schemas during the build process:
67+
68+
```bash
69+
npm run gen:schema
70+
```
71+
72+
The generation script is located at `scripts/build-schemas.ts`.
73+
74+
## Usage
75+
76+
### In TypeScript/JavaScript Projects
77+
78+
You can reference these JSON schemas for validation, documentation, or IDE support:
79+
80+
```typescript
81+
import fieldSchema from '@objectstack/spec/json-schema/data/Field.json';
82+
```
83+
84+
### In JSON Schema Tools
85+
86+
Use these schemas with any JSON Schema validator or documentation generator:
87+
88+
```bash
89+
ajv validate -s json-schema/data/Field.json -d myfield.json
90+
```
91+
92+
### In IDEs
93+
94+
Many IDEs support JSON schema validation. You can reference these schemas in your configuration files:
95+
96+
```json
97+
{
98+
"$schema": "./node_modules/@objectstack/spec/json-schema/data/Object.json"
99+
}
100+
```
101+
102+
## Schema Format
103+
104+
All schemas are generated with:
105+
- **Format:** JSON Schema Draft 7
106+
- **Strategy:** Self-contained (no external `$ref`s)
107+
- **Naming:** PascalCase matching the TypeScript type names
108+
109+
## Conventions
110+
111+
- **Configuration Keys (Properties):** `camelCase` (e.g., `maxLength`, `referenceFilters`)
112+
- **Machine Names (Data Values):** `snake_case` (e.g., `name: 'first_name'`, `object: 'project_task'`)
113+
114+
## Contributing
115+
116+
Do not manually edit these files. They are auto-generated from the Zod schemas in `src/`.
117+
118+
To update schemas:
119+
1. Edit the corresponding `.zod.ts` file in `src/{category}/`
120+
2. Run `npm run gen:schema`
121+
3. Commit both the Zod source and generated JSON schemas
122+
123+
---
124+
125+
**Total Schemas:** 325 (as of latest build)
126+
127+
For more information, see the main [README](../README.md).

0 commit comments

Comments
 (0)