feat: File

This commit is contained in:
BluJ
2023-05-12 14:10:32 -06:00
parent 09727c97dc
commit f661106423
2 changed files with 46 additions and 2 deletions

View File

@@ -628,6 +628,50 @@ export class Value<Type, Store, Vault> {
}
}, previousSpec.validator)
}
static file<Required extends boolean, Store, Vault>(a: {
name: string
description?: string | null
warning?: string | null
extensions: string[]
required: Required
}) {
const buildValue = {
type: "file" as const,
description: null,
warning: null,
...a,
}
if (a.required) {
return new Value<string, Store, Vault>(() => buildValue, string)
}
return new Value<string | null | undefined, Store, Vault>(
() => buildValue,
string.optional(),
)
}
static dynamicFile<Required extends boolean, Store, Vault>(
a: LazyBuild<
Store,
Vault,
{
name: string
description?: string | null
warning?: string | null
extensions: string[]
required: Required
}
>,
) {
return new Value<string | null | undefined, Store, Vault>(
async (options) => ({
type: "file" as const,
description: null,
warning: null,
...(await a(options)),
}),
string.optional(),
)
}
static union<Required extends RequiredDefault<string>, Type, Store, Vault>(
a: {
name: string

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@start9labs/start-sdk",
"version": "0.4.0-rev0.lib0.rc1",
"version": "0.4.0-rev0.lib0.rc2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@start9labs/start-sdk",
"version": "0.4.0-rev0.lib0.rc1",
"version": "0.4.0-rev0.lib0.rc2",
"license": "MIT",
"dependencies": {
"@iarna/toml": "^2.2.5",