open-index/open-npm huggingface dataset:
npm package: @gravito/astral
Description: Schema-driven OpenAPI generator for Gravito with Swagger UI support
Latest version: 2.0.0

# @gravito/astral 🌌

**為 Gravito 打造的「影子契約」OpenAPI 生成器。**

Astral 是一個 Schema 驅動的文檔引擎，能生成 OpenAPI 3.1 規範並提供內建的 Swagger UI，且完全不會污染您的業務邏輯。

## 🚀 核心理念：影子契約 (Shadow Contracts)

不同於傳統文檔工具需要在 Controller 中使用 Decorator（如 `@ApiOperation`），Astral 採用 **影子契約**。您在獨立的文件中定義 API 元數據，保持 Controller 的純淨，專注於業務邏輯。

## 📦 安裝

```bash
bun add @gravito/astral
# 或
npm install @gravito/astral
```

## 🛠️ 快速開始

### 1. 定義 DTO 與 Request
使用 Zod 定義您的數據結構。

```typescript
import { z } from 'zod'
import { FormRequest } from '@gravito/impulse'

export const UserDTO = z.object({
  id: z.number(),
  name: z.string().describe('使用者全名'),
  email: z.string().email()
})

export class CreateUserRequest extends FormRequest {
  schema = z.object({
    name: z.string().min(2),
    email: z.string().email()
  })
}
```

### 2. 建立影子契約
在獨立文件中將路由映射到 DTO。

```typescript
import { astral } from '@gravito/astral'
import { CreateUserRequest, UserDTO } from './dtos'

export const UserContract = astral.resource('/api/users', {
  tags: ['使用者管理'],
  operations: {
    index: {
      summary: '列出所有使用者',
      output: [UserDTO] // 自動推斷為陣列響應
    },
    store: {
      summary: '建立使用者',
      input: CreateUserRequest, // 自動推斷為 JSON 請求體
      output: UserDTO
    }
  }
})
```

### 3. 註冊 Orbit
將 `OrbitAstral` 加入您的 `PlanetCore` 配置。

```typescript
import { PlanetCore, defineConfig } from '@gravito/core'
import { OrbitAstral } from '@gravito/astral'
import { UserContract } from './contracts'

const config = defineConfig({
  orbits: [
    OrbitAstral.configure({
      title: '我的 API 專案',
      contracts: [UserContract]
    })
  ]
})

const core = await PlanetCore.boot(config)
await core.liftoff()
```

瀏覽 `http://localhost:3000/docs` 即可查看您的 Swagger UI！

## 📚 文檔

- [API 參考](./docs/API.md) - 配置、介面與輔助工具的詳細指南。
- [進階用法](./docs/ADVANCED.md) - 學習安全機制、可重用組件與自定義錯誤處理。

## ✨ 關鍵特性

- **零侵入性**：Controller 中無需 Decorator 或 JSDoc。
- **類型推斷**：自動將 Zod Schema 與 Impulse FormRequest 轉換為 OpenAPI 組件。
- **即時更新**：文檔始終與您的 DTO 即時同步。
- **內建 UI**：整合由 CDN 驅動的 Swagger UI。

## 📄 授權

MIT
npm package: @gravito/echo
Description: Enterprise-grade webhook handling for Gravito. Secure receiving and reliable sending.
Author: Carl Lee
Latest version: 4.0.0

# @gravito/echo

> Gravito 的企業級 Webhook 模組，安全接收與可靠發送。

## 安裝

```bash
bun add @gravito/echo
```

## 快速開始

```typescript
import { OrbitEcho, WebhookReceiver } from '@gravito/echo'

const core = new PlanetCore()

core.install(new OrbitEcho({
  providers: {
    stripe: { name: 'stripe', secret: process.env.STRIPE_WEBHOOK_SECRET! },
    github: { name: 'github', secret: process.env.GITHUB_WEBHOOK_SECRET! }
  }
}))

const receiver = core.container.make<WebhookReceiver>('echo.receiver')

receiver.on('stripe', 'payment_intent.succeeded', async (event) => {
  console.log('Payment received:', event.payload)
})
```
npm package: @gravito/enterprise
Description: Enterprise architecture primitives for Gravito framework (DDD/Clean Architecture)
Author: Gravito Team
Latest version: 1.0.6

# @gravito/enterprise

Enterprise architecture primitives for Gravito framework. This package provides the building blocks for Domain-Driven Design (DDD) and Clean Architecture in Gravito applications.

## ✨ Key Features

### 🧬 Galaxy-Ready DDD Primitives
- **AggregateRoot**: The standard foundation for Satellite domain models with integrated event dispatching.
- **Entity & ValueObject**: Building blocks for consistent domain logic and type safety across the Galaxy.
- **DomainEvent**: Unified structure for cross-satellite communication and state transitions.

### 🏗️ Universal Clean Architecture
- **UseCase & Repository**: Clean interfaces for decoupling business rules from infrastructure Orbits.
- **CQRS Primitives**: Base classes for Commands, Queries, and their respective Handlers.
- **Validation Shield**: Integration with `Mass` or `Impulse` for input protection.

## 🌌 Role in Galaxy Architecture

In the **Gravito Galaxy Architecture**, Enterprise acts as the **Architectural Blueprint DNA (Core Patterns)**.

- **Universal Language**: Provides the "Shared Vocabulary" (Entities, Events, Repositories) that allows developers to understand any Satellite's code at a glance.
- **Structural Guardian**: Enforces the separation of concerns, ensuring that the "Pure" business logic of a Satellite is never contaminated by infrastructure details.
- **Event-Driven Foundation**: Defines the standard for Domain Events that are propagated through the Galaxy's `Signal` and `Stream` nervous systems.

```mermaid
graph TD
    S[Satellite: Domain] -->|Implements| E{Enterprise Patterns}
    E -->|Aggregate| M[Model]
    E -->|Command| H[Handler]
    E -->|Event| D[Domain Event]
    D -->|Propagate| Signal[Signal Orbit]
```

## Usage

### Defining an Aggregate Root

```typescript
import { AggregateRoot, DomainEvent, ValueObject } from '@gravito/enterprise'

class UserCreated extends DomainEvent {
  // ...
}

class UserId extends ValueObject<{ value: string }> {}

class User extends AggregateRoot<UserId> {
  static create(id: UserId, name: string): User {
    const user = new User(id)
    user.addDomainEvent(new UserCreated())
    return user
  }
}
```

### Implementing CQRS

```typescript
import { Command, CommandHandler } from '@gravito/enterprise'

class CreateUserCommand extends Command {
  constructor(public readonly name: string) { super() }
}

class CreateUserHandler implements CommandHandler<CreateUserCommand, string> {
  async handle(command: CreateUserCommand): Promise<string> {
    // Logic here
    return 'new-id'
  }
}
```