mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-04-01 21:13:11 +00:00
feat: add autoConfig/ better types for wrapperData
This commit is contained in:
@@ -65,13 +65,13 @@ export class Config<A extends InputSpec> extends IBuilder<A> {
|
||||
}
|
||||
static withValue<K extends string, B extends ValueSpec>(
|
||||
key: K,
|
||||
value: Value<B>
|
||||
value: Value<B>,
|
||||
) {
|
||||
return Config.empty().withValue(key, value);
|
||||
}
|
||||
static addValue<K extends string, B extends ValueSpec>(
|
||||
key: K,
|
||||
value: Value<B>
|
||||
value: Value<B>,
|
||||
) {
|
||||
return Config.empty().withValue(key, value);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ export class List<A extends ValueSpecList> extends IBuilder<A> {
|
||||
patternDescription?: string | null;
|
||||
/** Default = "text" */
|
||||
inputmode?: ListValueSpecString["inputmode"];
|
||||
}
|
||||
},
|
||||
) {
|
||||
const spec = {
|
||||
type: "string" as const,
|
||||
@@ -77,7 +77,7 @@ export class List<A extends ValueSpecList> extends IBuilder<A> {
|
||||
range?: string;
|
||||
units?: string | null;
|
||||
placeholder?: string | null;
|
||||
}
|
||||
},
|
||||
) {
|
||||
const spec = {
|
||||
type: "number" as const,
|
||||
@@ -111,7 +111,7 @@ export class List<A extends ValueSpecList> extends IBuilder<A> {
|
||||
spec: Spec;
|
||||
displayAs?: null | string;
|
||||
uniqueBy?: null | UniqueBy;
|
||||
}
|
||||
},
|
||||
) {
|
||||
const { spec: previousSpecSpec, ...restSpec } = aSpec;
|
||||
const specSpec = previousSpecSpec.build() as BuilderExtract<Spec>;
|
||||
|
||||
@@ -154,7 +154,7 @@ export class Value<A extends ValueSpec> extends IBuilder<A> {
|
||||
description?: string | null;
|
||||
warning?: string | null;
|
||||
},
|
||||
previousSpec: Spec
|
||||
previousSpec: Spec,
|
||||
) {
|
||||
const spec = previousSpec.build() as BuilderExtract<Spec>;
|
||||
return new Value({
|
||||
@@ -166,7 +166,7 @@ export class Value<A extends ValueSpec> extends IBuilder<A> {
|
||||
});
|
||||
}
|
||||
static union<
|
||||
V extends Variants<{ [key: string]: { name: string; spec: InputSpec } }>
|
||||
V extends Variants<{ [key: string]: { name: string; spec: InputSpec } }>,
|
||||
>(
|
||||
a: {
|
||||
name: string;
|
||||
@@ -175,7 +175,7 @@ export class Value<A extends ValueSpec> extends IBuilder<A> {
|
||||
required: boolean;
|
||||
default?: string | null;
|
||||
},
|
||||
aVariants: V
|
||||
aVariants: V,
|
||||
) {
|
||||
const variants = aVariants.build() as BuilderExtract<V>;
|
||||
return new Value({
|
||||
|
||||
@@ -57,12 +57,12 @@ export class Variants<
|
||||
name: string;
|
||||
spec: InputSpec;
|
||||
};
|
||||
}
|
||||
},
|
||||
> extends IBuilder<A> {
|
||||
static of<
|
||||
A extends {
|
||||
[key: string]: { name: string; spec: Config<InputSpec> };
|
||||
}
|
||||
},
|
||||
>(a: A) {
|
||||
const variants: {
|
||||
[K in keyof A]: { name: string; spec: BuilderExtract<A[K]["spec"]> };
|
||||
@@ -82,7 +82,7 @@ export class Variants<
|
||||
}
|
||||
static withVariant<K extends string, B extends InputSpec>(
|
||||
key: K,
|
||||
value: Config<B>
|
||||
value: Config<B>,
|
||||
) {
|
||||
return Variants.empty().withVariant(key, value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user