mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
port 040 config (#2657)
* port 040 config, WIP * update fixtures * use taiga modal for backups too * fix: update Taiga UI and refactor everything to work * chore: package-lock * fix interfaces and mocks for interfaces * better mocks * function to transform old spec to new * delete unused fns * delete unused FE config utils * fix exports from sdk * reorganize exports * functions to translate config * rename unionSelectKey and unionValueKey * Adding in the transformation of the getConfig to the new types. * chore: add Taiga UI to preloader --------- Co-authored-by: waterplea <alexander@inkin.ru> Co-authored-by: Aiden McClelland <me@drbonez.dev> Co-authored-by: J H <dragondef@gmail.com>
This commit is contained in:
@@ -268,26 +268,9 @@ describe("values", () => {
|
||||
}),
|
||||
)
|
||||
const validator = value.validator
|
||||
validator.unsafeCast({ unionSelectKey: "a", unionValueKey: { b: false } })
|
||||
validator.unsafeCast({ selection: "a", value: { b: false } })
|
||||
type Test = typeof validator._TYPE
|
||||
testOutput<Test, { unionSelectKey: "a"; unionValueKey: { b: boolean } }>()(
|
||||
null,
|
||||
)
|
||||
})
|
||||
test("list", async () => {
|
||||
const value = Value.list(
|
||||
List.number(
|
||||
{
|
||||
name: "test",
|
||||
},
|
||||
{
|
||||
integer: false,
|
||||
},
|
||||
),
|
||||
)
|
||||
const validator = value.validator
|
||||
validator.unsafeCast([1, 2, 3])
|
||||
testOutput<typeof validator._TYPE, number[]>()(null)
|
||||
testOutput<Test, { selection: "a"; value: { b: boolean } }>()(null)
|
||||
})
|
||||
|
||||
describe("dynamic", () => {
|
||||
@@ -577,12 +560,12 @@ describe("values", () => {
|
||||
}),
|
||||
)
|
||||
const validator = value.validator
|
||||
validator.unsafeCast({ unionSelectKey: "a", unionValueKey: { b: false } })
|
||||
validator.unsafeCast({ selection: "a", value: { b: false } })
|
||||
type Test = typeof validator._TYPE
|
||||
testOutput<
|
||||
Test,
|
||||
| { unionSelectKey: "a"; unionValueKey: { b: boolean } }
|
||||
| { unionSelectKey: "b"; unionValueKey: { b: boolean } }
|
||||
| { selection: "a"; value: { b: boolean } }
|
||||
| { selection: "b"; value: { b: boolean } }
|
||||
>()(null)
|
||||
|
||||
const built = await value.build({} as any)
|
||||
@@ -644,12 +627,12 @@ describe("values", () => {
|
||||
}),
|
||||
)
|
||||
const validator = value.validator
|
||||
validator.unsafeCast({ unionSelectKey: "a", unionValueKey: { b: false } })
|
||||
validator.unsafeCast({ selection: "a", value: { b: false } })
|
||||
type Test = typeof validator._TYPE
|
||||
testOutput<
|
||||
Test,
|
||||
| { unionSelectKey: "a"; unionValueKey: { b: boolean } }
|
||||
| { unionSelectKey: "b"; unionValueKey: { b: boolean } }
|
||||
| { selection: "a"; value: { b: boolean } }
|
||||
| { selection: "b"; value: { b: boolean } }
|
||||
| null
|
||||
| undefined
|
||||
>()(null)
|
||||
@@ -736,24 +719,6 @@ describe("Builder List", () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
test("number", async () => {
|
||||
const value = Value.list(
|
||||
List.dynamicNumber(() => ({
|
||||
name: "test",
|
||||
spec: { integer: true },
|
||||
})),
|
||||
)
|
||||
const validator = value.validator
|
||||
expect(() => validator.unsafeCast(["test", "text"])).toThrowError()
|
||||
validator.unsafeCast([4, 2])
|
||||
expect(() => validator.unsafeCast(null)).toThrowError()
|
||||
validator.unsafeCast([])
|
||||
testOutput<typeof validator._TYPE, number[]>()(null)
|
||||
expect(await value.build({} as any)).toMatchObject({
|
||||
name: "test",
|
||||
spec: { integer: true },
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("Nested nullable values", () => {
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
import {
|
||||
ListValueSpecOf,
|
||||
ValueSpec,
|
||||
isValueSpecListOf,
|
||||
} from "../config/configTypes"
|
||||
import { ListValueSpecOf, isValueSpecListOf } from "../config/configTypes"
|
||||
import { Config } from "../config/builder/config"
|
||||
import { List } from "../config/builder/list"
|
||||
import { Value } from "../config/builder/value"
|
||||
|
||||
describe("Config Types", () => {
|
||||
test("isValueSpecListOf", async () => {
|
||||
const options = [List.obj, List.text, List.number]
|
||||
const options = [List.obj, List.text]
|
||||
for (const option of options) {
|
||||
const test = (option as any)(
|
||||
{} as any,
|
||||
@@ -18,8 +14,6 @@ describe("Config Types", () => {
|
||||
const someList = await Value.list(test).build({} as any)
|
||||
if (isValueSpecListOf(someList, "text")) {
|
||||
someList.spec satisfies ListValueSpecOf<"text">
|
||||
} else if (isValueSpecListOf(someList, "number")) {
|
||||
someList.spec satisfies ListValueSpecOf<"number">
|
||||
} else if (isValueSpecListOf(someList, "object")) {
|
||||
someList.spec satisfies ListValueSpecOf<"object">
|
||||
} else {
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
import {
|
||||
UnionSelectKey,
|
||||
unionSelectKey,
|
||||
UnionValueKey,
|
||||
unionValueKey,
|
||||
} from "../config/configTypes"
|
||||
import { ConfigSpec, matchConfigSpec } from "./output"
|
||||
import * as _I from "../index"
|
||||
import { camelCase } from "../../scripts/oldSpecToBuilder"
|
||||
@@ -30,13 +24,10 @@ testOutput<
|
||||
ConfigSpec["advanced"]["peers"]["addnode"][0]["hostname"],
|
||||
string | null | undefined
|
||||
>()(null)
|
||||
testOutput<
|
||||
ConfigSpec["testListUnion"][0]["union"][UnionValueKey]["name"],
|
||||
string
|
||||
>()(null)
|
||||
testOutput<ConfigSpec["testListUnion"][0]["union"][UnionSelectKey], "lnd">()(
|
||||
testOutput<ConfigSpec["testListUnion"][0]["union"]["value"]["name"], string>()(
|
||||
null,
|
||||
)
|
||||
testOutput<ConfigSpec["testListUnion"][0]["union"]["selection"], "lnd">()(null)
|
||||
testOutput<ConfigSpec["mediasources"], Array<"filebrowser" | "nextcloud">>()(
|
||||
null,
|
||||
)
|
||||
@@ -45,7 +36,7 @@ testOutput<ConfigSpec["mediasources"], Array<"filebrowser" | "nextcloud">>()(
|
||||
testOutput<ConfigSpec["rpc"]["enable"], string>()(null)
|
||||
// prettier-ignore
|
||||
// @ts-expect-error Expect that the string is the one above
|
||||
testOutput<ConfigSpec["testListUnion"][0][UnionSelectKey][UnionSelectKey], "unionSelectKey">()(null);
|
||||
testOutput<ConfigSpec["testListUnion"][0]['selection']['selection'], "selection">()(null);
|
||||
|
||||
/// Here we test the output of the matchConfigSpec function
|
||||
describe("Inputs", () => {
|
||||
@@ -53,7 +44,7 @@ describe("Inputs", () => {
|
||||
mediasources: ["filebrowser"],
|
||||
testListUnion: [
|
||||
{
|
||||
union: { [unionSelectKey]: "lnd", [unionValueKey]: { name: "string" } },
|
||||
union: { selection: "lnd", value: { name: "string" } },
|
||||
},
|
||||
],
|
||||
rpc: {
|
||||
@@ -92,8 +83,8 @@ describe("Inputs", () => {
|
||||
},
|
||||
dbcache: 5,
|
||||
pruning: {
|
||||
unionSelectKey: "disabled",
|
||||
unionValueKey: {},
|
||||
selection: "disabled",
|
||||
value: {},
|
||||
},
|
||||
blockfilters: {
|
||||
blockfilterindex: false,
|
||||
|
||||
Reference in New Issue
Block a user