/** * Copyright 2023 Fluence Labs Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import type { JSONSchemaType, ValidateFunction } from "ajv"; import type { ValidationResult } from "../helpers/validations.js"; import type { Mutable } from "../typeHelpers.js"; export type InitializedReadonlyConfig = Readonly & { $getPath(): string; $getDirPath(): string; $getConfigString(): string; $validateLatest: ValidateFunction; }; export type InitializedConfig = Mutable> & { $commit(): Promise; }; type BaseConfig = { version: number | string; } & Record; export type Migrations = Array<(config: Config) => Config | Promise>; export type GetDefaultConfig = () => string | Promise; type GetPath = () => string | Promise; export type ConfigValidateFunction = (config: LatestConfig, configPath: string) => ValidationResult | Promise; export type InitConfigOptions = { allSchemas: Array>; latestSchema: JSONSchemaType; migrations: Migrations; name: string; getConfigOrConfigDirPath: GetPath; getSchemaDirPath?: GetPath; validate?: ConfigValidateFunction; }; type InitFunction = () => Promise | null>; type InitFunctionWithDefault = () => Promise>; type InitReadonlyFunction = () => Promise | null>; type InitReadonlyFunctionWithDefault = () => Promise>; export declare const getConfigPath: (configOrConfigDirPath: string, configName: string) => { configPath: string; configDirPath: string; }; export declare function getReadonlyConfigInitFunction(options: InitConfigOptions, getDefaultConfig?: undefined): InitReadonlyFunction; export declare function getReadonlyConfigInitFunction(options: InitConfigOptions, getDefaultConfig?: GetDefaultConfig): InitReadonlyFunctionWithDefault; export declare function getConfigInitFunction(options: InitConfigOptions, getDefaultConfig?: never): InitFunction; export declare function getConfigInitFunction(options: InitConfigOptions, getDefaultConfig: GetDefaultConfig): InitFunctionWithDefault; export {};