@elle96/ng-json-schema-manager 0.2.1 → 0.4.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/index.d.ts
DELETED
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import { AbstractControl, ControlValueAccessor, FormGroup, FormArray, FormControl } from '@angular/forms';
|
|
2
|
-
import * as i0 from '@angular/core';
|
|
3
|
-
import { OnChanges, ElementRef, Renderer2, SimpleChanges, OnDestroy, EventEmitter, ChangeDetectorRef, OnInit } from '@angular/core';
|
|
4
|
-
import { ErrorObject } from 'ajv';
|
|
5
|
-
|
|
6
|
-
type JsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
7
|
-
type JsonSchemaPrimitive = string | number | boolean | null;
|
|
8
|
-
interface JsonSchemaBase {
|
|
9
|
-
$schema?: string;
|
|
10
|
-
$id?: string;
|
|
11
|
-
$ref?: string;
|
|
12
|
-
$anchor?: string;
|
|
13
|
-
$dynamicRef?: string;
|
|
14
|
-
$dynamicAnchor?: string;
|
|
15
|
-
$comment?: string;
|
|
16
|
-
title?: string;
|
|
17
|
-
description?: string;
|
|
18
|
-
type?: JsonSchemaType | JsonSchemaType[];
|
|
19
|
-
enum?: JsonSchemaPrimitive[];
|
|
20
|
-
const?: JsonSchemaPrimitive;
|
|
21
|
-
default?: unknown;
|
|
22
|
-
examples?: unknown[];
|
|
23
|
-
format?: string;
|
|
24
|
-
readOnly?: boolean;
|
|
25
|
-
writeOnly?: boolean;
|
|
26
|
-
deprecated?: boolean;
|
|
27
|
-
nullable?: boolean;
|
|
28
|
-
contentMediaType?: string;
|
|
29
|
-
contentEncoding?: string;
|
|
30
|
-
minLength?: number;
|
|
31
|
-
maxLength?: number;
|
|
32
|
-
pattern?: string;
|
|
33
|
-
minimum?: number;
|
|
34
|
-
maximum?: number;
|
|
35
|
-
exclusiveMinimum?: number;
|
|
36
|
-
exclusiveMaximum?: number;
|
|
37
|
-
multipleOf?: number;
|
|
38
|
-
minItems?: number;
|
|
39
|
-
maxItems?: number;
|
|
40
|
-
uniqueItems?: boolean;
|
|
41
|
-
minContains?: number;
|
|
42
|
-
maxContains?: number;
|
|
43
|
-
required?: string[];
|
|
44
|
-
}
|
|
45
|
-
interface JsonSchemaObject {
|
|
46
|
-
properties?: Record<string, JsonSchema>;
|
|
47
|
-
patternProperties?: Record<string, JsonSchema>;
|
|
48
|
-
additionalProperties?: boolean | JsonSchema;
|
|
49
|
-
unevaluatedProperties?: boolean | JsonSchema;
|
|
50
|
-
propertyNames?: JsonSchema;
|
|
51
|
-
dependencies?: Record<string, string[] | JsonSchema>;
|
|
52
|
-
dependentRequired?: Record<string, string[]>;
|
|
53
|
-
dependentSchemas?: Record<string, JsonSchema>;
|
|
54
|
-
minProperties?: number;
|
|
55
|
-
maxProperties?: number;
|
|
56
|
-
}
|
|
57
|
-
interface JsonSchemaArray {
|
|
58
|
-
items?: JsonSchema | boolean;
|
|
59
|
-
prefixItems?: JsonSchema[];
|
|
60
|
-
additionalItems?: JsonSchema | boolean;
|
|
61
|
-
unevaluatedItems?: JsonSchema | boolean;
|
|
62
|
-
contains?: JsonSchema;
|
|
63
|
-
}
|
|
64
|
-
interface JsonSchemaCombinators extends JsonSchemaBase {
|
|
65
|
-
allOf?: JsonSchema[];
|
|
66
|
-
anyOf?: JsonSchema[];
|
|
67
|
-
oneOf?: JsonSchema[];
|
|
68
|
-
not?: JsonSchema;
|
|
69
|
-
if?: JsonSchema;
|
|
70
|
-
then?: JsonSchema;
|
|
71
|
-
else?: JsonSchema;
|
|
72
|
-
}
|
|
73
|
-
interface JsonSchema extends JsonSchemaBase, JsonSchemaObject, JsonSchemaArray, JsonSchemaCombinators {
|
|
74
|
-
$defs?: Record<string, JsonSchema>;
|
|
75
|
-
definitions?: Record<string, JsonSchema>;
|
|
76
|
-
}
|
|
77
|
-
interface SchemaFieldContext {
|
|
78
|
-
schema: JsonSchema;
|
|
79
|
-
path: string;
|
|
80
|
-
required: boolean;
|
|
81
|
-
}
|
|
82
|
-
interface SchemaError {
|
|
83
|
-
path: string;
|
|
84
|
-
message: string;
|
|
85
|
-
keyword: string;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
declare class JsonSchemaFormService {
|
|
89
|
-
buildControl(schema: JsonSchema, value?: unknown, required?: boolean): AbstractControl;
|
|
90
|
-
resolveType(schema: JsonSchema): JsonSchema['type'] | 'enum';
|
|
91
|
-
private applyCombinators;
|
|
92
|
-
resolveDynamicSchema(schema: JsonSchema, key: string): JsonSchema | undefined;
|
|
93
|
-
private resolveInitialValue;
|
|
94
|
-
private buildValidators;
|
|
95
|
-
private isRecord;
|
|
96
|
-
private mergeSchemas;
|
|
97
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<JsonSchemaFormService, never>;
|
|
98
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<JsonSchemaFormService>;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
declare class JsonSchemaResolverService {
|
|
102
|
-
resolve(schema: JsonSchema, baseUri?: string): Promise<JsonSchema>;
|
|
103
|
-
private resolveRefs;
|
|
104
|
-
private resolveExternalRef;
|
|
105
|
-
private fetchSchema;
|
|
106
|
-
private resolvePointer;
|
|
107
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<JsonSchemaResolverService, never>;
|
|
108
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<JsonSchemaResolverService>;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
type JsonSchemaDraft = 'draft4' | 'draft6' | 'draft7' | 'draft2019' | 'draft2020';
|
|
112
|
-
declare class JsonSchemaValidationService {
|
|
113
|
-
private readonly ajvCache;
|
|
114
|
-
validate(schema: JsonSchema, value: unknown): ErrorObject[];
|
|
115
|
-
/**
|
|
116
|
-
* Validates the schema itself against its JSON Schema meta-schema.
|
|
117
|
-
* Returns a list of SchemaError describing what is wrong in the schema definition.
|
|
118
|
-
*/
|
|
119
|
-
validateSchema(schema: JsonSchema): SchemaError[];
|
|
120
|
-
detectDraft(schema: JsonSchema): JsonSchemaDraft;
|
|
121
|
-
private getAjv;
|
|
122
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<JsonSchemaValidationService, never>;
|
|
123
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<JsonSchemaValidationService>;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
declare class JsonSchemaStylesService {
|
|
127
|
-
private platformId;
|
|
128
|
-
private injected;
|
|
129
|
-
constructor(platformId: object);
|
|
130
|
-
inject(): void;
|
|
131
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<JsonSchemaStylesService, never>;
|
|
132
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<JsonSchemaStylesService>;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** Character shown between the integer and decimal part of a number. */
|
|
136
|
-
type DecimalSeparator = '.' | ',';
|
|
137
|
-
/**
|
|
138
|
-
* Options shared by every node of a form. Provided by `jsm-json-schema-form`, so each form instance has its own.
|
|
139
|
-
*/
|
|
140
|
-
declare class JsonSchemaFormOptions {
|
|
141
|
-
decimalSeparator: DecimalSeparator;
|
|
142
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<JsonSchemaFormOptions, never>;
|
|
143
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<JsonSchemaFormOptions>;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Keeps digits, a leading minus and a single decimal separator (written with `separator`);
|
|
147
|
-
* `,` and `.` are both accepted as input.
|
|
148
|
-
*/
|
|
149
|
-
declare function sanitizeNumericText(text: string, separator: DecimalSeparator): string;
|
|
150
|
-
/** Text → model: empty → `null`, a complete number → number, anything else stays a string (validation reports it). */
|
|
151
|
-
declare function parseNumericText(text: string): number | string | null;
|
|
152
|
-
/** Model → text shown in the input. */
|
|
153
|
-
declare function formatNumeric(value: unknown, separator: DecimalSeparator): string;
|
|
154
|
-
/** Shows decimals with the configured separator inside messages ("must be >= 0.1" → "must be >= 0,1"). */
|
|
155
|
-
declare function localizeNumbers(message: string, separator: DecimalSeparator): string;
|
|
156
|
-
/**
|
|
157
|
-
* `ControlValueAccessor` for `number`/`integer` fields. The input is a text field (`inputmode="decimal"`), so the
|
|
158
|
-
* decimal comma is accepted, and the model always holds a JSON number once the text is a complete number.
|
|
159
|
-
* It never writes to the control while rendering or when the text is unchanged.
|
|
160
|
-
*/
|
|
161
|
-
declare class NumericInputDirective implements ControlValueAccessor, OnChanges {
|
|
162
|
-
private readonly _el;
|
|
163
|
-
private readonly _renderer;
|
|
164
|
-
jsmDecimalSeparator: DecimalSeparator;
|
|
165
|
-
private _model;
|
|
166
|
-
private _onChange;
|
|
167
|
-
private _onTouched;
|
|
168
|
-
constructor(_el: ElementRef<HTMLInputElement>, _renderer: Renderer2);
|
|
169
|
-
private _show;
|
|
170
|
-
ngOnChanges(changes: SimpleChanges): void;
|
|
171
|
-
writeValue(value: unknown): void;
|
|
172
|
-
registerOnChange(fn: (value: unknown) => void): void;
|
|
173
|
-
registerOnTouched(fn: () => void): void;
|
|
174
|
-
setDisabledState(isDisabled: boolean): void;
|
|
175
|
-
onInput(): void;
|
|
176
|
-
onBlur(): void;
|
|
177
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<NumericInputDirective, never>;
|
|
178
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<NumericInputDirective, "input[jsmNumeric]", never, { "jsmDecimalSeparator": { "alias": "jsmDecimalSeparator"; "required": false; }; }, {}, never, never, true, never>;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
declare class JsonSchemaFormComponent implements OnChanges, OnDestroy {
|
|
182
|
-
private readonly schemaService;
|
|
183
|
-
private readonly resolver;
|
|
184
|
-
private readonly validation;
|
|
185
|
-
private readonly cdr;
|
|
186
|
-
private readonly options;
|
|
187
|
-
schema: JsonSchema;
|
|
188
|
-
value?: unknown;
|
|
189
|
-
data?: unknown;
|
|
190
|
-
allowAdditionalProperties: boolean;
|
|
191
|
-
/**
|
|
192
|
-
* Decimal separator of number/integer fields. `,` shows and accepts `0,5` (both `,` and `.` are accepted as input
|
|
193
|
-
* either way); the emitted value is always a JSON number.
|
|
194
|
-
*/
|
|
195
|
-
decimalSeparator: DecimalSeparator;
|
|
196
|
-
formReady: EventEmitter<FormGroup<any>>;
|
|
197
|
-
valueChange: EventEmitter<unknown>;
|
|
198
|
-
schemaReady: EventEmitter<JsonSchema>;
|
|
199
|
-
schemaErrors: EventEmitter<SchemaError[]>;
|
|
200
|
-
form: FormGroup;
|
|
201
|
-
rootControl: AbstractControl;
|
|
202
|
-
resolvedSchema?: JsonSchema;
|
|
203
|
-
errorsMap: Map<string, string[]>;
|
|
204
|
-
schemaErrorList: SchemaError[];
|
|
205
|
-
loading: boolean;
|
|
206
|
-
/** When true, all field errors are shown regardless of touched/dirty state. */
|
|
207
|
-
showErrors: boolean;
|
|
208
|
-
private valueSub?;
|
|
209
|
-
/** Last value emitted through valueChange (same reference the parent gets back through `data`/`value`). */
|
|
210
|
-
private lastEmitted;
|
|
211
|
-
constructor(schemaService: JsonSchemaFormService, resolver: JsonSchemaResolverService, validation: JsonSchemaValidationService, cdr: ChangeDetectorRef, options: JsonSchemaFormOptions, stylesService: JsonSchemaStylesService);
|
|
212
|
-
ngOnChanges(changes: SimpleChanges): void;
|
|
213
|
-
ngOnDestroy(): void;
|
|
214
|
-
/**
|
|
215
|
-
* Marks all fields as touched and forces error display across the entire form.
|
|
216
|
-
* Call this from an external "Save" or "Submit" button to show all validation errors at once.
|
|
217
|
-
* Returns true if the form is valid, false otherwise.
|
|
218
|
-
*/
|
|
219
|
-
validate(): boolean;
|
|
220
|
-
private buildForm;
|
|
221
|
-
private updateErrors;
|
|
222
|
-
onRootReplaced(control: AbstractControl): void;
|
|
223
|
-
private attachValueSub;
|
|
224
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<JsonSchemaFormComponent, never>;
|
|
225
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<JsonSchemaFormComponent, "jsm-json-schema-form", never, { "schema": { "alias": "schema"; "required": true; }; "value": { "alias": "value"; "required": false; }; "data": { "alias": "data"; "required": false; }; "allowAdditionalProperties": { "alias": "allowAdditionalProperties"; "required": false; }; "decimalSeparator": { "alias": "decimalSeparator"; "required": false; }; }, { "formReady": "formReady"; "valueChange": "valueChange"; "schemaReady": "schemaReady"; "schemaErrors": "schemaErrors"; }, never, never, true, never>;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
declare class JsonSchemaNodeComponent implements OnInit, OnDestroy {
|
|
229
|
-
private readonly schemaService;
|
|
230
|
-
private readonly validation;
|
|
231
|
-
private readonly cdr;
|
|
232
|
-
private readonly options;
|
|
233
|
-
schema: JsonSchema;
|
|
234
|
-
control: AbstractControl;
|
|
235
|
-
label: string;
|
|
236
|
-
required: boolean;
|
|
237
|
-
path: string;
|
|
238
|
-
errorsMap: Map<string, string[]>;
|
|
239
|
-
parent?: FormGroup | FormArray;
|
|
240
|
-
controlKey?: string | number;
|
|
241
|
-
allowAdditionalProperties: boolean;
|
|
242
|
-
/** When true, errors are shown regardless of touched/dirty state (e.g. triggered by an external save button). */
|
|
243
|
-
showErrors: boolean;
|
|
244
|
-
controlReplaced: EventEmitter<AbstractControl<any, any, any>>;
|
|
245
|
-
selectedOneOf: number;
|
|
246
|
-
selectedAnyOf: Set<number>;
|
|
247
|
-
newPropertyKey: string;
|
|
248
|
-
propertyError: string;
|
|
249
|
-
/** Tracks whether this primitive control has been touched (for OnPush CD). */
|
|
250
|
-
isTouched: boolean;
|
|
251
|
-
private valueSub?;
|
|
252
|
-
constructor(schemaService: JsonSchemaFormService, validation: JsonSchemaValidationService, cdr: ChangeDetectorRef, options: JsonSchemaFormOptions | null);
|
|
253
|
-
ngOnInit(): void;
|
|
254
|
-
ngOnDestroy(): void;
|
|
255
|
-
/** Called on blur of primitive inputs to trigger CD after Angular marks the control as touched. */
|
|
256
|
-
onBlur(): void;
|
|
257
|
-
isSimpleChild(key: string): boolean;
|
|
258
|
-
badgeClass(badge: string): string;
|
|
259
|
-
get nodeKind(): 'oneOf' | 'anyOf' | 'allOf' | 'object' | 'array' | 'primitive';
|
|
260
|
-
get resolvedType(): JsonSchema['type'] | 'enum';
|
|
261
|
-
get decimalSeparator(): DecimalSeparator;
|
|
262
|
-
/** `multipleOf` of this node's own schema, exposed as step metadata. */
|
|
263
|
-
get numericStep(): string;
|
|
264
|
-
get inputKind(): 'text' | 'number' | 'textarea' | 'select' | 'checkbox';
|
|
265
|
-
get inputType(): string;
|
|
266
|
-
get controlAsGroup(): FormGroup;
|
|
267
|
-
get controlAsFormControl(): FormControl;
|
|
268
|
-
get controlAsArray(): FormArray;
|
|
269
|
-
get arrayControls(): AbstractControl[];
|
|
270
|
-
get objectKeys(): string[];
|
|
271
|
-
get simpleKeys(): string[];
|
|
272
|
-
get complexKeys(): string[];
|
|
273
|
-
get canAddProperty(): boolean;
|
|
274
|
-
get errorsForPath(): string[];
|
|
275
|
-
/** Combined errors: Ajv errors from errorsMap + Angular validator errors on the control. */
|
|
276
|
-
get allErrors(): string[];
|
|
277
|
-
get metaBadges(): string[];
|
|
278
|
-
get activeVariant(): JsonSchema | null;
|
|
279
|
-
get mergedAllOf(): JsonSchema[];
|
|
280
|
-
isRequired(key: string): boolean;
|
|
281
|
-
schemaForKey(key: string): JsonSchema;
|
|
282
|
-
isDynamicKey(key: string): boolean;
|
|
283
|
-
pathForChild(key: string | number): string;
|
|
284
|
-
addDynamicProperty(): void;
|
|
285
|
-
removeDynamicKey(key: string): void;
|
|
286
|
-
schemaForIndex(index: number): JsonSchema;
|
|
287
|
-
get canAddArrayItem(): boolean;
|
|
288
|
-
addArrayItem(): void;
|
|
289
|
-
removeArrayItem(index: number): void;
|
|
290
|
-
onOneOfChange(): void;
|
|
291
|
-
toggleAnyOf(index: number): void;
|
|
292
|
-
private replaceControl;
|
|
293
|
-
childControl(key: string): AbstractControl;
|
|
294
|
-
get effectiveSchema(): JsonSchema;
|
|
295
|
-
private applyConditional;
|
|
296
|
-
private applyDependencies;
|
|
297
|
-
private mergeSchemas;
|
|
298
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<JsonSchemaNodeComponent, [null, null, null, { optional: true; }]>;
|
|
299
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<JsonSchemaNodeComponent, "jsm-schema-node", never, { "schema": { "alias": "schema"; "required": true; }; "control": { "alias": "control"; "required": true; }; "label": { "alias": "label"; "required": false; }; "required": { "alias": "required"; "required": false; }; "path": { "alias": "path"; "required": false; }; "errorsMap": { "alias": "errorsMap"; "required": false; }; "parent": { "alias": "parent"; "required": false; }; "controlKey": { "alias": "controlKey"; "required": false; }; "allowAdditionalProperties": { "alias": "allowAdditionalProperties"; "required": false; }; "showErrors": { "alias": "showErrors"; "required": false; }; }, { "controlReplaced": "controlReplaced"; }, never, never, true, never>;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
declare class JsonSchemaFormModule {
|
|
303
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<JsonSchemaFormModule, never>;
|
|
304
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<JsonSchemaFormModule, never, [typeof JsonSchemaFormComponent, typeof JsonSchemaNodeComponent], [typeof JsonSchemaFormComponent, typeof JsonSchemaNodeComponent]>;
|
|
305
|
-
static ɵinj: i0.ɵɵInjectorDeclaration<JsonSchemaFormModule>;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Coerces values to the types declared by the schema so that the emitted value respects it:
|
|
310
|
-
* - `number`/`integer` numeric strings become JSON numbers (comma or dot as separator);
|
|
311
|
-
* - empty numeric values (`""`, whitespace, `null`) leave the key absent, never `""` or `0`;
|
|
312
|
-
* - integers with decimals are converted to their number but never truncated (validation reports them);
|
|
313
|
-
* - non-numeric strings are left unchanged (validation reports them).
|
|
314
|
-
* Descends into properties, patternProperties, additionalProperties, items, prefixItems and combinators.
|
|
315
|
-
* The same function feeds both the Ajv validation and the emitted value.
|
|
316
|
-
*/
|
|
317
|
-
declare function normalizeValue(schema: JsonSchema, value: unknown): unknown;
|
|
318
|
-
|
|
319
|
-
export { JsonSchemaFormComponent, JsonSchemaFormModule, JsonSchemaFormOptions, JsonSchemaFormService, JsonSchemaNodeComponent, JsonSchemaResolverService, JsonSchemaStylesService, JsonSchemaValidationService, NumericInputDirective, formatNumeric, localizeNumbers, normalizeValue, parseNumericText, sanitizeNumericText };
|
|
320
|
-
export type { DecimalSeparator, JsonSchema, JsonSchemaArray, JsonSchemaBase, JsonSchemaCombinators, JsonSchemaDraft, JsonSchemaObject, JsonSchemaPrimitive, JsonSchemaType, SchemaError, SchemaFieldContext };
|