Skip to content

@codesoul-co/hypha-memory / memory-server-redis-migration

Using this module

Use the Memory server redis migration module for using the public contracts and operations for this capability boundary. It exports 1 class, 1 function, 7 interfaces.

Import from the package entrypoint

ts
import {
  RedisStreamWorkingMemoryMigrationAdapter,
  scanRedisWorkingMemoryKeys,
} from '@codesoul-co/hypha-memory';

import type {
  RedisScanBudget,
  RedisScanReport,
  RedisStreamMigrationClient,
  RedisStreamWorkingMemoryMigrationAdapterOptions,
  WorkingMemoryMigrationAppend,
  WorkingMemoryMigrationEntry,
  WorkingMemoryMigrationPort,
} from '@codesoul-co/hypha-memory';

Usage patterns

  • Use the 7 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 1 class 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
RedisStreamWorkingMemoryMigrationAdapterclassnew RedisStreamWorkingMemoryMigrationAdapter(options: RedisStreamWorkingMemoryMigrationAdapterOptions): RedisStreamWorkingMemoryMigrationAdapterRedis Stream adapter used by dev to execute the Framework-owned migration acceptance suite.
scanRedisWorkingMemoryKeysfunctionscanRedisWorkingMemoryKeys(client: Pick<RedisStreamMigrationClient, "scan">, pattern: string, budget?: RedisScanBudget, nowMs?: () => number): Promise<RedisScanReport>Scan Redis Working Memory Keys function with 1 public call signature; parameters and return types are listed below.
RedisScanBudgetinterfaceinterface RedisScanBudgetRedis Scan Budget interface with 4 public fields or methods.
RedisScanReportinterfaceinterface RedisScanReportRedis Scan Report interface with 3 public fields or methods.
RedisStreamMigrationClientinterfaceinterface RedisStreamMigrationClientRedis Stream Migration Client interface with 6 public fields or methods.
RedisStreamWorkingMemoryMigrationAdapterOptionsinterfaceinterface RedisStreamWorkingMemoryMigrationAdapterOptionsRedis Stream Working Memory Migration Adapter Options interface with 4 public fields or methods.
WorkingMemoryMigrationAppendinterfaceinterface WorkingMemoryMigrationAppendWorking Memory Migration Append interface with 5 public fields or methods.
WorkingMemoryMigrationEntryinterfaceinterface WorkingMemoryMigrationEntryWorking Memory Migration Entry interface with 4 public fields or methods.
WorkingMemoryMigrationPortinterfaceinterface WorkingMemoryMigrationPortWorking Memory Migration Port interface with 4 public fields or methods.

RedisStreamWorkingMemoryMigrationAdapter

Redis Stream adapter used by dev to execute the Framework-owned migration acceptance suite.

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

Declaration

text
export declare class RedisStreamWorkingMemoryMigrationAdapter implements WorkingMemoryMigrationPort {
    constructor(options: RedisStreamWorkingMemoryMigrationAdapterOptions);
    append<TValue = unknown>(input: WorkingMemoryMigrationAppend<TValue>): Promise<void>;
    list<TValue = unknown>(scope: ManagedMemoryScope): Promise<Array<WorkingMemoryMigrationEntry<TValue>>>;
    latest<TValue = unknown>(scope: ManagedMemoryScope): Promise<WorkingMemoryMigrationEntry<TValue> | null>;
    clearScope(scope: ManagedMemoryScope, budget?: Partial<RedisScanBudget>): Promise<RedisScanReport>;
}

Public members

MemberKindSignatureDescription
appendmethodappend<TValue = unknown>(input: WorkingMemoryMigrationAppend<TValue>): Promise<void>Public method; parameters and return type are shown in the signature.
clearScopemethodclearScope(scope: ManagedMemoryScope, budget?: Partial<RedisScanBudget>): Promise<RedisScanReport>Public method; parameters and return type are shown in the signature.
constructorconstructor(options: RedisStreamWorkingMemoryMigrationAdapterOptions): RedisStreamWorkingMemoryMigrationAdapterCreates an instance of this class.
latestmethodlatest<TValue = unknown>(scope: ManagedMemoryScope): Promise<WorkingMemoryMigrationEntry<TValue> | null>Public method; parameters and return type are shown in the signature.
listmethodlist<TValue = unknown>(scope: ManagedMemoryScope): Promise<Array<WorkingMemoryMigrationEntry<TValue>>>Public method; parameters and return type are shown in the signature.

scanRedisWorkingMemoryKeys

Scan Redis Working Memory Keys function with 1 public call signature; parameters and return types are listed below.

Declaration

text
export declare function scanRedisWorkingMemoryKeys(client: Pick<RedisStreamMigrationClient, 'scan'>, pattern: string, budget?: RedisScanBudget, nowMs?: () => number): Promise<RedisScanReport>;

Call signature

text
scanRedisWorkingMemoryKeys(client: Pick<RedisStreamMigrationClient, "scan">, pattern: string, budget?: RedisScanBudget, nowMs?: () => number): Promise<RedisScanReport>

Parameters

ParameterTypeRequiredDescription
clientPick<RedisStreamMigrationClient, "scan">YesRequired parameter; accepted values are defined by the type column.
patternstringYesRequired parameter; accepted values are defined by the type column.
budgetRedisScanBudgetNoOptional parameter; accepted values are defined by the type column.
nowMs() => numberNoOptional parameter; accepted values are defined by the type column.

Returns

  • Type: Promise<RedisScanReport>
  • Description: The return contract is defined by the type shown above.

RedisScanBudget

Redis Scan Budget interface with 4 public fields or methods.

Declaration

text
export interface RedisScanBudget {
    maxCalls: number;
    maxItems: number;
    maxDurationMs: number;
    count: number;
}

Contract members

MemberKindSignatureDescription
countpropertycount: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxCallspropertymaxCalls: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxDurationMspropertymaxDurationMs: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxItemspropertymaxItems: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

RedisScanReport

Redis Scan Report interface with 3 public fields or methods.

Declaration

text
export interface RedisScanReport {
    keys: string[];
    calls: number;
    terminated: boolean;
}

Contract members

MemberKindSignatureDescription
callspropertycalls: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
keyspropertykeys: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
terminatedpropertyterminated: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.

RedisStreamMigrationClient

Redis Stream Migration Client interface with 6 public fields or methods.

Declaration

text
export interface RedisStreamMigrationClient {
    xadd(key: string, id: '*', field: 'entry', value: string): Promise<string | null>;
    xtrim(key: string, strategy: 'MAXLEN', threshold: number): Promise<number>;
    xrange(key: string, start: '-', end: '+'): Promise<Array<[string, string[]]>>;
    xrevrange(key: string, end: '+', start: '-', countToken: 'COUNT', count: 1): Promise<Array<[string, string[]]>>;
    scan(cursor: string, matchToken: 'MATCH', pattern: string, countToken: 'COUNT', count: number): Promise<[string, string[]]>;
    del(...keys: string[]): Promise<number>;
}

Contract members

MemberKindSignatureDescription
delmethoddel(...keys: string[]): Promise<number>Public method; parameters and return type are shown in the signature.
scanmethodscan(cursor: string, matchToken: "MATCH", pattern: string, countToken: "COUNT", count: number): Promise<[string, string[]]>Public method; parameters and return type are shown in the signature.
xaddmethodxadd(key: string, id: "*", field: "entry", value: string): Promise<string | null>Public method; parameters and return type are shown in the signature.
xrangemethodxrange(key: string, start: "-", end: "+"): Promise<Array<[string, string[]]>>Public method; parameters and return type are shown in the signature.
xrevrangemethodxrevrange(key: string, end: "+", start: "-", countToken: "COUNT", count: 1): Promise<Array<[string, string[]]>>Public method; parameters and return type are shown in the signature.
xtrimmethodxtrim(key: string, strategy: "MAXLEN", threshold: number): Promise<number>Public method; parameters and return type are shown in the signature.

RedisStreamWorkingMemoryMigrationAdapterOptions

Redis Stream Working Memory Migration Adapter Options interface with 4 public fields or methods.

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

Declaration

text
export interface RedisStreamWorkingMemoryMigrationAdapterOptions {
    client: RedisStreamMigrationClient;
    namespace?: string;
    scanBudget?: Partial<RedisScanBudget>;
    nowMs?: () => number;
}

Contract members

MemberKindSignatureDescription
clientpropertyclient: RedisStreamMigrationClientPublic property; its type, readonly modifier and optionality are shown in the signature.
namespacepropertynamespace?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
nowMsmethodnowMs?(): numberPublic method; parameters and return type are shown in the signature.
scanBudgetpropertyscanBudget?: Partial<RedisScanBudget>Public property; its type, readonly modifier and optionality are shown in the signature.

WorkingMemoryMigrationAppend

Working Memory Migration Append interface with 5 public fields or methods.

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

Declaration

text
export interface WorkingMemoryMigrationAppend<TValue = unknown> {
    id: string;
    scope: ManagedMemoryScope;
    value: TValue;
    createdAt: string;
    maxMessages: number;
}

Contract members

MemberKindSignatureDescription
createdAtpropertycreatedAt: stringPublic 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.
maxMessagespropertymaxMessages: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
scopepropertyscope: ManagedMemoryScopePublic property; its type, readonly modifier and optionality are shown in the signature.
valuepropertyvalue: TValuePublic property; its type, readonly modifier and optionality are shown in the signature.

WorkingMemoryMigrationEntry

Working Memory Migration Entry interface with 4 public fields or methods.

Declaration

text
export interface WorkingMemoryMigrationEntry<TValue = unknown> {
    id: string;
    scopeHash: string;
    value: TValue;
    createdAt: string;
}

Contract members

MemberKindSignatureDescription
createdAtpropertycreatedAt: stringPublic 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.
scopeHashpropertyscopeHash: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
valuepropertyvalue: TValuePublic property; its type, readonly modifier and optionality are shown in the signature.

WorkingMemoryMigrationPort

Working Memory Migration Port interface with 4 public fields or methods.

Declaration

text
export interface WorkingMemoryMigrationPort {
    append<TValue = unknown>(input: WorkingMemoryMigrationAppend<TValue>): Promise<void>;
    list<TValue = unknown>(scope: ManagedMemoryScope): Promise<Array<WorkingMemoryMigrationEntry<TValue>>>;
    latest<TValue = unknown>(scope: ManagedMemoryScope): Promise<WorkingMemoryMigrationEntry<TValue> | null>;
    clearScope(scope: ManagedMemoryScope, budget?: Partial<RedisScanBudget>): Promise<RedisScanReport>;
}

Contract members

MemberKindSignatureDescription
appendmethodappend<TValue = unknown>(input: WorkingMemoryMigrationAppend<TValue>): Promise<void>Public method; parameters and return type are shown in the signature.
clearScopemethodclearScope(scope: ManagedMemoryScope, budget?: Partial<RedisScanBudget>): Promise<RedisScanReport>Public method; parameters and return type are shown in the signature.
latestmethodlatest<TValue = unknown>(scope: ManagedMemoryScope): Promise<WorkingMemoryMigrationEntry<TValue> | null>Public method; parameters and return type are shown in the signature.
listmethodlist<TValue = unknown>(scope: ManagedMemoryScope): Promise<Array<WorkingMemoryMigrationEntry<TValue>>>Public method; parameters and return type are shown in the signature.