Comparing version 1.1.1-alpha.7 to 1.1.1-beta.0
@@ -63,4 +63,4 @@ import { OptionItem } from "./qm"; | ||
hostType: string; | ||
capabilities?: string[]; | ||
azureResources?: string[]; | ||
capabilities: string[]; | ||
azureResources: string[]; | ||
activeResourcePlugins: string[]; | ||
@@ -67,0 +67,0 @@ } |
@@ -55,10 +55,14 @@ // Copyright (c) Microsoft Corporation. | ||
const trimed = node.trim(); | ||
if (trimed) { | ||
newChildren.push(node); | ||
} | ||
if (trimed) | ||
newChildren.push(trimed); | ||
} | ||
this.children = newChildren; | ||
} | ||
if (this.data.type === NodeType.group && (!this.children || this.children.length === 0)) { | ||
return undefined; | ||
if (this.data.type === NodeType.group) { | ||
if (!this.children || this.children.length === 0) | ||
return undefined; | ||
if (this.children.length === 1) { | ||
this.children[0].condition = this.condition; | ||
return this.children[0]; | ||
} | ||
} | ||
@@ -65,0 +69,0 @@ return this; |
@@ -41,2 +41,4 @@ import { FxError } from "../error"; | ||
onDidChangeSelection?: (currentSelectedItems: OptionItem[], previousSelectedItems: OptionItem[]) => Promise<string[]>; | ||
step?: number; | ||
totalSteps?: number; | ||
} | ||
@@ -52,2 +54,4 @@ export interface FxInputBoxOption { | ||
number?: boolean; | ||
step?: number; | ||
totalSteps?: number; | ||
} | ||
@@ -96,2 +100,5 @@ export interface FxOpenDialogOption { | ||
validation?: (input: string) => Promise<string | undefined>; | ||
backButton?: boolean; | ||
step?: number; | ||
totalSteps?: number; | ||
} | ||
@@ -98,0 +105,0 @@ export declare enum InputResultType { |
@@ -1,2 +0,2 @@ | ||
import { QTreeNode, Question, SingleSelectQuestion, MultiSelectQuestion } from "./question"; | ||
import { QTreeNode, Question, SingleSelectQuestion, StaticOption, MultiSelectQuestion } from "./question"; | ||
import { RemoteFuncExecutor } from "./validation"; | ||
@@ -6,4 +6,8 @@ import { ConfigMap, Inputs } from "../config"; | ||
export declare function isAutoSkipSelect(q: Question): boolean; | ||
export declare function getSingleOption(q: SingleSelectQuestion | MultiSelectQuestion): any; | ||
export declare function loadOptions(q: Question, inputs: Inputs | ConfigMap, remoteFuncExecutor?: RemoteFuncExecutor): Promise<{ | ||
autoSkip: boolean; | ||
options?: StaticOption; | ||
}>; | ||
export declare function getSingleOption(q: SingleSelectQuestion | MultiSelectQuestion, option?: StaticOption): any; | ||
export declare function traverse(root: QTreeNode, inputs: Inputs | ConfigMap, ui: UserInterface, remoteFuncExecutor?: RemoteFuncExecutor): Promise<InputResult>; | ||
//# sourceMappingURL=visitor.d.ts.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.traverse = exports.getSingleOption = exports.isAutoSkipSelect = void 0; | ||
exports.traverse = exports.getSingleOption = exports.loadOptions = exports.isAutoSkipSelect = void 0; | ||
const question_1 = require("./question"); | ||
@@ -50,4 +50,37 @@ const validation_1 = require("./validation"); | ||
exports.isAutoSkipSelect = isAutoSkipSelect; | ||
function getSingleOption(q) { | ||
const option = q.option; | ||
async function loadOptions(q, inputs, remoteFuncExecutor) { | ||
if (q.type === question_1.NodeType.singleSelect || q.type === question_1.NodeType.multiSelect) { | ||
const selectQuestion = q; | ||
let option = []; | ||
if (selectQuestion.option instanceof Array) { | ||
//StaticOption | ||
option = selectQuestion.option; | ||
} | ||
else { | ||
// DynamicOption | ||
if (remoteFuncExecutor) { | ||
const res = await remoteFuncExecutor(selectQuestion.option, inputs); | ||
if (res.isOk()) { | ||
option = res.value; | ||
} | ||
else { | ||
throw res.error; | ||
} | ||
} | ||
} | ||
if (selectQuestion.skipSingleOption && option.length === 1) { | ||
return { autoSkip: true, options: option }; | ||
} | ||
else { | ||
return { autoSkip: false, options: option }; | ||
} | ||
} | ||
else { | ||
return { autoSkip: false }; | ||
} | ||
} | ||
exports.loadOptions = loadOptions; | ||
function getSingleOption(q, option) { | ||
if (!option) | ||
option = q.option; | ||
const optionIsString = typeof option[0] === "string"; | ||
@@ -75,3 +108,3 @@ let returnResult; | ||
*/ | ||
const questionVisitor = async function (question, parentValue, ui, backButton, inputs, remoteFuncExecutor) { | ||
const questionVisitor = async function (question, parentValue, ui, backButton, inputs, remoteFuncExecutor, step, totalSteps) { | ||
const type = question.type; | ||
@@ -106,3 +139,5 @@ //FunctionCallQuestion | ||
backButton: backButton, | ||
number: !!(type === question_1.NodeType.number) | ||
number: !!(type === question_1.NodeType.number), | ||
// step: step, | ||
// totalSteps: totalSteps | ||
}); | ||
@@ -112,23 +147,4 @@ } | ||
const selectQuestion = question; | ||
let option = []; | ||
if (selectQuestion.option instanceof Array) { | ||
//StaticOption | ||
option = selectQuestion.option; | ||
} | ||
else { | ||
// DynamicOption | ||
if (remoteFuncExecutor) { | ||
const res = await remoteFuncExecutor(selectQuestion.option, inputs); | ||
if (res.isOk()) { | ||
option = res.value; | ||
} | ||
else { | ||
return { | ||
type: ui_1.InputResultType.error, | ||
error: res.error | ||
}; | ||
} | ||
} | ||
} | ||
if (!option || option.length === 0) { | ||
const res = await loadOptions(selectQuestion, inputs, remoteFuncExecutor); | ||
if (!res.options || res.options.length === 0) { | ||
return { | ||
@@ -140,4 +156,4 @@ type: ui_1.InputResultType.error, | ||
// Skip single/mulitple option select | ||
if (isAutoSkipSelect(selectQuestion)) { | ||
const returnResult = getSingleOption(selectQuestion); | ||
if (res.autoSkip === true) { | ||
const returnResult = getSingleOption(selectQuestion, res.options); | ||
return { | ||
@@ -150,3 +166,3 @@ type: ui_1.InputResultType.pass, | ||
title: selectQuestion.title || selectQuestion.description || selectQuestion.name, | ||
items: option, | ||
items: res.options, | ||
canSelectMany: !!(type === question_1.NodeType.multiSelect), | ||
@@ -157,3 +173,5 @@ returnObject: selectQuestion.returnObject, | ||
backButton: backButton, | ||
onDidChangeSelection: type === question_1.NodeType.multiSelect ? selectQuestion.onDidChangeSelection : undefined | ||
onDidChangeSelection: type === question_1.NodeType.multiSelect ? selectQuestion.onDidChangeSelection : undefined, | ||
// step: step, | ||
// totalSteps: totalSteps | ||
}); | ||
@@ -164,9 +182,13 @@ } | ||
const validationFunc = fileQuestion.validation ? validation_1.getValidationFunction(fileQuestion.validation, inputs, remoteFuncExecutor) : undefined; | ||
let title = (fileQuestion.title || fileQuestion.description || fileQuestion.name); | ||
return await ui.showOpenDialog({ | ||
defaultUri: defaultValue, | ||
defaultUri: fileQuestion.value || defaultValue, | ||
canSelectFiles: false, | ||
canSelectFolders: true, | ||
canSelectMany: false, | ||
title: fileQuestion.title || fileQuestion.description || fileQuestion.name, | ||
validation: validationFunc | ||
title: title, | ||
validation: validationFunc, | ||
backButton: backButton, | ||
// step: step, | ||
// totalSteps: totalSteps | ||
}); | ||
@@ -185,2 +207,4 @@ } | ||
stack.push(root); | ||
let step = 0; | ||
let totalSteps = 1; | ||
const parentMap = new Map(); | ||
@@ -214,3 +238,5 @@ while (stack.length > 0) { | ||
firstQuestion = question; | ||
const inputResult = await questionVisitor(question, parentValue, ui, question !== firstQuestion, inputs, remoteFuncExecutor); | ||
++step; | ||
totalSteps = step + stack.length; | ||
const inputResult = await questionVisitor(question, parentValue, ui, question !== firstQuestion, inputs, remoteFuncExecutor, step, totalSteps); | ||
if (inputResult.type === ui_1.InputResultType.back) { | ||
@@ -230,2 +256,3 @@ //go back | ||
stack.push(curr); | ||
--step; | ||
// find the previoud input that is neither group nor func nor single option select | ||
@@ -248,5 +275,11 @@ let found = false; | ||
stack.push(last); | ||
--step; | ||
let autoSkip = false; | ||
if (last.data.type === question_1.NodeType.singleSelect || last.data.type === question_1.NodeType.multiSelect) { | ||
const loadOptionRes = await loadOptions(last.data, inputs, remoteFuncExecutor); | ||
autoSkip = loadOptionRes.autoSkip; | ||
} | ||
if (last.data.type !== question_1.NodeType.group && | ||
last.data.type !== question_1.NodeType.func && | ||
!isAutoSkipSelect(last.data)) { | ||
!autoSkip) { | ||
found = true; | ||
@@ -286,2 +319,21 @@ break; | ||
stack.push(child); | ||
// if(child.data.type === NodeType.func || child.data.type === NodeType.group) //ignore non-input node | ||
// continue; | ||
// if (child.condition) { //ignore node to skip | ||
// let currValue = curr.data.type !== NodeType.group ? curr.data.value : undefined; | ||
// if (curr.data.type === NodeType.singleSelect) { | ||
// const csq:SingleSelectQuestion = curr.data; | ||
// if (csq.returnObject) { | ||
// currValue = (csq.value as OptionItem).id; | ||
// } | ||
// } | ||
// const valueToValidate = child.condition.target ? await getRealValue(currValue, child.condition.target, inputs, remoteFuncExecutor) : currValue; | ||
// if (valueToValidate) { | ||
// const validRes = await validate(child.condition, valueToValidate as string | string[], inputs, remoteFuncExecutor); | ||
// if (validRes !== undefined) { | ||
// continue; | ||
// } | ||
// } | ||
// } | ||
// ++ totalSteps; | ||
} | ||
@@ -288,0 +340,0 @@ } |
{ | ||
"name": "fx-api", | ||
"version": "1.1.1-alpha.7", | ||
"version": "1.1.1-beta.0", | ||
"description": "teamsfx framework api", | ||
@@ -71,3 +71,3 @@ "main": "build/index.js", | ||
}, | ||
"gitHead": "3ef8721c264df02608e4305359a60bd3c0d0aee1" | ||
"gitHead": "95ac540b912951719a24226b35798c9c4c278f96" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
723407
4058