mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-04-01 21:13:11 +00:00
wip: Creating an sdk builder that has all the generics we need in one place
This commit is contained in:
@@ -24,9 +24,8 @@ import {
|
||||
unknown,
|
||||
} from "ts-matches"
|
||||
import { once } from "../../util/once"
|
||||
import { WrapperDataContract } from "../../wrapperData/wrapperDataContract"
|
||||
|
||||
type RequiredDefault<A> =
|
||||
export type RequiredDefault<A> =
|
||||
| false
|
||||
| {
|
||||
default: A | null
|
||||
@@ -96,7 +95,7 @@ const username = Value.string({
|
||||
```
|
||||
*/
|
||||
export class Value<Type, WD> {
|
||||
private constructor(
|
||||
protected constructor(
|
||||
public build: LazyBuild<WD, ValueSpec>,
|
||||
public validator: Parser<unknown, Type>,
|
||||
) {}
|
||||
@@ -122,7 +121,6 @@ export class Value<Type, WD> {
|
||||
)
|
||||
}
|
||||
static dynamicToggle<WD = never>(
|
||||
_wrapperDataContract: WrapperDataContract<WD>,
|
||||
a: LazyBuild<
|
||||
WD,
|
||||
{
|
||||
@@ -186,7 +184,6 @@ export class Value<Type, WD> {
|
||||
)
|
||||
}
|
||||
static dynamicText<WD = never>(
|
||||
_wrapperDataContract: WrapperDataContract<WD>,
|
||||
getA: LazyBuild<
|
||||
WD,
|
||||
{
|
||||
@@ -258,7 +255,6 @@ export class Value<Type, WD> {
|
||||
)
|
||||
}
|
||||
static dynamicTextarea<WD = never>(
|
||||
_wrapperDataContract: WrapperDataContract<WD>,
|
||||
getA: LazyBuild<
|
||||
WD,
|
||||
{
|
||||
@@ -325,7 +321,6 @@ export class Value<Type, WD> {
|
||||
)
|
||||
}
|
||||
static dynamicNumber<WD = never>(
|
||||
_wrapperDataContract: WrapperDataContract<WD>,
|
||||
getA: LazyBuild<
|
||||
WD,
|
||||
{
|
||||
@@ -387,7 +382,6 @@ export class Value<Type, WD> {
|
||||
}
|
||||
|
||||
static dynamicColor<WD = never>(
|
||||
_wrapperDataContract: WrapperDataContract<WD>,
|
||||
getA: LazyBuild<
|
||||
WD,
|
||||
{
|
||||
@@ -445,7 +439,6 @@ export class Value<Type, WD> {
|
||||
)
|
||||
}
|
||||
static dynamicDatetime<WD = never>(
|
||||
_wrapperDataContract: WrapperDataContract<WD>,
|
||||
getA: LazyBuild<
|
||||
WD,
|
||||
{
|
||||
@@ -642,7 +635,6 @@ export class Value<Type, WD> {
|
||||
Type extends Record<string, any>,
|
||||
WD = never,
|
||||
>(
|
||||
_wrapperDataContract: WrapperDataContract<WD>,
|
||||
getDisabledFn: LazyBuild<WD, string[]>,
|
||||
a: {
|
||||
name: string
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { SDKManifest } from "../manifest/ManifestTypes"
|
||||
import { Dependency } from "../types"
|
||||
|
||||
export type Dependencies<T extends SDKManifest> = {
|
||||
export type ConfigDependencies<T extends SDKManifest> = {
|
||||
exists(id: keyof T["dependencies"]): Dependency
|
||||
running(id: keyof T["dependencies"]): Dependency
|
||||
}
|
||||
|
||||
export const dependenciesSet = <T extends SDKManifest>(): Dependencies<T> => ({
|
||||
export const configDependenciesSet = <
|
||||
T extends SDKManifest,
|
||||
>(): ConfigDependencies<T> => ({
|
||||
exists(id: keyof T["dependencies"]) {
|
||||
return {
|
||||
id,
|
||||
@@ -1,5 +1,5 @@
|
||||
import "./builder"
|
||||
|
||||
import "./setupConfig"
|
||||
import "./dependencies"
|
||||
import "./constants"
|
||||
import "./configDependencies"
|
||||
import "./configConstants"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Effects, ExpectedExports } from "../types"
|
||||
import { SDKManifest } from "../manifest/ManifestTypes"
|
||||
import * as D from "./dependencies"
|
||||
import * as D from "./configDependencies"
|
||||
import { Config, ExtractConfigType } from "./builder/config"
|
||||
import { Utils, utils } from "../util"
|
||||
import nullIfEmpty from "../util/nullIfEmpty"
|
||||
@@ -22,7 +22,7 @@ export type Save<
|
||||
effects: Effects
|
||||
input: ExtractConfigType<A> & Record<string, any>
|
||||
utils: Utils<WD>
|
||||
dependencies: D.Dependencies<Manifest>
|
||||
dependencies: D.ConfigDependencies<Manifest>
|
||||
}) => Promise<{
|
||||
dependenciesReceipt: DependenciesReceipt
|
||||
restart: boolean
|
||||
@@ -70,7 +70,7 @@ export function setupConfig<
|
||||
input: JSON.parse(JSON.stringify(input)),
|
||||
effects,
|
||||
utils: utils(wrapperDataContract, effects),
|
||||
dependencies: D.dependenciesSet<Manifest>(),
|
||||
dependencies: D.configDependenciesSet<Manifest>(),
|
||||
})
|
||||
if (restart) {
|
||||
await effects.restart()
|
||||
|
||||
Reference in New Issue
Block a user