Skip to content

Commit b597b07

Browse files
committed
更新 README.md,重构使命和架构部分,添加 JSON Schema 使用说明
1 parent 6f8a84a commit b597b07

File tree

1 file changed

+65
-31
lines changed

1 file changed

+65
-31
lines changed

packages/spec/README.md

Lines changed: 65 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,95 @@
11
# @objectstack/spec
22

3+
ObjectStack Protocol & Specification — The "Constitution" of the Ecosystem.
4+
35
[![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue.svg)](https://www.typescriptlang.org/)
46
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
57

6-
> ObjectStack Protocol & Specification - The Constitution of the ObjectStack Ecosystem
7-
8-
## 📜 Overview
8+
## 📜 Mission
99

10-
This is the **main package** that re-exports all ObjectStack specification packages for convenience and backward compatibility.
10+
This package defines the **DNA** of ObjectStack. It contains:
11+
1. **Zod Schemas**: Runtime validation for the Kernel and CLI.
12+
2. **TypeScript Interfaces**: `z.infer<>` types for the IDE and Plugin developers.
13+
3. **JSON Schemas**: Auto-generated schemas for VS Code IntelliSense.
1114

1215
**Guiding Principle:** *"Strict Types, No Logic"*
1316

14-
This package aggregates:
15-
- `@objectstack/spec-meta` - Metamodel type definitions
16-
- `@objectstack/spec-plugin` - Plugin runtime interfaces
17-
- `@objectstack/spec-schemas` - Zod validation schemas
18-
- `@objectstack/spec-constants` - Convention constants
19-
2017
## 🚀 Installation
2118

2219
```bash
2320
pnpm install @objectstack/spec
2421
```
2522

26-
## 📦 What's Inside
23+
## 📦 Architecture
24+
25+
The specification is divided into three protocols:
2726

28-
This package provides a unified import for all ObjectStack specifications. You can import everything from this package, or use the individual packages for smaller bundle sizes.
27+
### 1. Data Protocol (`src/data`)
28+
*Core Business Logic & Data Modeling*
29+
* `Object`, `Field`, `Validation`
30+
* `Query` (AST), `Mapping` (ETL)
31+
* `Permission`, `Sharing`, `Flow`
32+
33+
### 2. UI Protocol (`src/ui`)
34+
*Presentation & Interaction*
35+
* `App`, `Page`, `View` (Grid/Kanban)
36+
* `Dashboard` (Widgets), `Report`
37+
* `Action` (Triggers)
38+
39+
### 3. System Protocol (`src/system`)
40+
*Runtime Configuration & Security*
41+
* `Manifest` (Config), `Datasource`
42+
* `Role` (Hierarchy), `Identity` (Auth)
43+
* `Webhook` (Integration), `Policy` (Compliance)
2944

3045
## 📚 Usage
3146

32-
### Using the main package (recommended for most use cases)
47+
### Validation (Runtime)
3348

3449
```typescript
35-
import {
36-
ObjectEntity,
37-
ObjectStackPlugin,
38-
ManifestSchema,
39-
PKG_CONVENTIONS
40-
} from '@objectstack/spec';
50+
import { ObjectSchema } from '@objectstack/spec';
51+
52+
const result = ObjectSchema.safeParse(userConfig);
53+
if (!result.success) {
54+
console.error("Invalid Object definition", result.error);
55+
}
4156
```
4257

43-
### Using individual packages (for smaller bundle sizes)
58+
### Type Definitions (Compile Time)
4459

4560
```typescript
46-
import { ObjectEntity } from '@objectstack/spec-meta';
47-
import { ObjectStackPlugin } from '@objectstack/spec-plugin';
48-
import { ManifestSchema } from '@objectstack/spec-schemas';
49-
import { PKG_CONVENTIONS } from '@objectstack/spec-constants';
61+
import type { Object, Field } from '@objectstack/spec';
62+
63+
const myObject: Object = {
64+
name: "project_task",
65+
fields: { ... }
66+
};
5067
```
5168

52-
## 📦 Sub-packages
69+
### JSON Schema (Tooling)
70+
The package includes valid JSON Schemas in the `/json-schema` directory.
71+
These can be used with:
72+
* [Ajv](https://ajv.js.org/) (High-performance validator)
73+
* [React Json Schema Form](https://rjsf-team.github.io/) (Auto-forms)
74+
* VS Code `json.schemas` setting for IntelliSense.
75+
76+
## 🛠️ Development
77+
78+
### Build & Generate
5379

54-
- **[@objectstack/spec-meta](../meta)** - Metamodel type definitions
55-
- **[@objectstack/spec-plugin](../plugin)** - Plugin runtime interfaces
56-
- **[@objectstack/spec-schemas](../schemas)** - Zod validation schemas
57-
- **[@objectstack/spec-constants](../constants)** - Convention constants
80+
```bash
81+
# Generate JSON Schemas + Markdown Docs + Compile TS
82+
pnpm build
83+
```
5884

59-
## 📄 License
85+
### Directory Structure
6086

61-
MIT
87+
```text
88+
packages/spec/
89+
├── src/ # Source Truth (Zod)
90+
│ ├── data/ # ObjectQL Protocol
91+
│ ├── ui/ # ObjectUI Protocol
92+
│ └── system/ # ObjectOS Protocol
93+
├── json-schema/ # Auto-generated (npm run gen:schema)
94+
└── dist/ # Compiled JS/D.TS
95+
```

0 commit comments

Comments
 (0)