mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 18:31:54 +00:00
feat: Add in the new types of the file and the value
This commit is contained in:
@@ -2,6 +2,7 @@ import { Config, LazyBuild, LazyBuildOptions } from "./config"
|
||||
import { List } from "./list"
|
||||
import { Variants } from "./variants"
|
||||
import {
|
||||
FilePath,
|
||||
Pattern,
|
||||
RandomString,
|
||||
ValueSpec,
|
||||
@@ -623,7 +624,7 @@ export class Value<Type, Store> {
|
||||
}
|
||||
}, spec.validator)
|
||||
}
|
||||
static file<Required extends boolean, Store>(a: {
|
||||
static file<Required extends RequiredDefault<string>, Store>(a: {
|
||||
name: string
|
||||
description?: string | null
|
||||
warning?: string | null
|
||||
@@ -636,12 +637,13 @@ export class Value<Type, Store> {
|
||||
warning: null,
|
||||
...a,
|
||||
}
|
||||
if (a.required) {
|
||||
return new Value<string, Store>(() => buildValue, string)
|
||||
}
|
||||
return new Value<string | null | undefined, Store>(
|
||||
() => buildValue,
|
||||
string.optional(),
|
||||
return new Value<AsRequired<FilePath, Required>, Store>(
|
||||
() => ({
|
||||
...buildValue,
|
||||
|
||||
...requiredLikeToAbove(a.required),
|
||||
}),
|
||||
asRequiredParser(object({ filePath: string }), a),
|
||||
)
|
||||
}
|
||||
static dynamicFile<Required extends boolean, Store>(
|
||||
|
||||
@@ -58,6 +58,10 @@ export interface ValueSpecTextarea extends WithStandalone {
|
||||
/** Immutable means it can only be configed at the first config then never again */
|
||||
immutable: boolean
|
||||
}
|
||||
|
||||
export type FilePath = {
|
||||
filePath: string
|
||||
}
|
||||
export interface ValueSpecNumber extends ListValueSpecNumber, WithStandalone {
|
||||
required: boolean
|
||||
default: number | null
|
||||
|
||||
@@ -4,10 +4,15 @@ import { Utils } from "../util/utils"
|
||||
export type SetupExports<Store> = (opts: {
|
||||
effects: Effects
|
||||
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) =>
|
||||
fn
|
||||
|
||||
Reference in New Issue
Block a user