@hotmeshio/hotmesh
Version:
Permanent-Memory Workflows & AI Agents
139 lines (138 loc) • 4.46 kB
TypeScript
/// <reference types="node" />
import { StoreService } from '../services/store';
import { AppSubscriptions, AppTransitions, AppVID } from '../types/app';
import { ProviderClient, ProviderTransaction, Providers } from '../types/provider';
import { StringAnyType } from '../types/serializer';
import { StreamCode, StreamData, StreamStatus } from '../types/stream';
import { SystemHealth } from '../types/quorum';
/**
* @private
*/
export declare const hashOptions: (options: any) => string;
export declare function getSystemHealth(): Promise<SystemHealth>;
export declare function deepCopy<T>(obj: T): T;
export declare function deterministicRandom(seed: number): number;
export declare function guid(size?: number): string;
export declare function sleepFor(ms: number): Promise<void>;
export declare function sleepImmediate(): Promise<void>;
export declare function XSleepFor(ms: number): {
promise: Promise<unknown>;
timerId: NodeJS.Timeout;
};
/**
* Identies the provider type based on the provider object. Customers may
* explicitly set the provider type in the configuration. But this is a
* convenience method to automatically identify the provider type.
* @private
*/
export declare function identifyProvider(provider: any): Providers | null;
/**
* @private
*/
export declare const polyfill: {
/**
* `connection` is the generic replacement
*/
providerConfig(obj: any): any;
};
/**
* @private
*/
export declare function matchesStatusCode(code: StreamCode, pattern: string | RegExp): boolean;
/**
* @private
*/
export declare function matchesStatus(status: StreamStatus, targetStatus: StreamStatus): boolean;
/**
* @private
*/
export declare function findTopKey(obj: AppTransitions, input: string): string | null;
/**
* @private
*/
export declare function findSubscriptionForTrigger(obj: AppSubscriptions, value: string): string | null;
/**
* Get the subscription topic for the flow to which activityId belongs.
* @private
*/
export declare function getSubscriptionTopic(activityId: string, store: StoreService<ProviderClient, ProviderTransaction>, appVID: AppVID): Promise<string | undefined>;
/**
* returns the 12-digit format of the iso timestamp (e.g, 202101010000); returns
* an empty string if overridden by the user to not segment by time (infinity).
* @private
*/
export declare function getTimeSeries(granularity: string): string;
/**
* @private
*/
export declare function formatISODate(input: Date | string): string;
/**
* @private
*/
export declare function getSymKey(number: number): string;
/**
* @private
*/
export declare function getSymVal(number: number): string;
/**
* @private
*/
export declare function getIndexedHash<T>(hash: T, target: string): [number, T];
/**
* @private
*/
export declare function getValueByPath(obj: {
[key: string]: any;
}, path: string): any;
/**
* @private
*/
export declare function restoreHierarchy(obj: StringAnyType): StringAnyType;
/**
* @private
*/
export declare function isValidCron(cronExpression: string): boolean;
/**
* Returns the number of seconds for a string using the milliseconds format
* used by the `ms` npm package as the input.
*/
export declare const s: (input: string) => number;
/**
* Normalizes retry policy configuration to a consistent format.
* Converts maximumInterval to seconds and applies defaults.
*
* @param policy - Retry policy to normalize
* @param defaults - Default values to use if not specified
* @returns Normalized retry policy with numeric values
*
* @example
* ```typescript
* const normalized = normalizeRetryPolicy({
* maximumAttempts: 5,
* backoffCoefficient: 2,
* maximumInterval: '300s',
* });
* // Returns: { max_retry_attempts: 5, backoff_coefficient: 2, maximum_interval_seconds: 300 }
* ```
*/
export declare function normalizeRetryPolicy(policy?: import('../types/stream').RetryPolicy, defaults?: {
maximumAttempts: number;
backoffCoefficient: number;
maximumInterval: number;
}): {
max_retry_attempts: number;
backoff_coefficient: number;
maximum_interval_seconds: number;
};
/**
* @private
*/
export declare const parseStreamMessage: (message: string) => StreamData;
/**
* @private
*/
export declare const isStreamMessage: (result: any) => boolean;
/**
* Transforms an array of arrays to an array of objects.
*/
export declare const arrayToHash: (response: [number, ...Array<string | string[]>]) => Record<string, string>[];