@c-time/frelio-types
v1.4.1
Published
Frelio CMS の共有型定義パッケージ。コンテンツ、スキーマ、ユーザー権限、ビルドレシピなど、全パッケージで共通の型を提供する。
Readme
@c-time/frelio-types
Frelio CMS の共有型定義パッケージ。コンテンツ、スキーマ、ユーザー権限、ビルドレシピなど、全パッケージで共通の型を提供する。
概要
Frelio エコシステム全体で使用される TypeScript 型定義の中心パッケージ。3つのエントリポイントを提供する:
- メインエントリ — 型定義の re-export
/schemas— Zod ベースのバリデーションスキーマと検証関数/guards— 軽量な型ガード関数(Zod 不要)
インストール
npm install @c-time/frelio-types
# スキーマバリデーションを使う場合
npm install zod使用例
// 型定義
import type { ContentType, Content, User, Permissions } from '@c-time/frelio-types'
// バリデーション(Zod 必要)
import { validateContentType, validateSiteRecipe } from '@c-time/frelio-types/schemas'
// 型ガード(Zod 不要)
import { isContentType, isContent, isUser } from '@c-time/frelio-types/guards'
// コンテンツタイプのバリデーション
const result = validateContentType(jsonData)
if (!result.success) {
console.error(result.errors)
}
// 型ガードによる判定
if (isContent(data)) {
console.log(data.status) // 'published' | 'draft' | 'unpublished'
}主な型
コンテンツ
| 型 | 説明 |
|----|------|
| ContentType | コンテンツタイプのスキーマ定義(フィールド定義の配列) |
| FieldDefinition | フィールド定義(型、オプション、バリデーション) |
| FieldType | フィールド型(text, html, markdown, number, boolean, date, image, file, select, relation, array, label) |
| Content | コンテンツデータ(ID、ステータス、データ、タイムスタンプ、著者) |
| ContentStatus | 'published' \| 'draft' \| 'unpublished' |
UI メタデータ
| 型 | 説明 |
|----|------|
| ContentTypeUi | コンテンツタイプの UI 設定(ラベル、フィールド UI、グループ) |
| UiFieldDefinition | フィールドの UI 設定(表示幅、フォーマット、色など) |
| FieldGroupDefinition | フィールドのグループ化定義 |
ビュー
| 型 | 説明 |
|----|------|
| ContentTypeViews | テーブルビューの定義(カラム、ソート、フィルタ) |
| ViewDefinition | ビュー定義 |
| ViewColumn / ViewFilter / ViewSort | ビューの構成要素 |
ユーザー・権限
| 型 | 説明 |
|----|------|
| User | ユーザー(GitHub ユーザー名、表示名、権限) |
| Permissions | 18 種の細粒度権限フラグ |
| RoleTemplate | 'owner' \| 'admin' \| 'developer' \| 'editor' \| 'viewer' \| 'custom' |
ビルド・デプロイ
| 型 | 説明 |
|----|------|
| BuildTarget | 'production' \| 'staging' \| 'preview-tmpl' |
| StagingBranch | ステージングブランチ定義 |
| FrelioBuildDataRecipe | ビルドレシピ(@c-time/frelio-data-json-recipe から re-export) |
| FrelioDependencyMap | 依存マップ(@c-time/frelio-dependency-map から re-export) |
バリデーション (/schemas)
Zod ベースのバリデーション関数。zod がピア依存。
| 関数 | 説明 |
|------|------|
| validateContentType(data) | ContentType JSON のバリデーション |
| validateContentTypeUi(data) | ContentTypeUi JSON のバリデーション |
| validateContentTypeViews(data) | Views JSON のバリデーション |
| validateSiteRecipe(data) | ビルドレシピのバリデーション |
| formatZodErrors(errors) | エラーメッセージの整形 |
型ガード (/guards)
Zod 不要の軽量な型ガード。
| 関数 | 説明 |
|------|------|
| isFieldType(value) | 有効な FieldType か判定 |
| isContentType(value) | 有効な ContentType か判定 |
| isContentTypeUi(value) | 有効な ContentTypeUi か判定 |
| isContent(value) | 有効な Content か判定 |
| isUser(value) | 有効な User か判定 |
| isContentTypeViews(value) | 有効な Views か判定 |
| isDashboardMetadata(value) | 有効な DashboardMetadata か判定 |
ライセンス
MIT
