mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
- Add seed/metadata.json to all 12 core packages installed at bootstrap - Update admin_dialog and dashboard metadata to current standard - Create comprehensive SEED_FORMAT.md documentation with usage guidelines - Create PACKAGE_AUDIT.md analyzing all 51 packages: - 12 core packages: have seed/metadata.json (100% complete) - 39 optional packages: no seed needed (components, tools, development) - Establish simple 1-folder-per-entity-type pattern as standard - Remove kitchen-sink anti-patterns from seed structure The seed system is now complete and ready for extending with entity-specific seed data (page-config, workflow, credential, etc.) as packages need them. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
6.0 KiB
6.0 KiB
Package Seed Data Format
Overview
Each MetaBuilder package can include seed data - initial records that populate the database when the system bootstraps. Seed data is:
- Simple JSON or YAML files - Just data, no code
- Entity-specific - One folder per entity type (e.g.,
page-config,workflow) - Loaded automatically - The DBAL seed orchestration loads them in order
- Idempotent - Safe to run multiple times (existing records are skipped)
Structure
packages/[packageId]/
├── seed/
│ ├── metadata.json [Required - manifest file]
│ ├── page-config.json [Optional - PageConfig records]
│ ├── workflow.json [Optional - Workflow records]
│ └── ...other entities...
└── ...other package files...
metadata.json Format
The metadata.json file tells the system:
- Which data files to load
- Basic package information
- Permission requirements
{
"$schema": "https://metabuilder.dev/schemas/package-metadata.schema.json",
"packageId": "ui_home",
"name": "Home Page",
"version": "1.0.0",
"description": "Seed data for ui_home package",
"author": "MetaBuilder Contributors",
"license": "MIT",
"category": "ui",
"minLevel": 0,
"primary": true,
"keywords": ["home", "landing", "seed-data"],
"seed": {
"schema": "page-config.json"
}
}
Fields
| Field | Type | Required | Description |
|---|---|---|---|
$schema |
string | No | JSON schema URL for validation |
packageId |
string | Yes | Must match package folder name |
name |
string | Yes | Human-readable package name |
version |
string | Yes | Semantic version (e.g., "1.0.0") |
description |
string | Yes | What this seed data does |
author |
string | Yes | Creator/maintainer |
license |
string | No | Software license (MIT, Apache-2.0, etc.) |
category |
string | No | Package category (ui, admin, system, etc.) |
minLevel |
number | No | Minimum permission level required (0-5) |
primary |
boolean | No | Is this a core system package? |
keywords |
array | No | Search keywords |
seed.schema |
string | No | Reference to data file (if any) |
Data File Format
Each data file contains an array of entity records:
[
{
"id": "page_ui_home_root",
"path": "/",
"title": "MetaBuilder",
"component": "home_page",
"level": 0,
"requiresAuth": false,
"isPublished": true
}
]
Important Rules
- Array format - Always a JSON array, even if one record
- No code - Only JSON data, no TypeScript functions
- Entity fields - Use fields defined in the DBAL entity schema
- No hardcoding - Values can be customized via admin panel after seed load
Entity Types
Common entity types that packages seed:
| Entity | File | Description |
|---|---|---|
| PageConfig | page-config.json |
Routes/pages that packages expose |
| Workflow | workflow.json |
Automation workflows |
| Credential | credential.json |
API credentials or secrets |
| ComponentConfig | component-config.json |
Reusable component configurations |
| Notification | notification.json |
Notification templates |
How Seed Loading Works
- System calls
POST /api/bootstrap - DBAL reads
/dbal/shared/seeds/database/installed_packages.yaml(list of packages to install) - For each package in the list:
- Reads
seed/metadata.json - If
seed.schemais specified, reads that data file - Creates records in database using DBAL client
- Skips if records already exist (idempotent)
- Reads
- Returns success/error JSON response
Example: Page Config Seed
File: packages/my_package/seed/page-config.json
[
{
"id": "page_my_pkg_dashboard",
"path": "/my-dashboard",
"title": "My Dashboard",
"description": "Custom dashboard for my package",
"component": "my_dashboard_component",
"level": 1,
"requiresAuth": true,
"isPublished": true
}
]
This creates a new route /my-dashboard that loads the component defined in this package.
Do's and Don'ts
✅ DO:
- Keep seed files simple - just data
- Use one file per entity type
- Include metadata for every seed package
- Match entity field names exactly
- Use the admin panel to customize after bootstrap
❌ DON'T:
- Add code files to seed folder
- Create documentation markdown in seed folder
- Add nested folder structures
- Include scripts or utilities
- Hardcode sensitive data (use Credential entity instead)
Bootstrap API
Endpoint
POST /api/bootstrap
Response (Success)
{
"success": true,
"message": "Database seeded successfully",
"packagesInstalled": 12,
"recordsCreated": 45
}
Response (Error)
{
"success": false,
"error": "Failed to create PageConfig: Duplicate path '/'"
}
Multi-Entity Seed
If a package needs to seed multiple entity types:
packages/complex_package/
└── seed/
├── metadata.json
├── page-config.json [Routes]
├── workflow.json [Workflows]
└── credential.json [Credentials]
Update metadata.json to reference all:
{
...other fields...,
"seed": {
"pageConfig": "page-config.json",
"workflow": "workflow.json",
"credential": "credential.json"
}
}
Then update /dbal/development/src/seeds/index.ts to load all referenced files.
Guidelines
- Keep it minimal - Only include essential bootstrap data
- Describe your data - Use meaningful field values, not placeholder text
- Version your data - Update version in metadata when seed data changes
- Test idempotency - Seed should be safe to run multiple times
- Document changes - When modifying seed data, update the description field
See Also
/dbal/development/src/seeds/index.ts- Seed orchestration implementation/dbal/shared/api/schema/entities/- Entity definitions (source of truth for fields)/packages/ui_home/seed/- Example: home page seed dataCLAUDE.md- Seed folder guidelines and mistakes to avoid