Metadata Persistence
Metadata Persistence protocol schemas
Metadata Scope Enum
Defines the lifecycle and mutability of a metadata item.
Source: packages/spec/src/system/metadata-persistence.zod.ts
import { MetadataCollectionInfo, MetadataExportOptions, MetadataFallbackStrategy, MetadataFormat, MetadataImportOptions, MetadataLoadOptions, MetadataLoadResult, MetadataLoaderContract, MetadataManagerConfig, MetadataRecord, MetadataSaveOptions, MetadataSaveResult, MetadataScope, MetadataSource, MetadataState, MetadataStats, MetadataWatchEvent, PackagePublishResult } from '@objectstack/spec/system';
import type { MetadataCollectionInfo, MetadataExportOptions, MetadataFallbackStrategy, MetadataFormat, MetadataImportOptions, MetadataLoadOptions, MetadataLoadResult, MetadataLoaderContract, MetadataManagerConfig, MetadataRecord, MetadataSaveOptions, MetadataSaveResult, MetadataScope, MetadataSource, MetadataState, MetadataStats, MetadataWatchEvent, PackagePublishResult } from '@objectstack/spec/system';
// Validate data
const result = MetadataCollectionInfo.parse(data);
| Property | Type | Required | Description |
|---|
| type | string | ✅ | |
| count | number | ✅ | |
| namespaces | string[] | ✅ | |
| Property | Type | Required | Description |
|---|
| types | string[] | optional | |
| namespaces | string[] | optional | |
| output | string | ✅ | Output directory or file |
| format | Enum<'json' | 'yaml' | 'yml' | 'ts' | 'js' | 'typescript' | 'javascript'> | ✅ | |
json
yaml
yml
ts
js
typescript
javascript
| Property | Type | Required | Description |
|---|
| source | string | ✅ | Input directory or file |
| strategy | Enum<'merge' | 'replace' | 'skip'> | ✅ | |
| validate | boolean | ✅ | |
| Property | Type | Required | Description |
|---|
| scope | Enum<'system' | 'platform' | 'user'> | optional | |
| namespace | string | optional | |
| raw | boolean | optional | Return raw file content instead of parsed JSON |
| cache | boolean | optional | |
| useCache | boolean | optional | |
| validate | boolean | optional | |
| ifNoneMatch | string | optional | |
| recursive | boolean | optional | |
| limit | number | optional | |
| patterns | string[] | optional | |
| loader | string | optional | Specific loader to use (e.g. filesystem, database) |
| Property | Type | Required | Description |
|---|
| data | any | ✅ | |
| stats | Object | optional | |
| format | Enum<'json' | 'yaml' | 'yml' | 'ts' | 'js' | 'typescript' | 'javascript'> | optional | |
| source | string | optional | |
| fromCache | boolean | optional | |
| etag | string | optional | |
| notModified | boolean | optional | |
| loadTime | number | optional | |
| Property | Type | Required | Description |
|---|
| name | string | ✅ | |
| protocol | Enum<'file:' | 'http:' | 's3:' | 'datasource:' | 'memory:'> | ✅ | Loader protocol identifier |
| description | string | optional | |
| supportedFormats | string[] | optional | |
| supportsWatch | boolean | optional | |
| supportsWrite | boolean | optional | |
| supportsCache | boolean | optional | |
| capabilities | Object | ✅ | |
| Property | Type | Required | Description |
|---|
| datasource | string | optional | Datasource name reference for database persistence |
| tableName | string | ✅ | Database table name for metadata storage |
| fallback | Enum<'filesystem' | 'memory' | 'none'> | ✅ | Fallback strategy when datasource is unavailable |
| rootDir | string | optional | Root directory for filesystem-based metadata |
| formats | Enum<'json' | 'yaml' | 'yml' | 'ts' | 'js' | 'typescript' | 'javascript'>[] | optional | Enabled metadata formats |
| watch | boolean | optional | Enable file watching for filesystem loaders |
| cache | boolean | optional | Enable metadata caching |
| watchOptions | Object | optional | File watcher options |
| Property | Type | Required | Description |
|---|
| id | string | ✅ | |
| name | string | ✅ | |
| type | string | ✅ | |
| namespace | string | ✅ | |
| packageId | string | optional | Package ID that owns/delivered this metadata |
| managedBy | Enum<'package' | 'platform' | 'user'> | optional | Who manages this metadata record lifecycle |
| scope | Enum<'system' | 'platform' | 'user'> | ✅ | |
| metadata | Record<string, any> | ✅ | |
| extends | string | optional | Name of the parent metadata to extend/override |
| strategy | Enum<'merge' | 'replace'> | ✅ | |
| owner | string | optional | |
| state | Enum<'draft' | 'active' | 'archived' | 'deprecated'> | ✅ | |
| tenantId | string | optional | Tenant identifier for multi-tenant isolation |
| version | number | ✅ | Record version for optimistic concurrency control |
| checksum | string | optional | Content checksum for change detection |
| source | Enum<'filesystem' | 'database' | 'api' | 'migration'> | optional | Origin of this metadata record |
| tags | string[] | optional | Classification tags for filtering and grouping |
| publishedDefinition | any | optional | Snapshot of the last published definition |
| publishedAt | string | optional | When this metadata was last published |
| publishedBy | string | optional | Who published this version |
| createdBy | string | optional | |
| createdAt | string | optional | Creation timestamp |
| updatedBy | string | optional | |
| updatedAt | string | optional | Last update timestamp |
| Property | Type | Required | Description |
|---|
| format | Enum<'json' | 'yaml' | 'yml' | 'ts' | 'js' | 'typescript' | 'javascript'> | optional | |
| create | boolean | ✅ | |
| overwrite | boolean | ✅ | |
| path | string | optional | |
| prettify | boolean | optional | |
| indent | number | optional | |
| sortKeys | boolean | optional | |
| backup | boolean | optional | |
| atomic | boolean | optional | |
| loader | string | optional | Specific loader to use (e.g. filesystem, database) |
| Property | Type | Required | Description |
|---|
| success | boolean | ✅ | |
| path | string | optional | |
| stats | Object | optional | |
| etag | string | optional | |
| size | number | optional | |
| saveTime | number | optional | |
| backupPath | string | optional | |
filesystem
database
api
migration
draft
active
archived
deprecated
| Property | Type | Required | Description |
|---|
| path | string | optional | |
| size | number | optional | |
| mtime | string | optional | |
| hash | string | optional | |
| etag | string | optional | |
| modifiedAt | string | optional | |
| format | Enum<'json' | 'yaml' | 'yml' | 'ts' | 'js' | 'typescript' | 'javascript'> | optional | |
| Property | Type | Required | Description |
|---|
| type | Enum<'add' | 'change' | 'unlink' | 'added' | 'changed' | 'deleted'> | ✅ | |
| path | string | ✅ | |
| name | string | optional | |
| stats | Object | optional | |
| metadataType | string | optional | |
| data | any | optional | |
| timestamp | string | optional | |
| Property | Type | Required | Description |
|---|
| success | boolean | ✅ | Whether the publish succeeded |
| packageId | string | ✅ | The package ID that was published |
| version | integer | ✅ | New version number after publish |
| publishedAt | string | ✅ | Publish timestamp |
| itemsPublished | integer | ✅ | Total metadata items published |
| validationErrors | Object[] | optional | Validation errors if publish failed |