|
1 | 1 | # @objectstack/spec |
2 | 2 |
|
| 3 | +ObjectStack Protocol & Specification — The "Constitution" of the Ecosystem. |
| 4 | + |
3 | 5 | [](https://www.typescriptlang.org/) |
4 | 6 | [](https://opensource.org/licenses/MIT) |
5 | 7 |
|
6 | | -> ObjectStack Protocol & Specification - The Constitution of the ObjectStack Ecosystem |
7 | | -
|
8 | | -## 📜 Overview |
| 8 | +## 📜 Mission |
9 | 9 |
|
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. |
11 | 14 |
|
12 | 15 | **Guiding Principle:** *"Strict Types, No Logic"* |
13 | 16 |
|
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 | | - |
20 | 17 | ## 🚀 Installation |
21 | 18 |
|
22 | 19 | ```bash |
23 | 20 | pnpm install @objectstack/spec |
24 | 21 | ``` |
25 | 22 |
|
26 | | -## 📦 What's Inside |
| 23 | +## 📦 Architecture |
| 24 | + |
| 25 | +The specification is divided into three protocols: |
27 | 26 |
|
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) |
29 | 44 |
|
30 | 45 | ## 📚 Usage |
31 | 46 |
|
32 | | -### Using the main package (recommended for most use cases) |
| 47 | +### Validation (Runtime) |
33 | 48 |
|
34 | 49 | ```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 | +} |
41 | 56 | ``` |
42 | 57 |
|
43 | | -### Using individual packages (for smaller bundle sizes) |
| 58 | +### Type Definitions (Compile Time) |
44 | 59 |
|
45 | 60 | ```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 | +}; |
50 | 67 | ``` |
51 | 68 |
|
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 |
53 | 79 |
|
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 | +``` |
58 | 84 |
|
59 | | -## 📄 License |
| 85 | +### Directory Structure |
60 | 86 |
|
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