Skip to content
Permalink
Browse files

Deprecated Chooser type

We prefer Options as name for this parameterType

[changelog:deprecated]
  • Loading branch information...
cdupuis committed Jan 27, 2019
1 parent 599ac97 commit 60739fccd95f0cb8515cf1aea9214daa015de491
Showing with 59 additions and 49 deletions.
  1. +3 −2 lib/internal/metadata/metadataReading.ts
  2. +18 −9 lib/metadata/automationMetadata.ts
  3. +3 −3 lib/metadata/parameterUtils.ts
  4. +35 −35 package-lock.json
@@ -7,6 +7,7 @@ import {
CommandHandlerMetadata,
EventHandlerMetadata,
MappedParameterDeclaration,
Options,
Parameter,
SecretDeclaration,
ValueDeclaration,
@@ -110,7 +111,7 @@ function parametersFromInstance(r: any, prefix: string = ""): Parameter[] {

const allParameters = directParams.concat(nestedParameters).map(p => {
if (!!p.type && p.type !== "boolean" && p.type !== "number" && p.type !== "string" && p.type !== "freeChoices") {
const chooser = p.type as Chooser;
const chooser = p.type as any;

let kind: "single" | "multiple" = "single";
if (chooser.pickOne !== undefined && chooser.pickOne !== null) {
@@ -126,7 +127,7 @@ function parametersFromInstance(r: any, prefix: string = ""): Parameter[] {
options = chooser.options;
}

const newChooser: Chooser = {
const newChooser: Options = {
kind,
options,
};
@@ -1,34 +1,43 @@

export interface Choice {
export interface Option {
value: string;
description?: string;
}

export type Choice = Option;

/**
* Represents a choice of exactly one or some strings from a fixed list of choices
* @deprecated use Options
*/
export interface Chooser {

/**
* @deprecated use kind
* @deprecated use Options.kind
*/
pickOne?: boolean;

/**
* Whether the user must select exactly one option. In this case,
* binds to string. Otherwise binds to string[]
* @deprecated use Options.options
*/
kind?: "single" | "multiple";
choices?: Choice[];
}

/**
* Represents a selection of exactly one or some strings from a fixed list of options
*/
export interface Options {

/**
* @deprecated use options
* Whether the user must select exactly one option. In this case,
* binds to string. Otherwise binds to string[]
*/
choices?: Choice[];
kind?: "single" | "multiple";

/**
* Possible options to select from
*/
options?: Choice[];
options?: Option[];
}

/**
@@ -38,7 +47,7 @@ export interface Chooser {
*/
export const FreeChoices = "freeChoices";

export type ParameterType = "string" | "number" | "boolean" | Chooser | "freeChoices";
export type ParameterType = "string" | "number" | "boolean" | Chooser | Options | "freeChoices";

/**
* Parameter to a command handler.
@@ -1,13 +1,13 @@
import { Chooser } from "./automationMetadata";
import { Options } from "./automationMetadata";

export function someOf(...values: string[]): Chooser {
export function someOf(...values: string[]): Options {
return {
kind: "multiple",
options: values.map(value => ({ value })),
};
}

export function oneOf(...values: string[]): Chooser {
export function oneOf(...values: string[]): Options {
return {
kind: "single",
options: values.map(value => ({ value })),
Oops, something went wrong.

0 comments on commit 60739fc

Please sign in to comment.
You can’t perform that action at this time.