feat: Add in the new types of the file and the value

This commit is contained in:
Blu-J
2023-07-28 14:03:29 -06:00
parent ba248eee28
commit 2d52b39409
3 changed files with 22 additions and 11 deletions

View File

@@ -2,6 +2,7 @@ import { Config, LazyBuild, LazyBuildOptions } from "./config"
import { List } from "./list" import { List } from "./list"
import { Variants } from "./variants" import { Variants } from "./variants"
import { import {
FilePath,
Pattern, Pattern,
RandomString, RandomString,
ValueSpec, ValueSpec,
@@ -623,7 +624,7 @@ export class Value<Type, Store> {
} }
}, spec.validator) }, spec.validator)
} }
static file<Required extends boolean, Store>(a: { static file<Required extends RequiredDefault<string>, Store>(a: {
name: string name: string
description?: string | null description?: string | null
warning?: string | null warning?: string | null
@@ -636,12 +637,13 @@ export class Value<Type, Store> {
warning: null, warning: null,
...a, ...a,
} }
if (a.required) { return new Value<AsRequired<FilePath, Required>, Store>(
return new Value<string, Store>(() => buildValue, string) () => ({
} ...buildValue,
return new Value<string | null | undefined, Store>(
() => buildValue, ...requiredLikeToAbove(a.required),
string.optional(), }),
asRequiredParser(object({ filePath: string }), a),
) )
} }
static dynamicFile<Required extends boolean, Store>( static dynamicFile<Required extends boolean, Store>(

View File

@@ -58,6 +58,10 @@ export interface ValueSpecTextarea extends WithStandalone {
/** Immutable means it can only be configed at the first config then never again */ /** Immutable means it can only be configed at the first config then never again */
immutable: boolean immutable: boolean
} }
export type FilePath = {
filePath: string
}
export interface ValueSpecNumber extends ListValueSpecNumber, WithStandalone { export interface ValueSpecNumber extends ListValueSpecNumber, WithStandalone {
required: boolean required: boolean
default: number | null default: number | null

View File

@@ -4,10 +4,15 @@ import { Utils } from "../util/utils"
export type SetupExports<Store> = (opts: { export type SetupExports<Store> = (opts: {
effects: Effects effects: Effects
utils: Utils<Store> utils: Utils<Store>
}) => { }) =>
ui: ExposeUiPaths<Store> | {
services: ExposeServicePaths<Store> ui: ExposeUiPaths<Store>
} services: ExposeServicePaths<Store>
}
| Promise<{
ui: ExposeUiPaths<Store>
services: ExposeServicePaths<Store>
}>
export const setupExports = <Store>(fn: (opts: SetupExports<Store>) => void) => export const setupExports = <Store>(fn: (opts: SetupExports<Store>) => void) =>
fn fn