mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
update sdk
This commit is contained in:
@@ -1,4 +1,21 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { ExposedUI } from "./ExposedUI";
|
||||
|
||||
export interface ExposeUiParams { paths: Array<ExposedUI>, }
|
||||
export type ExposeUiParams =
|
||||
| {
|
||||
type: "object";
|
||||
value: { [k: string]: ExposeUiParams };
|
||||
}
|
||||
| {
|
||||
type: "string";
|
||||
/** The path to the value in the Store. [JsonPath](https://jsonpath.com/) */
|
||||
path: string;
|
||||
/** A human readable description or explanation of the value */
|
||||
description: string | null;
|
||||
/** (string/number only) Whether or not to mask the value, for example, when displaying a password */
|
||||
masked: boolean;
|
||||
/** (string/number only) Whether or not to include a button for copying the value to clipboard */
|
||||
copyable: boolean | null;
|
||||
/** (string/number only) Whether or not to include a button for displaying the value as a QR code */
|
||||
qr: boolean | null;
|
||||
};
|
||||
|
||||
@@ -691,9 +691,19 @@ async fn expose_for_dependents(
|
||||
}
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(tag = "type")]
|
||||
#[ts(export)]
|
||||
struct ExposeUiParams {
|
||||
paths: Vec<ExposedUI>,
|
||||
enum ExposeUiParams {
|
||||
Object {
|
||||
value: Record<String, ExposeUiParams>,
|
||||
},
|
||||
r#String {
|
||||
path: String,
|
||||
description: Option<String>,
|
||||
masked: bool,
|
||||
copyable: Option<bool>,
|
||||
qr: Option<bool>,
|
||||
},
|
||||
}
|
||||
|
||||
async fn expose_ui(
|
||||
|
||||
@@ -54,6 +54,7 @@ import {
|
||||
} from "./interfaces/setupInterfaces"
|
||||
import { successFailure } from "./trigger/successFailure"
|
||||
import { SetupExports } from "./inits/setupExports"
|
||||
import { HealthReceipt } from "./health/HealthReceipt"
|
||||
|
||||
// prettier-ignore
|
||||
type AnyNeverCond<T extends any[], Then, Else> =
|
||||
@@ -234,7 +235,15 @@ export class StartSdk<Manifest extends SDKManifest, Store> {
|
||||
spec: Spec,
|
||||
) => Config.of<Spec, Store>(spec),
|
||||
},
|
||||
Daemons: { of: Daemons.of },
|
||||
Daemons: {
|
||||
of(config: {
|
||||
effects: Effects
|
||||
started: (onTerm: () => PromiseLike<void>) => PromiseLike<void>
|
||||
healthReceipts: HealthReceipt[]
|
||||
}) {
|
||||
return Daemons.of<Manifest>(config)
|
||||
},
|
||||
},
|
||||
DependencyConfig: {
|
||||
of<
|
||||
LocalConfig extends Record<string, any>,
|
||||
|
||||
@@ -42,7 +42,7 @@ export class Backups<M extends SDKManifest> {
|
||||
|
||||
private constructor(
|
||||
private options = DEFAULT_OPTIONS,
|
||||
private backupSet = [] as BackupSet<M["volumes"][0]>[],
|
||||
private backupSet = [] as BackupSet<M["volumes"][number]>[],
|
||||
) {}
|
||||
static volumes<M extends SDKManifest = never>(
|
||||
...volumeNames: Array<M["volumes"][0]>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { ExpectedExports } from "../types"
|
||||
import { _ } from "../util"
|
||||
|
||||
export type SetupBackupsParams<M extends SDKManifest> = Array<
|
||||
M["volumes"][0] | Backups<M>
|
||||
M["volumes"][number] | Backups<M>
|
||||
>
|
||||
|
||||
export function setupBackups<M extends SDKManifest>(
|
||||
|
||||
@@ -4,6 +4,7 @@ export { Overlay } from "./util/Overlay"
|
||||
export { Utils } from "./util/utils"
|
||||
export { StartSdk } from "./StartSdk"
|
||||
export { setupManifest } from "./manifest/setupManifest"
|
||||
export { FileHelper } from "./util/fileHelper"
|
||||
export * as actions from "./actions"
|
||||
export * as backup from "./backup"
|
||||
export * as config from "./config"
|
||||
|
||||
@@ -6,11 +6,11 @@ export type SetupExports<Store> = (opts: {
|
||||
utils: Utils<any, Store>
|
||||
}) =>
|
||||
| {
|
||||
ui: ExposeUiPaths<Store>
|
||||
ui: { [k: string]: ExposeUiPaths<Store> }
|
||||
services: ExposeServicePaths<Store>
|
||||
}
|
||||
| Promise<{
|
||||
ui: ExposeUiPaths<Store>
|
||||
ui: { [k: string]: ExposeUiPaths<Store> }
|
||||
services: ExposeServicePaths<Store>
|
||||
}>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { SetInterfaces } from "../interfaces/setupInterfaces"
|
||||
import { SDKManifest } from "../manifest/ManifestTypes"
|
||||
import { ExpectedExports } from "../types"
|
||||
import { ExpectedExports, ExposeUiPaths, ExposeUiPathsAll } from "../types"
|
||||
import { createUtils } from "../util"
|
||||
import { Migrations } from "./migrations/setupMigrations"
|
||||
import { SetupExports } from "./setupExports"
|
||||
@@ -32,14 +32,12 @@ export function setupInit<Manifest extends SDKManifest, Store>(
|
||||
utils,
|
||||
})
|
||||
await opts.effects.exposeForDependents(services)
|
||||
await opts.effects.exposeUi({
|
||||
paths: ui.map((x) => ({
|
||||
description: null,
|
||||
copyable: null,
|
||||
qr: null,
|
||||
...x,
|
||||
})),
|
||||
})
|
||||
await opts.effects.exposeUi(
|
||||
forExpose({
|
||||
type: "object",
|
||||
value: ui,
|
||||
}),
|
||||
)
|
||||
},
|
||||
uninit: async (opts) => {
|
||||
await migrations.uninit(opts)
|
||||
@@ -47,3 +45,21 @@ export function setupInit<Manifest extends SDKManifest, Store>(
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
function forExpose<Store>(ui: ExposeUiPaths<Store>): ExposeUiPathsAll {
|
||||
if (ui.type === ("object" as const)) {
|
||||
return {
|
||||
type: "object" as const,
|
||||
value: Object.fromEntries(
|
||||
Object.entries(ui.value).map(([key, value]) => [key, forExpose(value)]),
|
||||
),
|
||||
}
|
||||
}
|
||||
return {
|
||||
description: null,
|
||||
|
||||
copyable: null,
|
||||
qr: null,
|
||||
...ui,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,15 +82,15 @@ type NotProtocolsWithSslVariants = Exclude<
|
||||
type BindOptionsByKnownProtocol =
|
||||
| {
|
||||
protocol: ProtocolsWithSslVariants
|
||||
preferredExternalPort: number | null
|
||||
scheme: Scheme | null
|
||||
addSsl: Partial<AddSslOptions> | null
|
||||
preferredExternalPort?: number
|
||||
scheme?: Scheme
|
||||
addSsl?: Partial<AddSslOptions>
|
||||
}
|
||||
| {
|
||||
protocol: NotProtocolsWithSslVariants
|
||||
preferredExternalPort: number | null
|
||||
scheme: Scheme | null
|
||||
addSsl: AddSslOptions | null
|
||||
preferredExternalPort?: number
|
||||
scheme?: Scheme
|
||||
addSsl?: AddSslOptions
|
||||
}
|
||||
type BindOptionsByProtocol = BindOptionsByKnownProtocol | BindOptions
|
||||
|
||||
|
||||
@@ -9,9 +9,6 @@ describe("host", () => {
|
||||
const foo = utils.host.multi("foo")
|
||||
const fooOrigin = await foo.bindPort(80, {
|
||||
protocol: "http" as const,
|
||||
scheme: null,
|
||||
addSsl: null,
|
||||
preferredExternalPort: null,
|
||||
})
|
||||
const fooInterface = new ServiceInterfaceBuilder({
|
||||
effects,
|
||||
|
||||
@@ -261,22 +261,42 @@ export type ExposeServicePaths<Store = never> = {
|
||||
paths: Store extends never ? string[] : ExposeAllServicePaths<Store>[]
|
||||
}
|
||||
|
||||
export type ExposeUiPaths<Store> = Array<{
|
||||
/** The path to the value in the Store. [JsonPath](https://jsonpath.com/) */
|
||||
path: ExposeAllUiPaths<Store>
|
||||
/** A human readable title for the value */
|
||||
title: string
|
||||
/** A human readable description or explanation of the value */
|
||||
description?: string
|
||||
/** (string/number only) Whether or not to mask the value, for example, when displaying a password */
|
||||
masked: boolean
|
||||
/** (string/number only) Whether or not to include a button for copying the value to clipboard */
|
||||
copyable?: boolean
|
||||
/** (string/number only) Whether or not to include a button for displaying the value as a QR code */
|
||||
qr?: boolean
|
||||
}>
|
||||
|
||||
type tset = keyof Effects
|
||||
export type ExposeUiPaths<Store> =
|
||||
| {
|
||||
type: "object"
|
||||
value: { [k: string]: ExposeUiPaths<Store> }
|
||||
}
|
||||
| {
|
||||
type: "string"
|
||||
/** The path to the value in the Store. [JsonPath](https://jsonpath.com/) */
|
||||
path: ExposeAllUiPaths<Store>
|
||||
/** A human readable description or explanation of the value */
|
||||
description?: string
|
||||
/** (string/number only) Whether or not to mask the value, for example, when displaying a password */
|
||||
masked: boolean
|
||||
/** (string/number only) Whether or not to include a button for copying the value to clipboard */
|
||||
copyable?: boolean
|
||||
/** (string/number only) Whether or not to include a button for displaying the value as a QR code */
|
||||
qr?: boolean
|
||||
}
|
||||
export type ExposeUiPathsAll =
|
||||
| {
|
||||
type: "object"
|
||||
value: { [k: string]: ExposeUiPathsAll }
|
||||
}
|
||||
| {
|
||||
type: "string"
|
||||
/** The path to the value in the Store. [JsonPath](https://jsonpath.com/) */
|
||||
path: string
|
||||
/** A human readable description or explanation of the value */
|
||||
description: string | null
|
||||
/** (string/number only) Whether or not to mask the value, for example, when displaying a password */
|
||||
masked: boolean
|
||||
/** (string/number only) Whether or not to include a button for copying the value to clipboard */
|
||||
copyable: boolean | null
|
||||
/** (string/number only) Whether or not to include a button for displaying the value as a QR code */
|
||||
qr: boolean | null
|
||||
}
|
||||
|
||||
/** Used to reach out from the pure js runtime */
|
||||
export type Effects = {
|
||||
@@ -375,16 +395,7 @@ export type Effects = {
|
||||
|
||||
exposeForDependents(options: { paths: string[] }): Promise<void>
|
||||
|
||||
exposeUi<Store = never>(options: {
|
||||
paths: {
|
||||
path: string
|
||||
title: string | null
|
||||
description: string | null
|
||||
masked: boolean | null
|
||||
copyable: boolean | null
|
||||
qr: boolean | null
|
||||
}[]
|
||||
}): Promise<void>
|
||||
exposeUi(options: ExposeUiPathsAll): Promise<void>
|
||||
/**
|
||||
* There are times that we want to see the addresses that where exported
|
||||
* @param options.addressId If we want to filter the address id
|
||||
|
||||
@@ -56,23 +56,6 @@ export type Utils<
|
||||
Store,
|
||||
WrapperOverWrite = { const: never },
|
||||
> = {
|
||||
checkPortListening(
|
||||
port: number,
|
||||
options: {
|
||||
errorMessage: string
|
||||
successMessage: string
|
||||
timeoutMessage?: string
|
||||
timeout?: number
|
||||
},
|
||||
): Promise<CheckResult>
|
||||
checkWebUrl(
|
||||
url: string,
|
||||
options?: {
|
||||
timeout?: number
|
||||
successMessage?: string
|
||||
errorMessage?: string
|
||||
},
|
||||
): Promise<CheckResult>
|
||||
childProcess: typeof childProcess
|
||||
createInterface: (options: {
|
||||
name: string
|
||||
@@ -304,8 +287,6 @@ export const createUtils = <
|
||||
},
|
||||
}
|
||||
},
|
||||
checkPortListening: checkPortListening.bind(null, effects),
|
||||
checkWebUrl: checkWebUrl.bind(null, effects),
|
||||
|
||||
mountDependencies: <
|
||||
In extends
|
||||
|
||||
Reference in New Issue
Block a user