chore: Update types to match embassyd (#1539)

* chore: Update types to match embassyd

* chore: Undo the optional
This commit is contained in:
J M
2022-06-15 14:39:20 -06:00
committed by GitHub
parent b0068a333b
commit d05cd7de0d

View File

@@ -1,8 +1,8 @@
export namespace ExpectedExports { export namespace ExpectedExports {
/** Set configuration is called after we have modified and saved the configuration in the embassy ui. Use this to make a file for the docker to read from for configuration. */ /** Set configuration is called after we have modified and saved the configuration in the embassy ui. Use this to make a file for the docker to read from for configuration. */
export type setConfig = ( export type setConfig = (
effects: Effects, effects: Effects,
input: Config, input: Config,
) => Promise<ResultType<SetResult>>; ) => Promise<ResultType<SetResult>>;
/** Get configuration returns a shape that describes the format that the embassy ui will generate, and later send to the set config */ /** Get configuration returns a shape that describes the format that the embassy ui will generate, and later send to the set config */
export type getConfig = (effects: Effects) => Promise<ResultType<ConfigRes>>; export type getConfig = (effects: Effects) => Promise<ResultType<ConfigRes>>;
@@ -10,7 +10,7 @@ export namespace ExpectedExports {
export type dependencies = Dependencies; export type dependencies = Dependencies;
/** Properties are used to get values from the docker, like a username + password, what ports we are hosting from */ /** Properties are used to get values from the docker, like a username + password, what ports we are hosting from */
export type properties = ( export type properties = (
effects: Effects, effects: Effects,
) => Promise<ResultType<Properties>>; ) => Promise<ResultType<Properties>>;
} }
@@ -18,7 +18,7 @@ export namespace ExpectedExports {
export type Effects = { export type Effects = {
/** Usable when not sandboxed */ /** Usable when not sandboxed */
writeFile( writeFile(
input: { path: string; volumeId: string; toWrite: string }, input: { path: string; volumeId: string; toWrite: string },
): Promise<void>; ): Promise<void>;
readFile(input: { volumeId: string; path: string }): Promise<string>; readFile(input: { volumeId: string; path: string }): Promise<string>;
/** Create a directory. Usable when not sandboxed */ /** Create a directory. Usable when not sandboxed */
@@ -29,7 +29,7 @@ export type Effects = {
/** Write a json file into an object. Usable when not sandboxed */ /** Write a json file into an object. Usable when not sandboxed */
writeJsonFile( writeJsonFile(
input: { volumeId: string; path: string; toWrite: object }, input: { volumeId: string; path: string; toWrite: object },
): Promise<void>; ): Promise<void>;
/** Read a json file into an object */ /** Read a json file into an object */
@@ -101,7 +101,7 @@ export type Target<T extends string, V> = V & {
export type UniqueBy = export type UniqueBy =
| { | {
any: UniqueBy[]; any: UniqueBy[];
} }
| string | string
| null; | null;
@@ -112,24 +112,24 @@ export type WithNullable<T> = T & {
export type DefaultString = export type DefaultString =
| String | String
| { | {
/** The chars available for the randome generation */ /** The chars available for the randome generation */
charset?: string; charset?: string;
/** Length that we generate to */ /** Length that we generate to */
len: number; len: number;
}; };
export type ValueSpecString = export type ValueSpecString =
& ( & (
| {} | {}
| { | {
pattern: string; pattern: string;
"pattern-description": string; "pattern-description": string;
} }
) )
& { & {
copyable?: boolean; copyable?: boolean;
masked?: boolean; masked?: boolean;
placeholder?: string; placeholder?: string;
}; };
export type ValueSpecNumber = { export type ValueSpecNumber = {
/** Something like [3,6] or [0, *) */ /** Something like [3,6] or [0, *) */
@@ -143,81 +143,81 @@ export type ValueSpecBoolean = {};
export type ValueSpecAny = export type ValueSpecAny =
| Tag<"boolean", WithDescription<WithDefault<ValueSpecBoolean, boolean>>> | Tag<"boolean", WithDescription<WithDefault<ValueSpecBoolean, boolean>>>
| Tag< | Tag<
"string", "string",
WithDescription<WithDefault<WithNullable<ValueSpecString>, DefaultString>> WithDescription<WithDefault<WithNullable<ValueSpecString>, DefaultString>>
> >
| Tag< | Tag<
"number", "number",
WithDescription<WithDefault<WithNullable<ValueSpecNumber>, number>> WithDescription<WithDefault<WithNullable<ValueSpecNumber>, number>>
> >
| Tag< | Tag<
"enum", "enum",
WithDescription< WithDescription<
WithDefault< WithDefault<
{ {
values: string[]; values: string[];
"value-names": { "value-names": {
[key: string]: string; [key: string]: string;
}; };
}, },
string string
>
> >
>
> >
| Tag<"list", ValueSpecList> | Tag<"list", ValueSpecList>
| Tag<"object", WithDescription<WithDefault<ValueSpecObject, Config>>> | Tag<"object", WithDescription<WithDefault<ValueSpecObject, Config>>>
| Tag<"union", WithDescription<WithDefault<ValueSpecUnion, string>>> | Tag<"union", WithDescription<WithDefault<ValueSpecUnion, string>>>
| Tag< | Tag<
"pointer", "pointer",
WithDescription< WithDescription<
| Subtype< | Subtype<
"package", "package",
| Target< | Target<
"tor-key", "tor-key",
{ {
"package-id": string; "package-id": string;
interface: string; interface: string;
} }
> >
| Target< | Target<
"tor-address", "tor-address",
{ {
"package-id": string; "package-id": string;
interface: string; interface: string;
} }
> >
| Target< | Target<
"lan-address", "lan-address",
{ {
"package-id": string; "package-id": string;
interface: string; interface: string;
} }
> >
| Target< | Target<
"config", "config",
{ {
"package-id": string; "package-id": string;
selector: string; selector: string;
multi: boolean; multi: boolean;
} }
> >
>
| Subtype<"system", {}>
> >
| Subtype<"system", {}>
>
>; >;
export type ValueSpecUnion = { export type ValueSpecUnion = {
/** What tag for the specification, for tag unions */ /** What tag for the specification, for tag unions */
tag: { tag: {
id: string; id: string;
name: string; name: string;
description?: string; description?: string;
"variant-names": { "variant-names": {
[key: string]: string; [key: string]: string;
}; };
}; };
/** The possible enum values */ /** The possible enum values */
variants: { variants: {
[key: string]: ConfigSpec; [key: string]: ConfigSpec;
}; };
"display-as"?: string; "display-as"?: string;
"unique-by"?: UniqueBy; "unique-by"?: UniqueBy;
@@ -229,70 +229,75 @@ export type ValueSpecObject = {
}; };
export type ValueSpecList = export type ValueSpecList =
| Subtype< | Subtype<
"boolean", "boolean",
WithDescription<WithDefault<ListSpec<ValueSpecBoolean>, boolean>> WithDescription<WithDefault<ListSpec<ValueSpecBoolean>, boolean[]>>
> >
| Subtype< | Subtype<
"string", "string",
WithDescription<WithDefault<ListSpec<ValueSpecString>, string>> WithDescription<WithDefault<ListSpec<ValueSpecString>, string[]>>
> >
| Subtype< | Subtype<
"number", "number",
WithDescription<WithDefault<ListSpec<ValueSpecNumber>, number>> WithDescription<WithDefault<ListSpec<ValueSpecNumber>, number[]>>
> >
| Subtype< | Subtype<
"enum", "enum",
WithDescription< WithDescription<
WithDefault< WithDefault<
{ {
values: string[]; values: string[];
"value-names": { "value-names": {
[key: string]: string; [key: string]: string;
}; };
}, },
string string[]
>
> >
> >
| Subtype<
"object",
WithDescription<WithDefault<ListSpec<Tag<"object", WithDescription<WithDefault<ValueSpecObject, Config>>>>, {}[]>>
>; >;
export type SetResult = { export type SetResult = {
/** These are the unix process signals */ /** These are the unix process signals */
signal: signal:
| "SIGTERM" | "SIGTERM"
| "SIGHUP" | "SIGHUP"
| "SIGINT" | "SIGINT"
| "SIGQUIT" | "SIGQUIT"
| "SIGILL" | "SIGILL"
| "SIGTRAP" | "SIGTRAP"
| "SIGABRT" | "SIGABRT"
| "SIGBUS" | "SIGBUS"
| "SIGFPE" | "SIGFPE"
| "SIGKILL" | "SIGKILL"
| "SIGUSR1" | "SIGUSR1"
| "SIGSEGV" | "SIGSEGV"
| "SIGUSR2" | "SIGUSR2"
| "SIGPIPE" | "SIGPIPE"
| "SIGALRM" | "SIGALRM"
| "SIGSTKFLT" | "SIGSTKFLT"
| "SIGCHLD" | "SIGCHLD"
| "SIGCONT" | "SIGCONT"
| "SIGSTOP" | "SIGSTOP"
| "SIGTSTP" | "SIGTSTP"
| "SIGTTIN" | "SIGTTIN"
| "SIGTTOU" | "SIGTTOU"
| "SIGURG" | "SIGURG"
| "SIGXCPU" | "SIGXCPU"
| "SIGXFSZ" | "SIGXFSZ"
| "SIGVTALRM" | "SIGVTALRM"
| "SIGPROF" | "SIGPROF"
| "SIGWINCH" | "SIGWINCH"
| "SIGIO" | "SIGIO"
| "SIGPWR" | "SIGPWR"
| "SIGSYS" | "SIGSYS"
| "SIGEMT" | "SIGEMT"
| "SIGINFO"; | "SIGINFO";
"depends-on": { "depends-on": {
[packageId: string]: string[]; [packageId: string]: string[];
}; };
}; };
@@ -327,9 +332,9 @@ export type Properties = {
export type Dependencies = { export type Dependencies = {
/** Id is the id of the package, should be the same as the manifest */ /** Id is the id of the package, should be the same as the manifest */
[id: string]: { [id: string]: {
/** Checks are called to make sure that our dependency is in the correct shape. If a known error is returned we know that the dependency needs modification */ /** Checks are called to make sure that our dependency is in the correct shape. If a known error is returned we know that the dependency needs modification */
check(effects: Effects, input: Config): Promise<ResultType<void | null>>; check(effects: Effects, input: Config): Promise<ResultType<void | null>>;
/** This is called after we know that the dependency package needs a new configuration, this would be a transform for defaults */ /** This is called after we know that the dependency package needs a new configuration, this would be a transform for defaults */
autoConfigure(effects: Effects, input: Config): Promise<ResultType<Config>>; autoConfigure(effects: Effects, input: Config): Promise<ResultType<Config>>;
}; };
}; };