|
5 | 5 | * Use of this source code is governed by an MIT-style license that can be
|
6 | 6 | * found in the LICENSE file at https://angular.io/license
|
7 | 7 | */
|
8 |
| -import { Observable } from 'rxjs'; |
| 8 | +import { Observable, SubscribableOrPromise } from 'rxjs'; |
9 | 9 | import { JsonArray, JsonObject, JsonValue } from '../interface';
|
10 | 10 |
|
11 | 11 | export type JsonPointer = string & {
|
@@ -57,9 +57,13 @@ export interface SchemaValidatorResult {
|
57 | 57 | errors?: SchemaValidatorError[];
|
58 | 58 | }
|
59 | 59 |
|
| 60 | +export interface SchemaValidatorOptions { |
| 61 | + withPrompts: boolean; |
| 62 | +} |
| 63 | + |
60 | 64 | export interface SchemaValidator {
|
61 | 65 | // tslint:disable-next-line:no-any
|
62 |
| - (data: any): Observable<SchemaValidatorResult>; |
| 66 | + (data: any, options?: Partial<SchemaValidatorOptions>): Observable<SchemaValidatorResult>; |
63 | 67 | }
|
64 | 68 |
|
65 | 69 | export interface SchemaFormatter {
|
@@ -90,8 +94,25 @@ export interface SchemaKeywordValidator {
|
90 | 94 | ): boolean | Observable<boolean>;
|
91 | 95 | }
|
92 | 96 |
|
| 97 | +export interface PromptDefinition { |
| 98 | + id: string; |
| 99 | + type: string; |
| 100 | + message: string; |
| 101 | + default?: string | number | boolean | null; |
| 102 | + priority: number; |
| 103 | + validator?: (value: string) => boolean | string | Promise<boolean | string>; |
| 104 | + |
| 105 | + items?: Array<string | { value: JsonValue, label: string }>; |
| 106 | + |
| 107 | + raw?: string | JsonObject; |
| 108 | +} |
| 109 | + |
| 110 | +export type PromptProvider = (definitions: Array<PromptDefinition>) |
| 111 | + => SubscribableOrPromise<{ [id: string]: JsonValue }>; |
| 112 | + |
93 | 113 | export interface SchemaRegistry {
|
94 | 114 | compile(schema: Object): Observable<SchemaValidator>;
|
95 | 115 | addFormat(format: SchemaFormat): void;
|
96 | 116 | addSmartDefaultProvider<T>(source: string, provider: SmartDefaultProvider<T>): void;
|
| 117 | + usePromptProvider(provider: PromptProvider): void; |
97 | 118 | }
|
0 commit comments