@angular-devkit/core
- Version 13.3.5
- Published
- 441 kB
- 6 dependencies
- MIT license
Install
npm i @angular-devkit/core
yarn add @angular-devkit/core
pnpm add @angular-devkit/core
Overview
Angular DevKit - Core Utility Library
Index
Variables
Functions
Classes
Interfaces
Type Aliases
Namespaces
analytics
- Analytics
- AnalyticsForwarderFn
- AnalyticsReport
- AnalyticsReportBase
- AnalyticsReporter
- AnalyticsReportEvent
- AnalyticsReportKind
- AnalyticsReportPageview
- AnalyticsReportScreenview
- AnalyticsReportTiming
- CustomDimensionsAndMetricsOptions
- EventOptions
- ForwardingAnalytics
- LoggingAnalytics
- MultiAnalytics
- NgCliAnalyticsDimensions
- NgCliAnalyticsDimensionsFlagInfo
- NgCliAnalyticsMetrics
- NgCliAnalyticsMetricsFlagInfo
- NoopAnalytics
- PageviewOptions
- ScreenviewOptions
- TimingOptions
jobs
- ChannelAlreadyExistException
- createDispatcher()
- createJobFactory()
- createJobHandler()
- createLoggerJob()
- FallbackRegistry
- isJobHandler()
- Job
- JobArgumentSchemaValidationError
- JobDescription
- JobDispatcher
- JobDoesNotExistException
- JobHandler
- JobHandlerContext
- JobInboundMessage
- JobInboundMessageBase
- JobInboundMessageInput
- JobInboundMessageKind
- JobInboundMessagePing
- JobInboundMessageSchemaValidationError
- JobInboundMessageStop
- JobName
- JobNameAlreadyRegisteredException
- JobOutboundMessage
- JobOutboundMessageBase
- JobOutboundMessageChannelBase
- JobOutboundMessageChannelComplete
- JobOutboundMessageChannelCreate
- JobOutboundMessageChannelError
- JobOutboundMessageChannelMessage
- JobOutboundMessageEnd
- JobOutboundMessageKind
- JobOutboundMessageOnReady
- JobOutboundMessageOutput
- JobOutboundMessagePong
- JobOutboundMessageStart
- JobOutputSchemaValidationError
- JobState
- RegisterJobOptions
- Registry
- ScheduleJobOptions
- Scheduler
- SimpleJobHandlerContext
- SimpleJobHandlerFn
- SimpleJobRegistry
- SimpleScheduler
schema
- buildJsonPointer()
- CoreSchemaRegistry
- getTypesOfSchema()
- isJsonSchema()
- joinJsonPointer()
- JsonPointer
- JsonSchema
- JsonSchemaVisitor
- JsonVisitor
- mergeSchemas()
- parseJsonPointer()
- PromptDefinition
- PromptProvider
- ReferenceResolver
- SchemaFormat
- SchemaFormatter
- SchemaKeywordValidator
- SchemaRegistry
- SchemaValidationException
- SchemaValidator
- SchemaValidatorError
- SchemaValidatorOptions
- SchemaValidatorResult
- SmartDefaultProvider
- UriHandler
- visitJson()
- visitJsonSchema()
schema
- buildJsonPointer()
- CoreSchemaRegistry
- getTypesOfSchema()
- isJsonSchema()
- joinJsonPointer()
- JsonPointer
- JsonSchema
- JsonSchemaVisitor
- JsonVisitor
- mergeSchemas()
- parseJsonPointer()
- PromptDefinition
- PromptProvider
- ReferenceResolver
- SchemaFormat
- SchemaFormatter
- SchemaKeywordValidator
- SchemaRegistry
- SchemaValidationException
- SchemaValidator
- SchemaValidatorError
- SchemaValidatorOptions
- SchemaValidatorResult
- SmartDefaultProvider
- UriHandler
- visitJson()
- visitJsonSchema()
virtualFs
- AliasHost
- CordHost
- CordHostCreate
- CordHostDelete
- CordHostOverwrite
- CordHostRecord
- CordHostRename
- createSyncHost()
- Empty
- fileBuffer
- FileBuffer
- FileBufferLike
- fileBufferToString()
- Host
- HostCapabilities
- HostWatchEvent
- HostWatchEventType
- HostWatchOptions
- PatternMatchingHost
- ReadonlyHost
- ReplacementFunction
- ResolverHost
- SafeReadonlyHost
- ScopedHost
- SimpleMemoryHost
- SimpleMemoryHostStats
- Stats
- stringToFileBuffer()
- SyncDelegateHost
- SyncHostHandler
- SynchronousDelegateExpectedException
Variables
variable NormalizedRoot
const NormalizedRoot: String & { __PRIVATE_DEVKIT_PATH: void };
The root of a normalized path. {Path}
variable NormalizedSep
const NormalizedSep: String & { __PRIVATE_DEVKIT_PATH: void };
The Separator for normalized path. {Path}
variable path
const path: TemplateTag<Path>;
Functions
function asPosixPath
asPosixPath: (path: Path) => PosixPath;
function asWindowsPath
asWindowsPath: (path: Path) => WindowsPath;
function basename
basename: (path: Path) => PathFragment;
Return the basename of the path, as a Path. See path.basename
function clean
clean: <T>(array: Array<T | undefined>) => Array<T>;
Deprecated
Since v12.0, unused by the Angular tooling
function deepCopy
deepCopy: <T>(value: T) => T;
function dirname
dirname: (path: Path) => Path;
Return the dirname of the path, as a Path. See path.dirname
function extname
extname: (path: Path) => string;
function fragment
fragment: (path: string) => PathFragment;
function getSystemPath
getSystemPath: (path: Path) => string;
function isAbsolute
isAbsolute: (p: Path) => boolean;
Returns true if a path is absolute.
function isJsonArray
isJsonArray: (value: JsonValue) => value is JsonArray;
function isJsonObject
isJsonObject: (value: JsonValue) => value is JsonObject;
function isPromise
isPromise: (obj: any) => obj is Promise<any>;
Determine if the argument is shaped like a Promise
function join
join: (p1: Path, ...others: string[]) => Path;
Join multiple paths together, and normalize the result. Accepts strings that will be normalized as well (but the original must be a path).
function mapObject
mapObject: <T, V>( obj: { [k: string]: T }, mapper: (k: string, v: T) => V) => { [k: string]: V };
Deprecated
Since v12.0, unused by the Angular tooling
function noCacheNormalize
noCacheNormalize: (path: string) => Path;
The no cache version of the normalize() function. Used for benchmarking and testing.
function normalize
normalize: (path: string) => Path;
Normalize a string into a Path. This is the only mean to get a Path type from a string that represents a system path. This method cache the results as real world paths tend to be duplicated often. Normalization includes: - Windows backslashes
\\
are replaced with/
. - Windows drivers are replaced with/X/
, where X is the drive letter. - Absolute paths starts with/
. - Multiple/
are replaced by a single one. - Path segments.
are removed. - Path segments..
are resolved. - If a path is absolute, having a..
at the start is invalid (and will throw).Parameter path
The path to be normalized.
function relative
relative: (from: Path, to: Path) => Path;
Returns a path such that
join(from, relative(from, to)) == to
. Both paths must be absolute, otherwise it does not make much sense.
function resetNormalizeCache
resetNormalizeCache: () => void;
Reset the cache. This is only useful for testing.
function resolve
resolve: (p1: Path, p2: Path) => Path;
Returns a Path that is the resolution of p2, from p1. If p2 is absolute, it will return p2, otherwise will join both p1 and p2.
function split
split: (path: Path) => PathFragment[];
Split a path into multiple path fragments. Each fragments except the last one will end with a path separator.
Parameter path
The path to split.
Returns
{Path[]} An array of path fragments.
function template
template: <T>( content: string, options?: TemplateOptions) => (input: T) => string;
An equivalent of EJS templates, which is based on John Resig's
tmpl
implementation (http://ejohn.org/blog/javascript-micro-templating/) and Laura Doktorova's doT.js (https://github.com/olado/doT).This version differs from lodash by removing support from ES6 quasi-literals, and making the code slightly simpler to follow. It also does not depend on any third party, which is nice.
Finally, it supports SourceMap, if you ever need to debug, which is super nice.
Parameter content
The template content.
Parameter options
Optional Options. See TemplateOptions for more description. {(input: T) => string} A function that accept an input object and returns the content of the template with the input applied.
function templateParser
templateParser: (sourceText: string, fileName: string) => TemplateAst;
Given a source text (and a fileName), returns a TemplateAst.
Classes
class BaseException
class BaseException extends Error {}
Copyright Google LLC All Rights Reserved.
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at https://angular.io/license
constructor
constructor(message?: string);
class CircularDependencyFoundException
class CircularDependencyFoundException extends BaseException {}
constructor
constructor();
class ContentHasMutatedException
class ContentHasMutatedException extends BaseException {}
constructor
constructor(path: string);
class DependencyNotFoundException
class DependencyNotFoundException extends BaseException {}
constructor
constructor();
class FileAlreadyExistException
class FileAlreadyExistException extends BaseException {}
constructor
constructor(path: string);
class FileDoesNotExistException
class FileDoesNotExistException extends BaseException {}
constructor
constructor(path: string);
class InvalidPathException
class InvalidPathException extends BaseException {}
constructor
constructor(path: string);
class InvalidUpdateRecordException
class InvalidUpdateRecordException extends BaseException {}
constructor
constructor();
class MergeConflictException
class MergeConflictException extends BaseException {}
constructor
constructor(path: string);
class PartiallyOrderedSet
class PartiallyOrderedSet<T> implements Set<T> {}
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property size
readonly size: number;
method [Symbol.iterator]
[Symbol.iterator]: () => Generator<T, void, unknown>;
method add
add: (item: T, deps?: Set<T> | T[]) => this;
method clear
clear: () => void;
method delete
delete: (item: T) => boolean;
method entries
entries: () => IterableIterator<[T, T]>;
Returns an iterable of [v,v] pairs for every value
v
in the set.
method forEach
forEach: ( callbackfn: (value: T, value2: T, set: PartiallyOrderedSet<T>) => void, thisArg?: any) => void;
method has
has: (item: T) => boolean;
method keys
keys: () => IterableIterator<T>;
Despite its name, returns an iterable of the values in the set,
method values
values: () => IterableIterator<T>;
Returns an iterable of values in the set.
class PathCannotBeFragmentException
class PathCannotBeFragmentException extends BaseException {}
constructor
constructor(path: string);
class PathIsDirectoryException
class PathIsDirectoryException extends BaseException {}
constructor
constructor(path: string);
class PathIsFileException
class PathIsFileException extends BaseException {}
constructor
constructor(path: string);
class PathMustBeAbsoluteException
class PathMustBeAbsoluteException extends BaseException {}
constructor
constructor(path: string);
class PriorityQueue
class PriorityQueue<T> {}
Naive priority queue; not intended for large datasets
class UnimplementedException
class UnimplementedException extends BaseException {}
constructor
constructor();
class UnknownException
class UnknownException extends BaseException {}
constructor
constructor(message: string);
class UnsupportedPlatformException
class UnsupportedPlatformException extends BaseException {}
constructor
constructor();
Interfaces
interface DeepReadonlyArray
interface DeepReadonlyArray<T> extends Array<DeepReadonly<T>> {}
interface JsonArray
interface JsonArray extends Array<JsonValue> {}
Copyright Google LLC All Rights Reserved.
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at https://angular.io/license
interface JsonObject
interface JsonObject {}
index signature
[prop: string]: JsonValue;
interface TemplateAst
interface TemplateAst {}
A simple AST for templates. There's only one level of AST nodes, but it's still useful to have the information you're looking for.
interface TemplateAstBase
interface TemplateAstBase {}
The base, which contains positions.
interface TemplateAstComment
interface TemplateAstComment extends TemplateAstBase {}
A comment node.
interface TemplateAstContent
interface TemplateAstContent extends TemplateAstBase {}
A static content node.
interface TemplateAstEscape
interface TemplateAstEscape extends TemplateAstBase {}
An escape node, which is the code between
<%- ... %>
.
property expression
expression: string;
property kind
kind: 'escape';
interface TemplateAstEvaluate
interface TemplateAstEvaluate extends TemplateAstBase {}
An evaluate node, which is the code between
<% ... %>
.
property expression
expression: string;
property kind
kind: 'evaluate';
interface TemplateAstInterpolate
interface TemplateAstInterpolate extends TemplateAstBase {}
An interpolation node, which is the code between
<%= ... %>
.
property expression
expression: string;
property kind
kind: 'interpolate';
interface TemplateOptions
interface TemplateOptions {}
property fileName
fileName?: string;
property module
module?: | boolean | { exports: {}; };
property sourceMap
sourceMap?: boolean;
property sourceRoot
sourceRoot?: string;
property sourceURL
sourceURL?: string;
Type Aliases
type DeepReadonly
type DeepReadonly<T> = T extends (infer R)[] ? DeepReadonlyArray<R> : T extends Function ? T : T extends object ? DeepReadonlyObject<T> : T;
type DeepReadonlyObject
type DeepReadonlyObject<T> = { readonly [P in keyof T]: DeepReadonly<T[P]>;};
type JsonValue
type JsonValue = boolean | string | number | JsonArray | JsonObject | null;
type Path
type Path = string & { __PRIVATE_DEVKIT_PATH: void;};
A Path recognized by most methods in the DevKit.
type PathFragment
type PathFragment = Path & { __PRIVATE_DEVKIT_PATH_FRAGMENT: void;};
A Path fragment (file or directory name) recognized by most methods in the DevKit.
type PosixPath
type PosixPath = string & { __PRIVATE_DEVKIT_POSIX_PATH: void;};
type Readwrite
type Readwrite<T> = { -readonly [P in keyof T]: T[P];};
type TemplateAstNode
type TemplateAstNode = | TemplateAstContent | TemplateAstEvaluate | TemplateAstComment | TemplateAstEscape | TemplateAstInterpolate;
type WindowsPath
type WindowsPath = string & { __PRIVATE_DEVKIT_WINDOWS_PATH: void;};
Namespaces
namespace analytics
module 'src/analytics/index.d.ts' {}
Copyright Google LLC All Rights Reserved.
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at https://angular.io/license
variable NgCliAnalyticsDimensionsFlagInfo
const NgCliAnalyticsDimensionsFlagInfo: { [name: string]: [string, string] };
variable NgCliAnalyticsMetricsFlagInfo
const NgCliAnalyticsMetricsFlagInfo: { [name: string]: [string, string] };
class AnalyticsReporter
class AnalyticsReporter {}
constructor
constructor(_analytics: Analytics);
method report
report: (report: AnalyticsReport) => void;
class ForwardingAnalytics
class ForwardingAnalytics implements Analytics {}
A class that follows the Analytics interface and forwards analytic reports (JavaScript objects). AnalyticsReporter is the counterpart which takes analytic reports and report them to another Analytics interface.
constructor
constructor(_fn: AnalyticsForwarderFn);
method event
event: (category: string, action: string, options?: EventOptions) => void;
method flush
flush: () => Promise<void>;
method pageview
pageview: (path: string, options?: PageviewOptions) => void;
method screenview
screenview: ( screenName: string, appName: string, options?: ScreenviewOptions) => void;
method timing
timing: ( category: string, variable: string, time: string | number, options?: TimingOptions) => void;
class LoggingAnalytics
class LoggingAnalytics implements Analytics {}
Analytics implementation that logs analytics events to a logger. This should be used for debugging mainly.
constructor
constructor(_logger: Logger);
method event
event: (category: string, action: string, options?: EventOptions) => void;
method flush
flush: () => Promise<void>;
method pageview
pageview: (path: string, options?: PageviewOptions) => void;
method screenview
screenview: ( screenName: string, appName: string, options?: ScreenviewOptions) => void;
method timing
timing: ( category: string, variable: string, time: string | number, options?: TimingOptions) => void;
class MultiAnalytics
class MultiAnalytics implements Analytics {}
Analytics implementation that reports to multiple analytics backend.
constructor
constructor(_backends?: Analytics[]);
method event
event: (category: string, action: string, options?: EventOptions) => void;
method flush
flush: () => Promise<void>;
method pageview
pageview: (path: string, options?: PageviewOptions) => void;
method push
push: (...backend: Analytics[]) => void;
method screenview
screenview: ( screenName: string, appName: string, options?: ScreenviewOptions) => void;
method timing
timing: ( category: string, variable: string, time: string | number, options?: TimingOptions) => void;
class NoopAnalytics
class NoopAnalytics implements Analytics {}
Analytics implementation that does nothing.
method event
event: () => void;
method flush
flush: () => Promise<void>;
method pageview
pageview: () => void;
method screenview
screenview: () => void;
method timing
timing: () => void;
interface Analytics
interface Analytics {}
Interface for managing analytics. This is highly platform dependent, and mostly matches Google Analytics. The reason the interface is here is to remove the dependency to an implementation from most other places.
The methods exported from this interface more or less match those needed by us in the universal analytics package, see https://unpkg.com/@types/universal-analytics@0.4.2/index.d.ts for typings. We mostly named arguments to make it easier to follow, but didn't change or add any semantics to those methods. They're mapping GA and u-a one for one.
The Angular CLI (or any other kind of backend) should forward it to some compatible backend.
method event
event: (category: string, action: string, options?: EventOptions) => void;
method flush
flush: () => Promise<void>;
method pageview
pageview: (path: string, options?: PageviewOptions) => void;
method screenview
screenview: ( screenName: string, appName: string, options?: ScreenviewOptions) => void;
method timing
timing: ( category: string, variable: string, time: string | number, options?: TimingOptions) => void;
interface AnalyticsReportBase
interface AnalyticsReportBase extends JsonObject {}
property kind
kind: AnalyticsReportKind;
interface AnalyticsReportEvent
interface AnalyticsReportEvent extends AnalyticsReportBase {}
interface AnalyticsReportPageview
interface AnalyticsReportPageview extends AnalyticsReportBase {}
interface AnalyticsReportScreenview
interface AnalyticsReportScreenview extends AnalyticsReportBase {}
property appName
appName: string;
property kind
kind: AnalyticsReportKind.Screenview;
property options
options: JsonObject & ScreenviewOptions;
property screenName
screenName: string;
interface AnalyticsReportTiming
interface AnalyticsReportTiming extends AnalyticsReportBase {}
interface CustomDimensionsAndMetricsOptions
interface CustomDimensionsAndMetricsOptions {}
Copyright Google LLC All Rights Reserved.
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at https://angular.io/license
property dimensions
dimensions?: (boolean | number | string)[];
property metrics
metrics?: (boolean | number | string)[];
interface EventOptions
interface EventOptions extends CustomDimensionsAndMetricsOptions {}
interface PageviewOptions
interface PageviewOptions extends CustomDimensionsAndMetricsOptions {}
interface ScreenviewOptions
interface ScreenviewOptions extends CustomDimensionsAndMetricsOptions {}
property appId
appId?: string;
property appInstallerId
appInstallerId?: string;
property appVersion
appVersion?: string;
interface TimingOptions
interface TimingOptions extends CustomDimensionsAndMetricsOptions {}
property label
label?: string;
enum AnalyticsReportKind
enum AnalyticsReportKind { Event = 'event', Screenview = 'screenview', Pageview = 'pageview', Timing = 'timing',}
member Event
Event = 'event'
member Pageview
Pageview = 'pageview'
member Screenview
Screenview = 'screenview'
member Timing
Timing = 'timing'
enum NgCliAnalyticsDimensions
enum NgCliAnalyticsDimensions { CpuCount = 1, CpuSpeed = 2, RamInGigabytes = 3, NodeVersion = 4, NgAddCollection = 6, AngularCLIMajorVersion = 8, BuildErrors = 20,}
MAKE SURE TO KEEP THIS IN SYNC WITH THE TABLE AND CONTENT IN
/docs/design/analytics.md
. WE LIST THOSE DIMENSIONS (AND MORE).These cannot be in their respective schema.json file because we either change the type (e.g. --buildEventLog is string, but we want to know the usage of it, not its value), or some validation needs to be done (we cannot record ng add --collection if it's not marked as allowed).
member AngularCLIMajorVersion
AngularCLIMajorVersion = 8
member BuildErrors
BuildErrors = 20
member CpuCount
CpuCount = 1
member CpuSpeed
CpuSpeed = 2
member NgAddCollection
NgAddCollection = 6
member NodeVersion
NodeVersion = 4
member RamInGigabytes
RamInGigabytes = 3
enum NgCliAnalyticsMetrics
enum NgCliAnalyticsMetrics { NgComponentCount = 1, UNUSED_2 = 2, UNUSED_3 = 3, UNUSED_4 = 4, BuildTime = 5, NgOnInitCount = 6, InitialChunkSize = 7, TotalChunkCount = 8, TotalChunkSize = 9, LazyChunkCount = 10, LazyChunkSize = 11, AssetCount = 12, AssetSize = 13, PolyfillSize = 14, CssSize = 15,}
member AssetCount
AssetCount = 12
member AssetSize
AssetSize = 13
member BuildTime
BuildTime = 5
member CssSize
CssSize = 15
member InitialChunkSize
InitialChunkSize = 7
member LazyChunkCount
LazyChunkCount = 10
member LazyChunkSize
LazyChunkSize = 11
member NgComponentCount
NgComponentCount = 1
member NgOnInitCount
NgOnInitCount = 6
member PolyfillSize
PolyfillSize = 14
member TotalChunkCount
TotalChunkCount = 8
member TotalChunkSize
TotalChunkSize = 9
member UNUSED_2
UNUSED_2 = 2
member UNUSED_3
UNUSED_3 = 3
member UNUSED_4
UNUSED_4 = 4
type AnalyticsForwarderFn
type AnalyticsForwarderFn = (report: JsonObject & AnalyticsReport) => void;
A function that can forward analytics along some stream. AnalyticsReport is already a JsonObject descendant, but we force it here so the user knows it's safe to serialize.
type AnalyticsReport
type AnalyticsReport = | AnalyticsReportEvent | AnalyticsReportScreenview | AnalyticsReportPageview | AnalyticsReportTiming;
namespace experimental
module 'src/experimental.d.ts' {}
Copyright Google LLC All Rights Reserved.
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at https://angular.io/license
namespace jobs
module 'src/experimental/jobs/index.d.ts' {}
Copyright Google LLC All Rights Reserved.
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at https://angular.io/license
function createDispatcher
createDispatcher: < A extends JsonValue, I extends JsonValue, O extends JsonValue>( options?: Partial<Readwrite<JobDescription>>) => JobDispatcher<A, I, O>;
OnReady a dispatcher that can dispatch to a sub job, depending on conditions.
Parameter options
function createJobFactory
createJobFactory: < A extends JsonValue, I extends JsonValue, O extends JsonValue>( loader: () => Promise<JobHandler<A, I, O>>, options?: Partial<JobDescription>) => JobHandler<A, I, O>;
Lazily create a job using a function.
Parameter loader
A factory function that returns a promise/observable of a JobHandler.
Parameter options
Same options as createJob.
function createJobHandler
createJobHandler: < A extends JsonValue, I extends JsonValue, O extends JsonValue>( fn: SimpleJobHandlerFn<A, I, O>, options?: Partial<JobDescription>) => JobHandler<A, I, O>;
Make a simple job handler that sets start and end from a function that's synchronous.
Parameter fn
The function to create a handler for.
Parameter options
An optional set of properties to set on the handler. Some fields might be required by registry or schedulers.
function createLoggerJob
createLoggerJob: <A extends JsonValue, I extends JsonValue, O extends JsonValue>( job: JobHandler<A, I, O>, logger: LoggerApi) => JobHandler<A, I, O>;
Creates a job that logs out input/output messages of another Job. The messages are still propagated to the other job.
function isJobHandler
isJobHandler: <A extends JsonValue, I extends JsonValue, O extends JsonValue>( value: unknown) => value is JobHandler<A, I, O>;
class ChannelAlreadyExistException
class ChannelAlreadyExistException extends BaseException {}
constructor
constructor(name: string);
class FallbackRegistry
class FallbackRegistry< MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> implements Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT> {}
A simple job registry that keep a map of JobName => JobHandler internally.
constructor
constructor( _fallbacks?: Registry< MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT >[]);
method addFallback
addFallback: (registry: Registry) => void;
method get
get: < A extends MinimumArgumentValueT = MinimumArgumentValueT, I extends MinimumInputValueT = MinimumInputValueT, O extends MinimumOutputValueT = MinimumOutputValueT>( name: JobName) => Observable<JobHandler<A, I, O>>;
class JobArgumentSchemaValidationError
class JobArgumentSchemaValidationError extends schema.SchemaValidationException {}
constructor
constructor(errors?: ErrorObject[]);
class JobDoesNotExistException
class JobDoesNotExistException extends BaseException {}
constructor
constructor(name: string);
class JobInboundMessageSchemaValidationError
class JobInboundMessageSchemaValidationError extends schema.SchemaValidationException {}
constructor
constructor(errors?: ErrorObject[]);
class JobNameAlreadyRegisteredException
class JobNameAlreadyRegisteredException extends BaseException {}
constructor
constructor(name: string);
class JobOutputSchemaValidationError
class JobOutputSchemaValidationError extends schema.SchemaValidationException {}
constructor
constructor(errors?: ErrorObject[]);
class SimpleJobRegistry
class SimpleJobRegistry< MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> implements Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT> {}
A simple job registry that keep a map of JobName => JobHandler internally.
method get
get: < A extends MinimumArgumentValueT = MinimumArgumentValueT, I extends MinimumInputValueT = MinimumInputValueT, O extends MinimumOutputValueT = MinimumOutputValueT>( name: JobName) => Observable<JobHandler<A, I, O>>;
method getJobNames
getJobNames: () => JobName[];
Returns the job names of all jobs.
method register
register: { < A extends MinimumArgumentValueT, I extends MinimumInputValueT, O extends MinimumOutputValueT >( name: JobName, handler: JobHandler<A, I, O>, options?: RegisterJobOptions ): void; < ArgumentT extends JsonValue, InputT extends JsonValue, OutputT extends JsonValue >( handler: JobHandler<ArgumentT, InputT, OutputT>, options?: RegisterJobOptions & { name: string } ): void;};
Register a job handler. The name must be unique.
Parameter name
The name of the job.
Parameter handler
The function that will be called for the job.
Parameter options
An optional list of options to override the handler.
Register a job handler. The name must be unique.
Parameter handler
The function that will be called for the job.
Parameter options
An optional list of options to override the handler.
class SimpleScheduler
class SimpleScheduler< MinimumArgumentT extends JsonValue = JsonValue, MinimumInputT extends JsonValue = JsonValue, MinimumOutputT extends JsonValue = JsonValue> implements Scheduler<MinimumArgumentT, MinimumInputT, MinimumOutputT> {}
Simple scheduler. Should be the base of all registries and schedulers.
constructor
constructor( _jobRegistry: Registry<MinimumArgumentT, MinimumInputT, MinimumOutputT>, _schemaRegistry?: schema.SchemaRegistry);
method getDescription
getDescription: (name: JobName) => Observable<JobDescription>;
Get a job description for a named job.
Parameter name
The name of the job.
Returns
A description, or null if the job is not registered.
method has
has: (name: JobName) => Observable<boolean>;
Returns true if the job name has been registered.
Parameter name
The name of the job.
Returns
True if the job exists, false otherwise.
method pause
pause: () => () => void;
Pause the scheduler, temporary queueing _new_ jobs. Returns a resume function that should be used to resume execution. If multiple
pause()
were called, all their resume functions must be called before the Scheduler actually starts new jobs. Additional calls to the same resume function will have no effect.Jobs already running are NOT paused. This is pausing the scheduler only.
method schedule
schedule: < A extends MinimumArgumentT, I extends MinimumInputT, O extends MinimumOutputT>( name: JobName, argument: A, options?: ScheduleJobOptions) => Job<A, I, O>;
Schedule a job to be run, using its name.
Parameter name
The name of job to be run.
Parameter argument
The argument to send to the job when starting it.
Parameter options
Scheduling options.
Returns
The Job being run.
interface Job
interface Job< ArgumentT extends JsonValue = JsonValue, InputT extends JsonValue = JsonValue, OutputT extends JsonValue = JsonValue> {}
A Job instance, returned from scheduling a job. A Job instance is _not_ serializable.
property argument
readonly argument: ArgumentT;
Argument sent when scheduling the job. This is a copy of the argument.
property description
readonly description: Observable<JobDescription>;
Description of the job. Resolving the job's description can be done asynchronously, so this is an observable that will resolve when it's ready.
property inboundBus
readonly inboundBus: Observer<JobInboundMessage<InputT>>;
The JobInboundMessage messages TO the job.
property input
readonly input: Observer<InputT>;
The input to the job. This goes through the input channel as messages.
property outboundBus
readonly outboundBus: Observable<JobOutboundMessage<OutputT>>;
The JobOutboundMessage FROM the job.
property output
readonly output: Observable<OutputT>;
Outputs of this job.
property state
readonly state: JobState;
The current state of the job.
method getChannel
getChannel: <T extends JsonValue>( name: string, schema?: schema.JsonSchema) => Observable<T>;
Get a channel that validates against the schema. Messages will be filtered by the schema.
Parameter name
The name of the channel.
Parameter schema
A schema to use to validate messages.
method ping
ping: () => Observable<never>;
Pings the job and wait for the resulting Pong before completing.
method stop
stop: () => void;
Stops the job from running. This is different than unsubscribing from the output as in it sends the JobInboundMessageKind.Stop raw input to the job.
interface JobDescription
interface JobDescription extends JsonObject {}
Metadata associated with a job.
interface JobDispatcher
interface JobDispatcher< A extends JsonValue, I extends JsonValue, O extends JsonValue> extends JobHandler<A, I, O> {}
A JobDispatcher can be used to dispatch between multiple jobs.
method addConditionalJob
addConditionalJob: (predicate: (args: A) => boolean, name: string) => void;
Add a conditional job that will be selected if the input fits a predicate.
Parameter predicate
Parameter name
method setDefaultJob
setDefaultJob: ( name: JobName | null | JobHandler<JsonValue, JsonValue, JsonValue>) => void;
Set the default job if all conditionals failed.
Parameter name
The default name if all conditions are false.
interface JobHandler
interface JobHandler< ArgT extends JsonValue, InputT extends JsonValue, OutputT extends JsonValue> {}
The job handler function, which is a method that's executed for the job.
property jobDescription
jobDescription: Partial<JobDescription>;
call signature
(argument: ArgT, context: JobHandlerContext<ArgT, InputT, OutputT>): Observable< JobOutboundMessage<OutputT>>;
interface JobHandlerContext
interface JobHandlerContext< MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> {}
The context in which the job is run.
property dependencies
readonly dependencies: Job<JsonValue, JsonValue, JsonValue>[];
property description
readonly description: JobDescription;
property inboundBus
readonly inboundBus: Observable<JobInboundMessage<MinimumInputValueT>>;
property scheduler
readonly scheduler: Scheduler<JsonValue, JsonValue, JsonValue>;
interface JobInboundMessageBase
interface JobInboundMessageBase extends JsonObject {}
Base interface for the all job inbound messages.
property kind
readonly kind: JobInboundMessageKind;
The kind of message this is.
interface JobInboundMessageInput
interface JobInboundMessageInput<InputT extends JsonValue> extends JobInboundMessageBase {}
A Job wants to send a message to a channel. This can be marshaled, and the Job object has helpers to transform this into an observable. The context also can create RxJS subjects that marshall messages through a channel.
interface JobInboundMessagePing
interface JobInboundMessagePing extends JobInboundMessageBase {}
A ping to the job. The job should reply with a pong as soon as possible.
interface JobInboundMessageStop
interface JobInboundMessageStop extends JobInboundMessageBase {}
Stop the job. This is handled by the job itself and jobs might not handle it. It will also unsubscribe from the Observable<>. This is equivalent to SIGTERM.
property kind
readonly kind: JobInboundMessageKind.Stop;
interface JobOutboundMessageBase
interface JobOutboundMessageBase {}
Base interface for the all job messages.
property description
readonly description: JobDescription;
The job description.
property kind
readonly kind: JobOutboundMessageKind;
The kind of message this is.
interface JobOutboundMessageChannelBase
interface JobOutboundMessageChannelBase extends JobOutboundMessageBase {}
Base interface for all job message related to channels.
property name
readonly name: string;
The name of the channel.
interface JobOutboundMessageChannelComplete
interface JobOutboundMessageChannelComplete extends JobOutboundMessageChannelBase {}
A job wants to close the channel, as completed. This is done automatically when the job ends, or can be done from the job to close it. A closed channel might be reopened, but the user need to recall getChannel().
property kind
readonly kind: JobOutboundMessageKind.ChannelComplete;
interface JobOutboundMessageChannelCreate
interface JobOutboundMessageChannelCreate extends JobOutboundMessageChannelBase {}
A job wants to create a new channel.
property kind
readonly kind: JobOutboundMessageKind.ChannelCreate;
interface JobOutboundMessageChannelError
interface JobOutboundMessageChannelError extends JobOutboundMessageChannelBase {}
A job wants to send an error to one of its channel. This is the equivalent of throwing through an Observable. The side channel will not receive any more messages after this, and will not complete.
interface JobOutboundMessageChannelMessage
interface JobOutboundMessageChannelMessage extends JobOutboundMessageChannelBase {}
A job wants to send a message to a channel. This can be marshaled, and the Job object has helpers to transform this into an observable. The context also can create RxJS subjects that marshall messages through a channel.
interface JobOutboundMessageEnd
interface JobOutboundMessageEnd extends JobOutboundMessageBase {}
OnEnd of the job run.
property kind
readonly kind: JobOutboundMessageKind.End;
interface JobOutboundMessageOnReady
interface JobOutboundMessageOnReady extends JobOutboundMessageBase {}
The job has been created and will validate its input.
property kind
readonly kind: JobOutboundMessageKind.OnReady;
interface JobOutboundMessageOutput
interface JobOutboundMessageOutput<OutputT extends JsonValue> extends JobOutboundMessageBase {}
An output value is available.
interface JobOutboundMessagePong
interface JobOutboundMessagePong extends JobOutboundMessageBase {}
A pong response from a ping input. The id is the same as the one passed in.
interface JobOutboundMessageStart
interface JobOutboundMessageStart extends JobOutboundMessageBase {}
The job started. This is done by the job itself.
property kind
readonly kind: JobOutboundMessageKind.Start;
interface RegisterJobOptions
interface RegisterJobOptions extends Partial<JobDescription> {}
SimpleJobRegistry job registration options.
interface Registry
interface Registry< MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> {}
method get
get: < A extends MinimumArgumentValueT, I extends MinimumInputValueT, O extends MinimumOutputValueT>( name: JobName) => Observable<JobHandler<A, I, O>>;
Get a job handler.
Parameter name
The name of the job to get a handler from.
interface ScheduleJobOptions
interface ScheduleJobOptions {}
Options for scheduling jobs.
property dependencies
dependencies?: Job | Job[];
Jobs that need to finish before scheduling this job. These dependencies will be passed to the job itself in its context.
interface Scheduler
interface Scheduler< MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> {}
An interface that can schedule jobs.
method getDescription
getDescription: (name: JobName) => Observable<JobDescription>;
Get a job description for a named job.
Parameter name
The name of the job.
Returns
A description, or null if no description is available for this job.
method has
has: (name: JobName) => Observable<boolean>;
Returns true if the job name has been registered.
Parameter name
The name of the job.
Returns
True if the job exists, false otherwise.
method pause
pause: () => () => void;
Pause the scheduler, temporary queueing _new_ jobs. Returns a resume function that should be used to resume execution. If multiple
pause()
were called, all their resume functions must be called before the Scheduler actually starts new jobs. Additional calls to the same resume function will have no effect.Jobs already running are NOT paused. This is pausing the scheduler only.
Returns
A function that can be run to resume the scheduler. If multiple
pause()
calls were made, all their return function must be called (in any order) before the scheduler can resume.
method schedule
schedule: < A extends MinimumArgumentValueT, I extends MinimumInputValueT, O extends MinimumOutputValueT>( name: JobName, argument: A, options?: ScheduleJobOptions) => Job<A, I, O>;
Schedule a job to be run, using its name.
Parameter name
The name of job to be run.
Parameter argument
The argument to send to the job when starting it.
Parameter options
Scheduling options.
Returns
The job being run.
interface SimpleJobHandlerContext
interface SimpleJobHandlerContext< A extends JsonValue, I extends JsonValue, O extends JsonValue> extends JobHandlerContext<A, I, O> {}
Interface for the JobHandler context that is used when using
createJobHandler()
. It extends the basicJobHandlerContext
with additional functionality.
property createChannel
createChannel: (name: string) => Observer<JsonValue>;
property input
input: Observable<I>;
enum JobInboundMessageKind
enum JobInboundMessageKind { Ping = 'ip', Stop = 'is', Input = 'in',}
Messages that can be sent TO a job. The job needs to listen to those.
enum JobOutboundMessageKind
enum JobOutboundMessageKind { OnReady = 'c', Start = 's', End = 'e', Pong = 'p', Output = 'o', ChannelCreate = 'cn', ChannelMessage = 'cm', ChannelError = 'ce', ChannelComplete = 'cc',}
Kind of messages that can be outputted from a job.
member ChannelComplete
ChannelComplete = 'cc'
member ChannelCreate
ChannelCreate = 'cn'
member ChannelError
ChannelError = 'ce'
member ChannelMessage
ChannelMessage = 'cm'
member End
End = 'e'
member OnReady
OnReady = 'c'
member Output
Output = 'o'
member Pong
Pong = 'p'
member Start
Start = 's'
enum JobState
enum JobState { Queued = 'queued', Ready = 'ready', Started = 'started', Ended = 'ended', Errored = 'errored',}
The state of a job. These are changed as the job reports a new state through its messages.
member Ended
Ended = 'ended'
The job has ended and is done running.
member Errored
Errored = 'errored'
An error occured and the job stopped because of internal state.
member Queued
Queued = 'queued'
The job was queued and is waiting to start.
member Ready
Ready = 'ready'
The job description was found, its dependencies (see "Synchronizing and Dependencies") are done running, and the job's argument is validated and the job's code will be executed.
member Started
Started = 'started'
The job has been started. The job implementation is expected to send this as soon as its work is starting.
type JobInboundMessage
type JobInboundMessage<InputT extends JsonValue> = | JobInboundMessagePing | JobInboundMessageStop | JobInboundMessageInput<InputT>;
type JobName
type JobName = string;
A job name is just a string (needs to be serializable).
type JobOutboundMessage
type JobOutboundMessage<OutputT extends JsonValue> = | JobOutboundMessageOnReady | JobOutboundMessageStart | JobOutboundMessageOutput<OutputT> | JobOutboundMessageChannelCreate | JobOutboundMessageChannelMessage | JobOutboundMessageChannelError | JobOutboundMessageChannelComplete | JobOutboundMessageEnd | JobOutboundMessagePong;
Generic message type.
type SimpleJobHandlerFn
type SimpleJobHandlerFn< A extends JsonValue, I extends JsonValue, O extends JsonValue> = ( input: A, context: SimpleJobHandlerContext<A, I, O>) => O | Promise<O> | Observable<O>;
A simple version of the JobHandler. This simplifies a lot of the interaction with the job scheduler and registry. For example, instead of returning a JobOutboundMessage observable, you can directly return an output.
namespace experimental.jobs.strategy
namespace experimental.jobs.strategy {}
function memoize
memoize: < A extends JsonValue = JsonValue, I extends JsonValue = JsonValue, O extends JsonValue = JsonValue>( replayMessages?: boolean) => JobStrategy<A, I, O>;
Creates a JobStrategy that will reuse a running job if the argument matches.
Parameter replayMessages
Replay ALL messages if a job is reused, otherwise just hook up where it is.
function reuse
reuse: < A extends JsonValue = JsonValue, I extends JsonValue = JsonValue, O extends JsonValue = JsonValue>( replayMessages?: boolean) => JobStrategy<A, I, O>;
Creates a JobStrategy that will always reuse a running job, and restart it if the job ended.
Parameter replayMessages
Replay ALL messages if a job is reused, otherwise just hook up where it is.
function serialize
serialize: < A extends JsonValue = JsonValue, I extends JsonValue = JsonValue, O extends JsonValue = JsonValue>() => JobStrategy<A, I, O>;
Creates a JobStrategy that serializes every call. This strategy can be mixed between jobs.
type JobStrategy
type JobStrategy< A extends JsonValue = JsonValue, I extends JsonValue = JsonValue, O extends JsonValue = JsonValue> = ( handler: JobHandler<A, I, O>, options?: Partial<Readonly<JobDescription>>) => JobHandler<A, I, O>;
namespace json
module 'src/json/index.d.ts' {}
Copyright Google LLC All Rights Reserved.
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at https://angular.io/license
function isJsonArray
isJsonArray: (value: JsonValue) => value is JsonArray;
function isJsonObject
isJsonObject: (value: JsonValue) => value is JsonObject;
interface JsonArray
interface JsonArray extends Array<JsonValue> {}
Copyright Google LLC All Rights Reserved.
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at https://angular.io/license
interface JsonObject
interface JsonObject {}
index signature
[prop: string]: JsonValue;
type JsonValue
type JsonValue = boolean | string | number | JsonArray | JsonObject | null;
namespace schema
module 'src/json/schema/index.d.ts' {}
Copyright Google LLC All Rights Reserved.
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at https://angular.io/license
function buildJsonPointer
buildJsonPointer: (fragments: string[]) => JsonPointer;
function getTypesOfSchema
getTypesOfSchema: (schema: JsonSchema) => Set<string>;
function isJsonSchema
isJsonSchema: (value: unknown) => value is JsonSchema;
function joinJsonPointer
joinJsonPointer: (root: JsonPointer, ...others: string[]) => JsonPointer;
function mergeSchemas
mergeSchemas: (...schemas: (JsonSchema | undefined)[]) => JsonSchema;
Return a schema that is the merge of all subschemas, ie. it should validate all the schemas that were passed in. It is possible to make an invalid schema this way, e.g. by using
mergeSchemas({ type: 'number' }, { type: 'string' })
, which will never validate.Parameter schemas
All schemas to be merged.
function parseJsonPointer
parseJsonPointer: (pointer: JsonPointer) => string[];
function visitJson
visitJson: <ContextT>( json: JsonValue, visitor: JsonVisitor, schema?: JsonSchema, refResolver?: ReferenceResolver<ContextT>, context?: ContextT) => Observable<JsonValue>;
Visit all the properties in a JSON object, allowing to transform them. It supports calling properties synchronously or asynchronously (through Observables). The original object can be mutated or replaced entirely. In case where it's replaced, the new value is returned. When it's mutated though the original object will be changed.
Please note it is possible to have an infinite loop here (which will result in a stack overflow) if you return 2 objects that references each others (or the same object all the time).
Parameter json
The Json value to visit.
Parameter visitor
A function that will be called on every items.
Parameter schema
A JSON schema to pass through to the visitor (where possible).
Parameter refResolver
a function to resolve references in the schema.
Returns
{Observable< | undefined>} The observable of the new root, if the root changed.
function visitJsonSchema
visitJsonSchema: (schema: JsonSchema, visitor: JsonSchemaVisitor) => void;
class CoreSchemaRegistry
class CoreSchemaRegistry implements SchemaRegistry {}
constructor
constructor(formats?: SchemaFormat[]);
method addFormat
addFormat: (format: SchemaFormat) => void;
method addPostTransform
addPostTransform: (visitor: JsonVisitor, deps?: JsonVisitor[]) => void;
Add a transformation step after the validation of any Json. The JSON will not be validated after the POST, so if transformations are not compatible with the Schema it will not result in an error.
Parameter visitor
The visitor to transform every value.
Parameter deps
A list of other visitors to run before.
method addPreTransform
addPreTransform: (visitor: JsonVisitor, deps?: JsonVisitor[]) => void;
Add a transformation step before the validation of any Json.
Parameter visitor
The visitor to transform every value.
Parameter deps
A list of other visitors to run before.
method addSmartDefaultProvider
addSmartDefaultProvider: <T>( source: string, provider: SmartDefaultProvider<T>) => void;
method compile
compile: (schema: JsonSchema) => Observable<SchemaValidator>;
Compile and return a validation function for the Schema.
Parameter schema
The schema to validate. If a string, will fetch the schema before compiling it (using schema as a URI).
Returns
An Observable of the Validation function.
method flatten
flatten: (schema: JsonObject) => Observable<JsonObject>;
Flatten the Schema, resolving and replacing all the refs. Makes it into a synchronous schema that is also easier to traverse. Does not cache the result.
Parameter schema
The schema or URI to flatten.
Returns
An Observable of the flattened schema object.
Deprecated
since 11.2 without replacement. Producing a flatten schema document does not in all cases produce a schema with identical behavior to the original. See: https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.appendix.B.2
method registerUriHandler
registerUriHandler: (handler: UriHandler) => void;
method usePromptProvider
usePromptProvider: (provider: PromptProvider) => void;
method useXDeprecatedProvider
useXDeprecatedProvider: (onUsage: (message: string) => void) => void;
class SchemaValidationException
class SchemaValidationException extends BaseException {}
constructor
constructor(errors?: ErrorObject[], baseMessage?: string);
property errors
readonly errors: ErrorObject[];
method createMessages
static createMessages: (errors?: SchemaValidatorError[]) => string[];
interface JsonSchemaVisitor
interface JsonSchemaVisitor {}
call signature
( current: JsonObject | JsonArray, pointer: JsonPointer, parentSchema?: JsonObject | JsonArray, index?: string): void;
interface JsonVisitor
interface JsonVisitor {}
call signature
( value: JsonValue, pointer: JsonPointer, schema?: JsonObject, root?: JsonObject | JsonArray): Observable<JsonValue> | JsonValue;
interface PromptDefinition
interface PromptDefinition {}
property default
default?: string | string[] | number | boolean | null;
property id
id: string;
property items
items?: Array< | string | { value: JsonValue; label: string; }>;
property message
message: string;
property multiselect
multiselect?: boolean;
property propertyTypes
propertyTypes: Set<string>;
property raw
raw?: string | JsonObject;
property type
type: string;
property validator
validator?: (value: JsonValue) => boolean | string | Promise<boolean | string>;
interface ReferenceResolver
interface ReferenceResolver<ContextT> {}
call signature
(ref: string, context?: ContextT): { context?: ContextT; schema?: JsonObject;};
interface SchemaFormat
interface SchemaFormat {}
interface SchemaKeywordValidator
interface SchemaKeywordValidator {}
call signature
( data: JsonValue, schema: JsonValue, parent: JsonObject | JsonArray | undefined, parentProperty: string | number | undefined, pointer: JsonPointer, rootData: JsonValue): boolean | Observable<boolean>;
interface SchemaRegistry
interface SchemaRegistry {}
method addFormat
addFormat: (format: SchemaFormat) => void;
method addPostTransform
addPostTransform: (visitor: JsonVisitor, deps?: JsonVisitor[]) => void;
Add a transformation step after the validation of any Json. The JSON will not be validated after the POST, so if transformations are not compatible with the Schema it will not result in an error.
Parameter visitor
The visitor to transform every value.
Parameter deps
A list of other visitors to run before.
method addPreTransform
addPreTransform: (visitor: JsonVisitor, deps?: JsonVisitor[]) => void;
Add a transformation step before the validation of any Json.
Parameter visitor
The visitor to transform every value.
Parameter deps
A list of other visitors to run before.
method addSmartDefaultProvider
addSmartDefaultProvider: <T>( source: string, provider: SmartDefaultProvider<T>) => void;
method compile
compile: (schema: Object) => Observable<SchemaValidator>;
method flatten
flatten: (schema: JsonObject | string) => Observable<JsonObject>;
Deprecated
since 11.2 without replacement. Producing a flatten schema document does not in all cases produce a schema with identical behavior to the original. See: https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.appendix.B.2
method usePromptProvider
usePromptProvider: (provider: PromptProvider) => void;
method useXDeprecatedProvider
useXDeprecatedProvider: (onUsage: (message: string) => void) => void;
interface SchemaValidator
interface SchemaValidator {}
call signature
( data: JsonValue, options?: SchemaValidatorOptions): Observable<SchemaValidatorResult>;
interface SchemaValidatorOptions
interface SchemaValidatorOptions {}
property applyPostTransforms
applyPostTransforms?: boolean;
property applyPreTransforms
applyPreTransforms?: boolean;
property withPrompts
withPrompts?: boolean;
interface SchemaValidatorResult
interface SchemaValidatorResult {}
interface SmartDefaultProvider
interface SmartDefaultProvider<T> {}
call signature
(schema: JsonObject): T | Observable<T>;
type JsonPointer
type JsonPointer = string & { __PRIVATE_DEVKIT_JSON_POINTER: void;};
type JsonSchema
type JsonSchema = JsonObject | boolean;
A specialized interface for JsonSchema (to come). JsonSchemas are also JsonObject.
Modifiers
@public
type PromptProvider
type PromptProvider = ( definitions: Array<PromptDefinition>) => SubscribableOrPromise<{ [id: string]: JsonValue;}>;
type SchemaFormatter
type SchemaFormatter = Format;
type SchemaValidatorError
type SchemaValidatorError = Partial<ErrorObject>;
type UriHandler
type UriHandler = ( uri: string) => Observable<JsonObject> | Promise<JsonObject> | null | undefined;
namespace transforms
module 'src/json/schema/transforms.d.ts' {}
Copyright Google LLC All Rights Reserved.
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at https://angular.io/license
function addUndefinedDefaults
addUndefinedDefaults: ( value: JsonValue, _pointer: JsonPointer, schema?: JsonSchema) => JsonValue;
namespace logging
module 'src/logger/index.d.ts' {}
Copyright Google LLC All Rights Reserved.
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at https://angular.io/license
class IndentLogger
class IndentLogger extends Logger {}
constructor
constructor(name: string, parent?: Logger, indentation?: string);
class LevelCapLogger
class LevelCapLogger extends LevelTransformLogger {}
constructor
constructor(name: string, parent: Logger, levelCap: LogLevel);
property levelCap
readonly levelCap: LogLevel;
property levelMap
static levelMap: { [cap: string]: { [level: string]: string } };
property name
readonly name: string;
property parent
readonly parent: Logger;
class LevelTransformLogger
class LevelTransformLogger extends Logger {}
constructor
constructor( name: string, parent: Logger, levelTransform: (level: LogLevel) => LogLevel);
property levelTransform
readonly levelTransform: (level: LogLevel) => LogLevel;
property name
readonly name: string;
property parent
readonly parent: Logger;
method createChild
createChild: (name: string) => Logger;
method log
log: (level: LogLevel, message: string, metadata?: JsonObject) => void;
class Logger
class Logger extends Observable<LogEntry> implements LoggerApi {}
constructor
constructor(name: string, parent?: Logger);
property name
readonly name: string;
property parent
readonly parent: Logger;
method asApi
asApi: () => LoggerApi;
method complete
complete: () => void;
method createChild
createChild: (name: string) => Logger;
method debug
debug: (message: string, metadata?: JsonObject) => void;
method error
error: (message: string, metadata?: JsonObject) => void;
method fatal
fatal: (message: string, metadata?: JsonObject) => void;
method forEach
forEach: ( next: (value: LogEntry) => void, PromiseCtor?: typeof Promise) => Promise<void>;
method info
info: (message: string, metadata?: JsonObject) => void;
method lift
lift: <R>(operator: Operator<LogEntry, R>) => Observable<R>;
method log
log: (level: LogLevel, message: string, metadata?: JsonObject) => void;
method next
next: (entry: LogEntry) => void;
method subscribe
subscribe: { (): Subscription; (observer: PartialObserver<LogEntry>): Subscription; ( next?: (value: LogEntry) => void, error?: (error: Error) => void, complete?: () => void ): Subscription;};
method toString
toString: () => string;
method warn
warn: (message: string, metadata?: JsonObject) => void;
class NullLogger
class NullLogger extends Logger {}
constructor
constructor(parent?: Logger);
method asApi
asApi: () => LoggerApi;
class TransformLogger
class TransformLogger extends Logger {}
constructor
constructor( name: string, transform: (stream: Observable<LogEntry>) => Observable<LogEntry>, parent?: Logger);
interface LogEntry
interface LogEntry extends LoggerMetadata {}
interface LoggerApi
interface LoggerApi {}
method createChild
createChild: (name: string) => Logger;
method debug
debug: (message: string, metadata?: JsonObject) => void;
method error
error: (message: string, metadata?: JsonObject) => void;
method fatal
fatal: (message: string, metadata?: JsonObject) => void;
method info
info: (message: string, metadata?: JsonObject) => void;
method log
log: (level: LogLevel, message: string, metadata?: JsonObject) => void;
method warn
warn: (message: string, metadata?: JsonObject) => void;
interface LoggerMetadata
interface LoggerMetadata extends JsonObject {}
type LogLevel
type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'fatal';
namespace schema
module 'src/json/schema/index.d.ts' {}
Copyright Google LLC All Rights Reserved.
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at https://angular.io/license
function buildJsonPointer
buildJsonPointer: (fragments: string[]) => JsonPointer;
function getTypesOfSchema
getTypesOfSchema: (schema: JsonSchema) => Set<string>;
function isJsonSchema
isJsonSchema: (value: unknown) => value is JsonSchema;
function joinJsonPointer
joinJsonPointer: (root: JsonPointer, ...others: string[]) => JsonPointer;
function mergeSchemas
mergeSchemas: (...schemas: (JsonSchema | undefined)[]) => JsonSchema;
Return a schema that is the merge of all subschemas, ie. it should validate all the schemas that were passed in. It is possible to make an invalid schema this way, e.g. by using
mergeSchemas({ type: 'number' }, { type: 'string' })
, which will never validate.Parameter schemas
All schemas to be merged.
function parseJsonPointer
parseJsonPointer: (pointer: JsonPointer) => string[];
function visitJson
visitJson: <ContextT>( json: JsonValue, visitor: JsonVisitor, schema?: JsonSchema, refResolver?: ReferenceResolver<ContextT>, context?: ContextT) => Observable<JsonValue>;
Visit all the properties in a JSON object, allowing to transform them. It supports calling properties synchronously or asynchronously (through Observables). The original object can be mutated or replaced entirely. In case where it's replaced, the new value is returned. When it's mutated though the original object will be changed.
Please note it is possible to have an infinite loop here (which will result in a stack overflow) if you return 2 objects that references each others (or the same object all the time).
Parameter json
The Json value to visit.
Parameter visitor
A function that will be called on every items.
Parameter schema
A JSON schema to pass through to the visitor (where possible).
Parameter refResolver
a function to resolve references in the schema.
Returns
{Observable< | undefined>} The observable of the new root, if the root changed.
function visitJsonSchema
visitJsonSchema: (schema: JsonSchema, visitor: JsonSchemaVisitor) => void;
class CoreSchemaRegistry
class CoreSchemaRegistry implements SchemaRegistry {}
constructor
constructor(formats?: SchemaFormat[]);
method addFormat
addFormat: (format: SchemaFormat) => void;
method addPostTransform
addPostTransform: (visitor: JsonVisitor, deps?: JsonVisitor[]) => void;
Add a transformation step after the validation of any Json. The JSON will not be validated after the POST, so if transformations are not compatible with the Schema it will not result in an error.
Parameter visitor
The visitor to transform every value.
Parameter deps
A list of other visitors to run before.
method addPreTransform
addPreTransform: (visitor: JsonVisitor, deps?: JsonVisitor[]) => void;
Add a transformation step before the validation of any Json.
Parameter visitor
The visitor to transform every value.
Parameter deps
A list of other visitors to run before.
method addSmartDefaultProvider
addSmartDefaultProvider: <T>( source: string, provider: SmartDefaultProvider<T>) => void;
method compile
compile: (schema: JsonSchema) => Observable<SchemaValidator>;
Compile and return a validation function for the Schema.
Parameter schema
The schema to validate. If a string, will fetch the schema before compiling it (using schema as a URI).
Returns
An Observable of the Validation function.
method flatten
flatten: (schema: JsonObject) => Observable<JsonObject>;
Flatten the Schema, resolving and replacing all the refs. Makes it into a synchronous schema that is also easier to traverse. Does not cache the result.
Parameter schema
The schema or URI to flatten.
Returns
An Observable of the flattened schema object.
Deprecated
since 11.2 without replacement. Producing a flatten schema document does not in all cases produce a schema with identical behavior to the original. See: https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.appendix.B.2
method registerUriHandler
registerUriHandler: (handler: UriHandler) => void;
method usePromptProvider
usePromptProvider: (provider: PromptProvider) => void;
method useXDeprecatedProvider
useXDeprecatedProvider: (onUsage: (message: string) => void) => void;
class SchemaValidationException
class SchemaValidationException extends BaseException {}
constructor
constructor(errors?: ErrorObject[], baseMessage?: string);
property errors
readonly errors: ErrorObject[];
method createMessages
static createMessages: (errors?: SchemaValidatorError[]) => string[];
interface JsonSchemaVisitor
interface JsonSchemaVisitor {}
call signature
( current: JsonObject | JsonArray, pointer: JsonPointer, parentSchema?: JsonObject | JsonArray, index?: string): void;
interface JsonVisitor
interface JsonVisitor {}
call signature
( value: JsonValue, pointer: JsonPointer, schema?: JsonObject, root?: JsonObject | JsonArray): Observable<JsonValue> | JsonValue;
interface PromptDefinition
interface PromptDefinition {}
property default
default?: string | string[] | number | boolean | null;
property id
id: string;
property items
items?: Array< | string | { value: JsonValue; label: string; }>;
property message
message: string;
property multiselect
multiselect?: boolean;
property propertyTypes
propertyTypes: Set<string>;
property raw
raw?: string | JsonObject;