mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 10:21:55 +00:00
chore: Update the setupConfigExport
This commit is contained in:
@@ -11,29 +11,26 @@ import { TypeFromProps } from "../util/propertiesMatcher";
|
||||
* @param options
|
||||
* @returns
|
||||
*/
|
||||
export function setupConfigExports<A extends InputSpec>(options: {
|
||||
export function setupConfigExports<A extends InputSpec, ConfigType>(options: {
|
||||
spec: Config<A>;
|
||||
dependsOn: DependsOn;
|
||||
write(effects: Effects, config: TypeFromProps<A>): Promise<void>;
|
||||
read(effects: Effects): Promise<null | DeepPartial<TypeFromProps<A>>>;
|
||||
write(options: { effects: Effects; input: TypeFromProps<A> }): Promise<ConfigType>;
|
||||
read(options: { effects: Effects; config: ConfigType }): Promise<null | DeepPartial<TypeFromProps<A>>>;
|
||||
}) {
|
||||
const validator = options.spec.validator();
|
||||
return {
|
||||
setConfig: (async ({ effects, input: config }) => {
|
||||
if (!validator.test(config)) {
|
||||
await effects.error(String(validator.errorMessage(config)));
|
||||
setConfig: (async ({ effects, input }) => {
|
||||
if (!validator.test(input)) {
|
||||
await effects.error(String(validator.errorMessage(input)));
|
||||
return { error: "Set config type error for config" };
|
||||
}
|
||||
await options.write(effects, config);
|
||||
return {
|
||||
signal: "SIGTERM",
|
||||
"depends-on": options.dependsOn,
|
||||
};
|
||||
const output = await options.write({ input, effects });
|
||||
return output;
|
||||
}) as ExpectedExports.setConfig,
|
||||
getConfig: (async ({ effects }) => {
|
||||
getConfig: (async ({ effects, config }) => {
|
||||
return {
|
||||
spec: options.spec.build(),
|
||||
config: nullIfEmpty(await options.read(effects)),
|
||||
config: nullIfEmpty(await options.read({ effects, config: config as ConfigType })),
|
||||
};
|
||||
}) as ExpectedExports.getConfig,
|
||||
};
|
||||
|
||||
@@ -13,8 +13,8 @@ type Daemon<
|
||||
|
||||
ready: {
|
||||
display: null | {
|
||||
name: "Websocket Live";
|
||||
message: "The websocket is live";
|
||||
name: string;
|
||||
message: string;
|
||||
};
|
||||
fn: () => Promise<CheckResult> | CheckResult;
|
||||
trigger?: Trigger;
|
||||
|
||||
7
lib/mainFn/RunningMainRet.ts
Normal file
7
lib/mainFn/RunningMainRet.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Daemon } from "../types";
|
||||
import { ReadyProof } from "./ReadyProof";
|
||||
|
||||
export type RunningMainRet = {
|
||||
[ReadyProof]: never;
|
||||
daemon: Daemon;
|
||||
};
|
||||
@@ -1,8 +1,9 @@
|
||||
import { writeConvertedFile } from "../../scripts/oldSpecToBuilder";
|
||||
|
||||
writeConvertedFile(
|
||||
"./lib/test/output.ts",
|
||||
"./output.ts", // Make the location
|
||||
{
|
||||
// Put the config here
|
||||
testListUnion: {
|
||||
type: "list",
|
||||
subtype: "union",
|
||||
@@ -18,8 +19,7 @@ writeConvertedFile(
|
||||
tag: {
|
||||
id: "type",
|
||||
name: "Type",
|
||||
description:
|
||||
"- LND: Lightning Network Daemon from Lightning Labs\n- CLN: Core Lightning from Blockstream\n",
|
||||
description: "- LND: Lightning Network Daemon from Lightning Labs\n- CLN: Core Lightning from Blockstream\n",
|
||||
"variant-names": {
|
||||
lnd: "Lightning Network Daemon (LND)",
|
||||
"c-lightning": "Core Lightning (CLN)",
|
||||
@@ -58,8 +58,7 @@ writeConvertedFile(
|
||||
default: "bitcoin",
|
||||
masked: true,
|
||||
pattern: "^[a-zA-Z0-9_]+$",
|
||||
"pattern-description":
|
||||
"Must be alphanumeric (can contain underscore).",
|
||||
"pattern-description": "Must be alphanumeric (can contain underscore).",
|
||||
},
|
||||
password: {
|
||||
type: "string",
|
||||
@@ -71,8 +70,7 @@ writeConvertedFile(
|
||||
len: 20,
|
||||
},
|
||||
pattern: '^[^\\n"]*$',
|
||||
"pattern-description":
|
||||
"Must not contain newline or quote characters.",
|
||||
"pattern-description": "Must not contain newline or quote characters.",
|
||||
copyable: true,
|
||||
masked: true,
|
||||
},
|
||||
@@ -84,8 +82,7 @@ writeConvertedFile(
|
||||
default: "bitcoin",
|
||||
masked: true,
|
||||
pattern: "^[a-zA-Z0-9_]+$",
|
||||
"pattern-description":
|
||||
"Must be alphanumeric (can contain underscore).",
|
||||
"pattern-description": "Must be alphanumeric (can contain underscore).",
|
||||
textarea: true,
|
||||
},
|
||||
advanced: {
|
||||
@@ -101,18 +98,15 @@ writeConvertedFile(
|
||||
subtype: "string",
|
||||
default: [],
|
||||
spec: {
|
||||
pattern:
|
||||
"^[a-zA-Z0-9_-]+:([0-9a-fA-F]{2})+\\$([0-9a-fA-F]{2})+$",
|
||||
"pattern-description":
|
||||
'Each item must be of the form "<USERNAME>:<SALT>$<HASH>".',
|
||||
pattern: "^[a-zA-Z0-9_-]+:([0-9a-fA-F]{2})+\\$([0-9a-fA-F]{2})+$",
|
||||
"pattern-description": 'Each item must be of the form "<USERNAME>:<SALT>$<HASH>".',
|
||||
masked: false,
|
||||
},
|
||||
range: "[0,*)",
|
||||
},
|
||||
serialversion: {
|
||||
name: "Serialization Version",
|
||||
description:
|
||||
"Return raw transaction or block hex with Segwit or non-SegWit serialization.",
|
||||
description: "Return raw transaction or block hex with Segwit or non-SegWit serialization.",
|
||||
type: "enum",
|
||||
values: ["non-segwit", "segwit"],
|
||||
"value-names": {},
|
||||
@@ -120,8 +114,7 @@ writeConvertedFile(
|
||||
},
|
||||
servertimeout: {
|
||||
name: "Rpc Server Timeout",
|
||||
description:
|
||||
"Number of seconds after which an uncompleted RPC call will time out.",
|
||||
description: "Number of seconds after which an uncompleted RPC call will time out.",
|
||||
type: "number",
|
||||
nullable: false,
|
||||
range: "[5,300]",
|
||||
@@ -224,8 +217,7 @@ writeConvertedFile(
|
||||
type: "number",
|
||||
nullable: false,
|
||||
name: "Max Mempool Size",
|
||||
description:
|
||||
"Keep the transaction memory pool below <n> megabytes.",
|
||||
description: "Keep the transaction memory pool below <n> megabytes.",
|
||||
range: "[1,*)",
|
||||
integral: true,
|
||||
units: "MiB",
|
||||
@@ -235,8 +227,7 @@ writeConvertedFile(
|
||||
type: "number",
|
||||
nullable: false,
|
||||
name: "Mempool Expiration",
|
||||
description:
|
||||
"Do not keep transactions in the mempool longer than <n> hours.",
|
||||
description: "Do not keep transactions in the mempool longer than <n> hours.",
|
||||
range: "[1,*)",
|
||||
integral: true,
|
||||
units: "Hr",
|
||||
@@ -252,8 +243,7 @@ writeConvertedFile(
|
||||
listen: {
|
||||
type: "boolean",
|
||||
name: "Make Public",
|
||||
description:
|
||||
"Allow other nodes to find your server on the network.",
|
||||
description: "Allow other nodes to find your server on the network.",
|
||||
default: true,
|
||||
},
|
||||
onlyconnect: {
|
||||
@@ -293,8 +283,7 @@ writeConvertedFile(
|
||||
type: "number",
|
||||
nullable: true,
|
||||
name: "Port",
|
||||
description:
|
||||
"Port that peer is listening on for inbound p2p connections",
|
||||
description: "Port that peer is listening on for inbound p2p connections",
|
||||
range: "[0,65535]",
|
||||
integral: true,
|
||||
},
|
||||
@@ -318,8 +307,7 @@ writeConvertedFile(
|
||||
pruning: {
|
||||
type: "union",
|
||||
name: "Pruning Settings",
|
||||
description:
|
||||
"Blockchain Pruning Options\nReduce the blockchain size on disk\n",
|
||||
description: "Blockchain Pruning Options\nReduce the blockchain size on disk\n",
|
||||
warning:
|
||||
"If you set pruning to Manual and your disk is smaller than the total size of the blockchain, you MUST have something running that prunes these blocks or you may overfill your disk!\nDisabling pruning will convert your node into a full archival node. This requires a resync of the entire blockchain, a process that may take several days. Make sure you have enough free disk space or you may fill up your disk.\n",
|
||||
tag: {
|
||||
@@ -341,8 +329,7 @@ writeConvertedFile(
|
||||
nullable: false,
|
||||
name: "Max Chain Size",
|
||||
description: "Limit of blockchain size on disk.",
|
||||
warning:
|
||||
"Increasing this value will require re-syncing your node.",
|
||||
warning: "Increasing this value will require re-syncing your node.",
|
||||
default: 550,
|
||||
range: "[550,1000000)",
|
||||
integral: true,
|
||||
@@ -405,6 +392,6 @@ writeConvertedFile(
|
||||
},
|
||||
},
|
||||
{
|
||||
startSdk: "..",
|
||||
startSdk: "start-sdk",
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user