hypertune
Version:
[Hypertune](https://www.hypertune.com/) is the most flexible platform for feature flags, A/B testing, analytics and app configuration. Built with full end-to-end type-safety, Git-style version control and local, synchronous, in-memory flag evaluation. Opt
30 lines • 1.58 kB
TypeScript
type ValueType = "string" | "boolean" | "number" | "any";
export type Schema = {
[optionName: string]: ValueType;
};
/**
* Handler for a CLI command. Given `Options`, it asynchronously returns a `Result`
*/
export type Handler<Options extends object, Result> = (options: Options) => Promise<Result>;
/**
* A handler decorator, that given a handler will return a new handler, with some extra functionality
*/
export type Wrapper = <Options extends object, Result>(handler: Handler<Options, Result>, schema?: Schema) => Handler<Options, Result>;
/**
* Processes default options behavior:
* - removes `--` option as we never use it
* - file options (e.g. hypertune.config.js, hypertune.json, hypertune key in package.json)
* - environment variable options (e.g. HYPERTUNE_TOKEN)
* - any options passed in to the returned handler (i.e. CLI args)
*/
export declare const withOtherOptionSources: Wrapper;
/**
* Adds options validation to a handler based on a Zod schema.
*
* As Zod schemas can specify defaults, also changes the input type to what is actually required (e.g. okay not to provide something where it has a default).
*/
export declare function withValidation<Options extends object, HandlerResult>(schema: Schema, handler: Handler<Options, HandlerResult>): Handler<Options, HandlerResult>;
export declare function throwIfOptionIsUndefined<T>(optionName: string, value: T | undefined): T;
export declare function parseOptionValueWithSchema(valueType: ValueType, value: string): number | boolean | string;
export {};
//# sourceMappingURL=helpers.d.ts.map