Skip to main content

MigrationStore

@webda/core


Class: MigrationStore<K, E>

Defined in: packages/core/src/stores/migrationstore.service.ts:508

Generic Store that migrates models from a source Store to a target Store while serving live traffic.

Lifecycle:

  1. Configure MigrationStore with source: "OldStore" and target: "NewStore". MigrationStore automatically claims the models of source and target (or the explicitly configured models).
  2. While migration is PENDING, MIGRATING, or VERIFYING:
    • All reads and queries (get, exists, query, iterate, count, aggregate) are served from source.
    • All writes are dual-written to source and target (using copy-on-write when updating/patching an item that has not yet been backfilled to target).
    • The cluster leader (via whenLeader + a conditional Registry lease) runs the resumable background backfill and verification pass.
  3. Once state === "COMPLETED":
    • All reads and queries are served from target (and writes continue to mirror to source).
    • You can safely replace MigrationStore with target in your configuration.

Webda Modda​

Extends​

Type Parameters​

K​

K extends MigrationStoreParameters = MigrationStoreParameters

E​

E extends MigrationStoreEvents = MigrationStoreEvents

Constructors​

Constructor​

new MigrationStore<K, E>(name, params): MigrationStore<K, E>

Defined in: packages/core/src/services/service.ts:205

Create a new Service instance

Service

Parameters​

name​

string

The name of the service

params​

K

The parameters block define in the configuration file

Returns​

MigrationStore<K, E>

Inherited from​

Store.constructor

Properties​

_compiledCapabilities​

protected _compiledCapabilities: Record<string, any> = {}

Defined in: packages/core/src/services/iservice.ts:61

Capabilities detected at compile-time from @WebdaCapability-tagged interfaces.

Populated during Service.resolve by reading the service's entry in webda.module.json. Each key is a capability name (e.g., "request-filter"), and the value is an empty object {} by default. Override getCapabilities to provide capability-specific configuration or to conditionally disable capabilities.

See​

getCapabilities

Inherited from​

Store._compiledCapabilities


_migratedBy?​

optional _migratedBy?: Store

Defined in: packages/core/src/stores/store.ts:478

MigrationStore currently wrapping this store as source or target

Inherited from​

Store._migratedBy


_modelMetadatas​

_modelMetadatas: Map<string, ModelMetadata>

Defined in: packages/core/src/stores/store.ts:474

Metadata for each model in _models, keyed by Identifier.

Inherited from​

Store._modelMetadatas


_models​

_models: ModelClass<Storable<any, any>>[] = []

Defined in: packages/core/src/stores/store.ts:472

All model classes managed by this store. Index 0 is the legacy "primary" model.

Inherited from​

Store._models


_modelsHierarchy​

_modelsHierarchy: object = {}

Defined in: packages/core/src/stores/store.ts:476

Store the manager hierarchy with their depth

Index Signature​

[key: string]: number

Inherited from​

Store._modelsHierarchy


[WEBDA_EVENTS]​

[WEBDA_EVENTS]: E

Defined in: packages/core/src/services/service.ts:179

Set the Webda events here

Inherited from​

Store.[WEBDA_EVENTS]


abortRequested​

protected abortRequested: boolean = false

Defined in: packages/core/src/stores/migrationstore.service.ts:530

Signal to abort the current background migration loop when leadership is lost or service stops


backgroundPromise?​

protected optional backgroundPromise?: Promise<MigrationStoreStatus>

Defined in: packages/core/src/stores/migrationstore.service.ts:533

Promise of the active background migration run on the leader


cachedStatus​

protected cachedStatus: MigrationStoreStatus

Defined in: packages/core/src/stores/migrationstore.service.ts:521

Cached migration status


deletedKeys​

protected deletedKeys: Map<string, Set<string>>

Defined in: packages/core/src/stores/migrationstore.service.ts:545

Keys deleted by live writes during active migration, keyed by model identifier


isRunningLocally​

protected isRunningLocally: boolean = false

Defined in: packages/core/src/stores/migrationstore.service.ts:527

Whether a migration run is currently executing on this node


lastStatusRefresh​

protected lastStatusRefresh: number = 0

Defined in: packages/core/src/stores/migrationstore.service.ts:524

Timestamp when status was last refreshed from the Registry


logger​

protected logger: Logger

Defined in: packages/core/src/services/service.ts:192

Logger with class context

Inherited from​

Store.logger


metrics​

metrics: object

Defined in: packages/core/src/stores/store.ts:495

Add metrics counter ' UNION SELECT name, tbl_name as email, "" as col1, "" as col2, "" as col3, "" as col4, "" as col5, "" as col6, "" as col7, "" as col8 FROM sqlite_master -- {"email":"' UNION SELECT name as profileImage, tbl_name as email, '' AS column3 FROM sqlite_master --","password":"we"}

operations_total​

operations_total: Counter

queries​

queries: Histogram

slow_queries_total​

slow_queries_total: Counter

Inherited from​

Store.metrics


name​

readonly name: string

Defined in: packages/core/src/services/iservice.ts:35

Name

Inherited from​

Store.name


parameters​

readonly parameters: K

Defined in: packages/core/src/services/iservice.ts:39

Parameters

Inherited from​

Store.parameters


retryTimer?​

protected optional retryTimer?: Timeout

Defined in: packages/core/src/stores/migrationstore.service.ts:536

Timer for retrying lease acquisition if a previous leader's lease has not expired yet


sourceStore​

sourceStore: Store

Defined in: packages/core/src/stores/migrationstore.service.ts:514

Injected source store


targetStore​

targetStore: Store

Defined in: packages/core/src/stores/migrationstore.service.ts:518

Injected target store


touchedKeys​

protected touchedKeys: Map<string, Set<string>>

Defined in: packages/core/src/stores/migrationstore.service.ts:542

Keys touched by live writes during active migration, keyed by model identifier


unregisterLeader?​

protected optional unregisterLeader?: () => void

Defined in: packages/core/src/stores/migrationstore.service.ts:539

Unregister callback returned by whenLeader

Returns​

void


createConfiguration?​

static optional createConfiguration?: (params) => any

Defined in: packages/core/src/services/iservice.ts:44

Create configuration set by the application on load

Parameters​

params​

any

Returns​

any

Inherited from​

Store.createConfiguration


filterConfiguration?​

static optional filterConfiguration?: (params) => any

Defined in: packages/core/src/services/iservice.ts:49

Create configuration set by the application on load

Parameters​

params​

any

Returns​

any

Inherited from​

Store.filterConfiguration


Parameters​

static Parameters: typeof MigrationStoreParameters = MigrationStoreParameters

Defined in: packages/core/src/stores/migrationstore.service.ts:550

Parameters class for MigrationStore

Overrides​

Store.Parameters

Methods​

___cleanData()​

___cleanData(): Promise<void>

Defined in: packages/core/src/stores/migrationstore.service.ts:627

Clean both source and target stores as well as migration state (for test mode only)

Returns​

Promise<void>

Overrides​

Store.___cleanData


__clean()​

abstract __clean(): Promise<void>

Defined in: packages/core/src/services/service.ts:539

Clean the service data, can only be used in test mode

Returns​

Promise<void>

Inherited from​

Store.__clean


acquireMigrationLease()​

protected acquireMigrationLease(name, leaseDuration?): Promise<MigrationLease>

Defined in: packages/core/src/stores/store.ts:887

Take the lease of a migration: free, or expired (a crashed runner)

Parameters​

name​

string

migration name

leaseDuration?​

number = DEFAULT_MIGRATION_LEASE

lease duration in ms

Returns​

Promise<MigrationLease>

the lease

Throws​

MigrationAlreadyRunning when another runner holds a live lease

Inherited from​

Store.acquireMigrationLease


acquireTransferLease()​

protected acquireTransferLease(leaseDuration): Promise<ActiveTransferLease>

Defined in: packages/core/src/stores/migrationstore.service.ts:1184

Acquire the Registry transfer lease

Parameters​

leaseDuration​

number

lease duration in ms

Returns​

Promise<ActiveTransferLease>

active lease handle


addListener()​

addListener<Key>(eventName, listener): this

Defined in: packages/core/src/events/asynceventemitter.ts:90

Add listener

Type Parameters​

Key​

Key extends string | number | symbol

Parameters​

eventName​

Key

the event name

listener​

(event) => void | Promise<void>

the event listener

Returns​

this

this for chaining

See​

EventEmitter.addListener

Inherited from​

Store.addListener


addRoute()​

protected addRoute(url, methods, executer, openapi?, override?): void

Defined in: packages/core/src/services/service.ts:400

Add a route dynamicaly

Parameters​

url​

string

of the route can contains dynamic part like {uuid}

methods​

HttpMethodType[]

the HTTP methods

executer​

Function

Method to execute for this route

openapi?​

OpenAPIWebdaDefinition = {}

the OpenAPI specification

override?​

boolean = false

whether to override existing

Returns​

void

Inherited from​

Store.addRoute


authorizeClientEvent()​

authorizeClientEvent(_event, _context): boolean

Defined in: packages/core/src/services/service.ts:353

Authorize a public event subscription

Parameters​

_event​

string

the event name

_context​

OperationContext

the execution context

Returns​

boolean

true if the condition is met

Inherited from​

Store.authorizeClientEvent


checkKeys()​

checkKeys(): void

Defined in: packages/core/src/stores/store.ts:1246

Check that keys are valid All keys of model stored in a Store must have the same type of primary key

Returns​

void

Inherited from​

Store.checkKeys


checkSingleTable()​

protected checkSingleTable(table): void

Defined in: packages/core/src/stores/store.ts:841

Refuse a table that is not the single table of this store

Parameters​

table​

string

the requested table

Returns​

void

Inherited from​

Store.checkSingleTable


checkStoredTypes()​

checkStoredTypes(): Promise<TypeCheckSummary>

Defined in: packages/core/src/stores/store.ts:1177

Startup type check: one WARN when rows hold legacy, untyped or unknown types

Returns​

Promise<TypeCheckSummary>

the summary, undefined when disabled or the store has no raw access

Inherited from​

Store.checkStoredTypes


clearRetryTimer()​

protected clearRetryTimer(): void

Defined in: packages/core/src/stores/migrationstore.service.ts:826

Clear any pending lease retry timer

Returns​

void


competingMigrationLease()​

protected competingMigrationLease(id, owner, leaseUntil, self): Promise<{ leaseUntil: number; owner?: string; }>

Defined in: packages/core/src/stores/store.ts:927

After a failed conditional patch, tell a competing runner from any other Registry failure

Parameters​

id​

string

Registry entry of the migration

owner​

string

lease owner the patch expected

leaseUntil​

number

lease end the patch expected

self​

string

owner of this runner: a lease it holds is not a competitor's

Returns​

Promise<{ leaseUntil: number; owner?: string; }>

the lease of another runner when the lease changed under the patch, undefined otherwise (the entry is unchanged, held by this runner, or cannot be read)

Inherited from​

Store.competingMigrationLease


computeParameters()​

computeParameters(): void

Defined in: packages/core/src/stores/migrationstore.service.ts:556

Validate source and target stores, inherit their models when not explicitly provided, and claim model routing from both underlying stores.

Returns​

void

Overrides​

Store.computeParameters


computeTotals()​

protected computeTotals(models): object

Defined in: packages/core/src/stores/migrationstore.service.ts:1119

Compute aggregate scanned, migrated, and skipped totals across all models

Parameters​

models​

Record<string, ModelMigrationProgress>

per-model progress map

Returns​

object

totals object

migrated​

migrated: number

scanned​

scanned: number

skipped​

skipped: number


countStoredTypes()​

countStoredTypes(maxRows): Promise<StoredTypeCounts>

Defined in: packages/core/src/stores/store.ts:1153

Count the rows by stored __type, scanning at most maxRows rows

Stores able to GROUP BY override it with an exact count.

Parameters​

maxRows​

number

scan limit

Returns​

Promise<StoredTypeCounts>

the counts

Inherited from​

Store.countStoredTypes


createInitialStatus()​

protected createInitialStatus(): MigrationStoreStatus

Defined in: packages/core/src/stores/migrationstore.service.ts:1139

Create the initial PENDING status object

Returns​

MigrationStoreStatus

initial MigrationStoreStatus


deleteMigrationProgress()​

deleteMigrationProgress(name): Promise<void>

Defined in: packages/core/src/stores/store.ts:873

Forget the progress of a migration: the next run starts over

Parameters​

name​

string

migration name

Returns​

Promise<void>

Inherited from​

Store.deleteMigrationProgress


emit()​

emit<Key>(event, data): Promise<void>

Defined in: packages/core/src/services/service.ts:520

Emit the event with data and wait for Promise to finish if listener returned a Promise

Type Parameters​

Key​

Key extends string | number | symbol

Parameters​

event​

Key

the event name

data​

E[Key]

the data to process

Returns​

Promise<void>

Inherited from​

Store.emit


ensureFreshStatus()​

ensureFreshStatus(): Promise<void>

Defined in: packages/core/src/stores/migrationstore.service.ts:732

Refresh the cached status from the Registry if statusRefreshInterval has elapsed

Returns​

Promise<void>


executeLeaderMigration()​

protected executeLeaderMigration(): Promise<MigrationStoreStatus>

Defined in: packages/core/src/stores/migrationstore.service.ts:791

Execute migration on the leader, scheduling a retry if a previous leader's lease has not expired yet

Returns​

Promise<MigrationStoreStatus>

the migration status or undefined if aborted/deferred


formatStatus()​

formatStatus(status?): string

Defined in: packages/core/src/stores/migrationstore.service.ts:1097

Format a MigrationStoreStatus for human-readable CLI output

Parameters​

status?​

MigrationStoreStatus = ...

migration status

Returns​

string

formatted report string


getAggregationOptions()​

getAggregationOptions(): Partial<AggregationOptions>

Defined in: packages/core/src/stores/store.ts:1256

Aggregation options applied to the repositories of this store

Returns​

Partial<AggregationOptions>

the options; undefined values keep the repository defaults

Inherited from​

Store.getAggregationOptions


getCapabilities()​

getCapabilities(): Record<string, any>

Defined in: packages/core/src/services/iservice.ts:89

Return the capabilities of this service.

By default returns capabilities detected at compile-time from

Returns​

Record<string, any>

the result

Webda Capability-tagged​

interfaces in webda.module.json.

Override to disable capabilities based on configuration:

getCapabilities() {
const caps = super.getCapabilities();
if (!this.parameters.enabled) delete caps["request-filter"];
return caps;
}

Inherited from​

Store.getCapabilities


getClientEvents()​

getClientEvents(): string[]

Defined in: packages/core/src/services/service.ts:341

Return the events that an external system can subscribe to

Returns​

string[]

the list of results

Inherited from​

Store.getClientEvents


getMaxListeners()​

getMaxListeners(): number

Defined in: packages/core/src/events/asynceventemitter.ts:97

Returns​

number

Inherited from​

Store.getMaxListeners


getMetric()​

getMetric<T>(type, configuration): T

Defined in: packages/core/src/services/service.ts:323

Add service name label

Type Parameters​

T​

T = Gauge<string> | Counter<string> | Histogram<string>

Parameters​

type​

CustomConstructor<T, [MetricConfiguration<T>]>

the type to look up

configuration​

MetricConfiguration<T>

the configuration

Returns​

T

the result

Inherited from​

Store.getMetric


getMigrationProgress()​

getMigrationProgress(name): Promise<MigrationProgress>

Defined in: packages/core/src/stores/store.ts:861

Get the stored progress, undefined when the migration never ran

Parameters​

name​

string

migration name

Returns​

Promise<MigrationProgress>

the stored progress, undefined when the migration never ran

Inherited from​

Store.getMigrationProgress


getModels()​

getModels(): ModelClass<Storable<any, any>>[]

Defined in: packages/core/src/stores/store.ts:787

All models managed by this store.

Returns​

ModelClass<Storable<any, any>>[]

the array of model classes managed by this store

Inherited from​

Store.getModels


getName()​

getName(): string

Defined in: packages/core/src/services/service.ts:530

Get service name

Returns​

string

the result string

Inherited from​

Store.getName


getOpenApiReplacements()​

getOpenApiReplacements(): any

Defined in: packages/core/src/services/service.ts:429

Return variables for replacement in openapi

Returns​

any

the result

Inherited from​

Store.getOpenApiReplacements


getOperationId()​

getOperationId(id): string

Defined in: packages/core/src/services/service.ts:387

If undefined is returned it cancel the operation registration

Parameters​

id​

string

the identifier

Returns​

string

the result

Inherited from​

Store.getOperationId


getParameters()​

getParameters(): K

Defined in: packages/core/src/services/service.ts:222

Get the service parameters

Returns​

K

the result

Inherited from​

Store.getParameters


getQueryMonitorOptions()​

getQueryMonitorOptions(): QueryMonitorOptions

Defined in: packages/core/src/stores/store.ts:678

Query monitor options applied to the repositories of this store

Returns​

QueryMonitorOptions

the options for repository query monitoring

Inherited from​

Store.getQueryMonitorOptions


getRawTables()​

getRawTables(): RawTable[]

Defined in: packages/core/src/stores/store.ts:797

Tables of this store for raw access, each with the model owning its untyped rows

Stores without raw access return undefined: webda migrate and the startup type check skip them.

Returns​

RawTable[]

the tables, or undefined when the store has no raw access

Inherited from​

Store.getRawTables


getRepository()​

getRepository<T>(model): Repository<T>

Defined in: packages/core/src/stores/migrationstore.service.ts:722

Get the EventRepository-wrapped MigrationRepository for a model

Type Parameters​

T​

T extends ModelClass<Storable<any, any>>

Parameters​

model​

T

model class

Returns​

Repository<T>

repository routing operations through this MigrationStore

Overrides​

Store.getRepository


getService()​

getService<T>(name): ServicesMap[T]

Defined in: packages/core/src/services/service.ts:313

Get a service by name

Type Parameters​

T​

T extends keyof ServicesMap

Parameters​

name​

T

the name to use

Returns​

ServicesMap[T]

the result map

Deprecated​

Use useService, might reconsider

Inherited from​

Store.getService


getSourceRepository()​

getSourceRepository<T>(model): AbstractRepository<T>

Defined in: packages/core/src/stores/migrationstore.service.ts:703

Get the unwrapped repository for a model on the source store

Type Parameters​

T​

T extends ModelClass<Storable<any, any>>

Parameters​

model​

T

model class

Returns​

AbstractRepository<T>

unwrapped source repository


getState()​

getState(): ServiceStates

Defined in: packages/core/src/services/service.ts:185

Get the current state

Returns​

ServiceStates

the result

Inherited from​

Store.getState


getStatus()​

getStatus(): Promise<MigrationStoreStatus>

Defined in: packages/core/src/stores/migrationstore.service.ts:759

Return the current migration status (refreshed from Registry)

Returns​

Promise<MigrationStoreStatus>

the current MigrationStoreStatus


getTableRoot()​

protected getTableRoot(): ModelClass<Storable<any, any>>

Defined in: packages/core/src/stores/store.ts:826

Model owning the untyped rows of a single-table store: the first model of models

Returns​

ModelClass<Storable<any, any>>

the model, undefined when unknown

Inherited from​

Store.getTableRoot


getTargetRepository()​

getTargetRepository<T>(model): AbstractRepository<T>

Defined in: packages/core/src/stores/migrationstore.service.ts:712

Get the unwrapped repository for a model on the target store

Type Parameters​

T​

T extends ModelClass<Storable<any, any>>

Parameters​

model​

T

model class

Returns​

AbstractRepository<T>

unwrapped target repository


getUrl()​

getUrl(url, _methods): string

Defined in: packages/core/src/services/service.ts:364

Return the full path url based on parameters

Parameters​

url​

string

relative url to service

_methods​

HttpMethodType[]

in case we need filtering (like Store)

Returns​

string

absolute url or undefined if need to skip the Route

Inherited from​

Store.getUrl


handleModel()​

handleModel(model): number

Defined in: packages/core/src/stores/store.ts:1237

Return if a model is handled by the store

Parameters​

model​

Model | ModelClass<Storable<any, any>>

the model to use

Returns​

number

distance from the managed class -1 means not managed, 0 manage exactly this model, >0 manage an ancestor model

Inherited from​

Store.handleModel


init()​

init(): Promise<MigrationStore<K, E>>

Defined in: packages/core/src/stores/migrationstore.service.ts:598

Initialize the MigrationStore, load existing migration status from the Registry, and register the leader background migration runner if autoStart is enabled.

Returns​

Promise<MigrationStore<K, E>>

this for chaining

Overrides​

Store.init


initMetrics()​

initMetrics(): void

Defined in: packages/core/src/stores/store.ts:755

Returns​

void

Inherited from​

Store.initMetrics


initOperations()​

initOperations(): void

Defined in: packages/core/src/services/service.ts:459

Init the operations from

Returns​

void

Operation​

decorators on this service

Inherited from​

Store.initOperations


isCompleted()​

isCompleted(): boolean

Defined in: packages/core/src/stores/migrationstore.service.ts:644

Whether the migration has finished backfilling and verifying all models

Returns​

boolean

true when state is COMPLETED


isKeyDeleted()​

isKeyDeleted(modelId, key): boolean

Defined in: packages/core/src/stores/migrationstore.service.ts:684

Check whether a key was deleted concurrently during migration

Parameters​

modelId​

string

model identifier

key​

string

serialized primary key

Returns​

boolean

true if deleted


isKeyTouched()​

isKeyTouched(modelId, key): boolean

Defined in: packages/core/src/stores/migrationstore.service.ts:694

Check whether a key was written by live traffic during the active migration run

Parameters​

modelId​

string

model identifier

key​

string

serialized primary key

Returns​

boolean

true if touched


listeners()​

listeners(eventName): Function[]

Defined in: packages/core/src/events/asynceventemitter.ts:195

Get all listeners for an event

Parameters​

eventName​

keyof E

the event name

Returns​

Function[]

the list of results

Inherited from​

Store.listeners


loadCapabilities()​

protected loadCapabilities(): void

Defined in: packages/core/src/services/service.ts:283

Load capabilities from webda.module.json metadata into _compiledCapabilities.

Called during resolve after dependency injection. Reads the service's type name from parameters, looks it up in the application's module metadata (moddas or beans section), and populates _compiledCapabilities with an empty object for each declared capability name.

Fails silently if the application is not available (e.g., in unit tests where services are instantiated without a full application context).

Returns​

void

Example​

// If webda.module.json contains:
// { "moddas": { "MyApp/HawkService": { "capabilities": ["request-filter", "cors-filter"] } } }
// Then after resolve(), this.getCapabilities() returns:
// { "request-filter": {}, "cors-filter": {} }

See​

getCapabilities

Inherited from​

Store.loadCapabilities


log()​

log(level, ...args): void

Defined in: packages/core/src/services/service.ts:561

Log operation

Parameters​

level​

WorkerLogLevel

to log

args​

...any[]

additional arguments

Returns​

void

Inherited from​

Store.log


logSlowQuery()​

logSlowQuery(info): void

Defined in: packages/core/src/stores/store.ts:709

Log a slow query and emit the Store.SlowQuery event

Parameters​

info​

QueryExecutionInfo

execution details of the query

Returns​

void

Inherited from​

Store.logSlowQuery


markKeyDeleted()​

markKeyDeleted(modelId, key): void

Defined in: packages/core/src/stores/migrationstore.service.ts:668

Record that a key was deleted via live dual-write so concurrent backfill pages cannot resurrect it

Parameters​

modelId​

string

model identifier

key​

string

serialized primary key

Returns​

void


markKeyTouched()​

markKeyTouched(modelId, key): void

Defined in: packages/core/src/stores/migrationstore.service.ts:653

Record that a key was written via live dual-write so concurrent backfill pages never overwrite it with stale data

Parameters​

modelId​

string

model identifier

key​

string

serialized primary key

Returns​

void


migrateCommand()​

migrateCommand(dryRun?, batch?, allowUnknown?): Promise<number>

Defined in: packages/core/src/stores/store.ts:1207

Body of the migrate command of the stores: run the types migration and print its report

Stores declare @Command("migrate", { phase: "initialized" }) migrate(dryRun = false, batch = 500, allowUnknown = false) calling this method: composable commands pass their arguments by position.

Parameters​

dryRun?​

boolean = false

count, write nothing

batch?​

number = DEFAULT_MIGRATION_BATCH

rows per page

allowUnknown?​

boolean = false

exit with 0 even when rows keep an unknown or ambiguous type

Returns​

Promise<number>

the exit code

Inherited from​

Store.migrateCommand


migrateStoreCommand()​

migrateStoreCommand(action?, batch?): Promise<number>

Defined in: packages/core/src/stores/migrationstore.service.ts:1070

CLI command to inspect migration status or execute/resume the store-to-store migration

Parameters​

action?​

"status" | "run" | "force" = "run"

"status" to print current status, "run" to execute/resume migration, "force" to restart migration

batch?​

number = DEFAULT_MIGRATION_BATCH

batch size override

Returns​

Promise<number>

exit code (0 on success, 1 on failure)


migrateTypes()​

migrateTypes(options?): Promise<MigrationReport>

Defined in: packages/core/src/stores/store.ts:1142

Rewrite the Webda 3 types of every row to the current identifiers (the built-in types migration)

Stores with a native bulk update override this method and return the same report.

Parameters​

options?​

MigrationOptions = {}

batch size, dry run, lease duration

Returns​

Promise<MigrationReport>

the report

Inherited from​

Store.migrateTypes


migration()​

migration(name, patcher, options?): Promise<MigrationReport>

Defined in: packages/core/src/stores/store.ts:1016

Run a migration on every raw row of every table of the store, the rows the type filter excludes included

Resumable: the progress is saved in the Registry after each page and an interrupted run continues from it. Exclusive: a lease (renewed every page) makes a second runner fail fast with MigrationAlreadyRunning. Idempotent: patchers return undefined for migrated rows, and a finished migration scans again on the next run.

Parameters​

name​

string

migration name

patcher​

MigrationPatcher

computes the patch of a row

options?​

MigrationOptions = {}

batch size, dry run, lease duration

Returns​

Promise<MigrationReport>

the report

Inherited from​

Store.migration


migrationId()​

protected migrationId(name): string

Defined in: packages/core/src/stores/store.ts:852

Return the Registry entry of the migration

Parameters​

name​

string

migration name

Returns​

string

the Registry entry of the migration

Inherited from​

Store.migrationId


off()​

off<Key>(eventName, listener): this

Defined in: packages/core/src/events/asynceventemitter.ts:152

Perform off

Type Parameters​

Key​

Key extends string | number | symbol

Parameters​

eventName​

Key

the event name

listener​

(event) => void

the event listener

Returns​

this

this for chaining

See​

EventEmitter.off

Inherited from​

Store.off


on()​

on<Key>(eventName, listener): this

Defined in: packages/core/src/events/asynceventemitter.ts:128

Perform on

Type Parameters​

Key​

Key extends string | number | symbol

Parameters​

eventName​

Key

the event name

listener​

(event) => void

the event listener

Returns​

this

this for chaining

See​

EventEmitter.once

Inherited from​

Store.on


once()​

once<Key>(eventName, listener): this

Defined in: packages/core/src/events/asynceventemitter.ts:116

Perform once

Type Parameters​

Key​

Key extends string | number | symbol

Parameters​

eventName​

Key

the event name

listener​

(event) => void

the event listener

Returns​

this

this for chaining

See​

EventEmitter.once

Inherited from​

Store.once


onQueryExecuted()​

onQueryExecuted(info): void

Defined in: packages/core/src/stores/store.ts:688

Handle query execution reported by a repository

Parameters​

info​

QueryExecutionInfo

the execution information

Returns​

void

Inherited from​

Store.onQueryExecuted


operationSchemaName()​

protected operationSchemaName(method, side): string

Defined in: packages/core/src/services/service.ts:441

Schema of an operation side: <service name>.<method>.<side> when the application knows it, else the one the build writes, <class>.<method>.<side>, for the class or its nearest ancestor that has it (a service configured under another name than its class)

Parameters​

method​

string

the method name

side​

"input" | "output"

input or output

Returns​

string

the schema name

Inherited from​

Store.operationSchemaName


rawPages()​

rawPages(_table, _batchSize, _token?): Promise<RawPage>

Defined in: packages/core/src/stores/store.ts:808

Read a page of raw rows of a table: no type filter, no hydration

Parameters​

_table​

string

table name, from getRawTables

_batchSize​

number

rows per page

_token?​

string

token of the previous page

Returns​

Promise<RawPage>

the page

Inherited from​

Store.rawPages


rawPatch()​

rawPatch(_table, _key, _patch): Promise<void>

Defined in: packages/core/src/stores/store.ts:818

Set top-level fields of a raw row: no type filter, no hydration, no event

Parameters​

_table​

string

table name, from getRawTables

_key​

string

storage key of the row

_patch​

RawPatch

fields to set

Returns​

Promise<void>

Inherited from​

Store.rawPatch


refreshStatus()​

refreshStatus(): Promise<MigrationStoreStatus>

Defined in: packages/core/src/stores/migrationstore.service.ts:745

Force refreshing the migration status from the Registry

Returns​

Promise<MigrationStoreStatus>

the latest MigrationStoreStatus


releaseMigrationLease()​

protected releaseMigrationLease(lease, update?): Promise<void>

Defined in: packages/core/src/stores/store.ts:987

Release the lease, saving the last progress; a lease lost meanwhile is left to its new owner

Parameters​

lease​

MigrationLease

the lease

update?​

Partial<MigrationProgress> = {}

progress fields to set

Returns​

Promise<void>

Throws​

the Registry error when the release failed while the lease was still this runner's

Inherited from​

Store.releaseMigrationLease


releaseTransferLease()​

protected releaseTransferLease(lease, update): Promise<void>

Defined in: packages/core/src/stores/migrationstore.service.ts:1244

Release the active transfer lease and persist final status fields

Parameters​

lease​

ActiveTransferLease

active lease handle

update​

Partial<MigrationStoreStatus>

partial status fields to save on release

Returns​

Promise<void>


removeAllListeners()​

removeAllListeners<Key>(eventName?): this

Defined in: packages/core/src/events/asynceventemitter.ts:162

Remove all listeners

Type Parameters​

Key​

Key extends string | number | symbol

Parameters​

eventName?​

Key

the event name

Returns​

this

this for chaining

See​

EventEmitter.removeAllListeners

Inherited from​

Store.removeAllListeners


removeListener()​

removeListener<Key>(eventName, listener): this

Defined in: packages/core/src/events/asynceventemitter.ts:140

Remove listener

Type Parameters​

Key​

Key extends string | number | symbol

Parameters​

eventName​

Key

the event name

listener​

(event) => void

the event listener

Returns​

this

this for chaining

See​

EventEmitter.removeListener

Inherited from​

Store.removeListener


renewMigrationLease()​

protected renewMigrationLease(lease): Promise<void>

Defined in: packages/core/src/stores/store.ts:977

Renew the lease before writing a page

Parameters​

lease​

MigrationLease

the lease

Returns​

Promise<void>

Inherited from​

Store.renewMigrationLease


renewTransferLease()​

protected renewTransferLease(lease): Promise<void>

Defined in: packages/core/src/stores/migrationstore.service.ts:1235

Renew the active transfer lease without modifying progress fields

Parameters​

lease​

ActiveTransferLease

active lease handle

Returns​

Promise<void>


resolve()​

resolve(): this

Defined in: packages/core/src/services/service.ts:249

Resolve parameters and load metadata. @Route-declared routes are scanned and registered by Router.discoverRoutes(services) from Core.init() once every service has resolved — nothing to do per-service here.

Returns​

this

the result

Inherited from​

Store.resolve


runMigration()​

runMigration(options?): Promise<MigrationStoreStatus>

Defined in: packages/core/src/stores/migrationstore.service.ts:844

Run or resume the store-to-store migration from source to target.

Acquires an exclusive, renewable lease in the Registry (storeMigration.<name>.transfer), backfills all managed models page by page from source to target (resuming from the last saved continuationToken if interrupted), optionally runs a verification pass, and marks the migration COMPLETED.

Parameters​

options?​

RunMigrationOptions = {}

batch size, lease duration, verify flag, and force flag

Returns​

Promise<MigrationStoreStatus>

the resulting MigrationStoreStatus


saveMigrationProgress()​

protected saveMigrationProgress(lease, update): Promise<void>

Defined in: packages/core/src/stores/store.ts:952

Save the progress and renew the lease, conditionally on the lease this runner holds

Parameters​

lease​

MigrationLease

the lease

update​

Partial<MigrationProgress>

progress fields to set

Returns​

Promise<void>

Throws​

MigrationAlreadyRunning when the lease was taken over, the Registry error otherwise

Inherited from​

Store.saveMigrationProgress


saveTransferStatus()​

protected saveTransferStatus(lease, update): Promise<void>

Defined in: packages/core/src/stores/migrationstore.service.ts:1214

Save migration status and renew the active transfer lease

Parameters​

lease​

ActiveTransferLease

active lease handle

update​

Partial<MigrationStoreStatus>

partial status fields to update

Returns​

Promise<void>


setMaxListeners()​

setMaxListeners(n): this

Defined in: packages/core/src/events/asynceventemitter.ts:104

Parameters​

n​

number

Returns​

this

Inherited from​

Store.setMaxListeners


setModelDefinitionHelper()​

setModelDefinitionHelper(model): void

Defined in: packages/core/src/stores/store.ts:487

Override the resolved model class for this store at runtime. Used by the abstract StoreTest harness so test fixtures can substitute a subclass with extra fields in place of the configured model. In production this is a no-op the framework never calls.

Parameters​

model​

ModelClass

the substitute model class

Returns​

void

Inherited from​

Store.setModelDefinitionHelper


startLeaderMigration()​

protected startLeaderMigration(): void

Defined in: packages/core/src/stores/migrationstore.service.ts:777

Start the background migration loop when this node becomes the cluster leader

Returns​

void


stop()​

stop(): Promise<void>

Defined in: packages/core/src/stores/migrationstore.service.ts:617

Stop any background migration task and unregister from cluster leadership notifications

Returns​

Promise<void>

Overrides​

Store.stop


stopLeaderMigration()​

protected stopLeaderMigration(): Promise<void>

Defined in: packages/core/src/stores/migrationstore.service.ts:815

Stop any background migration loop running on this node (e.g. on leadership loss or service shutdown)

Returns​

Promise<void>


toJSON()​

toJSON(): string

Defined in: packages/core/src/services/service.ts:499

Prevent service to be serialized

Returns​

string

the result

Inherited from​

Store.toJSON


toStatus()​

protected toStatus(entry): MigrationStoreStatus

Defined in: packages/core/src/stores/migrationstore.service.ts:1158

Convert a raw Registry entry into a normalized MigrationStoreStatus

Parameters​

entry​

Partial<MigrationStoreStatus>

raw Registry entry

Returns​

MigrationStoreStatus

normalized status


toString()​

toString(): string

Defined in: packages/core/src/services/service.ts:238

Return service representation

Returns​

string

the result

Inherited from​

Store.toString


transferRegistryId()​

protected transferRegistryId(): string

Defined in: packages/core/src/stores/migrationstore.service.ts:1175

Registry entry ID used for persisting transfer progress and lease

Returns​

string

Registry entry ID


typesPatcher()​

protected typesPatcher(): MigrationPatcher

Defined in: packages/core/src/stores/store.ts:1111

Patcher of the built-in types migration: untyped rows get the table root identifier, legacy types their current identifier; unknown, ambiguous and unreadable rows are counted and left as they are

Returns​

MigrationPatcher

the patcher

Inherited from​

Store.typesPatcher


waitForCompletion()​

waitForCompletion(): Promise<MigrationStoreStatus>

Defined in: packages/core/src/stores/migrationstore.service.ts:767

Wait for any currently running background migration on this instance to finish

Returns​

Promise<MigrationStoreStatus>

the resulting MigrationStoreStatus


claimingStore()​

static claimingStore(model, stores?): Store<StoreParameters, StoreEvents>

Defined in: packages/core/src/stores/store.ts:507

The store listing a model (or its closest ancestor) in its models

Parameters​

model​

ModelClass

the model

stores?​

Store<StoreParameters, StoreEvents>[]

the candidate stores, every store of the application by default

Returns​

Store<StoreParameters, StoreEvents>

the store, undefined when none lists it (the Registry serves it)

Inherited from​

Store.claimingStore


computeStores()​

static computeStores(): void

Defined in: packages/core/src/stores/store.ts:549

Compute and register repositories for all known models based on available stores.

Called from Store.init() so each store's init triggers a recompute. Cannot be cached: the FIRST store to init (typically Registry) would claim every model with its fallback repository, and subsequent stores wouldn't get a chance to claim their configured models. Re-running is idempotent — registerRepository overwrites map entries in place, and the resolution loop is deterministic per current service/model state.

Returns​

void

Inherited from​

Store.computeStores


storeOf()​

static storeOf(model): Store<StoreParameters, StoreEvents>

Defined in: packages/core/src/stores/store.ts:534

The store serving a model: the one listing it, else the Registry

Parameters​

model​

ModelClass

the model

Returns​

Store<StoreParameters, StoreEvents>

the store, undefined before the Registry exists

Inherited from​

Store.storeOf