@microsoft/teamsfx-api 0.22.3 → 0.22.4-alpha.06f5ef6da.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli.d.ts +203 -0
- package/build/cli.d.ts.map +1 -0
- package/build/{v3/core.js → cli.js} +1 -1
- package/build/cli.js.map +1 -0
- package/build/constants.d.ts +4 -12
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +4 -12
- package/build/constants.js.map +1 -1
- package/build/context.d.ts +9 -28
- package/build/context.d.ts.map +1 -1
- package/build/error.d.ts +4 -47
- package/build/error.d.ts.map +1 -1
- package/build/error.js +9 -139
- package/build/error.js.map +1 -1
- package/build/index.d.ts +5 -16
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5 -17
- package/build/index.js.map +1 -1
- package/build/qm/index.d.ts +0 -1
- package/build/qm/index.d.ts.map +1 -1
- package/build/qm/index.js +0 -1
- package/build/qm/index.js.map +1 -1
- package/build/qm/question.d.ts +134 -26
- package/build/qm/question.d.ts.map +1 -1
- package/build/qm/question.js +0 -53
- package/build/qm/question.js.map +1 -1
- package/build/qm/ui.d.ts +72 -99
- package/build/qm/ui.d.ts.map +1 -1
- package/build/qm/ui.js +0 -86
- package/build/qm/ui.js.map +1 -1
- package/build/qm/validation.d.ts +7 -18
- package/build/qm/validation.d.ts.map +1 -1
- package/build/qm/validation.js +0 -159
- package/build/qm/validation.js.map +1 -1
- package/build/types.d.ts +73 -149
- package/build/types.d.ts.map +1 -1
- package/build/types.js +8 -97
- package/build/types.js.map +1 -1
- package/build/utils/log.d.ts +23 -36
- package/build/utils/log.d.ts.map +1 -1
- package/build/utils/log.js +7 -11
- package/build/utils/log.js.map +1 -1
- package/build/utils/login.d.ts +4 -4
- package/build/utils/login.d.ts.map +1 -1
- package/build/utils/login.js +4 -4
- package/build/utils/login.js.map +1 -1
- package/build/utils/telemetry.d.ts.map +1 -1
- package/package.json +8 -6
- package/build/action.d.ts +0 -109
- package/build/action.d.ts.map +0 -1
- package/build/action.js +0 -5
- package/build/action.js.map +0 -1
- package/build/bicep.d.ts +0 -19
- package/build/bicep.d.ts.map +0 -1
- package/build/bicep.js +0 -5
- package/build/bicep.js.map +0 -1
- package/build/component.d.ts +0 -31
- package/build/component.d.ts.map +0 -1
- package/build/component.js +0 -3
- package/build/component.js.map +0 -1
- package/build/core.d.ts +0 -50
- package/build/core.d.ts.map +0 -1
- package/build/core.js +0 -5
- package/build/core.js.map +0 -1
- package/build/plugin.d.ts +0 -71
- package/build/plugin.d.ts.map +0 -1
- package/build/plugin.js +0 -5
- package/build/plugin.js.map +0 -1
- package/build/qm/visitor.d.ts +0 -15
- package/build/qm/visitor.d.ts.map +0 -1
- package/build/qm/visitor.js +0 -388
- package/build/qm/visitor.js.map +0 -1
- package/build/solution.d.ts +0 -29
- package/build/solution.d.ts.map +0 -1
- package/build/solution.js +0 -5
- package/build/solution.js.map +0 -1
- package/build/v2/index.d.ts +0 -4
- package/build/v2/index.d.ts.map +0 -1
- package/build/v2/index.js +0 -9
- package/build/v2/index.js.map +0 -1
- package/build/v2/resourcePlugin.d.ts +0 -180
- package/build/v2/resourcePlugin.d.ts.map +0 -1
- package/build/v2/resourcePlugin.js +0 -5
- package/build/v2/resourcePlugin.js.map +0 -1
- package/build/v2/solutionPlugin.d.ts +0 -100
- package/build/v2/solutionPlugin.d.ts.map +0 -1
- package/build/v2/solutionPlugin.js +0 -5
- package/build/v2/solutionPlugin.js.map +0 -1
- package/build/v2/types.d.ts +0 -67
- package/build/v2/types.d.ts.map +0 -1
- package/build/v2/types.js +0 -28
- package/build/v2/types.js.map +0 -1
- package/build/v3/AzureResourceStates.d.ts +0 -58
- package/build/v3/AzureResourceStates.d.ts.map +0 -1
- package/build/v3/AzureResourceStates.js +0 -3
- package/build/v3/AzureResourceStates.js.map +0 -1
- package/build/v3/core.d.ts +0 -22
- package/build/v3/core.d.ts.map +0 -1
- package/build/v3/core.js.map +0 -1
- package/build/v3/index.d.ts +0 -7
- package/build/v3/index.d.ts.map +0 -1
- package/build/v3/index.js +0 -12
- package/build/v3/index.js.map +0 -1
- package/build/v3/plugins.d.ts +0 -104
- package/build/v3/plugins.d.ts.map +0 -1
- package/build/v3/plugins.js +0 -5
- package/build/v3/plugins.js.map +0 -1
- package/build/v3/resourceStates.d.ts +0 -66
- package/build/v3/resourceStates.d.ts.map +0 -1
- package/build/v3/resourceStates.js +0 -5
- package/build/v3/resourceStates.js.map +0 -1
- package/build/v3/solution.d.ts +0 -40
- package/build/v3/solution.d.ts.map +0 -1
- package/build/v3/solution.js +0 -5
- package/build/v3/solution.js.map +0 -1
- package/build/v3/types.d.ts +0 -28
- package/build/v3/types.d.ts.map +0 -1
- package/build/v3/types.js +0 -5
- package/build/v3/types.js.map +0 -1
- package/build/vscode.d.ts +0 -22
- package/build/vscode.d.ts.map +0 -1
- package/build/vscode.js +0 -5
- package/build/vscode.js.map +0 -1
package/build/qm/ui.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export interface UIConfig<T> {
|
|
|
36
36
|
/**
|
|
37
37
|
* default input value
|
|
38
38
|
*/
|
|
39
|
-
default?: T;
|
|
39
|
+
default?: T | (() => Promise<T>);
|
|
40
40
|
/**
|
|
41
41
|
* A function that will be called to validate input and to give a hint to the user.
|
|
42
42
|
*
|
|
@@ -63,23 +63,29 @@ export interface UIConfig<T> {
|
|
|
63
63
|
*/
|
|
64
64
|
export interface SingleSelectConfig extends UIConfig<string> {
|
|
65
65
|
/**
|
|
66
|
-
* option array
|
|
66
|
+
* option array or a callback function which returns option array
|
|
67
67
|
*/
|
|
68
|
-
options: StaticOptions;
|
|
68
|
+
options: StaticOptions | (() => Promise<StaticOptions>);
|
|
69
|
+
default?: string | (() => Promise<string>);
|
|
69
70
|
/**
|
|
70
71
|
* This config only works for option items with `OptionItem[]` type. If `returnObject` is true, the answer value is an `OptionItem` object; otherwise, the answer value is the `id` string of the `OptionItem`.
|
|
71
72
|
* In case of option items with `string[]` type, whether `returnObject` is true or false, the returned answer value is always a string.
|
|
72
73
|
*/
|
|
73
74
|
returnObject?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* whether skip selection if there is only one option, default is false
|
|
77
|
+
*/
|
|
78
|
+
skipSingleOption?: boolean;
|
|
74
79
|
}
|
|
75
80
|
/**
|
|
76
81
|
* multiple selection UI config
|
|
77
82
|
*/
|
|
78
83
|
export interface MultiSelectConfig extends UIConfig<string[]> {
|
|
79
84
|
/**
|
|
80
|
-
* option array
|
|
85
|
+
* option array or a callback function which returns option array
|
|
81
86
|
*/
|
|
82
|
-
options: StaticOptions;
|
|
87
|
+
options: StaticOptions | (() => Promise<StaticOptions>);
|
|
88
|
+
default?: string[] | (() => Promise<string[]>);
|
|
83
89
|
/**
|
|
84
90
|
* This config only works for option items with `OptionItem[]` type. If `returnObject` is true, the answer value is an array of `OptionItem` objects; otherwise, the answer value is an array of `id` strings.
|
|
85
91
|
* In case of option items with `string[]` type, whether `returnObject` is true or false, the returned answer value is always a string array.
|
|
@@ -92,6 +98,10 @@ export interface MultiSelectConfig extends UIConfig<string[]> {
|
|
|
92
98
|
* @returns the final selected option ids
|
|
93
99
|
*/
|
|
94
100
|
onDidChangeSelection?: OnSelectionChangeFunc;
|
|
101
|
+
/**
|
|
102
|
+
* whether skip selection if there is only one option, default is false
|
|
103
|
+
*/
|
|
104
|
+
skipSingleOption?: boolean;
|
|
95
105
|
}
|
|
96
106
|
/**
|
|
97
107
|
* text input UI config
|
|
@@ -101,12 +111,22 @@ export interface InputTextConfig extends UIConfig<string> {
|
|
|
101
111
|
* If the input value should be hidden. Defaults to false.
|
|
102
112
|
*/
|
|
103
113
|
password?: boolean;
|
|
114
|
+
default?: string | (() => Promise<string>);
|
|
115
|
+
/**
|
|
116
|
+
* A function that will be called to validate the input that user accepted.
|
|
117
|
+
*
|
|
118
|
+
* @param input The current value of the input to be validated.
|
|
119
|
+
* @return A human-readable string which is presented as diagnostic message.
|
|
120
|
+
* Return `undefined` when 'value' is valid.
|
|
121
|
+
*/
|
|
122
|
+
additionalValidationOnAccept?: (input: string) => string | undefined | Promise<string | undefined>;
|
|
104
123
|
}
|
|
105
124
|
/**
|
|
106
125
|
* single file selector config
|
|
107
126
|
*/
|
|
108
|
-
export
|
|
127
|
+
export type SelectFileConfig = UIConfig<string> & {
|
|
109
128
|
/**
|
|
129
|
+
* This will only take effect in VSC.
|
|
110
130
|
* A set of file filters that are used by the dialog. Each entry is a human-readable label,
|
|
111
131
|
* like "TypeScript", and an array of extensions, e.g.
|
|
112
132
|
* ```ts
|
|
@@ -119,6 +139,7 @@ export declare type SelectFileConfig = UIConfig<string> & {
|
|
|
119
139
|
filters?: {
|
|
120
140
|
[name: string]: string[];
|
|
121
141
|
};
|
|
142
|
+
default?: string | (() => Promise<string>);
|
|
122
143
|
/**
|
|
123
144
|
* Possible files that will be listed for users to select.
|
|
124
145
|
* The id cannot be "default" or "browse" as they are reserved for default and browse options.
|
|
@@ -132,8 +153,9 @@ export declare type SelectFileConfig = UIConfig<string> & {
|
|
|
132
153
|
/**
|
|
133
154
|
* multiple files selector config
|
|
134
155
|
*/
|
|
135
|
-
export
|
|
156
|
+
export type SelectFilesConfig = UIConfig<string[]> & {
|
|
136
157
|
/**
|
|
158
|
+
* This will only take effect in VSC.
|
|
137
159
|
* A set of file filters that are used by the dialog. Each entry is a human-readable label,
|
|
138
160
|
* like "TypeScript", and an array of extensions, e.g.
|
|
139
161
|
* ```ts
|
|
@@ -146,11 +168,14 @@ export declare type SelectFilesConfig = UIConfig<string[]> & {
|
|
|
146
168
|
filters?: {
|
|
147
169
|
[name: string]: string[];
|
|
148
170
|
};
|
|
171
|
+
default?: string[] | (() => Promise<string[]>);
|
|
149
172
|
};
|
|
150
173
|
/**
|
|
151
174
|
* folder selector config
|
|
152
175
|
*/
|
|
153
|
-
export
|
|
176
|
+
export type SelectFolderConfig = UIConfig<string> & {
|
|
177
|
+
default?: string | (() => Promise<string>);
|
|
178
|
+
};
|
|
154
179
|
/**
|
|
155
180
|
* func execution config
|
|
156
181
|
*/
|
|
@@ -158,6 +183,30 @@ export interface ExecuteFuncConfig extends UIConfig<string> {
|
|
|
158
183
|
func: LocalFunc<any>;
|
|
159
184
|
inputs: Inputs;
|
|
160
185
|
}
|
|
186
|
+
export interface SingleFileOrInputConfig extends UIConfig<string> {
|
|
187
|
+
/**
|
|
188
|
+
* An item shown in the list in VSC that user can click to input text.
|
|
189
|
+
*/
|
|
190
|
+
inputOptionItem: OptionItem;
|
|
191
|
+
/**
|
|
192
|
+
* Config for the input box.
|
|
193
|
+
*/
|
|
194
|
+
inputBoxConfig: UIConfig<string>;
|
|
195
|
+
/**
|
|
196
|
+
* This will only take effect in VSC.
|
|
197
|
+
* A set of file filters that are used by the dialog. Each entry is a human-readable label,
|
|
198
|
+
* like "TypeScript", and an array of extensions, e.g.
|
|
199
|
+
* ```ts
|
|
200
|
+
* {
|
|
201
|
+
* 'Images': ['png', 'jpg']
|
|
202
|
+
* 'TypeScript': ['ts', 'tsx']
|
|
203
|
+
* }
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
filters?: {
|
|
207
|
+
[name: string]: string[];
|
|
208
|
+
};
|
|
209
|
+
}
|
|
161
210
|
/**
|
|
162
211
|
* a wrapper of user input result
|
|
163
212
|
*/
|
|
@@ -173,73 +222,12 @@ export interface InputResult<T> {
|
|
|
173
222
|
*/
|
|
174
223
|
result?: T;
|
|
175
224
|
}
|
|
176
|
-
export
|
|
177
|
-
export
|
|
178
|
-
export
|
|
179
|
-
export
|
|
180
|
-
export
|
|
181
|
-
export
|
|
182
|
-
/**
|
|
183
|
-
* Definition of a runnable task
|
|
184
|
-
*/
|
|
185
|
-
export interface RunnableTask<T> {
|
|
186
|
-
/**
|
|
187
|
-
* task name
|
|
188
|
-
*/
|
|
189
|
-
name?: string;
|
|
190
|
-
/**
|
|
191
|
-
* current progress
|
|
192
|
-
*/
|
|
193
|
-
current?: number;
|
|
194
|
-
/**
|
|
195
|
-
* total progress
|
|
196
|
-
*/
|
|
197
|
-
readonly total?: number;
|
|
198
|
-
/**
|
|
199
|
-
* status message
|
|
200
|
-
*/
|
|
201
|
-
message?: string;
|
|
202
|
-
/**
|
|
203
|
-
* a function that realy implements the running of the task
|
|
204
|
-
* @param args args
|
|
205
|
-
*/
|
|
206
|
-
run(...args: any): Promise<Result<T, FxError>>;
|
|
207
|
-
/**
|
|
208
|
-
* a function that implements the cancelling of the task
|
|
209
|
-
*/
|
|
210
|
-
cancel?(): void;
|
|
211
|
-
/**
|
|
212
|
-
* a state that indicate whether the task is cancelled or not
|
|
213
|
-
*/
|
|
214
|
-
isCanceled?: boolean;
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* task running configuration
|
|
218
|
-
*/
|
|
219
|
-
export interface TaskConfig {
|
|
220
|
-
/**
|
|
221
|
-
* whether task can be cancelled or not
|
|
222
|
-
*/
|
|
223
|
-
cancellable?: boolean;
|
|
224
|
-
/**
|
|
225
|
-
* whether to show the numeric progress of the task
|
|
226
|
-
*/
|
|
227
|
-
showProgress?: boolean;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* task group configuration
|
|
231
|
-
*/
|
|
232
|
-
export interface TaskGroupConfig {
|
|
233
|
-
/**
|
|
234
|
-
* if true, the tasks in the group are running in parallel
|
|
235
|
-
* if false, the tasks are running in sequence.
|
|
236
|
-
*/
|
|
237
|
-
sequential?: boolean;
|
|
238
|
-
/**
|
|
239
|
-
* whether to terminate all tasks if some task is failed or canceled
|
|
240
|
-
*/
|
|
241
|
-
fastFail?: boolean;
|
|
242
|
-
}
|
|
225
|
+
export type SingleSelectResult = InputResult<string | OptionItem>;
|
|
226
|
+
export type MultiSelectResult = InputResult<StaticOptions>;
|
|
227
|
+
export type InputTextResult = InputResult<string>;
|
|
228
|
+
export type SelectFileResult = InputResult<string>;
|
|
229
|
+
export type SelectFilesResult = InputResult<string[]>;
|
|
230
|
+
export type SelectFolderResult = InputResult<string>;
|
|
243
231
|
/**
|
|
244
232
|
* Definition of user interaction, which is platform independent
|
|
245
233
|
*/
|
|
@@ -321,14 +309,6 @@ export interface UserInteraction {
|
|
|
321
309
|
* @returns the handler of a progress bar
|
|
322
310
|
*/
|
|
323
311
|
createProgressBar: (title: string, totalSteps: number) => IProgressHandler;
|
|
324
|
-
/**
|
|
325
|
-
* A function to run a task with progress bar. (CLI and VS Code has different UI experience for progress bar)
|
|
326
|
-
* @param task a runnable task with progress definition
|
|
327
|
-
* @param config task running configuration
|
|
328
|
-
* @param args args for task run() API
|
|
329
|
-
* @returns A promise that resolves the wrapper of task running result or FxError
|
|
330
|
-
*/
|
|
331
|
-
runWithProgress<T>(task: RunnableTask<T>, config: TaskConfig, ...args: any): Promise<Result<T, FxError>>;
|
|
332
312
|
/**
|
|
333
313
|
* Reload window to update user interface. (Only works for VS Code)
|
|
334
314
|
* @returns A promise indicating if reload is successful.
|
|
@@ -358,6 +338,14 @@ export interface UserInteraction {
|
|
|
358
338
|
[k: string]: string;
|
|
359
339
|
};
|
|
360
340
|
}): Promise<Result<string, FxError>>;
|
|
341
|
+
/**
|
|
342
|
+
* In VSC, it shows two options to user, one will open a dialog to the user which allows to select a single file, another one will show an input box asking to enter a value.
|
|
343
|
+
* If CLI, it will directly asks user to enter a value.
|
|
344
|
+
* @param config config to select local file or enter a value
|
|
345
|
+
* @returns A promise that resolves to the local file path or the value entered by user or FxError
|
|
346
|
+
* @throws FxError
|
|
347
|
+
*/
|
|
348
|
+
selectFileOrInput?(config: SingleFileOrInputConfig): Promise<Result<InputResult<string>, FxError>>;
|
|
361
349
|
}
|
|
362
350
|
export interface IProgressHandler {
|
|
363
351
|
/**
|
|
@@ -377,21 +365,6 @@ export interface IProgressHandler {
|
|
|
377
365
|
* End the progress bar and tell if success. After calling it, the progress bar will disappear. This handler
|
|
378
366
|
* can be reused after calling end().
|
|
379
367
|
*/
|
|
380
|
-
end: (success: boolean) => Promise<void>;
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* An implementation of task group that will define the progress when all tasks are running
|
|
384
|
-
*/
|
|
385
|
-
export declare class GroupOfTasks<T> implements RunnableTask<Result<T, FxError>[]> {
|
|
386
|
-
name?: string;
|
|
387
|
-
current: number;
|
|
388
|
-
readonly total: number;
|
|
389
|
-
isCanceled: boolean;
|
|
390
|
-
tasks: RunnableTask<T>[];
|
|
391
|
-
config?: TaskGroupConfig;
|
|
392
|
-
message?: string;
|
|
393
|
-
constructor(tasks: RunnableTask<T>[], config?: TaskGroupConfig);
|
|
394
|
-
run(...args: any): Promise<Result<Result<T, FxError>[], FxError>>;
|
|
395
|
-
cancel(): void;
|
|
368
|
+
end: (success: boolean, hideAfterFinish?: boolean) => Promise<void>;
|
|
396
369
|
}
|
|
397
370
|
//# sourceMappingURL=ui.d.ts.map
|
package/build/qm/ui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/qm/ui.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/qm/ui.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,SAAS,EAAgB,MAAM,GAAG,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,MAAM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AAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzC;;;OAGG;IACH,GAAG,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrE"}
|
package/build/qm/ui.js
CHANGED
|
@@ -2,90 +2,4 @@
|
|
|
2
2
|
// Copyright (c) Microsoft Corporation.
|
|
3
3
|
// Licensed under the MIT license.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.GroupOfTasks = void 0;
|
|
6
|
-
const neverthrow_1 = require("neverthrow");
|
|
7
|
-
const error_1 = require("../error");
|
|
8
|
-
/**
|
|
9
|
-
* An implementation of task group that will define the progress when all tasks are running
|
|
10
|
-
*/
|
|
11
|
-
class GroupOfTasks {
|
|
12
|
-
constructor(tasks, config) {
|
|
13
|
-
this.current = 0;
|
|
14
|
-
this.isCanceled = false;
|
|
15
|
-
this.tasks = tasks;
|
|
16
|
-
this.config = config;
|
|
17
|
-
this.total = this.tasks.length;
|
|
18
|
-
}
|
|
19
|
-
async run(...args) {
|
|
20
|
-
if (this.tasks.length === 0)
|
|
21
|
-
return neverthrow_1.ok([]);
|
|
22
|
-
return new Promise(async (resolve) => {
|
|
23
|
-
let results = [];
|
|
24
|
-
const isFastFail = this.config && this.config.fastFail;
|
|
25
|
-
const isSeq = this.config && this.config.sequential;
|
|
26
|
-
if (isSeq) {
|
|
27
|
-
this.current = 0;
|
|
28
|
-
for (let i = 0; i < this.tasks.length; ++i) {
|
|
29
|
-
if (this.isCanceled === true) {
|
|
30
|
-
resolve(neverthrow_1.err(error_1.UserCancelError));
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const task = this.tasks[i];
|
|
34
|
-
if (task.name) {
|
|
35
|
-
this.message = task.name;
|
|
36
|
-
}
|
|
37
|
-
try {
|
|
38
|
-
const taskRes = await task.run(args);
|
|
39
|
-
if (taskRes.isErr() && isFastFail) {
|
|
40
|
-
this.isCanceled = true;
|
|
41
|
-
resolve(neverthrow_1.err(taskRes.error));
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
results.push(taskRes);
|
|
45
|
-
}
|
|
46
|
-
catch (e) {
|
|
47
|
-
if (isFastFail) {
|
|
48
|
-
this.isCanceled = true;
|
|
49
|
-
resolve(neverthrow_1.err(e));
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
results.push(neverthrow_1.err(e));
|
|
53
|
-
}
|
|
54
|
-
finally {
|
|
55
|
-
this.current = i + 1;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
const promiseResults = this.tasks.map((t) => t.run(args));
|
|
61
|
-
promiseResults.forEach((p) => {
|
|
62
|
-
p.then((v) => {
|
|
63
|
-
this.current++;
|
|
64
|
-
if (v.isErr() && isFastFail) {
|
|
65
|
-
this.isCanceled = true;
|
|
66
|
-
resolve(neverthrow_1.err(v.error));
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
}).catch((e) => {
|
|
70
|
-
this.current++;
|
|
71
|
-
if (isFastFail) {
|
|
72
|
-
this.isCanceled = true;
|
|
73
|
-
resolve(neverthrow_1.err(e));
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
results = await Promise.all(promiseResults);
|
|
79
|
-
}
|
|
80
|
-
resolve(neverthrow_1.ok(results));
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
cancel() {
|
|
84
|
-
for (const task of this.tasks)
|
|
85
|
-
if (task.cancel)
|
|
86
|
-
task.cancel();
|
|
87
|
-
this.isCanceled = true;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
exports.GroupOfTasks = GroupOfTasks;
|
|
91
5
|
//# sourceMappingURL=ui.js.map
|
package/build/qm/ui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/qm/ui.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/qm/ui.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC"}
|
package/build/qm/validation.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Inputs, OptionItem } from "../types";
|
|
2
|
-
export
|
|
2
|
+
export type ValidateFunc<T> = (input: T, inputs?: Inputs) => string | undefined | Promise<string | undefined>;
|
|
3
3
|
/**
|
|
4
4
|
* Validation for Any Instance Type
|
|
5
5
|
* JSON Schema Validation reference: http://json-schema.org/draft/2019-09/json-schema-validation.html
|
|
@@ -54,6 +54,10 @@ export interface StringValidation extends StaticValidation {
|
|
|
54
54
|
* An instance validates successfully against this keyword if its value is not equal to the value of the keyword.
|
|
55
55
|
*/
|
|
56
56
|
notEquals?: string;
|
|
57
|
+
/**
|
|
58
|
+
* A string instance validates successfully against this keyword if its value does not equal to any of the elements in this keyword's array value.
|
|
59
|
+
*/
|
|
60
|
+
excludesEnum?: string[];
|
|
57
61
|
}
|
|
58
62
|
/**
|
|
59
63
|
* Validation for String Arrays
|
|
@@ -111,24 +115,9 @@ export interface FuncValidation<T extends string | string[] | OptionItem | Optio
|
|
|
111
115
|
*/
|
|
112
116
|
validFunc: ValidateFunc<T>;
|
|
113
117
|
}
|
|
118
|
+
export type ConditionFunc = (inputs: Inputs) => boolean | Promise<boolean>;
|
|
114
119
|
/**
|
|
115
120
|
* Definition of validation schema, which is a union of `StringValidation`, `StringArrayValidation` and `FuncValidation<any>`
|
|
116
121
|
*/
|
|
117
|
-
export
|
|
118
|
-
/**
|
|
119
|
-
* A function to return a validation function according the validation schema
|
|
120
|
-
* @param validation validation schema
|
|
121
|
-
* @param inputs object to carry all user inputs
|
|
122
|
-
* @returns a validation function
|
|
123
|
-
*/
|
|
124
|
-
export declare function getValidationFunction<T extends string | string[] | undefined>(validation: ValidationSchema, inputs: Inputs): (input: T) => string | undefined | Promise<string | undefined>;
|
|
125
|
-
/**
|
|
126
|
-
* Implementation of validation function
|
|
127
|
-
* @param validSchema validation schema
|
|
128
|
-
* @param value value to validate
|
|
129
|
-
* @param inputs user inputs object, which works as the context of the validation
|
|
130
|
-
* @returns A human-readable string which is presented as diagnostic message.
|
|
131
|
-
* Return `undefined` when 'value' is valid.
|
|
132
|
-
*/
|
|
133
|
-
export declare function validate<T extends string | string[] | OptionItem | OptionItem[] | undefined>(validSchema: ValidationSchema, value: T, inputs?: Inputs): Promise<string | undefined>;
|
|
122
|
+
export type ValidationSchema = StringValidation | StringArrayValidation | FuncValidation<any>;
|
|
134
123
|
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/qm/validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/qm/validation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE9C,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAC5B,KAAK,EAAE,CAAC,EACR,MAAM,CAAC,EAAE,MAAM,KACZ,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;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,qBAAqB,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC"}
|
package/build/qm/validation.js
CHANGED
|
@@ -1,162 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validate = exports.getValidationFunction = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
// Copyright (c) Microsoft Corporation.
|
|
6
|
-
// Licensed under the MIT license.
|
|
7
|
-
const jsonschema = tslib_1.__importStar(require("jsonschema"));
|
|
8
|
-
/**
|
|
9
|
-
* A function to return a validation function according the validation schema
|
|
10
|
-
* @param validation validation schema
|
|
11
|
-
* @param inputs object to carry all user inputs
|
|
12
|
-
* @returns a validation function
|
|
13
|
-
*/
|
|
14
|
-
function getValidationFunction(validation, inputs) {
|
|
15
|
-
return function (input) {
|
|
16
|
-
return validate(validation, input, inputs);
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
exports.getValidationFunction = getValidationFunction;
|
|
20
|
-
/**
|
|
21
|
-
* Implementation of validation function
|
|
22
|
-
* @param validSchema validation schema
|
|
23
|
-
* @param value value to validate
|
|
24
|
-
* @param inputs user inputs object, which works as the context of the validation
|
|
25
|
-
* @returns A human-readable string which is presented as diagnostic message.
|
|
26
|
-
* Return `undefined` when 'value' is valid.
|
|
27
|
-
*/
|
|
28
|
-
async function validate(validSchema, value, inputs) {
|
|
29
|
-
{
|
|
30
|
-
//FuncValidation
|
|
31
|
-
const funcValidation = validSchema;
|
|
32
|
-
if (funcValidation.validFunc) {
|
|
33
|
-
const res = await funcValidation.validFunc(value, inputs);
|
|
34
|
-
return res;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (!value) {
|
|
38
|
-
if (validSchema.required === true)
|
|
39
|
-
return `input value is required.`;
|
|
40
|
-
}
|
|
41
|
-
{
|
|
42
|
-
// StringValidation
|
|
43
|
-
const stringValidation = validSchema;
|
|
44
|
-
const strToValidate = value;
|
|
45
|
-
if (typeof strToValidate === "string") {
|
|
46
|
-
const schema = {};
|
|
47
|
-
if (stringValidation.equals && typeof stringValidation.equals === "string")
|
|
48
|
-
schema.const = stringValidation.equals;
|
|
49
|
-
if (stringValidation.enum &&
|
|
50
|
-
stringValidation.enum.length > 0 &&
|
|
51
|
-
typeof stringValidation.enum[0] === "string")
|
|
52
|
-
schema.enum = stringValidation.enum;
|
|
53
|
-
if (stringValidation.minLength)
|
|
54
|
-
schema.minLength = stringValidation.minLength;
|
|
55
|
-
if (stringValidation.maxLength)
|
|
56
|
-
schema.maxLength = stringValidation.maxLength;
|
|
57
|
-
if (stringValidation.pattern)
|
|
58
|
-
schema.pattern = stringValidation.pattern;
|
|
59
|
-
if (Object.keys(schema).length > 0) {
|
|
60
|
-
const validateResult = jsonschema.validate(strToValidate, schema);
|
|
61
|
-
if (validateResult.errors && validateResult.errors.length > 0) {
|
|
62
|
-
return `'${strToValidate}' ${validateResult.errors[0].message}`;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (stringValidation.startsWith) {
|
|
66
|
-
if (!strToValidate.startsWith(stringValidation.startsWith)) {
|
|
67
|
-
return `'${strToValidate}' does not meet startsWith:'${stringValidation.startsWith}'`;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
if (stringValidation.endsWith) {
|
|
71
|
-
if (!strToValidate.endsWith(stringValidation.endsWith)) {
|
|
72
|
-
return `'${strToValidate}' does not meet endsWith:'${stringValidation.endsWith}'`;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (stringValidation.includes && typeof strToValidate === "string") {
|
|
76
|
-
if (!strToValidate.includes(stringValidation.includes)) {
|
|
77
|
-
return `'${strToValidate}' does not meet includes:'${stringValidation.includes}'`;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (stringValidation.notEquals && typeof strToValidate === "string") {
|
|
81
|
-
if (strToValidate === stringValidation.notEquals) {
|
|
82
|
-
return `'${strToValidate}' does not meet notEquals:'${stringValidation.notEquals}'`;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
//StringArrayValidation
|
|
88
|
-
{
|
|
89
|
-
const stringArrayValidation = validSchema;
|
|
90
|
-
const arrayToValidate = value;
|
|
91
|
-
if (arrayToValidate instanceof Array) {
|
|
92
|
-
const schema = {};
|
|
93
|
-
if (stringArrayValidation.maxItems)
|
|
94
|
-
schema.maxItems = stringArrayValidation.maxItems;
|
|
95
|
-
if (stringArrayValidation.minItems)
|
|
96
|
-
schema.minItems = stringArrayValidation.minItems;
|
|
97
|
-
if (stringArrayValidation.uniqueItems)
|
|
98
|
-
schema.uniqueItems = stringArrayValidation.uniqueItems;
|
|
99
|
-
if (Object.keys(schema).length > 0) {
|
|
100
|
-
const validateResult = jsonschema.validate(arrayToValidate, schema);
|
|
101
|
-
if (validateResult.errors && validateResult.errors.length > 0) {
|
|
102
|
-
return `'${arrayToValidate}' ${validateResult.errors[0].message}`;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (stringArrayValidation.equals) {
|
|
106
|
-
if (stringArrayValidation.equals instanceof Array) {
|
|
107
|
-
stringArrayValidation.enum = stringArrayValidation.equals;
|
|
108
|
-
stringArrayValidation.containsAll = stringArrayValidation.equals;
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
return `Array '${arrayToValidate}' does not equals to string:'${stringArrayValidation.equals}'`;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
if (stringArrayValidation.enum) {
|
|
115
|
-
for (const item of arrayToValidate) {
|
|
116
|
-
if (!stringArrayValidation.enum.includes(item)) {
|
|
117
|
-
return `'${arrayToValidate}' does not meet with enum:'${stringArrayValidation.enum}'`;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (stringArrayValidation.excludes) {
|
|
122
|
-
if (arrayToValidate.includes(stringArrayValidation.excludes)) {
|
|
123
|
-
return `'${arrayToValidate}' does not meet with excludes:'${stringArrayValidation.excludes}'`;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (stringArrayValidation.contains) {
|
|
127
|
-
if (!arrayToValidate.includes(stringArrayValidation.contains)) {
|
|
128
|
-
return `'${arrayToValidate}' does not meet with contains:'${stringArrayValidation.contains}'`;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (stringArrayValidation.containsAll) {
|
|
132
|
-
const containsAll = stringArrayValidation.containsAll;
|
|
133
|
-
if (containsAll.length > 0) {
|
|
134
|
-
for (const i of containsAll) {
|
|
135
|
-
if (!arrayToValidate.includes(i)) {
|
|
136
|
-
return `'${arrayToValidate}' does not meet with containsAll:'${containsAll}'`;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
if (stringArrayValidation.containsAny) {
|
|
142
|
-
const containsAny = stringArrayValidation.containsAny;
|
|
143
|
-
if (containsAny.length > 0) {
|
|
144
|
-
// let array = valueToValidate as string[];
|
|
145
|
-
let found = false;
|
|
146
|
-
for (const i of containsAny) {
|
|
147
|
-
if (arrayToValidate.includes(i)) {
|
|
148
|
-
found = true;
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if (!found) {
|
|
153
|
-
return `'${arrayToValidate}' does not meet containsAny:'${containsAny}'`;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return undefined;
|
|
160
|
-
}
|
|
161
|
-
exports.validate = validate;
|
|
162
3
|
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/qm/validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/qm/validation.ts"],"names":[],"mappings":""}
|