Skip to content

@codesoul-co/hypha-memory / memory-data-migration

Using this module

Use the Memory data migration module for using the public contracts and operations for this capability boundary. It exports 2 classes, 1 function, 5 interfaces.

Import from the package entrypoint

ts
import {
  MemoryDataMigrationCoordinator,
  StructuredMemoryDataMigrationStateStore,
  migrationPlanHash,
} from '@codesoul-co/hypha-memory';

import type {
  MemoryDataMigrationCoordinatorOptions,
  MemoryDataMigrationPlan,
  MemoryDataMigrationState,
  MemoryDataMigrationStateStore,
  MemoryDataMigrationStep,
} from '@codesoul-co/hypha-memory';

Usage patterns

  • Use the 5 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The module exposes 2 classes as constructable runtime implementations. Each symbol entry lists its constructor and public methods.
  • The module exposes 1 function as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.

Public exports

SymbolKindSignatureDescription
MemoryDataMigrationCoordinatorclassnew MemoryDataMigrationCoordinator(options: MemoryDataMigrationCoordinatorOptions): MemoryDataMigrationCoordinatorResumable migration/rollback runner. Step implementations remain with the data owner.
StructuredMemoryDataMigrationStateStoreclassnew StructuredMemoryDataMigrationStateStore(store: StructuredStoreProvider, table?: string): StructuredMemoryDataMigrationStateStoreStructured Memory Data Migration State Store class with 3 public constructor or member entries; its exact declarations are listed below.
migrationPlanHashfunctionmigrationPlanHash(plan: MemoryDataMigrationPlan): stringMigration Plan Hash function with 1 public call signature; parameters and return types are listed below.
MemoryDataMigrationCoordinatorOptionsinterfaceinterface MemoryDataMigrationCoordinatorOptionsMemory Data Migration Coordinator Options interface with 2 public fields or methods.
MemoryDataMigrationPlaninterfaceinterface MemoryDataMigrationPlanMemory Data Migration Plan interface with 5 public fields or methods.
MemoryDataMigrationStateinterfaceinterface MemoryDataMigrationStateMemory Data Migration State interface with 9 public fields or methods.
MemoryDataMigrationStateStoreinterfaceinterface MemoryDataMigrationStateStoreMemory Data Migration State Store interface with 2 public fields or methods.
MemoryDataMigrationStepinterfaceinterface MemoryDataMigrationStepMemory Data Migration Step interface with 3 public fields or methods.

MemoryDataMigrationCoordinator

Resumable migration/rollback runner. Step implementations remain with the data owner.

  • Kind: class
  • Import: import { MemoryDataMigrationCoordinator } from '@codesoul-co/hypha-memory';
  • Source module: memory-data-migration

Declaration

text
export declare class MemoryDataMigrationCoordinator {
    constructor(options: MemoryDataMigrationCoordinatorOptions);
    apply(plan: MemoryDataMigrationPlan): Promise<MemoryDataMigrationState>;
    rollback(plan: MemoryDataMigrationPlan): Promise<MemoryDataMigrationState>;
}

Public members

MemberKindSignatureDescription
applymethodapply(plan: MemoryDataMigrationPlan): Promise<MemoryDataMigrationState>Public method; parameters and return type are shown in the signature.
constructorconstructor(options: MemoryDataMigrationCoordinatorOptions): MemoryDataMigrationCoordinatorCreates an instance of this class.
rollbackmethodrollback(plan: MemoryDataMigrationPlan): Promise<MemoryDataMigrationState>Public method; parameters and return type are shown in the signature.

StructuredMemoryDataMigrationStateStore

Structured Memory Data Migration State Store class with 3 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { StructuredMemoryDataMigrationStateStore } from '@codesoul-co/hypha-memory';
  • Source module: memory-data-migration

Declaration

text
export declare class StructuredMemoryDataMigrationStateStore implements MemoryDataMigrationStateStore {
    constructor(store: StructuredStoreProvider, table?: string);
    get(planId: string): Promise<MemoryDataMigrationState | null>;
    save(state: MemoryDataMigrationState): Promise<void>;
}

Public members

MemberKindSignatureDescription
constructorconstructor(store: StructuredStoreProvider, table?: string): StructuredMemoryDataMigrationStateStoreCreates an instance of this class.
getmethodget(planId: string): Promise<MemoryDataMigrationState | null>Public method; parameters and return type are shown in the signature.
savemethodsave(state: MemoryDataMigrationState): Promise<void>Public method; parameters and return type are shown in the signature.

migrationPlanHash

Migration Plan Hash function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { migrationPlanHash } from '@codesoul-co/hypha-memory';
  • Source module: memory-data-migration

Declaration

text
export declare function migrationPlanHash(plan: MemoryDataMigrationPlan): string;

Call signature

text
migrationPlanHash(plan: MemoryDataMigrationPlan): string

Parameters

ParameterTypeRequiredDescription
planMemoryDataMigrationPlanYesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: string
  • Description: The return contract is defined by the type shown above.

MemoryDataMigrationCoordinatorOptions

Memory Data Migration Coordinator Options interface with 2 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryDataMigrationCoordinatorOptions } from '@codesoul-co/hypha-memory';
  • Source module: memory-data-migration

Declaration

text
export interface MemoryDataMigrationCoordinatorOptions {
    stateStore: MemoryDataMigrationStateStore;
    now?: () => string;
}

Contract members

MemberKindSignatureDescription
nowmethodnow?(): stringPublic method; parameters and return type are shown in the signature.
stateStorepropertystateStore: MemoryDataMigrationStateStorePublic property; its type, readonly modifier and optionality are shown in the signature.

MemoryDataMigrationPlan

Memory Data Migration Plan interface with 5 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryDataMigrationPlan } from '@codesoul-co/hypha-memory';
  • Source module: memory-data-migration

Declaration

text
export interface MemoryDataMigrationPlan {
    id: string;
    version: string;
    source: string;
    target: string;
    steps: readonly MemoryDataMigrationStep[];
}

Contract members

MemberKindSignatureDescription
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
sourcepropertysource: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
stepspropertysteps: readonly MemoryDataMigrationStep[]Public property; its type, readonly modifier and optionality are shown in the signature.
targetpropertytarget: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
versionpropertyversion: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

MemoryDataMigrationState

Memory Data Migration State interface with 9 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryDataMigrationState } from '@codesoul-co/hypha-memory';
  • Source module: memory-data-migration

Declaration

text
export interface MemoryDataMigrationState {
    id: string;
    planId: string;
    planVersion: string;
    planHash: string;
    state: 'pending' | 'applying' | 'applied' | 'rolling_back' | 'rolled_back' | 'failed';
    appliedStepIds: string[];
    activeStepId?: string;
    lastError?: ReturnType<typeof normalizeMemoryError>;
    updatedAt: string;
}

Contract members

MemberKindSignatureDescription
activeStepIdpropertyactiveStepId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
appliedStepIdspropertyappliedStepIds: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
lastErrorpropertylastError?: import("/Users/erwin/Downloads/codespace/Hypha/packages/memory/dist/contracts").NormalizedMemoryErrorPublic property; its type, readonly modifier and optionality are shown in the signature.
planHashpropertyplanHash: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
planIdpropertyplanId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
planVersionpropertyplanVersion: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
statepropertystate: "failed" | "applied" | "pending" | "applying" | "rolling_back" | "rolled_back"Public property; its type, readonly modifier and optionality are shown in the signature.
updatedAtpropertyupdatedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

MemoryDataMigrationStateStore

Memory Data Migration State Store interface with 2 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryDataMigrationStateStore } from '@codesoul-co/hypha-memory';
  • Source module: memory-data-migration

Declaration

text
export interface MemoryDataMigrationStateStore {
    get(planId: string): Promise<MemoryDataMigrationState | null>;
    save(state: MemoryDataMigrationState): Promise<void>;
}

Contract members

MemberKindSignatureDescription
getmethodget(planId: string): Promise<MemoryDataMigrationState | null>Public method; parameters and return type are shown in the signature.
savemethodsave(state: MemoryDataMigrationState): Promise<void>Public method; parameters and return type are shown in the signature.

MemoryDataMigrationStep

Memory Data Migration Step interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryDataMigrationStep } from '@codesoul-co/hypha-memory';
  • Source module: memory-data-migration

Declaration

text
export interface MemoryDataMigrationStep {
    id: string;
    apply(): Promise<void>;
    rollback(): Promise<void>;
}

Contract members

MemberKindSignatureDescription
applymethodapply(): Promise<void>Public method; parameters and return type are shown in the signature.
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
rollbackmethodrollback(): Promise<void>Public method; parameters and return type are shown in the signature.