Refactor/actions (#2733)

* store, properties, manifest

* interfaces

* init and backups

* fix init and backups

* file models

* more versions

* dependencies

* config except dynamic types

* clean up config

* remove disabled from non-dynamic vaues

* actions

* standardize example code block formats

* wip: actions refactor

Co-authored-by: Jade <Blu-J@users.noreply.github.com>

* commit types

* fix types

* update types

* update action request type

* update apis

* add description to actionrequest

* clean up imports

* revert package json

* chore: Remove the recursive to the index

* chore: Remove the other thing I was testing

* flatten action requests

* update container runtime with new config paradigm

* new actions strategy

* seems to be working

* misc backend fixes

* fix fe bugs

* only show breakages if breakages

* only show success modal if result

* don't panic on failed removal

* hide config from actions page

* polyfill autoconfig

* use metadata strategy for actions instead of prev

* misc fixes

* chore: split the sdk into 2 libs (#2736)

* follow sideload progress (#2718)

* follow sideload progress

* small bugfix

* shareReplay with no refcount false

* don't wrap sideload progress in RPCResult

* dont present toast

---------

Co-authored-by: Aiden McClelland <me@drbonez.dev>

* chore: Add the initial of the creation of the two sdk

* chore: Add in the baseDist

* chore: Add in the baseDist

* chore: Get the web and the runtime-container running

* chore: Remove the empty file

* chore: Fix it so the container-runtime works

---------

Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com>
Co-authored-by: Aiden McClelland <me@drbonez.dev>

* misc fixes

* update todos

* minor clean up

* fix link script

* update node version in CI test

* fix node version syntax in ci build

* wip: fixing callbacks

* fix sdk makefile dependencies

* add support for const outside of main

* update apis

* don't panic!

* Chore: Capture weird case on rpc, and log that

* fix procedure id issue

* pass input value for dep auto config

* handle disabled and warning for actions

* chore: Fix for link not having node_modules

* sdk fixes

* fix build

* fix build

* fix build

---------

Co-authored-by: Matt Hill <mattnine@protonmail.com>
Co-authored-by: Jade <Blu-J@users.noreply.github.com>
Co-authored-by: J H <dragondef@gmail.com>
Co-authored-by: Jade <2364004+Blu-J@users.noreply.github.com>
Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com>
This commit is contained in:
Aiden McClelland
2024-09-25 16:12:52 -06:00
committed by GitHub
parent eec5cf6b65
commit db0695126f
469 changed files with 16218 additions and 10485 deletions

View File

@@ -6,7 +6,7 @@ import { Metric, NotificationLevel, RR, ServerNotifications } from './api.types'
import { BTC_ICON, LND_ICON, PROXY_ICON, REGISTRY_ICON } from './api-icons'
import { Log } from '@start9labs/shared'
import { configBuilderToSpec } from 'src/app/util/configBuilderToSpec'
import { T, CB } from '@start9labs/start-sdk'
import { T, ISB, IST } from '@start9labs/start-sdk'
import { GetPackagesRes } from '@start9labs/marketplace'
const mockBlake3Commitment: T.Blake3Commitment = {
@@ -112,7 +112,6 @@ export module Mock {
},
osVersion: '0.2.12',
dependencies: {},
hasConfig: true,
images: {
main: {
source: 'packed',
@@ -170,7 +169,6 @@ export module Mock {
s9pk: '',
},
},
hasConfig: true,
images: {
main: {
source: 'packed',
@@ -221,7 +219,6 @@ export module Mock {
s9pk: '',
},
},
hasConfig: false,
images: {
main: {
source: 'packed',
@@ -949,7 +946,8 @@ export module Mock {
},
}
export const ActionResponse: RR.ExecutePackageActionRes = {
export const ActionResponse: T.ActionResult = {
version: '0',
message:
'Password changed successfully. If you lose your new password, you will be lost forever.',
value: 'NewPassword1234!',
@@ -1137,31 +1135,29 @@ export module Mock {
},
}
export const getInputSpec = async (): Promise<
RR.GetPackageConfigRes['spec']
> =>
export const getActionInputSpec = async (): Promise<IST.InputSpec> =>
configBuilderToSpec(
CB.Config.of({
bitcoin: CB.Value.object(
ISB.InputSpec.of({
bitcoin: ISB.Value.object(
{
name: 'Bitcoin Settings',
description:
'RPC and P2P interface configuration options for Bitcoin Core',
},
CB.Config.of({
'bitcoind-p2p': CB.Value.union(
ISB.InputSpec.of({
'bitcoind-p2p': ISB.Value.union(
{
name: 'P2P Settings',
description:
'<p>The Bitcoin Core node to connect to over the peer-to-peer (P2P) interface:</p><ul><li><strong>Bitcoin Core</strong>: The Bitcoin Core service installed on this device</li><li><strong>External Node</strong>: A Bitcoin node running on a different device</li></ul>',
required: { default: 'internal' },
},
CB.Variants.of({
internal: { name: 'Bitcoin Core', spec: CB.Config.of({}) },
ISB.Variants.of({
internal: { name: 'Bitcoin Core', spec: ISB.InputSpec.of({}) },
external: {
name: 'External Node',
spec: CB.Config.of({
'p2p-host': CB.Value.text({
spec: ISB.InputSpec.of({
'p2p-host': ISB.Value.text({
name: 'Public Address',
required: {
default: null,
@@ -1169,7 +1165,7 @@ export module Mock {
description:
'The public address of your Bitcoin Core server',
}),
'p2p-port': CB.Value.number({
'p2p-port': ISB.Value.number({
name: 'P2P Port',
description:
'The port that your Bitcoin Core P2P server is bound to',
@@ -1186,24 +1182,23 @@ export module Mock {
),
}),
),
color: CB.Value.color({
color: ISB.Value.color({
name: 'Color',
required: false,
}),
datetime: CB.Value.datetime({
datetime: ISB.Value.datetime({
name: 'Datetime',
required: false,
}),
file: CB.Value.file({
file: ISB.Value.file({
name: 'File',
required: false,
extensions: ['png', 'pdf'],
}),
users: CB.Value.multiselect({
users: ISB.Value.multiselect({
name: 'Users',
default: [],
maxLength: 2,
disabled: ['matt'],
values: {
matt: 'Matt Hill',
alex: 'Alex Inkin',
@@ -1211,21 +1206,19 @@ export module Mock {
lucy: 'Lucy',
},
}),
advanced: CB.Value.object(
advanced: ISB.Value.object(
{
name: 'Advanced',
description: 'Advanced settings',
},
CB.Config.of({
rpcsettings: CB.Value.object(
ISB.InputSpec.of({
rpcsettings: ISB.Value.object(
{
name: 'RPC Settings',
description: 'rpc username and password',
warning:
'Adding RPC users gives them special permissions on your node.',
},
CB.Config.of({
rpcuser2: CB.Value.text({
ISB.InputSpec.of({
rpcuser2: ISB.Value.text({
name: 'RPC Username',
required: {
default: 'defaultrpcusername',
@@ -1238,7 +1231,7 @@ export module Mock {
},
],
}),
rpcuser: CB.Value.text({
rpcuser: ISB.Value.text({
name: 'RPC Username',
required: {
default: 'defaultrpcusername',
@@ -1251,7 +1244,7 @@ export module Mock {
},
],
}),
rpcpass: CB.Value.text({
rpcpass: ISB.Value.text({
name: 'RPC User Password',
required: {
default: {
@@ -1261,7 +1254,7 @@ export module Mock {
},
description: 'rpc password',
}),
rpcpass2: CB.Value.text({
rpcpass2: ISB.Value.text({
name: 'RPC User Password',
required: {
default: {
@@ -1275,15 +1268,15 @@ export module Mock {
),
}),
),
testnet: CB.Value.toggle({
testnet: ISB.Value.toggle({
name: 'Testnet',
default: true,
description:
'<ul><li>determines whether your node is running on testnet or mainnet</li></ul><script src="fake"></script>',
warning: 'Chain will have to resync!',
}),
'object-list': CB.Value.list(
CB.List.obj(
'object-list': ISB.Value.list(
ISB.List.obj(
{
name: 'Object List',
minLength: 0,
@@ -1295,13 +1288,13 @@ export module Mock {
description: 'This is a list of objects, like users or something',
},
{
spec: CB.Config.of({
'first-name': CB.Value.text({
spec: ISB.InputSpec.of({
'first-name': ISB.Value.text({
name: 'First Name',
required: false,
description: 'User first name',
}),
'last-name': CB.Value.text({
'last-name': ISB.Value.text({
name: 'Last Name',
required: {
default: {
@@ -1317,7 +1310,7 @@ export module Mock {
},
],
}),
age: CB.Value.number({
age: ISB.Value.number({
name: 'Age',
description: 'The age of the user',
warning: 'User must be at least 18.',
@@ -1331,8 +1324,8 @@ export module Mock {
},
),
),
'union-list': CB.Value.list(
CB.List.obj(
'union-list': ISB.Value.list(
ISB.List.obj(
{
name: 'Union List',
minLength: 0,
@@ -1342,27 +1335,27 @@ export module Mock {
warning: 'If you change this, things may work.',
},
{
spec: CB.Config.of({
spec: ISB.InputSpec.of({
/* TODO: Convert range for this value ([0, 2])*/
union: CB.Value.union(
union: ISB.Value.union(
{
name: 'Preference',
description: null,
warning: null,
required: { default: 'summer' },
},
CB.Variants.of({
ISB.Variants.of({
summer: {
name: 'summer',
spec: CB.Config.of({
'favorite-tree': CB.Value.text({
spec: ISB.InputSpec.of({
'favorite-tree': ISB.Value.text({
name: 'Favorite Tree',
required: {
default: 'Maple',
},
description: 'What is your favorite tree?',
}),
'favorite-flower': CB.Value.select({
'favorite-flower': ISB.Value.select({
name: 'Favorite Flower',
description: 'Select your favorite flower',
required: {
@@ -1379,8 +1372,8 @@ export module Mock {
},
winter: {
name: 'winter',
spec: CB.Config.of({
'like-snow': CB.Value.toggle({
spec: ISB.InputSpec.of({
'like-snow': ISB.Value.toggle({
name: 'Like Snow?',
default: true,
description: 'Do you like snow or not?',
@@ -1394,7 +1387,7 @@ export module Mock {
},
),
),
'random-select': CB.Value.select({
'random-select': ISB.Value.dynamicSelect(() => ({
name: 'Random select',
description: 'This is not even real.',
warning: 'Be careful changing this!',
@@ -1407,47 +1400,47 @@ export module Mock {
option3: 'option3',
},
disabled: ['option2'],
}),
})),
'favorite-number':
/* TODO: Convert range for this value ((-100,100])*/ CB.Value.number({
name: 'Favorite Number',
description: 'Your favorite number of all time',
warning:
'Once you set this number, it can never be changed without severe consequences.',
required: {
default: 7,
/* TODO: Convert range for this value ((-100,100])*/ ISB.Value.number(
{
name: 'Favorite Number',
description: 'Your favorite number of all time',
warning:
'Once you set this number, it can never be changed without severe consequences.',
required: {
default: 7,
},
integer: false,
units: 'BTC',
},
integer: false,
units: 'BTC',
}),
rpcsettings: CB.Value.object(
),
rpcsettings: ISB.Value.object(
{
name: 'RPC Settings',
description: 'rpc username and password',
warning:
'Adding RPC users gives them special permissions on your node.',
},
CB.Config.of({
laws: CB.Value.object(
ISB.InputSpec.of({
laws: ISB.Value.object(
{
name: 'Laws',
description: 'the law of the realm',
},
CB.Config.of({
law1: CB.Value.text({
ISB.InputSpec.of({
law1: ISB.Value.text({
name: 'First Law',
required: false,
description: 'the first law',
}),
law2: CB.Value.text({
law2: ISB.Value.text({
name: 'Second Law',
required: false,
description: 'the second law',
}),
}),
),
rulemakers: CB.Value.list(
CB.List.obj(
rulemakers: ISB.Value.list(
ISB.List.obj(
{
name: 'Rule Makers',
minLength: 0,
@@ -1455,8 +1448,8 @@ export module Mock {
description: 'the people who make the rules',
},
{
spec: CB.Config.of({
rulemakername: CB.Value.text({
spec: ISB.InputSpec.of({
rulemakername: ISB.Value.text({
name: 'Rulemaker Name',
required: {
default: {
@@ -1466,7 +1459,7 @@ export module Mock {
},
description: 'the name of the rule maker',
}),
rulemakerip: CB.Value.text({
rulemakerip: ISB.Value.text({
name: 'Rulemaker IP',
required: {
default: '192.168.1.0',
@@ -1484,7 +1477,7 @@ export module Mock {
},
),
),
rpcuser: CB.Value.text({
rpcuser: ISB.Value.text({
name: 'RPC Username',
required: {
default: 'defaultrpcusername',
@@ -1497,7 +1490,7 @@ export module Mock {
},
],
}),
rpcpass: CB.Value.text({
rpcpass: ISB.Value.text({
name: 'RPC User Password',
required: {
default: {
@@ -1510,33 +1503,32 @@ export module Mock {
}),
}),
),
'bitcoin-node': CB.Value.union(
'bitcoin-node': ISB.Value.union(
{
name: 'Bitcoin Node',
description: 'Options<ul><li>Item 1</li><li>Item 2</li></ul>',
warning: 'Careful changing this',
required: { default: 'internal' },
disabled: ['fake'],
},
CB.Variants.of({
ISB.Variants.of({
fake: {
name: 'Fake',
spec: CB.Config.of({}),
spec: ISB.InputSpec.of({}),
},
internal: {
name: 'Internal',
spec: CB.Config.of({}),
spec: ISB.InputSpec.of({}),
},
external: {
name: 'External',
spec: CB.Config.of({
'emergency-contact': CB.Value.object(
spec: ISB.InputSpec.of({
'emergency-contact': ISB.Value.object(
{
name: 'Emergency Contact',
description: 'The person to contact in case of emergency.',
},
CB.Config.of({
name: CB.Value.text({
ISB.InputSpec.of({
name: ISB.Value.text({
name: 'Name',
required: {
default: null,
@@ -1548,7 +1540,7 @@ export module Mock {
},
],
}),
email: CB.Value.text({
email: ISB.Value.text({
name: 'Email',
inputmode: 'email',
required: {
@@ -1557,7 +1549,7 @@ export module Mock {
}),
}),
),
'public-domain': CB.Value.text({
'public-domain': ISB.Value.text({
name: 'Public Domain',
required: {
default: 'bitcoinnode.com',
@@ -1570,7 +1562,7 @@ export module Mock {
},
],
}),
'private-domain': CB.Value.text({
'private-domain': ISB.Value.text({
name: 'Private Domain',
required: {
default: null,
@@ -1583,7 +1575,7 @@ export module Mock {
},
}),
),
port: CB.Value.number({
port: ISB.Value.number({
name: 'Port',
description:
'the default port for your Bitcoin node. default: 8333, testnet: 18333, regtest: 18444',
@@ -1595,7 +1587,7 @@ export module Mock {
step: 1,
integer: true,
}),
'favorite-slogan': CB.Value.text({
'favorite-slogan': ISB.Value.text({
name: 'Favorite Slogan',
generate: {
charset: 'a-z,A-Z,2-9',
@@ -1606,8 +1598,8 @@ export module Mock {
'You most favorite slogan in the whole world, used for paying you.',
masked: true,
}),
rpcallowip: CB.Value.list(
CB.List.text(
rpcallowip: ISB.Value.list(
ISB.List.text(
{
name: 'RPC Allowed IPs',
minLength: 1,
@@ -1629,8 +1621,8 @@ export module Mock {
},
),
),
rpcauth: CB.Value.list(
CB.List.text(
rpcauth: ISB.Value.list(
ISB.List.text(
{
name: 'RPC Auth',
description:
@@ -1694,14 +1686,21 @@ export module Mock {
icon: '/assets/img/service-icons/bitcoind.svg',
lastBackup: null,
status: {
configured: true,
main: {
status: 'running',
started: new Date().toISOString(),
health: {},
main: 'running',
started: new Date().toISOString(),
health: {},
},
actions: {
config: {
name: 'Bitcoin Config',
description: 'edit bitcoin.conf',
warning: null,
visibility: 'enabled',
allowedStatuses: 'any',
hasInput: true,
group: null,
},
},
actions: {},
serviceInterfaces: {
ui: {
id: 'ui',
@@ -1860,6 +1859,7 @@ export module Mock {
storeExposedDependents: [],
registry: 'https://registry.start9.com/',
developerKey: 'developer-key',
requestedActions: {},
}
export const bitcoinProxy: PackageDataEntry<InstalledState> = {
@@ -1871,10 +1871,7 @@ export module Mock {
icon: '/assets/img/service-icons/btc-rpc-proxy.png',
lastBackup: null,
status: {
configured: false,
main: {
status: 'stopped',
},
main: 'stopped',
},
actions: {},
serviceInterfaces: {
@@ -1902,13 +1899,13 @@ export module Mock {
kind: 'running',
versionRange: '>=26.0.0',
healthChecks: [],
configSatisfied: true,
},
},
hosts: {},
storeExposedDependents: [],
registry: 'https://registry.start9.com/',
developerKey: 'developer-key',
requestedActions: {},
}
export const lnd: PackageDataEntry<InstalledState> = {
@@ -1920,10 +1917,7 @@ export module Mock {
icon: '/assets/img/service-icons/lnd.png',
lastBackup: null,
status: {
configured: true,
main: {
status: 'stopped',
},
main: 'stopped',
},
actions: {},
serviceInterfaces: {
@@ -1986,20 +1980,19 @@ export module Mock {
kind: 'running',
versionRange: '>=26.0.0',
healthChecks: [],
configSatisfied: true,
},
'btc-rpc-proxy': {
title: Mock.MockManifestBitcoinProxy.title,
icon: 'assets/img/service-icons/btc-rpc-proxy.png',
kind: 'exists',
versionRange: '>2.0.0',
configSatisfied: false,
},
},
hosts: {},
storeExposedDependents: [],
registry: 'https://registry.start9.com/',
developerKey: 'developer-key',
requestedActions: {},
}
export const LocalPkgs: { [key: string]: PackageDataEntry<InstalledState> } =