Skip to content

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

Using this module

Use the Memory server redis migration fixtures module for writing deterministic tests and contract assertions. It exports 2 classes, 1 constant, 2 functions, 2 interfaces, 2 types.

Import from the package entrypoint

ts
import {
  InMemoryRedisStreamMigrationClient,
  InMemoryWorkingMemoryMigrationPort,
  redisWorkingMemoryBoundaryCases,
  createInMemoryWorkingMemoryMigrationHarness,
  createRedisStreamWorkingMemoryMigrationHarness,
} from '@codesoul-co/hypha-memory';

import type {
  RedisWorkingMemoryBoundaryCase,
  WorkingMemoryMigrationAcceptanceHarness,
  RedisMigrationCommand,
  WorkingMemoryMigrationHarnessFactory,
} from '@codesoul-co/hypha-memory';

Usage patterns

  • Use the 4 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 2 functions as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.
  • The 1 constant/enum export provides stable values, schemas, definitions, or defaults. Reuse these exports instead of copying internal values into an application.

Public exports

SymbolKindSignatureDescription
InMemoryRedisStreamMigrationClientclassnew InMemoryRedisStreamMigrationClient(): InMemoryRedisStreamMigrationClientIn Memory Redis Stream Migration Client class with 10 public constructor or member entries; its exact declarations are listed below.
InMemoryWorkingMemoryMigrationPortclassnew InMemoryWorkingMemoryMigrationPort(storage?: Map<string, WorkingMemoryMigrationEntry<unknown>[]>): InMemoryWorkingMemoryMigrationPortIn Memory Working Memory Migration Port class with 5 public constructor or member entries; its exact declarations are listed below.
redisWorkingMemoryBoundaryCasesconstantconst redisWorkingMemoryBoundaryCases: readonly RedisWorkingMemoryBoundaryCase[]Redis Working Memory Boundary Cases constant exported by the memory-server-redis-migration-fixtures module.
createInMemoryWorkingMemoryMigrationHarnessfunctioncreateInMemoryWorkingMemoryMigrationHarness(): WorkingMemoryMigrationAcceptanceHarnessCreate In Memory Working Memory Migration Harness function with 1 public call signature; parameters and return types are listed below.
createRedisStreamWorkingMemoryMigrationHarnessfunctioncreateRedisStreamWorkingMemoryMigrationHarness(fixtureId: string, client?: InMemoryRedisStreamMigrationClient): WorkingMemoryMigrationAcceptanceHarness & { client: InMemoryRedisStreamMigrationClient; }Create Redis Stream Working Memory Migration Harness function with 1 public call signature; parameters and return types are listed below.
RedisWorkingMemoryBoundaryCaseinterfaceinterface RedisWorkingMemoryBoundaryCaseRedis Working Memory Boundary Case interface with 6 public fields or methods.
WorkingMemoryMigrationAcceptanceHarnessinterfaceinterface WorkingMemoryMigrationAcceptanceHarnessWorking Memory Migration Acceptance Harness interface with 2 public fields or methods.
RedisMigrationCommandtypetype RedisMigrationCommand = { name: 'XADD'; key: string; } | { name: 'XTRIM'; key: string; strategy: 'MAXLEN'; threshold: number; } | { name: 'XRANGE'; key: string; start: '-'; end: '+'; } | { name: 'XREVRANGE'; key: string; end: '+'; start: '-'; count: 1; } | { name: 'SCAN'; cursor: string; pattern: string; count: number; } | { name: 'DEL'; keys: string[]; }Public type alias for Redis Migration Command; the declaration contains its complete type expression.
WorkingMemoryMigrationHarnessFactorytypetype WorkingMemoryMigrationHarnessFactory = (fixtureId: string) => WorkingMemoryMigrationAcceptanceHarnessPublic type alias for Working Memory Migration Harness Factory; the declaration contains its complete type expression.

InMemoryRedisStreamMigrationClient

In Memory Redis Stream Migration Client class with 10 public constructor or member entries; its exact declarations are listed below.

Declaration

text
export declare class InMemoryRedisStreamMigrationClient implements RedisStreamMigrationClient {
    readonly commands: RedisMigrationCommand[];
    xadd(key: string, _id: '*', field: 'entry', value: string): Promise<string>;
    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>;
    seedStream(key: string): void;
    repeatScanCursor(cursor: string): void;
}

Public members

MemberKindSignatureDescription
commandspropertyreadonly commands: RedisMigrationCommand[]Public property; its type, readonly modifier and optionality are shown in the signature.
constructorconstructor(): InMemoryRedisStreamMigrationClientCreates an instance of this class.
delmethoddel(...keys: string[]): Promise<number>Public method; parameters and return type are shown in the signature.
repeatScanCursormethodrepeatScanCursor(cursor: string): voidPublic 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.
seedStreammethodseedStream(key: string): voidPublic method; parameters and return type are shown in the signature.
xaddmethodxadd(key: string, _id: "*", field: "entry", value: string): Promise<string>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.

InMemoryWorkingMemoryMigrationPort

In Memory Working Memory Migration Port class with 5 public constructor or member entries; its exact declarations are listed below.

Declaration

text
export declare class InMemoryWorkingMemoryMigrationPort implements WorkingMemoryMigrationPort {
    constructor(storage?: Map<string, WorkingMemoryMigrationEntry<unknown>[]>);
    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(storage?: Map<string, WorkingMemoryMigrationEntry<unknown>[]>): InMemoryWorkingMemoryMigrationPortCreates 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.

redisWorkingMemoryBoundaryCases

Redis Working Memory Boundary Cases constant exported by the memory-server-redis-migration-fixtures module.

Declaration

text
export declare const redisWorkingMemoryBoundaryCases: readonly RedisWorkingMemoryBoundaryCase[];

createInMemoryWorkingMemoryMigrationHarness

Create In Memory Working Memory Migration Harness function with 1 public call signature; parameters and return types are listed below.

Declaration

text
export declare function createInMemoryWorkingMemoryMigrationHarness(): WorkingMemoryMigrationAcceptanceHarness;

Call signature

text
createInMemoryWorkingMemoryMigrationHarness(): WorkingMemoryMigrationAcceptanceHarness

Parameters

No parameters.

Returns

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

createRedisStreamWorkingMemoryMigrationHarness

Create Redis Stream Working Memory Migration Harness function with 1 public call signature; parameters and return types are listed below.

Declaration

text
export declare function createRedisStreamWorkingMemoryMigrationHarness(fixtureId: string, client?: InMemoryRedisStreamMigrationClient): WorkingMemoryMigrationAcceptanceHarness & {
    client: InMemoryRedisStreamMigrationClient;
};

Call signature

text
createRedisStreamWorkingMemoryMigrationHarness(fixtureId: string, client?: InMemoryRedisStreamMigrationClient): WorkingMemoryMigrationAcceptanceHarness & { client: InMemoryRedisStreamMigrationClient; }

Parameters

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

Returns

  • Type: WorkingMemoryMigrationAcceptanceHarness & { client: InMemoryRedisStreamMigrationClient; }
  • Description: The return contract is defined by the type shown above.

RedisWorkingMemoryBoundaryCase

Redis Working Memory Boundary Case interface with 6 public fields or methods.

Declaration

text
export interface RedisWorkingMemoryBoundaryCase {
    id: string;
    preloadCount: number;
    appendCount: number;
    maxMessages: number;
    concurrent: boolean;
    exactOrder: boolean;
}

Contract members

MemberKindSignatureDescription
appendCountpropertyappendCount: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
concurrentpropertyconcurrent: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
exactOrderpropertyexactOrder: booleanPublic 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.
preloadCountpropertypreloadCount: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

WorkingMemoryMigrationAcceptanceHarness

Working Memory Migration Acceptance Harness interface with 2 public fields or methods.

Declaration

text
export interface WorkingMemoryMigrationAcceptanceHarness {
    port: WorkingMemoryMigrationPort;
    restart(): WorkingMemoryMigrationPort;
}

Contract members

MemberKindSignatureDescription
portpropertyport: WorkingMemoryMigrationPortPublic property; its type, readonly modifier and optionality are shown in the signature.
restartmethodrestart(): WorkingMemoryMigrationPortPublic method; parameters and return type are shown in the signature.

RedisMigrationCommand

Public type alias for Redis Migration Command; the declaration contains its complete type expression.

Declaration

text
export type RedisMigrationCommand = {
    name: 'XADD';
    key: string;
} | {
    name: 'XTRIM';
    key: string;
    strategy: 'MAXLEN';
    threshold: number;
} | {
    name: 'XRANGE';
    key: string;
    start: '-';
    end: '+';
} | {
    name: 'XREVRANGE';
    key: string;
    end: '+';
    start: '-';
    count: 1;
} | {
    name: 'SCAN';
    cursor: string;
    pattern: string;
    count: number;
} | {
    name: 'DEL';
    keys: string[];
};

WorkingMemoryMigrationHarnessFactory

Public type alias for Working Memory Migration Harness Factory; the declaration contains its complete type expression.

Declaration

text
export type WorkingMemoryMigrationHarnessFactory = (fixtureId: string) => WorkingMemoryMigrationAcceptanceHarness;