ObjectStackObjectStack

Metadata Persistence — System Protocol

Metadata Persistence schemas of the ObjectStack System Protocol — each property with its type, default and a TypeScript example.

Source: packages/spec/src/system/metadata-persistence.zod.ts

TypeScript Usage

import { MetadataCollectionInfoSchema, MetadataDiffResultSchema, MetadataFallbackStrategySchema, MetadataFormatSchema, MetadataHistoryQueryOptionsSchema, MetadataHistoryQueryResultSchema, MetadataHistoryRecordSchema, MetadataHistoryRetentionPolicySchema, MetadataLoadOptionsSchema, MetadataLoadResultSchema, MetadataLoaderContractSchema, MetadataManagerConfigSchema, MetadataRecordSchema, MetadataSaveOptionsSchema, MetadataSaveResultSchema, MetadataScopeSchema, MetadataSourceSchema, MetadataStateSchema, MetadataStatsSchema, MetadataWatchEventSchema, PackagePublishResultSchema } from '@objectstack/spec/system';
import type { MetadataCollectionInfo, MetadataDiffResult, MetadataFallbackStrategy, MetadataFormat, MetadataHistoryQueryOptions, MetadataHistoryQueryResult, MetadataHistoryRecord, MetadataHistoryRetentionPolicy, MetadataLoadOptions, MetadataLoadResult, MetadataLoaderContract, MetadataManagerConfig, MetadataRecord, MetadataSaveOptions, MetadataSaveResult, MetadataScope, MetadataSource, MetadataState, MetadataStats, MetadataWatchEvent, PackagePublishResult } from '@objectstack/spec/system';

// Validate data
const result = MetadataCollectionInfoSchema.parse(data);

MetadataCollectionInfo

Properties

PropertyTypeRequiredDescription
typestring✅
countnumber✅
namespacesstring[]✅

MetadataDiffResult

Properties

PropertyTypeRequiredDescription
typestring✅
namestring✅
version1number✅
version2number✅
checksum1string✅
checksum2string✅
identicalboolean✅
patchany[]optionalJSON patch operations
summarystringoptionalHuman-readable summary of changes

MetadataFallbackStrategy

Allowed Values

  • filesystem
  • memory
  • none

MetadataFormat

Metadata file format

Allowed Values

  • yaml
  • json
  • typescript
  • javascript

MetadataHistoryQueryOptions

Properties

PropertyTypeRequiredDescription
limitintegeroptionalMaximum number of history records to return
offsetintegeroptionalNumber of records to skip
sincestringoptionalOnly return history after this timestamp
untilstringoptionalOnly return history before this timestamp
operationTypeEnum<'create' | 'update' | 'publish' | 'revert' | 'delete'>optionalFilter by operation type
includeMetadatabooleanoptional (default: true)Include full metadata payload

MetadataHistoryQueryResult

Properties

PropertyTypeRequiredDescription
records{ id: string; name: string; type: string; version: number; … }[]✅
totalinteger✅
hasMoreboolean✅

Nested Shape: MetadataHistoryQueryResult.records[number]

PropertyTypeRequiredDescription
idstring✅
namestring✅
typestring✅
versionnumber✅Version number at this snapshot
operationTypeEnum<'create' | 'update' | 'publish' | 'revert' | 'delete'>✅Type of operation that created this history entry
metadatastring | Record<string, any> | nulloptionalSnapshot of metadata definition at this version (raw JSON string or parsed object)
checksumstring✅SHA-256 checksum of metadata content
previousChecksumstringoptionalChecksum of the previous version
changeNotestringoptionalDescription of changes made in this version
organizationIdstringoptionalOrganization identifier for multi-tenant isolation
environmentIdstringoptionalDeprecated (ADR-0006 v4): legacy environment_id column. New writes leave unset.
recordedBystringoptionalUser who made this change
recordedAtstring✅Timestamp when this version was recorded

MetadataHistoryRecord

Properties

PropertyTypeRequiredDescription
idstring✅
namestring✅
typestring✅
versionnumber✅Version number at this snapshot
operationTypeEnum<'create' | 'update' | 'publish' | 'revert' | 'delete'>✅Type of operation that created this history entry
metadatastring | Record<string, any> | nulloptionalSnapshot of metadata definition at this version (raw JSON string or parsed object)
checksumstring✅SHA-256 checksum of metadata content
previousChecksumstringoptionalChecksum of the previous version
changeNotestringoptionalDescription of changes made in this version
organizationIdstringoptionalOrganization identifier for multi-tenant isolation
environmentIdstringoptionalDeprecated (ADR-0006 v4): legacy environment_id column. New writes leave unset.
recordedBystringoptionalUser who made this change
recordedAtstring✅Timestamp when this version was recorded

MetadataHistoryRetentionPolicy

Properties

PropertyTypeRequiredDescription
maxVersionsintegeroptionalMaximum number of versions to retain
maxAgeDaysintegeroptionalMaximum age of history records in days
autoCleanupbooleanoptional (default: false)Enable automatic cleanup of old history
cleanupIntervalHoursintegeroptional (default: 24)How often to run cleanup (in hours)

MetadataLoadOptions

Properties

PropertyTypeRequiredDescription
scopeEnum<'system' | 'platform' | 'user'>optional
namespacestringoptional
rawbooleanoptionalReturn raw file content instead of parsed JSON
cachebooleanoptional
useCachebooleanoptional
validatebooleanoptional
ifNoneMatchstringoptional
recursivebooleanoptional
limitnumberoptional
patternsstring[]optional
loaderstringoptionalSpecific loader to use (e.g. filesystem, database)

MetadataLoadResult

Properties

PropertyTypeRequiredDescription
dataany✅
stats{ path?: string; size?: number; mtime?: string; hash?: string; … }optional
formatEnum<'yaml' | 'json' | 'typescript' | 'javascript'>optionalMetadata file format
sourcestringoptional
fromCachebooleanoptional
etagstringoptional
notModifiedbooleanoptional
loadTimeintegeroptionalHow long the load took, in milliseconds

Nested Shape: MetadataLoadResult.stats

PropertyTypeRequiredDescription
pathstringoptional
sizenumberoptional
mtimestringoptional
hashstringoptional
etagstringoptional
modifiedAtstringoptional
formatEnum<'yaml' | 'json' | 'typescript' | 'javascript'>optionalMetadata file format

MetadataLoaderContract

Properties

PropertyTypeRequiredDescription
namestring✅
protocolEnum<'file:' | 'http:' | 's3:' | 'datasource:' | 'memory:'>✅Loader protocol identifier
descriptionstringoptional
supportedFormatsstring[]optional
supportsWatchbooleanoptional
supportsWritebooleanoptional
supportsCachebooleanoptional
capabilities{ read?: boolean; write?: boolean; watch?: boolean; list?: boolean }✅

MetadataManagerConfig

Properties

PropertyTypeRequiredDescription
datasourcestringoptionalDatasource name reference for database persistence
tableNamestringoptional (default: "sys_metadata")Database table name for metadata storage
fallbackEnum<'filesystem' | 'memory' | 'none'>optional (default: "none")Fallback strategy when datasource is unavailable
rootDirstringoptionalRoot directory path
formatsEnum<'yaml' | 'json' | 'typescript' | 'javascript'>[]optional (default: ["typescript","json","yaml"])Enabled formats
cache{ databaseLoader?: object }optionalCache settings — only databaseLoader is read at runtime; the outer keys are retired
watchbooleanoptional (default: false)Enable file watching
watchOptions{ ignored?: string[]; persistent?: boolean; ignoreInitial?: boolean }optionalFile watcher options
validation{ strict?: boolean; throwOnError?: boolean }optionalValidation settings
loaderOptionsRecord<string, any>optionalLoader-specific configuration
persistence{ writable?: boolean }optionalPersistence write gates

Nested Shape: MetadataManagerConfig.cache

PropertyTypeRequiredDescription
enabledneveroptional[REMOVED] cache.enabled was removed from MetadataManagerConfig in @objectstack/spec 17 (ADR-0049 enforce-or-remove) — nothing ever read it: the outer cache block was declared and documented but consumed by no runtime, so enabled: false switched nothing off. Delete the key. The cache that actually runs is the DatabaseLoader read-through LRU under cache.databaseLoader; its enabled is the switch that is honoured.
ttlSecondsneveroptional[REMOVED] cache.ttlSeconds was removed from MetadataManagerConfig in @objectstack/spec 17 (ADR-0049 enforce-or-remove) — nothing ever read it: the outer cache block was declared and documented but consumed by no runtime, so the number expired nothing. Delete the key. The TTL that is honoured is cache.databaseLoader.ttlMs (milliseconds, default 60000) on the DatabaseLoader read-through cache.
ttlneveroptional[REMOVED] cache.ttl was removed from MetadataManagerConfig in @objectstack/spec 17 — nothing ever read it: the outer cache block was declared and documented but consumed by no runtime, and its unit-suffixed respelling ttlSeconds was retired with it before it shipped (ADR-0049 enforce-or-remove). Delete the key. The TTL that is honoured is cache.databaseLoader.ttlMs (milliseconds, default 60000) on the DatabaseLoader read-through cache.
maxSizeneveroptional[REMOVED] cache.maxSize was removed from MetadataManagerConfig in @objectstack/spec 17 (ADR-0049 enforce-or-remove) — nothing ever read it: the outer cache block was declared and documented but consumed by no runtime, so the byte cap capped nothing. Delete the key. The cap that is honoured is cache.databaseLoader.maxSize (an entry count, default 500) on the DatabaseLoader read-through cache.
databaseLoader{ enabled?: boolean; maxSize?: integer; ttlMs?: integer }optionalDatabaseLoader read-through cache

Nested Shape: MetadataManagerConfig.watchOptions

PropertyTypeRequiredDescription
ignoredstring[]optionalPatterns to ignore
persistentbooleanoptional (default: true)Keep process running
ignoreInitialbooleanoptional (default: true)Ignore initial add events

Nested Shape: MetadataManagerConfig.validation

PropertyTypeRequiredDescription
strictbooleanoptional (default: true)Strict validation
throwOnErrorbooleanoptional (default: true)Throw on validation error

Nested Shape: MetadataManagerConfig.persistence

PropertyTypeRequiredDescription
writablebooleanoptional (default: true)Allow base metadata writes via register()
overlayWritableneveroptional[REMOVED] persistence.overlayWritable was removed from MetadataManagerConfig in @objectstack/spec 17 (ADR-0049 enforce-or-remove) — the only thing it gated was MetadataManager.saveOverlay(), a paper-protocol method no route or UI ever called, removed with the metadata-customization protocol (ADR-0126 supersedes it on the record). Delete the key. The base write gate that remains is persistence.writable; the real org-overlay writes (ADR-0005) ride the REST meta write doors' manage_metadata permission gate, not this flag.

MetadataRecord

Properties

PropertyTypeRequiredDescription
idstring✅
namestring✅
typestring✅
namespacestringoptional (default: "default")
packageIdstringoptionalPackage ID that owns/delivered this metadata
managedByEnum<'package' | 'platform' | 'user'>optionalWho manages this metadata record lifecycle
scopeEnum<'system' | 'platform' | 'user'>optional (default: "platform")
metadataRecord<string, any>✅
extendsstringoptionalName of the parent metadata to extend/override
strategyEnum<'merge' | 'replace'>optional (default: "merge")
ownerstringoptional
stateEnum<'draft' | 'active' | 'archived' | 'deprecated'>optional (default: "active")
organizationIdstringoptionalOrganization identifier for multi-tenant isolation
tenantIdstringoptionalTenant identifier for multi-tenant isolation
environmentIdstringoptionalDeprecated (ADR-0006 v4): legacy environment_id column. New code must use organization_id only.
versionnumberoptional (default: 1)Record version for optimistic concurrency control
checksumstringoptionalContent checksum for change detection
sourceEnum<'filesystem' | 'database' | 'api' | 'migration'>optionalOrigin of this metadata record
tagsstring[]optionalClassification tags for filtering and grouping
publishedDefinitionanyoptionalSnapshot of the last published definition
publishedAtstringoptionalWhen this metadata was last published
publishedBystringoptionalWho published this version
createdBystringoptional
createdAtstringoptionalCreation timestamp
updatedBystringoptional
updatedAtstringoptionalLast update timestamp

MetadataSaveOptions

Properties

PropertyTypeRequiredDescription
formatEnum<'yaml' | 'json' | 'typescript' | 'javascript'>optionalMetadata file format
createbooleanoptional (default: true)
overwritebooleanoptional (default: true)
pathstringoptional
prettifybooleanoptional
indentnumberoptional
sortKeysbooleanoptional
backupbooleanoptional
atomicbooleanoptional
loaderstringoptionalSpecific loader to use (e.g. filesystem, database)

MetadataSaveResult

Properties

PropertyTypeRequiredDescription
successboolean✅
pathstringoptional
stats{ path?: string; size?: number; mtime?: string; hash?: string; … }optional
etagstringoptional
sizenumberoptional
saveTimeintegeroptionalHow long the save took, in milliseconds
backupPathstringoptional

Nested Shape: MetadataSaveResult.stats

PropertyTypeRequiredDescription
pathstringoptional
sizenumberoptional
mtimestringoptional
hashstringoptional
etagstringoptional
modifiedAtstringoptional
formatEnum<'yaml' | 'json' | 'typescript' | 'javascript'>optionalMetadata file format

MetadataScope

Allowed Values

  • system
  • platform
  • user

MetadataSource

Allowed Values

  • filesystem
  • database
  • api
  • migration

MetadataState

Allowed Values

  • draft
  • active
  • archived
  • deprecated

MetadataStats

Properties

PropertyTypeRequiredDescription
pathstringoptional
sizenumberoptional
mtimestringoptional
hashstringoptional
etagstringoptional
modifiedAtstringoptional
formatEnum<'yaml' | 'json' | 'typescript' | 'javascript'>optionalMetadata file format

MetadataWatchEvent

Properties

PropertyTypeRequiredDescription
typeEnum<'added' | 'changed' | 'deleted'>✅
pathstring✅
namestringoptional
stats{ path?: string; size?: number; mtime?: string; hash?: string; … }optional
metadataTypestringoptional
dataanyoptional
timestampstringoptional

Nested Shape: MetadataWatchEvent.stats

PropertyTypeRequiredDescription
pathstringoptional
sizenumberoptional
mtimestringoptional
hashstringoptional
etagstringoptional
modifiedAtstringoptional
formatEnum<'yaml' | 'json' | 'typescript' | 'javascript'>optionalMetadata file format

PackagePublishResult

Properties

PropertyTypeRequiredDescription
successboolean✅Whether the publish succeeded
packageIdstring✅The package ID that was published
versioninteger✅New version number after publish
publishedAtstring✅Publish timestamp
itemsPublishedinteger✅Total metadata items published
validationErrors{ type: string; name: string; message: string }[]optionalValidation errors if publish failed

Nested Shape: PackagePublishResult.validationErrors[number]

PropertyTypeRequiredDescription
typestring✅Metadata type that failed validation
namestring✅Item name that failed validation
messagestring✅Validation error message

On this page