Skip to Content
⚠️Active Development Notice: TimeTiles is under active development. Information may be placeholder content or not up-to-date.

web


web / lib/services/schema-versioning

lib/services/schema-versioning

Provides a centralized service for managing dataset schema versions.

This service contains a set of static methods to handle the lifecycle of dataset schemas. It ensures that schema versions are created and numbered consistently, whether through an automated process or manual approval. This consolidation prevents duplicate logic and race conditions.

Key responsibilities:

  • Determining the next available version number for a dataset’s schema.
  • Creating a new, versioned schema document in the database.
  • Linking an import job to the specific schema version it was validated against.

⚠️ Payload CMS Deadlock Prevention This service uses nested Payload operations and must receive the req parameter. See: apps/docs/content/developer-guide/development/payload-deadlocks.mdx

Classes

SchemaVersioningService

Consolidated schema versioning service to prevent duplicate creation and ensure consistent version numbering across auto and manual approval flows.

Constructors

Constructor

new SchemaVersioningService(): SchemaVersioningService

Returns

SchemaVersioningService

Methods

getNextSchemaVersion()

static getNextSchemaVersion(payload, datasetId, req?): Promise<number>

Get the next schema version number for a dataset.

Parameters
payload

BasePayload

datasetId

string | number

req?

PayloadRequest

Returns

Promise<number>

createSchemaVersion()

static createSchemaVersion(payload, __namedParameters): Promise<DatasetSchema>

Create a new schema version with consistent data structure.

Parameters
payload

BasePayload

__namedParameters
dataset

string | number | Dataset

schema

unknown

fieldMetadata?

Record<string, unknown> = {}

fieldMappings?

{ titlePath?: null | string; descriptionPath?: null | string; timestampPath?: null | string; }

fieldMappings.titlePath?

null | string

fieldMappings.descriptionPath?

null | string

fieldMappings.timestampPath?

null | string

autoApproved?

boolean = false

approvedBy?

null | string | number

importSources?

object[] = []

req?

PayloadRequest

Returns

Promise<DatasetSchema>

linkImportToSchemaVersion()

static linkImportToSchemaVersion(payload, importJobId, schemaVersionId, req?): Promise<void>

Link an import job to a schema version.

Parameters
payload

BasePayload

importJobId

string | number

schemaVersionId

string | number

req?

PayloadRequest

Returns

Promise<void>

Last updated on