Hans c89a0420d5 feat(@angular-devkit/core): add DeepReadonly<> and Readwrite<> types
Readwrite removes readonly, while DeepReadonly recursively sets it. A ReadonlyArray
should be used if the type is an array, but that is too much of a change to our API
(JsonValue includes JsonArray but then we would need a ReadonlyJsonValue, and same
for object, which has deep roots in our API).

We should fix this in a further refactor at some point.
2018-12-14 10:55:04 -08:00
..
2018-11-30 11:53:54 -08:00

Core

Shared utilities for Angular DevKit.

Exception

Json

Schema

SchemaValidatorResult

export interface SchemaValidatorResult {
  success: boolean;
  errors?: string[];
}

SchemaValidator

export interface SchemaValidator {
  (data: any): Observable<SchemaValidatorResult>;
}

SchemaFormatter

export interface SchemaFormatter {
  readonly async: boolean;
  validate(data: any): boolean | Observable<boolean>;
}

SchemaRegistry

export interface SchemaRegistry {
  compile(schema: Object): Observable<SchemaValidator>;
  addFormat(name: string, formatter: SchemaFormatter): void;
}

CoreSchemaRegistry

SchemaRegistry implementation using https://github.com/epoberezkin/ajv. Constructor accepts object containing SchemaFormatter that will be added automatically.

export class CoreSchemaRegistry implements SchemaRegistry {
  constructor(formats: { [name: string]: SchemaFormatter} = {}) {}
}

Logger

Utils

Virtual FS