-
Notifications
You must be signed in to change notification settings - Fork 6
docs(metadata): rewrite README and add ROADMAP #665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,13 +1,245 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| # @objectstack/metadata | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| The **Model Definition** layer. It provides classes and utilities for parsing and validating ObjectStack metadata schemas. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| > **Metadata Loading, Persistence & Customization Layer for ObjectStack.** | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Features | ||||||||||||||||||||||||||||||||||||||||||||||||||
| `@objectstack/metadata` is the central service responsible for loading, validating, persisting and watching all metadata definitions (Objects, Views, Flows, Apps, Agents, etc.) in the ObjectStack platform. | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - **Schema Loading**: Load metadata from JSON/YAML or TypeScript files. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - **Reference Resolution**: Resolves cross-object references and inheritance. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - **Validation**: Strict validation against the Zod schemas in `@objectstack/spec`. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| It implements the **`IMetadataService`** contract from `@objectstack/spec` and acts as the single source of truth that all other packages depend on. | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Architecture Overview | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ┌─────────────────────────────────────────────────────────────┐ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ IMetadataService │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ (Contract: @objectstack/spec) │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ├─────────────────────────────────────────────────────────────┤ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ MetadataManager │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ (Orchestrator: this package) │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ ┌─────────────┐ ┌──────────────┐ ┌───────────────────┐ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ │ In-Memory │ │ Overlay │ │ Type Registry │ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ │ Registry │ │ System │ │ & Dependencies │ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ └─────────────┘ └──────────────┘ └───────────────────┘ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ├─────────────────────────────────────────────────────────────┤ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ Loader Layer │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ ┌─────────────┐ ┌──────────────┐ ┌───────────────────┐ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ │ Filesystem │ │ Remote │ │ Memory │ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ │ Loader │ │ Loader │ │ Loader │ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ │ (files) │ │ (HTTP) │ │ (test) │ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ └─────────────┘ └──────────────┘ └───────────────────┘ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ ┌──────────────────────────────────────────────────────┐ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ │ DatabaseLoader (planned — datasource-backed storage) │ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ └──────────────────────────────────────────────────────┘ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ├─────────────────────────────────────────────────────────────┤ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ Serializer Layer │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ ┌──────────┐ ┌──────────┐ ┌──────────────────────────┐ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ │ JSON │ │ YAML │ │ TypeScript/JavaScript │ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| │ └──────────┘ └──────────┘ └──────────────────────────┘ │ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| └─────────────────────────────────────────────────────────────┘ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Core Concepts | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ### 1. Metadata Sources (Three-Scope Model) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ObjectStack adopts a three-scope layered model for metadata: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| | Scope | Storage | Mutability | Description | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| |:-----------|:-------------|:-------------|:-------------------------------------------| | ||||||||||||||||||||||||||||||||||||||||||||||||||
| | `system` | Filesystem | Read-only | Defined in code, shipped with packages | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| | `platform` | Database | Admin-editable | Created/modified by admins via UI | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| | `user` | Database | User-editable | Personal customizations per user | | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| Resolution order: **system** ← merge(**platform**) ← merge(**user**). | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ### 2. Loaders | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| Loaders are pluggable data sources that know how to read/write metadata from different backends. Each loader declares a `MetadataLoaderContract` with name, protocol, and capabilities: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| | Loader | Protocol | Read | Write | Watch | Status | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| |:--------------------|:---------------|:-----|:------|:------|:-------------| | ||||||||||||||||||||||||||||||||||||||||||||||||||
| | `FilesystemLoader` | `file:` | ✅ | ✅ | ✅ | Implemented | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| | `MemoryLoader` | `memory:` | ✅ | ✅ | ❌ | Implemented | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| | `RemoteLoader` | `http:` | ✅ | ✅ | ❌ | Implemented | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| | `DatabaseLoader` | `datasource:` | ✅ | ✅ | ✅ | Planned | | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ### 3. Serializers | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| Serializers convert metadata objects to/from different file formats: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - **JSONSerializer** — `.json` files with optional key sorting | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - **YAMLSerializer** — `.yaml`/`.yml` files (JSON_SCHEMA for security) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - **TypeScriptSerializer** — `.ts`/`.js` module exports (for `defineObject()`, `defineView()`, etc.) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - **TypeScriptSerializer** — `.ts`/`.js` module exports (for `defineObject()`, `defineView()`, etc.) | |
| - **TypeScriptSerializer** — `.ts`/`.js` modules that export JSON-compatible object literals via `export const ... = {}` or `export default {}` (parsed with `JSON.parse`, does not support `defineObject()` / `defineView()` calls) |
Copilot
AI
Feb 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overlay section describes overlays as “JSON Merge Patch”, but the current implementation of getEffective() in MetadataManager performs a shallow object spread ({ ...base, ...patch }) for platform/user overlays. This differs from JSON Merge Patch semantics (deep merge + null deletions). Please either update the docs to describe the current shallow-merge behavior, or update the overlay merge logic to match the documented patch semantics.
| The overlay system enables non-destructive customizations on top of package-delivered (system) metadata, following a delta-based approach (JSON Merge Patch): | |
| - **getOverlay** / **saveOverlay** / **removeOverlay** — manage customization deltas | |
| - **getEffective** — returns the merged result of base + platform overlay + user overlay | |
| - Overlays never modify the base definition — they are additive patches | |
| The overlay system enables non-destructive customizations on top of package-delivered (system) metadata, using a shallow, top-level merge of overlay objects (via object spread) where later overlays override earlier ones: | |
| - **getOverlay** / **saveOverlay** / **removeOverlay** — manage customization deltas | |
| - **getEffective** — returns the merged result of base + platform overlay + user overlay (top-level keys from platform/user overlays override the base) | |
| - Overlays never modify the base definition — they are additive patches; `null` values are treated as literal values, not deletions |
Copilot
AI
Feb 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The “26 built-in metadata types” and the type list/domain table do not match the actual built-in registry used by MetadataPlugin (DEFAULT_METADATA_TYPE_REGISTRY in @objectstack/spec/kernel/metadata-plugin.zod.ts), which currently contains 23 types (e.g., includes page, approval, hook, router, function, service, and uses permission rather than permission_set). Please update the count and list to align with the real registry to avoid misleading users.
| The platform supports **26 built-in metadata types** across 6 protocol domains: | |
| | Domain | Types | | |
| |:-------------|:----------------------------------------------------------------------------| | |
| | **Data** | `object`, `field`, `datasource`, `validation` | | |
| | **UI** | `view`, `app`, `dashboard`, `report`, `action`, `theme` | | |
| | **Automation** | `flow`, `workflow`, `trigger`, `schedule` | | |
| | **System** | `manifest`, `translation`, `api`, `permission_set`, `role`, `profile` | | |
| | **Security** | `permission_set`, `role` | | |
| | **AI** | `agent`, `rag_pipeline`, `model`, `prompt`, `tool` | | |
| Each type has a defined `loadOrder` (dependencies load before dependents), file patterns (e.g. `**/*.object.{ts,json,yaml}`), and overlay support flag. | |
| Metadata types are organized into protocol domains. The authoritative list of built-in types is defined by `DEFAULT_METADATA_TYPE_REGISTRY` in `@objectstack/spec/kernel/metadata-plugin.zod.ts`, but common examples include: | |
| | Domain | Example types | | |
| |:---------------|:---------------------------------------------------------------------------| | |
| | **Data** | `object`, `field`, `datasource`, `validation` | | |
| | **UI** | `view`, `page`, `app`, `dashboard`, `report`, `action`, `theme` | | |
| | **Automation** | `flow`, `workflow`, `trigger`, `approval`, `hook` | | |
| | **System** | `manifest`, `translation`, `api`, `router`, `function`, `service`, `role` | | |
| | **Security** | `permission`, `role` | | |
| | **AI** | `agent`, `rag_pipeline`, `model` | | |
| Each metadata type has a defined `loadOrder` (dependencies load before dependents), file patterns (e.g. `**/*.object.{ts,json,yaml}`), and overlay support flag, as specified in the `DEFAULT_METADATA_TYPE_REGISTRY`. |
Copilot
AI
Feb 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The “With Kernel Plugin” example calls MetadataPlugin({...}) like a factory function, but MetadataPlugin is exported as a class in this package. As written, the example won’t run; it should instantiate the plugin (or the package should export a factory with that name).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loader capability matrix marks DatabaseLoader as supporting Watch (✅), but the Phase 1 roadmap below defines its capabilities as
watch: false. Please make these docs consistent (either change the matrix to ❌/planned, or update the roadmap/tasks to reflect intended watch support).