Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions content/docs/concepts/enterprise-framework.cn.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ my-erp/

## 下一步

* **[SDK 参考](../specifications/sdk)**: `@objectstack/sdk` 的详细 API 文档
* **[CLI 指南](../specifications/cli)**: 命令参考和使用示例
* **[部署模式](../specifications/deployment)**: Docker、Kubernetes 和云部署策略
* **[创造层](../creator-layer)**: 了解用于开发的 SDK 和 CLI 工具
* **[治理层](../governance-layer)**: 理解 CI/CD 流水线和部署
* **[执行层](../execution-layer)**: 探索 ObjectQL、ObjectOS 和 ObjectUI 引擎

:::tip 企业级准备
ObjectStack 企业框架专为重视代码质量、版本控制和可维护性的团队而设计。它将低代码的力量带入专业开发工作流程。
Expand Down
6 changes: 3 additions & 3 deletions content/docs/concepts/enterprise-framework.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ However, it adds a critical developer experience layer:

## Next Steps

* **[SDK Reference](../specifications/sdk)**: Detailed API documentation for `@objectstack/sdk`
* **[CLI Guide](../specifications/cli)**: Command reference and usage examples
* **[Deployment Patterns](../specifications/deployment)**: Docker, Kubernetes, and cloud deployment strategies
* **[Creator Layer](../creator-layer)**: Learn about the SDK and CLI tools for development
* **[Governance Layer](../governance-layer)**: Understand the CI/CD pipeline and deployment
* **[Execution Layer](../execution-layer)**: Explore the ObjectQL, ObjectOS, and ObjectUI engines

:::tip Enterprise-Ready
The ObjectStack Enterprise Framework is designed for teams that value code quality, version control, and maintainability. It brings the power of low-code to professional development workflows.
Expand Down
146 changes: 146 additions & 0 deletions content/docs/creator-layer/index.cn.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
---
title: 创造层
description: "层级 A:ObjectStack SDK - 在 IDE 中定义世界"
---

# 创造层:ObjectStack SDK

**"在 IDE 中定义世界"**

创造层是开发者工作的地方——编写代码、定义元数据、构建业务逻辑,而无需离开他们熟悉的 IDE 环境。这一层通过将所有配置和开发带入 TypeScript 代码,消除了对网页后台的需求。

## 概述

在 ObjectStack 企业框架中,创造层代表开发者的主要工作空间。开发者不再需要点击配置界面,而是使用:

* **ObjectStack CLI**: 用于快速脚手架和项目管理的命令行工具
* **TypeScript SDK**: 用于定义对象、逻辑和界面的类型安全 API
* **代码化元数据**: 从 Schema 到 UI 布局的一切都作为版本控制的代码存在

## 核心理念

> "没有黑盒。所有业务定义都在本地代码中,基于 TypeScript,清晰透明。"

这一层体现了**透明性**原则:
* 所有元数据都是可读的 TypeScript 代码
* 所有变更都在 Git 中跟踪
* 所有业务逻辑都可以使用标准 IDE 工具进行测试和重构

## 开发者体验

### 1. 项目初始化

```bash
ostack init my-enterprise-app
cd my-enterprise-app
```

这将生成一个标准项目结构,包含:
- 预配置的 TypeScript 设置
- ObjectStack SDK 依赖
- 示例对象和工作流
- 测试基础设施

### 2. 对象定义

使用 SDK 定义业务实体:

```typescript
import { defineObject, Field } from '@objectstack/sdk';

export const Contract = defineObject({
name: 'contract',
label: '销售合同',
fields: {
title: Field.String({
label: '标题',
required: true
}),
amount: Field.Currency({
label: '金额',
precision: 18,
scale: 2
}),
status: Field.Select({
options: ['draft', 'signed', 'cancelled'],
defaultValue: 'draft'
})
}
});
```

### 3. 逻辑与触发器

将业务逻辑编写为 TypeScript 函数:

```typescript
export const Contract = defineObject({
// ... 字段 ...

triggers: {
beforeInsert: async ({ doc }) => {
if (doc.amount < 0) {
throw new Error("金额不能为负");
}
},

afterUpdate: async ({ doc, oldDoc }) => {
if (doc.status === 'signed' && oldDoc.status !== 'signed') {
doc.signedAt = new Date();
}
}
}
});
```

### 4. 本地开发

```bash
ostack dev
```

这将启动一个热重载开发服务器,你可以:
* 即时测试更改
* 使用 Chrome DevTools 调试
* 无需部署即可快速迭代

## 架构集成

创造层输出**代码化元数据**,流入**治理层**(CI/CD 流水线)进行编译和部署。

```mermaid
graph LR
CLI[ObjectStack CLI] --> MetaCode[代码化元数据]
SDK[TypeScript SDK] --> MetaCode
MetaCode --> Extract[治理层]

style CLI fill:#e1f5ff
style SDK fill:#e1f5ff
style MetaCode fill:#fff4e1
```

## 价值主张

### 类型安全
* VS Code 中的完整 IntelliSense 支持
* 编译时错误检测
* 自信地重构

### Git 原生工作流
* 所有更改都是提交
* 通过 Pull Request 进行代码审查
* 回滚只需 `git revert`

### 无厂商锁定
* 你的代码存在于你的仓库中
* 无需特殊工具即可读取和修改
* 可跨环境移植

## 此层中的工具

* **[SDK 参考](./sdk)**: `@objectstack/sdk` 的详细 API 文档
* **[CLI 指南](./cli)**: 命令参考和使用示例

---

**下一步:** **[治理层](../governance-layer)** - 了解你的代码如何构建和部署
146 changes: 146 additions & 0 deletions content/docs/creator-layer/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
---
title: Creator Layer
description: "Layer A: ObjectStack SDK - Define the World in Your IDE"
---

# Creator Layer: ObjectStack SDK

**"Define the World in Your IDE"**

The Creator Layer is where developers work—writing code, defining metadata, and building business logic without leaving their familiar IDE environment. This layer eliminates the need for web-based admin consoles by bringing all configuration and development into TypeScript code.

## Overview

In the ObjectStack Enterprise Framework, the Creator Layer represents the developer's primary workspace. Instead of clicking through configuration screens, developers use:

* **ObjectStack CLI**: Command-line tools for rapid scaffolding and project management
* **TypeScript SDK**: Type-safe APIs for defining objects, logic, and interfaces
* **Metadata as Code**: Everything from schemas to UI layouts exists as version-controlled code

## Core Philosophy

> "No Black Boxes. All business definitions exist in local code, based on TypeScript, clear and transparent."

This layer embodies the principle of **transparency**:
* All metadata is readable TypeScript code
* All changes are tracked in Git
* All business logic is testable and refactorable with standard IDE tools

## The Developer Experience

### 1. Project Initialization

```bash
ostack init my-enterprise-app
cd my-enterprise-app
```

This generates a standard project structure with:
- Pre-configured TypeScript setup
- ObjectStack SDK dependencies
- Example objects and workflows
- Testing infrastructure

### 2. Object Definition

Define business entities using the SDK:

```typescript
import { defineObject, Field } from '@objectstack/sdk';

export const Contract = defineObject({
name: 'contract',
label: 'Sales Contract',
fields: {
title: Field.String({
label: 'Title',
required: true
}),
amount: Field.Currency({
label: 'Amount',
precision: 18,
scale: 2
}),
status: Field.Select({
options: ['draft', 'signed', 'cancelled'],
defaultValue: 'draft'
})
}
});
```

### 3. Logic & Triggers

Write business logic as TypeScript functions:

```typescript
export const Contract = defineObject({
// ... fields ...

triggers: {
beforeInsert: async ({ doc }) => {
if (doc.amount < 0) {
throw new Error("Amount cannot be negative");
}
},

afterUpdate: async ({ doc, oldDoc }) => {
if (doc.status === 'signed' && oldDoc.status !== 'signed') {
doc.signedAt = new Date();
}
}
}
});
```

### 4. Local Development

```bash
ostack dev
```

This starts a hot-reloading development server where you can:
* Test changes instantly
* Debug with Chrome DevTools
* Iterate rapidly without deploying

## Architecture Integration

The Creator Layer outputs **Metadata as Code** which flows into the **Governance Layer** (CI/CD Pipeline) for compilation and deployment.

```mermaid
graph LR
CLI[ObjectStack CLI] --> MetaCode[Metadata as Code]
SDK[TypeScript SDK] --> MetaCode
MetaCode --> Extract[Governance Layer]

style CLI fill:#e1f5ff
style SDK fill:#e1f5ff
style MetaCode fill:#fff4e1
```

## Value Propositions

### Type Safety
* Full IntelliSense support in VS Code
* Compile-time error detection
* Refactoring with confidence

### Git-Native Workflow
* All changes are commits
* Code reviews via Pull Requests
* Rollback is just `git revert`

### No Vendor Lock-in
* Your code lives in your repository
* Can be read and modified without special tools
* Portable across environments

## Tools in This Layer

* **[SDK Reference](./sdk)**: Detailed API documentation for `@objectstack/sdk`
* **[CLI Guide](./cli)**: Command reference and usage examples

---

**Next:** **[Governance Layer](../governance-layer)** - Learn how your code gets built and deployed
8 changes: 8 additions & 0 deletions content/docs/creator-layer/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"title": "Creator Layer",
"pages": [
"index",
"sdk",
"cli"
]
}
Loading
Loading