Skip to content

@codesoul-co/hypha-memory / provider-pagination

Using this module

Use the Provider pagination module for binding external or local providers to Hypha ports. It exports 3 functions, 2 interfaces.

Import from the package entrypoint

ts
import {
  beginProviderPage,
  encodeProviderCursor,
  finishProviderPage,
} from '@codesoul-co/hypha-memory';

import type {
  ProviderPageContext,
  ProviderPaginationBudget,
} from '@codesoul-co/hypha-memory';

Usage patterns

  • Use the 2 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 3 functions as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.

Public exports

SymbolKindSignatureDescription
beginProviderPagefunctionbeginProviderPage(providerId: string, scope: ManagedMemoryScope, pagination: PaginationRequest | undefined, nowMs?: number): ProviderPageContextBegin Provider Page function with 1 public call signature; parameters and return types are listed below.
encodeProviderCursorfunctionencodeProviderCursor(envelope: ProviderCursorEnvelope): stringEncode Provider Cursor function with 1 public call signature; parameters and return types are listed below.
finishProviderPagefunctionfinishProviderPage(context: ProviderPageContext, providerId: string, scope: ManagedMemoryScope, records: unknown[], nextProviderCursor?: string, nowMs?: number): { nextCursor?: string; hasMore: boolean; }Finish Provider Page function with 1 public call signature; parameters and return types are listed below.
ProviderPageContextinterfaceinterface ProviderPageContextProvider Page Context interface with 5 public fields or methods.
ProviderPaginationBudgetinterfaceinterface ProviderPaginationBudgetProvider Pagination Budget interface with 5 public fields or methods.

beginProviderPage

Begin Provider Page function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { beginProviderPage } from '@codesoul-co/hypha-memory';
  • Source module: provider-pagination

Declaration

text
export declare function beginProviderPage(providerId: string, scope: ManagedMemoryScope, pagination: PaginationRequest | undefined, nowMs?: number): ProviderPageContext;

Call signature

text
beginProviderPage(providerId: string, scope: ManagedMemoryScope, pagination: PaginationRequest | undefined, nowMs?: number): ProviderPageContext

Parameters

ParameterTypeRequiredDescription
providerIdstringYesRequired parameter; accepted values are defined by the type column.
scopeManagedMemoryScopeYesRequired parameter; accepted values are defined by the type column.
paginationPaginationRequestYesRequired parameter; accepted values are defined by the type column.
nowMsnumberNoOptional parameter; accepted values are defined by the type column.

Returns

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

encodeProviderCursor

Encode Provider Cursor function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { encodeProviderCursor } from '@codesoul-co/hypha-memory';
  • Source module: provider-pagination

Declaration

text
export declare function encodeProviderCursor(envelope: ProviderCursorEnvelope): string;

Call signature

text
encodeProviderCursor(envelope: ProviderCursorEnvelope): string

Parameters

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

Returns

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

finishProviderPage

Finish Provider Page function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { finishProviderPage } from '@codesoul-co/hypha-memory';
  • Source module: provider-pagination

Declaration

text
export declare function finishProviderPage(context: ProviderPageContext, providerId: string, scope: ManagedMemoryScope, records: unknown[], nextProviderCursor?: string, nowMs?: number): {
    nextCursor?: string;
    hasMore: boolean;
};

Call signature

text
finishProviderPage(context: ProviderPageContext, providerId: string, scope: ManagedMemoryScope, records: unknown[], nextProviderCursor?: string, nowMs?: number): { nextCursor?: string; hasMore: boolean; }

Parameters

ParameterTypeRequiredDescription
contextProviderPageContextYesRequired parameter; accepted values are defined by the type column.
providerIdstringYesRequired parameter; accepted values are defined by the type column.
scopeManagedMemoryScopeYesRequired parameter; accepted values are defined by the type column.
recordsunknown[]YesRequired parameter; accepted values are defined by the type column.
nextProviderCursorstringNoOptional parameter; accepted values are defined by the type column.
nowMsnumberNoOptional parameter; accepted values are defined by the type column.

Returns

  • Type: { nextCursor?: string; hasMore: boolean; }
  • Description: The return contract is defined by the type shown above.

ProviderPageContext

Provider Page Context interface with 5 public fields or methods.

  • Kind: interface
  • Import: import type { ProviderPageContext } from '@codesoul-co/hypha-memory';
  • Source module: provider-pagination

Declaration

text
export interface ProviderPageContext {
    providerCursor?: string;
    envelope?: ProviderCursorEnvelope;
    budget: ProviderPaginationBudget;
    startedAt: string;
    nowMs: number;
}

Contract members

MemberKindSignatureDescription
budgetpropertybudget: ProviderPaginationBudgetPublic property; its type, readonly modifier and optionality are shown in the signature.
envelopepropertyenvelope?: ProviderCursorEnvelopePublic property; its type, readonly modifier and optionality are shown in the signature.
nowMspropertynowMs: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
providerCursorpropertyproviderCursor?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
startedAtpropertystartedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

ProviderPaginationBudget

Provider Pagination Budget interface with 5 public fields or methods.

  • Kind: interface
  • Import: import type { ProviderPaginationBudget } from '@codesoul-co/hypha-memory';
  • Source module: provider-pagination

Declaration

text
export interface ProviderPaginationBudget {
    maxPages: number;
    maxItems: number;
    maxBytes: number;
    maxDurationMs: number;
    maxCalls: number;
}

Contract members

MemberKindSignatureDescription
maxBytespropertymaxBytes: 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.
maxPagespropertymaxPages: numberPublic property; its type, readonly modifier and optionality are shown in the signature.