From 75a2b2d2ab15c6a67652a0bf5728c6e1d90dad7d Mon Sep 17 00:00:00 2001 From: J M <2364004+Blu-J@users.noreply.github.com> Date: Wed, 15 Jun 2022 19:31:47 -0600 Subject: [PATCH] chore: Update the lite types to include the union and enum (#1542) --- libs/artifacts/types.d.ts | 204 +++++++++++++++++++------------------- 1 file changed, 104 insertions(+), 100 deletions(-) diff --git a/libs/artifacts/types.d.ts b/libs/artifacts/types.d.ts index ac35cae22..61031f2e2 100644 --- a/libs/artifacts/types.d.ts +++ b/libs/artifacts/types.d.ts @@ -1,8 +1,8 @@ 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. */ export type setConfig = ( - effects: Effects, - input: Config, + effects: Effects, + input: Config, ) => Promise>; /** 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>; @@ -10,7 +10,7 @@ export namespace ExpectedExports { export type dependencies = Dependencies; /** Properties are used to get values from the docker, like a username + password, what ports we are hosting from */ export type properties = ( - effects: Effects, + effects: Effects, ) => Promise>; } @@ -18,7 +18,7 @@ export namespace ExpectedExports { export type Effects = { /** Usable when not sandboxed */ writeFile( - input: { path: string; volumeId: string; toWrite: string }, + input: { path: string; volumeId: string; toWrite: string }, ): Promise; readFile(input: { volumeId: string; path: string }): Promise; /** 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 */ writeJsonFile( - input: { volumeId: string; path: string; toWrite: object }, + input: { volumeId: string; path: string; toWrite: object }, ): Promise; /** Read a json file into an object */ @@ -101,7 +101,7 @@ export type Target = V & { export type UniqueBy = | { - any: UniqueBy[]; + any: UniqueBy[]; } | string | null; @@ -112,24 +112,24 @@ export type WithNullable = T & { export type DefaultString = | String | { - /** The chars available for the randome generation */ - charset?: string; - /** Length that we generate to */ - len: number; + /** The chars available for the randome generation */ + charset?: string; + /** Length that we generate to */ + len: number; }; export type ValueSpecString = & ( - | {} - | { - pattern: string; - "pattern-description": string; - } + | {} + | { + pattern: string; + "pattern-description": string; + } ) & { - copyable?: boolean; - masked?: boolean; - placeholder?: string; + copyable?: boolean; + masked?: boolean; + placeholder?: string; }; export type ValueSpecNumber = { /** Something like [3,6] or [0, *) */ @@ -143,81 +143,81 @@ export type ValueSpecBoolean = {}; export type ValueSpecAny = | Tag<"boolean", WithDescription>> | Tag< - "string", - WithDescription, DefaultString>> + "string", + WithDescription, DefaultString>> > | Tag< - "number", - WithDescription, number>> + "number", + WithDescription, number>> > | Tag< - "enum", - WithDescription< - WithDefault< - { - values: string[]; - "value-names": { - [key: string]: string; - }; - }, - string - > + "enum", + WithDescription< + WithDefault< + { + values: string[]; + "value-names": { + [key: string]: string; + }; + }, + string > + > > | Tag<"list", ValueSpecList> | Tag<"object", WithDescription>> | Tag<"union", WithDescription>> | Tag< - "pointer", - WithDescription< - | Subtype< - "package", - | Target< - "tor-key", - { - "package-id": string; - interface: string; - } - > - | Target< - "tor-address", - { - "package-id": string; - interface: string; - } - > - | Target< - "lan-address", - { - "package-id": string; - interface: string; - } - > - | Target< - "config", - { - "package-id": string; - selector: string; - multi: boolean; - } - > - > - | Subtype<"system", {}> + "pointer", + WithDescription< + | Subtype< + "package", + | Target< + "tor-key", + { + "package-id": string; + interface: string; + } + > + | Target< + "tor-address", + { + "package-id": string; + interface: string; + } + > + | Target< + "lan-address", + { + "package-id": string; + interface: string; + } + > + | Target< + "config", + { + "package-id": string; + selector: string; + multi: boolean; + } + > > + | Subtype<"system", {}> + > >; export type ValueSpecUnion = { /** What tag for the specification, for tag unions */ tag: { - id: string; - name: string; - description?: string; - "variant-names": { - [key: string]: string; - }; + id: string; + name: string; + description?: string; + "variant-names": { + [key: string]: string; + }; }; /** The possible enum values */ variants: { - [key: string]: ConfigSpec; + [key: string]: ConfigSpec; }; "display-as"?: string; "unique-by"?: UniqueBy; @@ -229,36 +229,40 @@ export type ValueSpecObject = { }; export type ValueSpecList = | Subtype< - "boolean", - WithDescription, boolean[]>> + "boolean", + WithDescription, boolean[]>> > | Subtype< - "string", - WithDescription, string[]>> + "string", + WithDescription, string[]>> > | Subtype< - "number", - WithDescription, number[]>> + "number", + WithDescription, number[]>> > | Subtype< - "enum", - WithDescription< - WithDefault< - { - values: string[]; - "value-names": { - [key: string]: string; - }; - }, - string[] - > + "enum", + WithDescription< + WithDefault< + ListSpec< + ValueSpecEnum + >, + string[] > + > > | Subtype< - "object", - WithDescription>>>, {}[]>> + "object", + WithDescription, {}[]>> + > + | Subtype< + "union", + WithDescription, string[]>> >; - +export type ValueSpecEnum = { + values: string[], + "value-names": { [key: string]: string }; +} export type SetResult = { /** These are the unix process signals */ @@ -297,7 +301,7 @@ export type SetResult = { | "SIGEMT" | "SIGINFO"; "depends-on": { - [packageId: string]: string[]; + [packageId: string]: string[]; }; }; @@ -332,9 +336,9 @@ export type Properties = { export type Dependencies = { /** Id is the id of the package, should be the same as the manifest */ [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 */ - check(effects: Effects, input: Config): Promise>; - /** 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>; + /** 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>; + /** 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>; }; };