mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-31 04:33:40 +00:00
chore: charlie23
This commit is contained in:
@@ -2,4 +2,4 @@ export * as configBuilder from "./builder";
|
||||
|
||||
export { setupConfigExports } from "./setupConfigExports";
|
||||
export { specToBuilder, specToBuilderFile } from "./specToBuilder";
|
||||
export * as dependencies from './dependencies'
|
||||
export * as dependencies from "./dependencies";
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { Config } from "./builder";
|
||||
import { DeepPartial, Dependencies, DependsOn, Effects, ExpectedExports } from "../types";
|
||||
import {
|
||||
DeepPartial,
|
||||
Dependencies,
|
||||
DependsOn,
|
||||
Effects,
|
||||
ExpectedExports,
|
||||
} from "../types";
|
||||
import { InputSpec } from "./configTypes";
|
||||
import { nullIfEmpty } from "../util";
|
||||
import { TypeFromProps } from "../util/propertiesMatcher";
|
||||
@@ -13,8 +19,14 @@ import { TypeFromProps } from "../util/propertiesMatcher";
|
||||
*/
|
||||
export function setupConfigExports<A extends InputSpec, ConfigType>(options: {
|
||||
spec: Config<A>;
|
||||
write(options: { effects: Effects; input: TypeFromProps<A> }): Promise<[ConfigType, Dependencies]>;
|
||||
read(options: { effects: Effects; config: ConfigType }): Promise<null | DeepPartial<TypeFromProps<A>>>;
|
||||
write(options: {
|
||||
effects: Effects;
|
||||
input: TypeFromProps<A>;
|
||||
}): Promise<[ConfigType, Dependencies]>;
|
||||
read(options: {
|
||||
effects: Effects;
|
||||
config: ConfigType;
|
||||
}): Promise<null | DeepPartial<TypeFromProps<A>>>;
|
||||
}) {
|
||||
const validator = options.spec.validator();
|
||||
return {
|
||||
@@ -31,7 +43,9 @@ export function setupConfigExports<A extends InputSpec, ConfigType>(options: {
|
||||
getConfig: (async ({ effects, config }) => {
|
||||
return {
|
||||
spec: options.spec.build(),
|
||||
config: nullIfEmpty(await options.read({ effects, config: config as ConfigType })),
|
||||
config: nullIfEmpty(
|
||||
await options.read({ effects, config: config as ConfigType })
|
||||
),
|
||||
};
|
||||
}) as ExpectedExports.getConfig,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user