SchemaMetadataManager
Class: SchemaMetadataManager
Manager for schema metadata persistence.
Handles:
- Per-model schema metadata storage and retrieval
- Namespace-level schema snapshots
- Conversion between runtime and storage formats
Constructors
new SchemaMetadataManager()
new SchemaMetadataManager(adapter): SchemaMetadataManagerParameters
| Parameter | Type |
|---|---|
adapter | FlashcoreAdapter<string, unknown> |
Returns
Methods
deleteModelMetadata()
deleteModelMetadata(modelName, namespace?): Promise<void>Delete schema metadata for a model.
Parameters
| Parameter | Type | Description |
|---|---|---|
modelName | string | Model name |
namespace? | string | Optional namespace |
Returns
Promise<void>
deleteSnapshot()
deleteSnapshot(namespace?): Promise<void>Delete the schema snapshot for a namespace.
Parameters
| Parameter | Type | Description |
|---|---|---|
namespace? | string | Namespace name (undefined for default) |
Returns
Promise<void>
getModelMetadata()
getModelMetadata(modelName, namespace?): Promise<SchemaMetadata>Get schema metadata for a model.
Parameters
| Parameter | Type | Description |
|---|---|---|
modelName | string | Model name |
namespace? | string | Optional namespace |
Returns
Promise<SchemaMetadata>
Schema metadata or null if not found
getSnapshot()
getSnapshot(namespace?): Promise<SchemaSnapshot>Get the schema snapshot for a namespace.
Parameters
| Parameter | Type | Description |
|---|---|---|
namespace? | string | Namespace name (undefined for default) |
Returns
Promise<SchemaSnapshot>
Schema snapshot or null if not found
hasModelMetadata()
hasModelMetadata(modelName, namespace?): Promise<boolean>Check if schema metadata exists for a model.
Parameters
| Parameter | Type | Description |
|---|---|---|
modelName | string | Model name |
namespace? | string | Optional namespace |
Returns
Promise<boolean>
setModelMetadata()
setModelMetadata(
modelName,
metadata,
namespace?): Promise<void>Store schema metadata for a model.
Parameters
| Parameter | Type | Description |
|---|---|---|
modelName | string | Model name |
metadata | SchemaMetadata | Schema metadata to store |
namespace? | string | Optional namespace |
Returns
Promise<void>
setSnapshot()
setSnapshot(snapshot, namespace?): Promise<void>Store a schema snapshot for a namespace.
Parameters
| Parameter | Type | Description |
|---|---|---|
snapshot | SchemaSnapshot | Schema snapshot to store |
namespace? | string | Namespace name (undefined for default) |
Returns
Promise<void>
computeCombinedChecksum()
static computeCombinedChecksum(models): stringCompute a combined checksum for multiple models.
Used for namespace-level snapshot checksums.
Parameters
| Parameter | Type | Description |
|---|---|---|
models | Record<string, SchemaMetadata> | Map of model name to schema metadata |
Returns
string
Combined checksum string
createInitialMetadata()
static createInitialMetadata(schema): SchemaMetadataCreate initial metadata for a new model.
Parameters
| Parameter | Type | Description |
|---|---|---|
schema | NormalizedSchema | Normalized schema |
Returns
Initial schema metadata
createSnapshot()
static createSnapshot(
models,
namespace,
version): SchemaSnapshotCreate a schema snapshot from multiple models.
Parameters
| Parameter | Type | Description |
|---|---|---|
models | Record<string, SchemaMetadata> | Map of model name to schema metadata |
namespace | string | Namespace name |
version | number | Snapshot version |
Returns
Schema snapshot
createUpdatedMetadata()
static createUpdatedMetadata(
schema,
previous,
migrationName?): SchemaMetadataCreate updated metadata after a schema change.
Parameters
| Parameter | Type | Description |
|---|---|---|
schema | NormalizedSchema | New normalized schema |
previous | SchemaMetadata | Previous schema metadata |
migrationName? | string | Optional migration name if applied by migration |
Returns
Updated schema metadata
schemaToMetadata()
static schemaToMetadata(
schema,
version,
migrationHistory): SchemaMetadataConvert a NormalizedSchema to SchemaMetadata for storage.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
schema | NormalizedSchema | undefined | Normalized schema from a model |
version | number | 1 | Version number (default 1 for new) |
migrationHistory | string[] | [] | List of applied migrations |
Returns
Schema metadata ready for storage
