@hotmeshio/hotmesh
Version:
Serverless Workflow
120 lines (119 loc) • 3.99 kB
TypeScript
/// <reference types="node" />
import { StoreService } from '../services/store';
import { AppSubscriptions, AppTransitions, AppVID } from '../types/app';
import { ProviderClient, ProviderConfig, ProviderTransaction, Providers, ProvidersConfig } 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: {
/**
* `redis` is deprecated; `connection` is the generic replacement
*/
providerConfig(obj: any): any;
/**
* NOTE: `redisClass and redisOptions` input parameters are deprecated; use `connection` for all configuration inputs
*/
meshDataConfig(obj: {
connection?: Partial<ProviderConfig | ProvidersConfig>;
redisClass?: any;
redisOptions?: StringAnyType;
}): Partial<ProviderConfig> | Partial<ProvidersConfig>;
};
/**
* @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;
/**
* @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>[];