mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
Merge branch 'integration/new-container-runtime' of github.com:Start9Labs/start-os into integration/new-container-runtime
This commit is contained in:
@@ -200,6 +200,7 @@ export class StartSdk<Manifest extends SDKManifest, Store> {
|
||||
| Config<any, never>,
|
||||
Type extends Record<string, any> = ExtractConfigType<ConfigType>,
|
||||
>(
|
||||
id: string,
|
||||
metaData: Omit<ActionMetadata, "input"> & {
|
||||
input: Config<Type, Store> | Config<Type, never>
|
||||
},
|
||||
@@ -209,7 +210,12 @@ export class StartSdk<Manifest extends SDKManifest, Store> {
|
||||
}) => Promise<ActionResult>,
|
||||
) => {
|
||||
const { input, ...rest } = metaData
|
||||
return createAction<Manifest, Store, ConfigType, Type>(rest, fn, input)
|
||||
return createAction<Manifest, Store, ConfigType, Type>(
|
||||
id,
|
||||
rest,
|
||||
fn,
|
||||
input,
|
||||
)
|
||||
},
|
||||
configConstants: { smtpConfig },
|
||||
createInterface: (
|
||||
@@ -238,6 +244,7 @@ export class StartSdk<Manifest extends SDKManifest, Store> {
|
||||
| Config<any, never>,
|
||||
Type extends Record<string, any> = ExtractConfigType<ConfigType>,
|
||||
>(
|
||||
id: string,
|
||||
metaData: (options: {
|
||||
effects: Effects
|
||||
}) => MaybePromise<Omit<ActionMetadata, "input">>,
|
||||
@@ -248,6 +255,7 @@ export class StartSdk<Manifest extends SDKManifest, Store> {
|
||||
input: Config<Type, Store> | Config<Type, never>,
|
||||
) => {
|
||||
return createAction<Manifest, Store, ConfigType, Type>(
|
||||
id,
|
||||
metaData,
|
||||
fn,
|
||||
input,
|
||||
|
||||
@@ -15,7 +15,8 @@ export class CreatedAction<
|
||||
Type extends Record<string, any> = ExtractConfigType<ConfigType>,
|
||||
> {
|
||||
private constructor(
|
||||
public readonly myMetaData: MaybeFn<
|
||||
public readonly id: string,
|
||||
public readonly myMetadata: MaybeFn<
|
||||
Manifest,
|
||||
Store,
|
||||
Omit<ActionMetadata, "input">
|
||||
@@ -37,12 +38,14 @@ export class CreatedAction<
|
||||
| Config<any, never>,
|
||||
Type extends Record<string, any> = ExtractConfigType<ConfigType>,
|
||||
>(
|
||||
metaData: MaybeFn<Manifest, Store, Omit<ActionMetadata, "input">>,
|
||||
id: string,
|
||||
metadata: MaybeFn<Manifest, Store, Omit<ActionMetadata, "input">>,
|
||||
fn: (options: { effects: Effects; input: Type }) => Promise<ActionResult>,
|
||||
inputConfig: Config<Type, Store> | Config<Type, never>,
|
||||
) {
|
||||
return new CreatedAction<Manifest, Store, ConfigType, Type>(
|
||||
metaData,
|
||||
id,
|
||||
metadata,
|
||||
fn,
|
||||
inputConfig as Config<Type, Store>,
|
||||
)
|
||||
@@ -62,15 +65,15 @@ export class CreatedAction<
|
||||
})
|
||||
}
|
||||
|
||||
async metaData(options: { effects: Effects }) {
|
||||
if (this.myMetaData instanceof Function)
|
||||
return await this.myMetaData(options)
|
||||
return this.myMetaData
|
||||
async metadata(options: { effects: Effects }) {
|
||||
if (this.myMetadata instanceof Function)
|
||||
return await this.myMetadata(options)
|
||||
return this.myMetadata
|
||||
}
|
||||
|
||||
async ActionMetadata(options: { effects: Effects }): Promise<ActionMetadata> {
|
||||
return {
|
||||
...(await this.metaData(options)),
|
||||
...(await this.metadata(options)),
|
||||
input: await this.input.build(options),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { SDKManifest } from "../manifest/ManifestTypes"
|
||||
import { Effects, ExpectedExports } from "../types"
|
||||
import { once } from "../util/once"
|
||||
import { CreatedAction } from "./createAction"
|
||||
|
||||
export function setupActions<Manifest extends SDKManifest, Store>(
|
||||
@@ -9,8 +8,7 @@ export function setupActions<Manifest extends SDKManifest, Store>(
|
||||
const myActions = async (options: { effects: Effects }) => {
|
||||
const actions: Record<string, CreatedAction<Manifest, Store, any>> = {}
|
||||
for (const action of createdActions) {
|
||||
const actionMetadata = await action.metaData(options)
|
||||
actions[actionMetadata.id] = action
|
||||
actions[action.id] = action
|
||||
}
|
||||
return actions
|
||||
}
|
||||
|
||||
@@ -169,9 +169,10 @@ export type DaemonReturned = {
|
||||
export type ActionMetadata = {
|
||||
name: string
|
||||
description: string
|
||||
id: string
|
||||
warning: string | null
|
||||
input: InputSpec
|
||||
allowedStatuses: "only-running" | "only-stopped" | "any" | "disabled"
|
||||
disabled: boolean
|
||||
allowedStatuses: "only-running" | "only-stopped" | "any"
|
||||
/**
|
||||
* So the ordering of the actions is by alphabetical order of the group, then followed by the alphabetical of the actions
|
||||
*/
|
||||
@@ -447,7 +448,7 @@ export type Effects = {
|
||||
*
|
||||
* @param options
|
||||
*/
|
||||
exportAction(options: ActionMetadata): Promise<void>
|
||||
exportAction(options: { id: string; metadata: ActionMetadata }): Promise<void>
|
||||
/**
|
||||
* Remove an action that was exported. Used problably during main or during setConfig.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user