mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-15 10:11:50 +08:00
refactor: move experimental jobs
API from @angular-devkit/core
to @angular-devkit/architect
With this change we move `jobs` APIs to `@angular-devkit/architect` as this are intended to used with `@angular-devkit/architect`.
This commit is contained in:
parent
b06421d15e
commit
93adeeb798
@ -5,17 +5,21 @@
|
||||
```ts
|
||||
|
||||
import { analytics } from '@angular-devkit/core';
|
||||
import { experimental } from '@angular-devkit/core';
|
||||
import { BaseException } from '@angular-devkit/core';
|
||||
import { json } from '@angular-devkit/core';
|
||||
import { JsonObject } from '@angular-devkit/core';
|
||||
import { JsonValue } from '@angular-devkit/core';
|
||||
import { logging } from '@angular-devkit/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observer } from 'rxjs';
|
||||
import { schema } from '@angular-devkit/core';
|
||||
import { SubscribableOrPromise } from 'rxjs';
|
||||
|
||||
// @public (undocumented)
|
||||
export class Architect {
|
||||
constructor(_host: ArchitectHost, registry?: json.schema.SchemaRegistry, additionalJobRegistry?: experimental.jobs.Registry);
|
||||
constructor(_host: ArchitectHost, registry?: json.schema.SchemaRegistry, additionalJobRegistry?: Registry);
|
||||
// (undocumented)
|
||||
has(name: experimental.jobs.JobName): Observable<boolean>;
|
||||
has(name: JobName): Observable<boolean>;
|
||||
// (undocumented)
|
||||
scheduleBuilder(name: string, options: json.JsonObject, scheduleOptions?: ScheduleOptions): Promise<BuilderRun>;
|
||||
// (undocumented)
|
||||
@ -89,7 +93,7 @@ export enum BuilderProgressState {
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export type BuilderRegistry = experimental.jobs.Registry<json.JsonObject, BuilderInput, BuilderOutput>;
|
||||
export type BuilderRegistry = Registry<json.JsonObject, BuilderInput, BuilderOutput>;
|
||||
|
||||
// @public
|
||||
export interface BuilderRun {
|
||||
@ -101,15 +105,334 @@ export interface BuilderRun {
|
||||
stop(): Promise<void>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
class ChannelAlreadyExistException extends BaseException {
|
||||
constructor(name: string);
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export function createBuilder<OptT = json.JsonObject, OutT extends BuilderOutput = BuilderOutput>(fn: BuilderHandlerFn<OptT>): Builder<OptT & json.JsonObject>;
|
||||
|
||||
// @public
|
||||
function createDispatcher<A extends JsonValue, I extends JsonValue, O extends JsonValue>(options?: Partial<Readwrite<JobDescription>>): JobDispatcher<A, I, O>;
|
||||
|
||||
// @public
|
||||
function createJobFactory<A extends JsonValue, I extends JsonValue, O extends JsonValue>(loader: () => Promise<JobHandler<A, I, O>>, options?: Partial<JobDescription>): JobHandler<A, I, O>;
|
||||
|
||||
// @public
|
||||
function createJobHandler<A extends JsonValue, I extends JsonValue, O extends JsonValue>(fn: SimpleJobHandlerFn<A, I, O>, options?: Partial<JobDescription>): JobHandler<A, I, O>;
|
||||
|
||||
// @public
|
||||
function createLoggerJob<A extends JsonValue, I extends JsonValue, O extends JsonValue>(job: JobHandler<A, I, O>, logger: logging.LoggerApi): JobHandler<A, I, O>;
|
||||
|
||||
// @public
|
||||
class FallbackRegistry<MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> implements Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT> {
|
||||
constructor(_fallbacks?: Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT>[]);
|
||||
// (undocumented)
|
||||
addFallback(registry: Registry): void;
|
||||
// (undocumented)
|
||||
protected _fallbacks: Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT>[];
|
||||
// (undocumented)
|
||||
get<A extends MinimumArgumentValueT = MinimumArgumentValueT, I extends MinimumInputValueT = MinimumInputValueT, O extends MinimumOutputValueT = MinimumOutputValueT>(name: JobName): Observable<JobHandler<A, I, O> | null>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export function fromAsyncIterable<T>(iterable: AsyncIterable<T>): Observable<T>;
|
||||
|
||||
// @public (undocumented)
|
||||
export function isBuilderOutput(obj: any): obj is BuilderOutput;
|
||||
|
||||
// @public (undocumented)
|
||||
function isJobHandler<A extends JsonValue, I extends JsonValue, O extends JsonValue>(value: unknown): value is JobHandler<A, I, O>;
|
||||
|
||||
// @public
|
||||
interface Job<ArgumentT extends JsonValue = JsonValue, InputT extends JsonValue = JsonValue, OutputT extends JsonValue = JsonValue> {
|
||||
readonly argument: ArgumentT;
|
||||
readonly description: Observable<JobDescription>;
|
||||
getChannel<T extends JsonValue>(name: string, schema?: schema.JsonSchema): Observable<T>;
|
||||
readonly inboundBus: Observer<JobInboundMessage<InputT>>;
|
||||
readonly input: Observer<InputT>;
|
||||
readonly outboundBus: Observable<JobOutboundMessage<OutputT>>;
|
||||
readonly output: Observable<OutputT>;
|
||||
ping(): Observable<never>;
|
||||
readonly state: JobState;
|
||||
stop(): void;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
class JobArgumentSchemaValidationError extends schema.SchemaValidationException {
|
||||
constructor(errors?: schema.SchemaValidatorError[]);
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobDescription extends JsonObject {
|
||||
// (undocumented)
|
||||
readonly argument: DeepReadonly<schema.JsonSchema>;
|
||||
// (undocumented)
|
||||
readonly input: DeepReadonly<schema.JsonSchema>;
|
||||
// (undocumented)
|
||||
readonly name: JobName;
|
||||
// (undocumented)
|
||||
readonly output: DeepReadonly<schema.JsonSchema>;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobDispatcher<A extends JsonValue, I extends JsonValue, O extends JsonValue> extends JobHandler<A, I, O> {
|
||||
addConditionalJob(predicate: (args: A) => boolean, name: string): void;
|
||||
setDefaultJob(name: JobName | null | JobHandler<JsonValue, JsonValue, JsonValue>): void;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
class JobDoesNotExistException extends BaseException {
|
||||
constructor(name: JobName);
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobHandler<ArgT extends JsonValue, InputT extends JsonValue, OutputT extends JsonValue> {
|
||||
// (undocumented)
|
||||
(argument: ArgT, context: JobHandlerContext<ArgT, InputT, OutputT>): Observable<JobOutboundMessage<OutputT>>;
|
||||
// (undocumented)
|
||||
jobDescription: Partial<JobDescription>;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobHandlerContext<MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> {
|
||||
// (undocumented)
|
||||
readonly dependencies: Job<JsonValue, JsonValue, JsonValue>[];
|
||||
// (undocumented)
|
||||
readonly description: JobDescription;
|
||||
// (undocumented)
|
||||
readonly inboundBus: Observable<JobInboundMessage<MinimumInputValueT>>;
|
||||
// (undocumented)
|
||||
readonly scheduler: Scheduler<JsonValue, JsonValue, JsonValue>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
type JobInboundMessage<InputT extends JsonValue> = JobInboundMessagePing | JobInboundMessageStop | JobInboundMessageInput<InputT>;
|
||||
|
||||
// @public
|
||||
interface JobInboundMessageBase extends JsonObject {
|
||||
readonly kind: JobInboundMessageKind;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobInboundMessageInput<InputT extends JsonValue> extends JobInboundMessageBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobInboundMessageKind.Input;
|
||||
readonly value: InputT;
|
||||
}
|
||||
|
||||
// @public
|
||||
enum JobInboundMessageKind {
|
||||
// (undocumented)
|
||||
Input = "in",
|
||||
// (undocumented)
|
||||
Ping = "ip",
|
||||
// (undocumented)
|
||||
Stop = "is"
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobInboundMessagePing extends JobInboundMessageBase {
|
||||
readonly id: number;
|
||||
// (undocumented)
|
||||
readonly kind: JobInboundMessageKind.Ping;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
class JobInboundMessageSchemaValidationError extends schema.SchemaValidationException {
|
||||
constructor(errors?: schema.SchemaValidatorError[]);
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobInboundMessageStop extends JobInboundMessageBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobInboundMessageKind.Stop;
|
||||
}
|
||||
|
||||
// @public
|
||||
type JobName = string;
|
||||
|
||||
// @public (undocumented)
|
||||
class JobNameAlreadyRegisteredException extends BaseException {
|
||||
constructor(name: JobName);
|
||||
}
|
||||
|
||||
// @public
|
||||
type JobOutboundMessage<OutputT extends JsonValue> = JobOutboundMessageOnReady | JobOutboundMessageStart | JobOutboundMessageOutput<OutputT> | JobOutboundMessageChannelCreate | JobOutboundMessageChannelMessage | JobOutboundMessageChannelError | JobOutboundMessageChannelComplete | JobOutboundMessageEnd | JobOutboundMessagePong;
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageBase {
|
||||
readonly description: JobDescription;
|
||||
readonly kind: JobOutboundMessageKind;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageChannelBase extends JobOutboundMessageBase {
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageChannelComplete extends JobOutboundMessageChannelBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.ChannelComplete;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageChannelCreate extends JobOutboundMessageChannelBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.ChannelCreate;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageChannelError extends JobOutboundMessageChannelBase {
|
||||
readonly error: JsonValue;
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.ChannelError;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageChannelMessage extends JobOutboundMessageChannelBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.ChannelMessage;
|
||||
readonly message: JsonValue;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageEnd extends JobOutboundMessageBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.End;
|
||||
}
|
||||
|
||||
// @public
|
||||
enum JobOutboundMessageKind {
|
||||
// (undocumented)
|
||||
ChannelComplete = "cc",
|
||||
// (undocumented)
|
||||
ChannelCreate = "cn",
|
||||
// (undocumented)
|
||||
ChannelError = "ce",
|
||||
// (undocumented)
|
||||
ChannelMessage = "cm",
|
||||
// (undocumented)
|
||||
End = "e",
|
||||
// (undocumented)
|
||||
OnReady = "c",
|
||||
// (undocumented)
|
||||
Output = "o",
|
||||
// (undocumented)
|
||||
Pong = "p",
|
||||
// (undocumented)
|
||||
Start = "s"
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageOnReady extends JobOutboundMessageBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.OnReady;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageOutput<OutputT extends JsonValue> extends JobOutboundMessageBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.Output;
|
||||
readonly value: OutputT;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessagePong extends JobOutboundMessageBase {
|
||||
readonly id: number;
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.Pong;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageStart extends JobOutboundMessageBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.Start;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
class JobOutputSchemaValidationError extends schema.SchemaValidationException {
|
||||
constructor(errors?: schema.SchemaValidatorError[]);
|
||||
}
|
||||
|
||||
declare namespace jobs {
|
||||
export {
|
||||
isJobHandler,
|
||||
JobName,
|
||||
JobHandler,
|
||||
JobHandlerContext,
|
||||
JobDescription,
|
||||
JobInboundMessageKind,
|
||||
JobInboundMessageBase,
|
||||
JobInboundMessagePing,
|
||||
JobInboundMessageStop,
|
||||
JobInboundMessageInput,
|
||||
JobInboundMessage,
|
||||
JobOutboundMessageKind,
|
||||
JobOutboundMessageBase,
|
||||
JobOutboundMessageOnReady,
|
||||
JobOutboundMessageStart,
|
||||
JobOutboundMessageOutput,
|
||||
JobOutboundMessageChannelBase,
|
||||
JobOutboundMessageChannelMessage,
|
||||
JobOutboundMessageChannelError,
|
||||
JobOutboundMessageChannelCreate,
|
||||
JobOutboundMessageChannelComplete,
|
||||
JobOutboundMessageEnd,
|
||||
JobOutboundMessagePong,
|
||||
JobOutboundMessage,
|
||||
JobState,
|
||||
Job,
|
||||
ScheduleJobOptions,
|
||||
Registry,
|
||||
Scheduler,
|
||||
createJobHandler,
|
||||
createJobFactory,
|
||||
createLoggerJob,
|
||||
ChannelAlreadyExistException,
|
||||
SimpleJobHandlerContext,
|
||||
SimpleJobHandlerFn,
|
||||
JobNameAlreadyRegisteredException,
|
||||
JobDoesNotExistException,
|
||||
createDispatcher,
|
||||
JobDispatcher,
|
||||
FallbackRegistry,
|
||||
RegisterJobOptions,
|
||||
SimpleJobRegistry,
|
||||
JobArgumentSchemaValidationError,
|
||||
JobInboundMessageSchemaValidationError,
|
||||
JobOutputSchemaValidationError,
|
||||
SimpleScheduler,
|
||||
strategy
|
||||
}
|
||||
}
|
||||
export { jobs }
|
||||
|
||||
// @public
|
||||
enum JobState {
|
||||
Ended = "ended",
|
||||
Errored = "errored",
|
||||
Queued = "queued",
|
||||
Ready = "ready",
|
||||
Started = "started"
|
||||
}
|
||||
|
||||
// @public
|
||||
interface RegisterJobOptions extends Partial<JobDescription> {
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
interface Registry<MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> {
|
||||
get<A extends MinimumArgumentValueT, I extends MinimumInputValueT, O extends MinimumOutputValueT>(name: JobName): Observable<JobHandler<A, I, O> | null>;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface ScheduleJobOptions {
|
||||
dependencies?: Job | Job[];
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export interface ScheduleOptions {
|
||||
// (undocumented)
|
||||
@ -118,9 +441,65 @@ export interface ScheduleOptions {
|
||||
logger?: logging.Logger;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface Scheduler<MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> {
|
||||
getDescription(name: JobName): Observable<JobDescription | null>;
|
||||
has(name: JobName): Observable<boolean>;
|
||||
pause(): () => void;
|
||||
schedule<A extends MinimumArgumentValueT, I extends MinimumInputValueT, O extends MinimumOutputValueT>(name: JobName, argument: A, options?: ScheduleJobOptions): Job<A, I, O>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export function scheduleTargetAndForget(context: BuilderContext, target: Target, overrides?: json.JsonObject, scheduleOptions?: ScheduleOptions_2): Observable<BuilderOutput>;
|
||||
|
||||
// @public
|
||||
interface SimpleJobHandlerContext<A extends JsonValue, I extends JsonValue, O extends JsonValue> extends JobHandlerContext<A, I, O> {
|
||||
// (undocumented)
|
||||
createChannel: (name: string) => Observer<JsonValue>;
|
||||
// (undocumented)
|
||||
input: Observable<I>;
|
||||
}
|
||||
|
||||
// @public
|
||||
type SimpleJobHandlerFn<A extends JsonValue, I extends JsonValue, O extends JsonValue> = (input: A, context: SimpleJobHandlerContext<A, I, O>) => O | Promise<O> | Observable<O>;
|
||||
|
||||
// @public
|
||||
class SimpleJobRegistry<MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> implements Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT> {
|
||||
// (undocumented)
|
||||
get<A extends MinimumArgumentValueT = MinimumArgumentValueT, I extends MinimumInputValueT = MinimumInputValueT, O extends MinimumOutputValueT = MinimumOutputValueT>(name: JobName): Observable<JobHandler<A, I, O> | null>;
|
||||
getJobNames(): JobName[];
|
||||
register<A extends MinimumArgumentValueT, I extends MinimumInputValueT, O extends MinimumOutputValueT>(name: JobName, handler: JobHandler<A, I, O>, options?: RegisterJobOptions): void;
|
||||
register<ArgumentT extends JsonValue, InputT extends JsonValue, OutputT extends JsonValue>(handler: JobHandler<ArgumentT, InputT, OutputT>, options?: RegisterJobOptions & {
|
||||
name: string;
|
||||
}): void;
|
||||
// (undocumented)
|
||||
protected _register<ArgumentT extends JsonValue, InputT extends JsonValue, OutputT extends JsonValue>(name: JobName, handler: JobHandler<ArgumentT, InputT, OutputT>, options: RegisterJobOptions): void;
|
||||
}
|
||||
|
||||
// @public
|
||||
class SimpleScheduler<MinimumArgumentT extends JsonValue = JsonValue, MinimumInputT extends JsonValue = JsonValue, MinimumOutputT extends JsonValue = JsonValue> implements Scheduler<MinimumArgumentT, MinimumInputT, MinimumOutputT> {
|
||||
constructor(_jobRegistry: Registry<MinimumArgumentT, MinimumInputT, MinimumOutputT>, _schemaRegistry?: schema.SchemaRegistry);
|
||||
getDescription(name: JobName): Observable<JobDescription | null>;
|
||||
has(name: JobName): Observable<boolean>;
|
||||
// (undocumented)
|
||||
protected _jobRegistry: Registry<MinimumArgumentT, MinimumInputT, MinimumOutputT>;
|
||||
pause(): () => void;
|
||||
schedule<A extends MinimumArgumentT, I extends MinimumInputT, O extends MinimumOutputT>(name: JobName, argument: A, options?: ScheduleJobOptions): Job<A, I, O>;
|
||||
// (undocumented)
|
||||
protected _scheduleJob<A extends MinimumArgumentT, I extends MinimumInputT, O extends MinimumOutputT>(name: JobName, argument: A, options: ScheduleJobOptions, waitable: Observable<never>): Job<A, I, O>;
|
||||
// (undocumented)
|
||||
protected _schemaRegistry: schema.SchemaRegistry;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
namespace strategy {
|
||||
// (undocumented)
|
||||
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>;
|
||||
function memoize<A extends JsonValue = JsonValue, I extends JsonValue = JsonValue, O extends JsonValue = JsonValue>(replayMessages?: boolean): JobStrategy<A, I, O>;
|
||||
function reuse<A extends JsonValue = JsonValue, I extends JsonValue = JsonValue, O extends JsonValue = JsonValue>(replayMessages?: boolean): JobStrategy<A, I, O>;
|
||||
function serialize<A extends JsonValue = JsonValue, I extends JsonValue = JsonValue, O extends JsonValue = JsonValue>(): JobStrategy<A, I, O>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export type Target = json.JsonObject & Target_2;
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
import { ErrorObject } from 'ajv';
|
||||
import { Format } from 'ajv';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observer } from 'rxjs';
|
||||
import { Operator } from 'rxjs';
|
||||
import { PartialObserver } from 'rxjs';
|
||||
import { Position } from 'source-map';
|
||||
@ -176,11 +175,6 @@ function camelize(str: string): string;
|
||||
// @public
|
||||
function capitalize(str: string): string;
|
||||
|
||||
// @public (undocumented)
|
||||
class ChannelAlreadyExistException extends BaseException {
|
||||
constructor(name: string);
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export class CircularDependencyFoundException extends BaseException {
|
||||
constructor();
|
||||
@ -318,18 +312,6 @@ class CoreSchemaRegistry implements SchemaRegistry {
|
||||
useXDeprecatedProvider(onUsage: (message: string) => void): void;
|
||||
}
|
||||
|
||||
// @public
|
||||
function createDispatcher<A extends JsonValue, I extends JsonValue, O extends JsonValue>(options?: Partial<Readwrite<JobDescription>>): JobDispatcher<A, I, O>;
|
||||
|
||||
// @public
|
||||
function createJobFactory<A extends JsonValue, I extends JsonValue, O extends JsonValue>(loader: () => Promise<JobHandler<A, I, O>>, options?: Partial<JobDescription>): JobHandler<A, I, O>;
|
||||
|
||||
// @public
|
||||
function createJobHandler<A extends JsonValue, I extends JsonValue, O extends JsonValue>(fn: SimpleJobHandlerFn<A, I, O>, options?: Partial<JobDescription>): JobHandler<A, I, O>;
|
||||
|
||||
// @public
|
||||
function createLoggerJob<A extends JsonValue, I extends JsonValue, O extends JsonValue>(job: JobHandler<A, I, O>, logger: LoggerApi): JobHandler<A, I, O>;
|
||||
|
||||
// @public (undocumented)
|
||||
function createSyncHost<StatsT extends object = {}>(handler: SyncHostHandler<StatsT>): Host<StatsT>;
|
||||
|
||||
@ -353,18 +335,6 @@ function decamelize(str: string): string;
|
||||
// @public
|
||||
export function deepCopy<T>(value: T): T;
|
||||
|
||||
// @public (undocumented)
|
||||
export type DeepReadonly<T> = T extends (infer R)[] ? DeepReadonlyArray<R> : T extends Function ? T : T extends object ? DeepReadonlyObject<T> : T;
|
||||
|
||||
// @public (undocumented)
|
||||
export interface DeepReadonlyArray<T> extends Array<DeepReadonly<T>> {
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export type DeepReadonlyObject<T> = {
|
||||
readonly [P in keyof T]: DeepReadonly<T[P]>;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
type DefinitionCollectionListener<V extends object> = (name: string, newValue: V | undefined, collection: DefinitionCollection<V>) => void;
|
||||
|
||||
@ -402,27 +372,9 @@ interface EventOptions extends CustomDimensionsAndMetricsOptions {
|
||||
value?: string;
|
||||
}
|
||||
|
||||
declare namespace experimental {
|
||||
export {
|
||||
jobs
|
||||
}
|
||||
}
|
||||
export { experimental }
|
||||
|
||||
// @public (undocumented)
|
||||
export function extname(path: Path): string;
|
||||
|
||||
// @public
|
||||
class FallbackRegistry<MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> implements Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT> {
|
||||
constructor(_fallbacks?: Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT>[]);
|
||||
// (undocumented)
|
||||
addFallback(registry: Registry): void;
|
||||
// (undocumented)
|
||||
protected _fallbacks: Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT>[];
|
||||
// (undocumented)
|
||||
get<A extends MinimumArgumentValueT = MinimumArgumentValueT, I extends MinimumInputValueT = MinimumInputValueT, O extends MinimumOutputValueT = MinimumOutputValueT>(name: JobName): Observable<JobHandler<A, I, O> | null>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export class FileAlreadyExistException extends BaseException {
|
||||
constructor(path: string);
|
||||
@ -540,9 +492,6 @@ export class InvalidUpdateRecordException extends BaseException {
|
||||
// @public
|
||||
export function isAbsolute(p: Path): boolean;
|
||||
|
||||
// @public (undocumented)
|
||||
function isJobHandler<A extends JsonValue, I extends JsonValue, O extends JsonValue>(value: unknown): value is JobHandler<A, I, O>;
|
||||
|
||||
// @public (undocumented)
|
||||
export function isJsonArray(value: JsonValue): value is JsonArray;
|
||||
|
||||
@ -555,279 +504,6 @@ function isJsonSchema(value: unknown): value is JsonSchema;
|
||||
// @public
|
||||
export function isPromise(obj: any): obj is Promise<any>;
|
||||
|
||||
// @public
|
||||
interface Job<ArgumentT extends JsonValue = JsonValue, InputT extends JsonValue = JsonValue, OutputT extends JsonValue = JsonValue> {
|
||||
readonly argument: ArgumentT;
|
||||
readonly description: Observable<JobDescription>;
|
||||
getChannel<T extends JsonValue>(name: string, schema?: schema.JsonSchema): Observable<T>;
|
||||
readonly inboundBus: Observer<JobInboundMessage<InputT>>;
|
||||
readonly input: Observer<InputT>;
|
||||
readonly outboundBus: Observable<JobOutboundMessage<OutputT>>;
|
||||
readonly output: Observable<OutputT>;
|
||||
ping(): Observable<never>;
|
||||
readonly state: JobState;
|
||||
stop(): void;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
class JobArgumentSchemaValidationError extends schema.SchemaValidationException {
|
||||
constructor(errors?: schema.SchemaValidatorError[]);
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobDescription extends JsonObject {
|
||||
// (undocumented)
|
||||
readonly argument: DeepReadonly<schema.JsonSchema>;
|
||||
// (undocumented)
|
||||
readonly input: DeepReadonly<schema.JsonSchema>;
|
||||
// (undocumented)
|
||||
readonly name: JobName;
|
||||
// (undocumented)
|
||||
readonly output: DeepReadonly<schema.JsonSchema>;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobDispatcher<A extends JsonValue, I extends JsonValue, O extends JsonValue> extends JobHandler<A, I, O> {
|
||||
addConditionalJob(predicate: (args: A) => boolean, name: string): void;
|
||||
setDefaultJob(name: JobName | null | JobHandler<JsonValue, JsonValue, JsonValue>): void;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
class JobDoesNotExistException extends BaseException {
|
||||
constructor(name: JobName);
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobHandler<ArgT extends JsonValue, InputT extends JsonValue, OutputT extends JsonValue> {
|
||||
// (undocumented)
|
||||
(argument: ArgT, context: JobHandlerContext<ArgT, InputT, OutputT>): Observable<JobOutboundMessage<OutputT>>;
|
||||
// (undocumented)
|
||||
jobDescription: Partial<JobDescription>;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobHandlerContext<MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> {
|
||||
// (undocumented)
|
||||
readonly dependencies: Job<JsonValue, JsonValue, JsonValue>[];
|
||||
// (undocumented)
|
||||
readonly description: JobDescription;
|
||||
// (undocumented)
|
||||
readonly inboundBus: Observable<JobInboundMessage<MinimumInputValueT>>;
|
||||
// (undocumented)
|
||||
readonly scheduler: Scheduler<JsonValue, JsonValue, JsonValue>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
type JobInboundMessage<InputT extends JsonValue> = JobInboundMessagePing | JobInboundMessageStop | JobInboundMessageInput<InputT>;
|
||||
|
||||
// @public
|
||||
interface JobInboundMessageBase extends JsonObject {
|
||||
readonly kind: JobInboundMessageKind;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobInboundMessageInput<InputT extends JsonValue> extends JobInboundMessageBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobInboundMessageKind.Input;
|
||||
readonly value: InputT;
|
||||
}
|
||||
|
||||
// @public
|
||||
enum JobInboundMessageKind {
|
||||
// (undocumented)
|
||||
Input = "in",
|
||||
// (undocumented)
|
||||
Ping = "ip",
|
||||
// (undocumented)
|
||||
Stop = "is"
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobInboundMessagePing extends JobInboundMessageBase {
|
||||
readonly id: number;
|
||||
// (undocumented)
|
||||
readonly kind: JobInboundMessageKind.Ping;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
class JobInboundMessageSchemaValidationError extends schema.SchemaValidationException {
|
||||
constructor(errors?: schema.SchemaValidatorError[]);
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobInboundMessageStop extends JobInboundMessageBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobInboundMessageKind.Stop;
|
||||
}
|
||||
|
||||
// @public
|
||||
type JobName = string;
|
||||
|
||||
// @public (undocumented)
|
||||
class JobNameAlreadyRegisteredException extends BaseException {
|
||||
constructor(name: JobName);
|
||||
}
|
||||
|
||||
// @public
|
||||
type JobOutboundMessage<OutputT extends JsonValue> = JobOutboundMessageOnReady | JobOutboundMessageStart | JobOutboundMessageOutput<OutputT> | JobOutboundMessageChannelCreate | JobOutboundMessageChannelMessage | JobOutboundMessageChannelError | JobOutboundMessageChannelComplete | JobOutboundMessageEnd | JobOutboundMessagePong;
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageBase {
|
||||
readonly description: JobDescription;
|
||||
readonly kind: JobOutboundMessageKind;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageChannelBase extends JobOutboundMessageBase {
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageChannelComplete extends JobOutboundMessageChannelBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.ChannelComplete;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageChannelCreate extends JobOutboundMessageChannelBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.ChannelCreate;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageChannelError extends JobOutboundMessageChannelBase {
|
||||
readonly error: JsonValue;
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.ChannelError;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageChannelMessage extends JobOutboundMessageChannelBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.ChannelMessage;
|
||||
readonly message: JsonValue;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageEnd extends JobOutboundMessageBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.End;
|
||||
}
|
||||
|
||||
// @public
|
||||
enum JobOutboundMessageKind {
|
||||
// (undocumented)
|
||||
ChannelComplete = "cc",
|
||||
// (undocumented)
|
||||
ChannelCreate = "cn",
|
||||
// (undocumented)
|
||||
ChannelError = "ce",
|
||||
// (undocumented)
|
||||
ChannelMessage = "cm",
|
||||
// (undocumented)
|
||||
End = "e",
|
||||
// (undocumented)
|
||||
OnReady = "c",
|
||||
// (undocumented)
|
||||
Output = "o",
|
||||
// (undocumented)
|
||||
Pong = "p",
|
||||
// (undocumented)
|
||||
Start = "s"
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageOnReady extends JobOutboundMessageBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.OnReady;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageOutput<OutputT extends JsonValue> extends JobOutboundMessageBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.Output;
|
||||
readonly value: OutputT;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessagePong extends JobOutboundMessageBase {
|
||||
readonly id: number;
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.Pong;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface JobOutboundMessageStart extends JobOutboundMessageBase {
|
||||
// (undocumented)
|
||||
readonly kind: JobOutboundMessageKind.Start;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
class JobOutputSchemaValidationError extends schema.SchemaValidationException {
|
||||
constructor(errors?: schema.SchemaValidatorError[]);
|
||||
}
|
||||
|
||||
declare namespace jobs {
|
||||
export {
|
||||
isJobHandler,
|
||||
JobName,
|
||||
JobHandler,
|
||||
JobHandlerContext,
|
||||
JobDescription,
|
||||
JobInboundMessageKind,
|
||||
JobInboundMessageBase,
|
||||
JobInboundMessagePing,
|
||||
JobInboundMessageStop,
|
||||
JobInboundMessageInput,
|
||||
JobInboundMessage,
|
||||
JobOutboundMessageKind,
|
||||
JobOutboundMessageBase,
|
||||
JobOutboundMessageOnReady,
|
||||
JobOutboundMessageStart,
|
||||
JobOutboundMessageOutput,
|
||||
JobOutboundMessageChannelBase,
|
||||
JobOutboundMessageChannelMessage,
|
||||
JobOutboundMessageChannelError,
|
||||
JobOutboundMessageChannelCreate,
|
||||
JobOutboundMessageChannelComplete,
|
||||
JobOutboundMessageEnd,
|
||||
JobOutboundMessagePong,
|
||||
JobOutboundMessage,
|
||||
JobState,
|
||||
Job,
|
||||
ScheduleJobOptions,
|
||||
Registry,
|
||||
Scheduler,
|
||||
createJobHandler,
|
||||
createJobFactory,
|
||||
createLoggerJob,
|
||||
ChannelAlreadyExistException,
|
||||
SimpleJobHandlerContext,
|
||||
SimpleJobHandlerFn,
|
||||
JobNameAlreadyRegisteredException,
|
||||
JobDoesNotExistException,
|
||||
createDispatcher,
|
||||
JobDispatcher,
|
||||
FallbackRegistry,
|
||||
RegisterJobOptions,
|
||||
SimpleJobRegistry,
|
||||
JobArgumentSchemaValidationError,
|
||||
JobInboundMessageSchemaValidationError,
|
||||
JobOutputSchemaValidationError,
|
||||
SimpleScheduler,
|
||||
strategy
|
||||
}
|
||||
}
|
||||
|
||||
// @public
|
||||
enum JobState {
|
||||
Ended = "ended",
|
||||
Errored = "errored",
|
||||
Queued = "queued",
|
||||
Ready = "ready",
|
||||
Started = "started"
|
||||
}
|
||||
|
||||
// @public
|
||||
export function join(p1: Path, ...others: string[]): Path;
|
||||
|
||||
@ -1343,11 +1019,6 @@ function readWorkspace(path: string, host: WorkspaceHost, format?: WorkspaceForm
|
||||
workspace: WorkspaceDefinition;
|
||||
}>;
|
||||
|
||||
// @public (undocumented)
|
||||
export type Readwrite<T> = {
|
||||
-readonly [P in keyof T]: T[P];
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
interface ReferenceResolver<ContextT> {
|
||||
// (undocumented)
|
||||
@ -1357,15 +1028,6 @@ interface ReferenceResolver<ContextT> {
|
||||
};
|
||||
}
|
||||
|
||||
// @public
|
||||
interface RegisterJobOptions extends Partial<JobDescription> {
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
interface Registry<MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> {
|
||||
get<A extends MinimumArgumentValueT, I extends MinimumInputValueT, O extends MinimumOutputValueT>(name: JobName): Observable<JobHandler<A, I, O> | null>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export function relative(from: Path, to: Path): Path;
|
||||
|
||||
@ -1428,19 +1090,6 @@ class SafeReadonlyHost<StatsT extends object = {}> implements ReadonlyHost<Stats
|
||||
stat(path: Path): Observable<Stats<StatsT> | null> | null;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface ScheduleJobOptions {
|
||||
dependencies?: Job | Job[];
|
||||
}
|
||||
|
||||
// @public
|
||||
interface Scheduler<MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> {
|
||||
getDescription(name: JobName): Observable<JobDescription | null>;
|
||||
has(name: JobName): Observable<boolean>;
|
||||
pause(): () => void;
|
||||
schedule<A extends MinimumArgumentValueT, I extends MinimumInputValueT, O extends MinimumOutputValueT>(name: JobName, argument: A, options?: ScheduleJobOptions): Job<A, I, O>;
|
||||
}
|
||||
|
||||
declare namespace schema {
|
||||
export {
|
||||
transforms,
|
||||
@ -1567,30 +1216,6 @@ interface ScreenviewOptions extends CustomDimensionsAndMetricsOptions {
|
||||
appVersion?: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface SimpleJobHandlerContext<A extends JsonValue, I extends JsonValue, O extends JsonValue> extends JobHandlerContext<A, I, O> {
|
||||
// (undocumented)
|
||||
createChannel: (name: string) => Observer<JsonValue>;
|
||||
// (undocumented)
|
||||
input: Observable<I>;
|
||||
}
|
||||
|
||||
// @public
|
||||
type SimpleJobHandlerFn<A extends JsonValue, I extends JsonValue, O extends JsonValue> = (input: A, context: SimpleJobHandlerContext<A, I, O>) => O | Promise<O> | Observable<O>;
|
||||
|
||||
// @public
|
||||
class SimpleJobRegistry<MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> implements Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT> {
|
||||
// (undocumented)
|
||||
get<A extends MinimumArgumentValueT = MinimumArgumentValueT, I extends MinimumInputValueT = MinimumInputValueT, O extends MinimumOutputValueT = MinimumOutputValueT>(name: JobName): Observable<JobHandler<A, I, O> | null>;
|
||||
getJobNames(): JobName[];
|
||||
register<A extends MinimumArgumentValueT, I extends MinimumInputValueT, O extends MinimumOutputValueT>(name: JobName, handler: JobHandler<A, I, O>, options?: RegisterJobOptions): void;
|
||||
register<ArgumentT extends JsonValue, InputT extends JsonValue, OutputT extends JsonValue>(handler: JobHandler<ArgumentT, InputT, OutputT>, options?: RegisterJobOptions & {
|
||||
name: string;
|
||||
}): void;
|
||||
// (undocumented)
|
||||
protected _register<ArgumentT extends JsonValue, InputT extends JsonValue, OutputT extends JsonValue>(name: JobName, handler: JobHandler<ArgumentT, InputT, OutputT>, options: RegisterJobOptions): void;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
class SimpleMemoryHost implements Host<{}> {
|
||||
constructor();
|
||||
@ -1675,21 +1300,6 @@ interface SimpleMemoryHostStats {
|
||||
readonly content: FileBuffer | null;
|
||||
}
|
||||
|
||||
// @public
|
||||
class SimpleScheduler<MinimumArgumentT extends JsonValue = JsonValue, MinimumInputT extends JsonValue = JsonValue, MinimumOutputT extends JsonValue = JsonValue> implements Scheduler<MinimumArgumentT, MinimumInputT, MinimumOutputT> {
|
||||
constructor(_jobRegistry: Registry<MinimumArgumentT, MinimumInputT, MinimumOutputT>, _schemaRegistry?: schema.SchemaRegistry);
|
||||
getDescription(name: JobName): Observable<JobDescription | null>;
|
||||
has(name: JobName): Observable<boolean>;
|
||||
// (undocumented)
|
||||
protected _jobRegistry: Registry<MinimumArgumentT, MinimumInputT, MinimumOutputT>;
|
||||
pause(): () => void;
|
||||
schedule<A extends MinimumArgumentT, I extends MinimumInputT, O extends MinimumOutputT>(name: JobName, argument: A, options?: ScheduleJobOptions): Job<A, I, O>;
|
||||
// (undocumented)
|
||||
protected _scheduleJob<A extends MinimumArgumentT, I extends MinimumInputT, O extends MinimumOutputT>(name: JobName, argument: A, options: ScheduleJobOptions, waitable: Observable<never>): Job<A, I, O>;
|
||||
// (undocumented)
|
||||
protected _schemaRegistry: schema.SchemaRegistry;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
interface SmartDefaultProvider<T> {
|
||||
// (undocumented)
|
||||
@ -1710,15 +1320,6 @@ type Stats<T extends object = {}> = T & {
|
||||
readonly birthtime: Date;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
namespace strategy {
|
||||
// (undocumented)
|
||||
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>;
|
||||
function memoize<A extends JsonValue = JsonValue, I extends JsonValue = JsonValue, O extends JsonValue = JsonValue>(replayMessages?: boolean): JobStrategy<A, I, O>;
|
||||
function reuse<A extends JsonValue = JsonValue, I extends JsonValue = JsonValue, O extends JsonValue = JsonValue>(replayMessages?: boolean): JobStrategy<A, I, O>;
|
||||
function serialize<A extends JsonValue = JsonValue, I extends JsonValue = JsonValue, O extends JsonValue = JsonValue>(): JobStrategy<A, I, O>;
|
||||
}
|
||||
|
||||
declare namespace strings {
|
||||
export {
|
||||
decamelize,
|
||||
|
@ -6,28 +6,16 @@
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { ErrorObject } from 'ajv';
|
||||
import { Format } from 'ajv';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observer } from 'rxjs';
|
||||
import { Operator } from 'rxjs';
|
||||
import { PartialObserver } from 'rxjs';
|
||||
import { Stats as Stats_2 } from 'fs';
|
||||
import { Subject } from 'rxjs';
|
||||
import { SubscribableOrPromise } from 'rxjs';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { ValidateFunction } from 'ajv';
|
||||
|
||||
// @public
|
||||
export function createConsoleLogger(verbose?: boolean, stdout?: ProcessOutput, stderr?: ProcessOutput, colors?: Partial<Record<logging.LogLevel, (s: string) => string>>): logging.Logger;
|
||||
|
||||
declare namespace experimental {
|
||||
export {
|
||||
NodeModuleJobRegistry
|
||||
}
|
||||
}
|
||||
export { experimental }
|
||||
|
||||
// @public
|
||||
export class NodeJsAsyncHost implements virtualFs.Host<Stats_2> {
|
||||
// (undocumented)
|
||||
@ -80,13 +68,6 @@ export class NodeJsSyncHost implements virtualFs.Host<Stats_2> {
|
||||
write(path: Path, content: virtualFs.FileBuffer): Observable<void>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
class NodeModuleJobRegistry<MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> implements experimental_2.jobs.Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT> {
|
||||
get<A extends MinimumArgumentValueT, I extends MinimumInputValueT, O extends MinimumOutputValueT>(name: experimental_2.jobs.JobName): Observable<experimental_2.jobs.JobHandler<A, I, O> | null>;
|
||||
// (undocumented)
|
||||
protected _resolve(name: string): string | null;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export interface ProcessOutput {
|
||||
// (undocumented)
|
||||
|
@ -3,7 +3,9 @@
|
||||
# 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
|
||||
|
||||
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
|
||||
load("//tools:defaults.bzl", "ts_library")
|
||||
load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS")
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
@ -21,7 +23,35 @@ ts_library(
|
||||
"//packages/angular_devkit/architect",
|
||||
"//packages/angular_devkit/core",
|
||||
"//packages/angular_devkit/core/node",
|
||||
"//tests/angular_devkit/architect/node/jobs:jobs_test_lib",
|
||||
"@npm//@types/node",
|
||||
"@npm//rxjs",
|
||||
],
|
||||
)
|
||||
|
||||
ts_library(
|
||||
name = "node_test_lib",
|
||||
testonly = True,
|
||||
srcs = glob(
|
||||
include = [
|
||||
"**/*_spec.ts",
|
||||
],
|
||||
),
|
||||
deps = [
|
||||
":node",
|
||||
"//packages/angular_devkit/architect",
|
||||
],
|
||||
)
|
||||
|
||||
[
|
||||
jasmine_node_test(
|
||||
name = "node_test_" + toolchain_name,
|
||||
srcs = [":node_test_lib"],
|
||||
tags = [toolchain_name],
|
||||
toolchain = toolchain,
|
||||
)
|
||||
for toolchain_name, toolchain in zip(
|
||||
TOOLCHAINS_NAMES,
|
||||
TOOLCHAINS_VERSIONS,
|
||||
)
|
||||
]
|
||||
|
@ -6,4 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import * as jobs from './jobs/job-registry';
|
||||
|
||||
export * from './node-modules-architect-host';
|
||||
|
||||
export { jobs };
|
||||
|
@ -6,15 +6,15 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { jobs } from '@angular-devkit/architect';
|
||||
import { JsonValue, schema } from '@angular-devkit/core';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { JsonValue, experimental as core_experimental, schema } from '../../../src';
|
||||
|
||||
export class NodeModuleJobRegistry<
|
||||
MinimumArgumentValueT extends JsonValue = JsonValue,
|
||||
MinimumInputValueT extends JsonValue = JsonValue,
|
||||
MinimumOutputValueT extends JsonValue = JsonValue,
|
||||
> implements
|
||||
core_experimental.jobs.Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT>
|
||||
> implements jobs.Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT>
|
||||
{
|
||||
protected _resolve(name: string): string | null {
|
||||
try {
|
||||
@ -34,8 +34,8 @@ export class NodeModuleJobRegistry<
|
||||
* @returns A description, or null if the job is not registered.
|
||||
*/
|
||||
get<A extends MinimumArgumentValueT, I extends MinimumInputValueT, O extends MinimumOutputValueT>(
|
||||
name: core_experimental.jobs.JobName,
|
||||
): Observable<core_experimental.jobs.JobHandler<A, I, O> | null> {
|
||||
name: jobs.JobName,
|
||||
): Observable<jobs.JobHandler<A, I, O> | null> {
|
||||
const [moduleName, exportName] = name.split(/#/, 2);
|
||||
|
||||
const resolvedPath = this._resolve(moduleName);
|
@ -6,19 +6,16 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { jobs } from '@angular-devkit/architect';
|
||||
import * as path from 'path';
|
||||
import { experimental as core_experimental } from '../../../src';
|
||||
import { NodeModuleJobRegistry } from './job-registry';
|
||||
|
||||
const root = path.join(
|
||||
path.dirname(require.resolve(__filename)),
|
||||
'../../../../../../tests/angular_devkit/core/node/jobs',
|
||||
);
|
||||
const root = path.join(__dirname, '../../../../../tests/angular_devkit/architect/node/jobs');
|
||||
|
||||
describe('NodeModuleJobScheduler', () => {
|
||||
it('works', async () => {
|
||||
const registry = new NodeModuleJobRegistry();
|
||||
const scheduler = new core_experimental.jobs.SimpleScheduler(registry);
|
||||
const scheduler = new jobs.SimpleScheduler(registry);
|
||||
|
||||
const job = scheduler.schedule(path.join(root, 'add'), [1, 2, 3]);
|
||||
expect(await job.output.toPromise()).toBe(6);
|
@ -6,10 +6,11 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { analytics, experimental, json, logging } from '@angular-devkit/core';
|
||||
import { analytics, json, logging } from '@angular-devkit/core';
|
||||
import { Observable, SubscribableOrPromise, Subscriber, from } from 'rxjs';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { Schema as RealBuilderInput, Target as RealTarget } from './input-schema';
|
||||
import { Registry } from './jobs';
|
||||
import { Schema as RealBuilderOutput } from './output-schema';
|
||||
import { State as BuilderProgressState, Schema as RealBuilderProgress } from './progress-schema';
|
||||
|
||||
@ -17,11 +18,7 @@ export type Target = json.JsonObject & RealTarget;
|
||||
export { BuilderProgressState };
|
||||
|
||||
// Type short hands.
|
||||
export type BuilderRegistry = experimental.jobs.Registry<
|
||||
json.JsonObject,
|
||||
BuilderInput,
|
||||
BuilderOutput
|
||||
>;
|
||||
export type BuilderRegistry = Registry<json.JsonObject, BuilderInput, BuilderOutput>;
|
||||
|
||||
/**
|
||||
* An API typed BuilderProgress. The interface generated from the schema is too permissive,
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { analytics, experimental, json, logging } from '@angular-devkit/core';
|
||||
import { analytics, json, logging } from '@angular-devkit/core';
|
||||
import { Observable, from, merge, of, onErrorResumeNext } from 'rxjs';
|
||||
import {
|
||||
concatMap,
|
||||
@ -28,6 +28,20 @@ import {
|
||||
targetStringFromTarget,
|
||||
} from './api';
|
||||
import { ArchitectHost, BuilderDescription, BuilderJobHandler } from './internal';
|
||||
import {
|
||||
FallbackRegistry,
|
||||
JobHandler,
|
||||
JobHandlerContext,
|
||||
JobInboundMessage,
|
||||
JobInboundMessageKind,
|
||||
JobName,
|
||||
JobOutboundMessageKind,
|
||||
Registry,
|
||||
Scheduler,
|
||||
SimpleJobRegistry,
|
||||
SimpleScheduler,
|
||||
createJobHandler,
|
||||
} from './jobs';
|
||||
import { scheduleByName, scheduleByTarget } from './schedule-by-name';
|
||||
|
||||
const inputSchema = require('./input-schema.json');
|
||||
@ -48,11 +62,11 @@ function _createJobHandlerFromBuilderInfo(
|
||||
info,
|
||||
};
|
||||
|
||||
function handler(argument: json.JsonObject, context: experimental.jobs.JobHandlerContext) {
|
||||
function handler(argument: json.JsonObject, context: JobHandlerContext) {
|
||||
// Add input validation to the inbound bus.
|
||||
const inboundBusWithInputValidation = context.inboundBus.pipe(
|
||||
concatMap((message) => {
|
||||
if (message.kind === experimental.jobs.JobInboundMessageKind.Input) {
|
||||
if (message.kind === JobInboundMessageKind.Input) {
|
||||
const v = message.value as BuilderInput;
|
||||
const options = {
|
||||
...baseOptions,
|
||||
@ -73,7 +87,7 @@ function _createJobHandlerFromBuilderInfo(
|
||||
map((value) => ({ ...message, value })),
|
||||
);
|
||||
} else {
|
||||
return of(message as experimental.jobs.JobInboundMessage<BuilderInput>);
|
||||
return of(message as JobInboundMessage<BuilderInput>);
|
||||
}
|
||||
}),
|
||||
// Using a share replay because the job might be synchronously sending input, but
|
||||
@ -93,7 +107,7 @@ function _createJobHandlerFromBuilderInfo(
|
||||
|
||||
return builder.handler(argument, { ...context, inboundBus }).pipe(
|
||||
map((output) => {
|
||||
if (output.kind === experimental.jobs.JobOutboundMessageKind.Output) {
|
||||
if (output.kind === JobOutboundMessageKind.Output) {
|
||||
// Add target to it.
|
||||
return {
|
||||
...output,
|
||||
@ -198,7 +212,7 @@ class ArchitectBuilderJobRegistry implements BuilderRegistry {
|
||||
|
||||
get<A extends json.JsonObject, I extends BuilderInput, O extends BuilderOutput>(
|
||||
name: string,
|
||||
): Observable<experimental.jobs.JobHandler<A, I, O> | null> {
|
||||
): Observable<JobHandler<A, I, O> | null> {
|
||||
const m = name.match(/^([^:]+):([^:]+)$/i);
|
||||
if (!m) {
|
||||
return of(null);
|
||||
@ -207,7 +221,7 @@ class ArchitectBuilderJobRegistry implements BuilderRegistry {
|
||||
return from(this._resolveBuilder(name)).pipe(
|
||||
concatMap((builderInfo) => (builderInfo ? this._createBuilder(builderInfo) : of(null))),
|
||||
first(null, null),
|
||||
) as Observable<experimental.jobs.JobHandler<A, I, O> | null>;
|
||||
) as Observable<JobHandler<A, I, O> | null>;
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,7 +231,7 @@ class ArchitectBuilderJobRegistry implements BuilderRegistry {
|
||||
class ArchitectTargetJobRegistry extends ArchitectBuilderJobRegistry {
|
||||
override get<A extends json.JsonObject, I extends BuilderInput, O extends BuilderOutput>(
|
||||
name: string,
|
||||
): Observable<experimental.jobs.JobHandler<A, I, O> | null> {
|
||||
): Observable<JobHandler<A, I, O> | null> {
|
||||
const m = name.match(/^{([^:]+):([^:]+)(?::([^:]*))?}$/i);
|
||||
if (!m) {
|
||||
return of(null);
|
||||
@ -251,12 +265,12 @@ class ArchitectTargetJobRegistry extends ArchitectBuilderJobRegistry {
|
||||
);
|
||||
}),
|
||||
first(null, null),
|
||||
) as Observable<experimental.jobs.JobHandler<A, I, O> | null>;
|
||||
) as Observable<JobHandler<A, I, O> | null>;
|
||||
}
|
||||
}
|
||||
|
||||
function _getTargetOptionsFactory(host: ArchitectHost) {
|
||||
return experimental.jobs.createJobHandler<Target, json.JsonValue, json.JsonObject>(
|
||||
return createJobHandler<Target, json.JsonValue, json.JsonObject>(
|
||||
(target) => {
|
||||
return host.getOptionsForTarget(target).then((options) => {
|
||||
if (options === null) {
|
||||
@ -275,7 +289,7 @@ function _getTargetOptionsFactory(host: ArchitectHost) {
|
||||
}
|
||||
|
||||
function _getProjectMetadataFactory(host: ArchitectHost) {
|
||||
return experimental.jobs.createJobHandler<Target, json.JsonValue, json.JsonObject>(
|
||||
return createJobHandler<Target, json.JsonValue, json.JsonObject>(
|
||||
(target) => {
|
||||
return host.getProjectMetadata(target).then((options) => {
|
||||
if (options === null) {
|
||||
@ -296,7 +310,7 @@ function _getProjectMetadataFactory(host: ArchitectHost) {
|
||||
}
|
||||
|
||||
function _getBuilderNameForTargetFactory(host: ArchitectHost) {
|
||||
return experimental.jobs.createJobHandler<Target, never, string>(
|
||||
return createJobHandler<Target, never, string>(
|
||||
async (target) => {
|
||||
const builderName = await host.getBuilderNameForTarget(target);
|
||||
if (!builderName) {
|
||||
@ -314,7 +328,7 @@ function _getBuilderNameForTargetFactory(host: ArchitectHost) {
|
||||
}
|
||||
|
||||
function _validateOptionsFactory(host: ArchitectHost, registry: json.schema.SchemaRegistry) {
|
||||
return experimental.jobs.createJobHandler<[string, json.JsonObject], never, json.JsonObject>(
|
||||
return createJobHandler<[string, json.JsonObject], never, json.JsonObject>(
|
||||
async ([builderName, options]) => {
|
||||
// Get option schema from the host.
|
||||
const builderInfo = await host.resolveBuilder(builderName);
|
||||
@ -348,33 +362,33 @@ function _validateOptionsFactory(host: ArchitectHost, registry: json.schema.Sche
|
||||
}
|
||||
|
||||
export class Architect {
|
||||
private readonly _scheduler: experimental.jobs.Scheduler;
|
||||
private readonly _scheduler: Scheduler;
|
||||
private readonly _jobCache = new Map<string, Observable<BuilderJobHandler>>();
|
||||
private readonly _infoCache = new Map<string, Observable<BuilderInfo>>();
|
||||
|
||||
constructor(
|
||||
private _host: ArchitectHost,
|
||||
registry: json.schema.SchemaRegistry = new json.schema.CoreSchemaRegistry(),
|
||||
additionalJobRegistry?: experimental.jobs.Registry,
|
||||
additionalJobRegistry?: Registry,
|
||||
) {
|
||||
const privateArchitectJobRegistry = new experimental.jobs.SimpleJobRegistry();
|
||||
const privateArchitectJobRegistry = new SimpleJobRegistry();
|
||||
// Create private jobs.
|
||||
privateArchitectJobRegistry.register(_getTargetOptionsFactory(_host));
|
||||
privateArchitectJobRegistry.register(_getBuilderNameForTargetFactory(_host));
|
||||
privateArchitectJobRegistry.register(_validateOptionsFactory(_host, registry));
|
||||
privateArchitectJobRegistry.register(_getProjectMetadataFactory(_host));
|
||||
|
||||
const jobRegistry = new experimental.jobs.FallbackRegistry([
|
||||
const jobRegistry = new FallbackRegistry([
|
||||
new ArchitectTargetJobRegistry(_host, registry, this._jobCache, this._infoCache),
|
||||
new ArchitectBuilderJobRegistry(_host, registry, this._jobCache, this._infoCache),
|
||||
privateArchitectJobRegistry,
|
||||
...(additionalJobRegistry ? [additionalJobRegistry] : []),
|
||||
] as experimental.jobs.Registry[]);
|
||||
] as Registry[]);
|
||||
|
||||
this._scheduler = new experimental.jobs.SimpleScheduler(jobRegistry, registry);
|
||||
this._scheduler = new SimpleScheduler(jobRegistry, registry);
|
||||
}
|
||||
|
||||
has(name: experimental.jobs.JobName) {
|
||||
has(name: JobName) {
|
||||
return this._scheduler.has(name);
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { analytics, experimental, json, logging } from '@angular-devkit/core';
|
||||
import { analytics, json, logging } from '@angular-devkit/core';
|
||||
import { Observable, Subscription, from, isObservable, of, throwError } from 'rxjs';
|
||||
import { mergeMap, tap } from 'rxjs/operators';
|
||||
import {
|
||||
@ -24,13 +24,14 @@ import {
|
||||
targetStringFromTarget,
|
||||
} from './api';
|
||||
import { Builder, BuilderSymbol, BuilderVersionSymbol } from './internal';
|
||||
import { JobInboundMessageKind, createJobHandler } from './jobs';
|
||||
import { scheduleByName, scheduleByTarget } from './schedule-by-name';
|
||||
|
||||
// eslint-disable-next-line max-lines-per-function
|
||||
export function createBuilder<OptT = json.JsonObject, OutT extends BuilderOutput = BuilderOutput>(
|
||||
fn: BuilderHandlerFn<OptT>,
|
||||
): Builder<OptT & json.JsonObject> {
|
||||
const cjh = experimental.jobs.createJobHandler;
|
||||
const cjh = createJobHandler;
|
||||
// eslint-disable-next-line max-lines-per-function
|
||||
const handler = cjh<json.JsonObject, BuilderInput, OutT>((options, context) => {
|
||||
const scheduler = context.scheduler;
|
||||
@ -73,7 +74,7 @@ export function createBuilder<OptT = json.JsonObject, OutT extends BuilderOutput
|
||||
|
||||
const inputSubscription = context.inboundBus.subscribe((i) => {
|
||||
switch (i.kind) {
|
||||
case experimental.jobs.JobInboundMessageKind.Stop:
|
||||
case JobInboundMessageKind.Stop:
|
||||
// Run teardown logic then complete.
|
||||
tearingDown = true;
|
||||
Promise.all(teardownLogics.map((fn) => fn() || Promise.resolve())).then(
|
||||
@ -81,7 +82,7 @@ export function createBuilder<OptT = json.JsonObject, OutT extends BuilderOutput
|
||||
(err) => observer.error(err),
|
||||
);
|
||||
break;
|
||||
case experimental.jobs.JobInboundMessageKind.Input:
|
||||
case JobInboundMessageKind.Input:
|
||||
if (!tearingDown) {
|
||||
onInput(i.value);
|
||||
}
|
||||
|
@ -6,6 +6,10 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import * as jobs from './jobs';
|
||||
|
||||
export * from './api';
|
||||
export { Architect, ScheduleOptions } from './architect';
|
||||
export { createBuilder } from './create-builder';
|
||||
|
||||
export { jobs };
|
||||
|
@ -6,8 +6,9 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { experimental, json } from '@angular-devkit/core';
|
||||
import { json } from '@angular-devkit/core';
|
||||
import { BuilderInfo, BuilderInput, BuilderOutput, Target } from './api';
|
||||
import { JobDescription, JobHandler } from './jobs';
|
||||
|
||||
// Internal types that should not be exported directly. These are used by the host and architect
|
||||
// itself. Host implementations should import the host.ts file.
|
||||
@ -35,14 +36,14 @@ export const BuilderVersionSymbol = Symbol.for('@angular-devkit/architect:versio
|
||||
export type BuilderJobHandler<
|
||||
A extends json.JsonObject = json.JsonObject,
|
||||
I extends BuilderInput = BuilderInput,
|
||||
O extends BuilderOutput = BuilderOutput
|
||||
> = experimental.jobs.JobHandler<A, I, O> & { jobDescription: BuilderDescription };
|
||||
O extends BuilderOutput = BuilderOutput,
|
||||
> = JobHandler<A, I, O> & { jobDescription: BuilderDescription };
|
||||
|
||||
/**
|
||||
* A Builder description, which is used internally. Adds the builder info which is the
|
||||
* metadata attached to a builder in Architect.
|
||||
*/
|
||||
export interface BuilderDescription extends experimental.jobs.JobDescription {
|
||||
export interface BuilderDescription extends JobDescription {
|
||||
info: BuilderInfo;
|
||||
}
|
||||
|
||||
@ -51,7 +52,7 @@ export interface BuilderDescription extends experimental.jobs.JobDescription {
|
||||
*/
|
||||
export interface Builder<OptionT extends json.JsonObject = json.JsonObject> {
|
||||
// A fully compatible job handler.
|
||||
handler: experimental.jobs.JobHandler<json.JsonObject, BuilderInput, BuilderOutput>;
|
||||
handler: JobHandler<json.JsonObject, BuilderInput, BuilderOutput>;
|
||||
|
||||
// Metadata associated with this builder.
|
||||
[BuilderSymbol]: true;
|
||||
|
@ -205,9 +205,7 @@ declare const scheduler: jobs.Scheduler;
|
||||
const job = scheduler.schedule('count', 0);
|
||||
job.getChannel('side').subscribe((x) => console.log(x));
|
||||
// You can type a channel too. Messages will be filtered out.
|
||||
job
|
||||
.getChannel<number>('progress', { type: 'number' })
|
||||
.subscribe((x) => console.log(x));
|
||||
job.getChannel<number>('progress', { type: 'number' }).subscribe((x) => console.log(x));
|
||||
```
|
||||
|
||||
## <a name="Communicating"></a>Communicating With Jobs
|
@ -6,9 +6,9 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { JsonObject, JsonValue, schema } from '@angular-devkit/core';
|
||||
import { Observable, Observer } from 'rxjs';
|
||||
import { JsonObject, JsonValue, schema } from '../../json/index';
|
||||
import { DeepReadonly } from '../../utils/index';
|
||||
import { DeepReadonly } from './types';
|
||||
|
||||
/**
|
||||
* A job name is just a string (needs to be serializable).
|
||||
@ -21,7 +21,7 @@ export type JobName = string;
|
||||
export interface JobHandler<
|
||||
ArgT extends JsonValue,
|
||||
InputT extends JsonValue,
|
||||
OutputT extends JsonValue
|
||||
OutputT extends JsonValue,
|
||||
> {
|
||||
(argument: ArgT, context: JobHandlerContext<ArgT, InputT, OutputT>): Observable<
|
||||
JobOutboundMessage<OutputT>
|
||||
@ -36,7 +36,7 @@ export interface JobHandler<
|
||||
export interface JobHandlerContext<
|
||||
MinimumArgumentValueT extends JsonValue = JsonValue,
|
||||
MinimumInputValueT extends JsonValue = JsonValue,
|
||||
MinimumOutputValueT extends JsonValue = JsonValue
|
||||
MinimumOutputValueT extends JsonValue = JsonValue,
|
||||
> {
|
||||
readonly description: JobDescription;
|
||||
readonly scheduler: Scheduler<JsonValue, JsonValue, JsonValue>;
|
||||
@ -300,7 +300,7 @@ export enum JobState {
|
||||
export interface Job<
|
||||
ArgumentT extends JsonValue = JsonValue,
|
||||
InputT extends JsonValue = JsonValue,
|
||||
OutputT extends JsonValue = JsonValue
|
||||
OutputT extends JsonValue = JsonValue,
|
||||
> {
|
||||
/**
|
||||
* Description of the job. Resolving the job's description can be done asynchronously, so this
|
||||
@ -371,7 +371,7 @@ export interface ScheduleJobOptions {
|
||||
export interface Registry<
|
||||
MinimumArgumentValueT extends JsonValue = JsonValue,
|
||||
MinimumInputValueT extends JsonValue = JsonValue,
|
||||
MinimumOutputValueT extends JsonValue = JsonValue
|
||||
MinimumOutputValueT extends JsonValue = JsonValue,
|
||||
> {
|
||||
/**
|
||||
* Get a job handler.
|
||||
@ -388,7 +388,7 @@ export interface Registry<
|
||||
export interface Scheduler<
|
||||
MinimumArgumentValueT extends JsonValue = JsonValue,
|
||||
MinimumInputValueT extends JsonValue = JsonValue,
|
||||
MinimumOutputValueT extends JsonValue = JsonValue
|
||||
MinimumOutputValueT extends JsonValue = JsonValue,
|
||||
> {
|
||||
/**
|
||||
* Get a job description for a named job.
|
||||
@ -429,7 +429,7 @@ export interface Scheduler<
|
||||
schedule<
|
||||
A extends MinimumArgumentValueT,
|
||||
I extends MinimumInputValueT,
|
||||
O extends MinimumOutputValueT
|
||||
O extends MinimumOutputValueT,
|
||||
>(
|
||||
name: JobName,
|
||||
argument: A,
|
@ -6,12 +6,9 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { BaseException, JsonValue, isPromise, logging } from '@angular-devkit/core';
|
||||
import { Observable, Observer, Subject, Subscription, from, isObservable, of } from 'rxjs';
|
||||
import { switchMap, tap } from 'rxjs/operators';
|
||||
import { BaseException } from '../../exception';
|
||||
import { JsonValue } from '../../json/index';
|
||||
import { LoggerApi } from '../../logger';
|
||||
import { isPromise } from '../../utils/index';
|
||||
import {
|
||||
JobDescription,
|
||||
JobHandler,
|
||||
@ -182,7 +179,7 @@ export function createJobFactory<A extends JsonValue, I extends JsonValue, O ext
|
||||
*/
|
||||
export function createLoggerJob<A extends JsonValue, I extends JsonValue, O extends JsonValue>(
|
||||
job: JobHandler<A, I, O>,
|
||||
logger: LoggerApi,
|
||||
logger: logging.LoggerApi,
|
||||
): JobHandler<A, I, O> {
|
||||
const handler = (argument: A, context: JobHandlerContext<A, I, O>) => {
|
||||
context.inboundBus
|
@ -6,10 +6,10 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { JsonValue } from '../../json/index';
|
||||
import { Readwrite } from '../../utils/index';
|
||||
import { JsonValue } from '@angular-devkit/core';
|
||||
import { Job, JobDescription, JobHandler, JobHandlerContext, JobName, isJobHandler } from './api';
|
||||
import { JobDoesNotExistException } from './exception';
|
||||
import { Readwrite } from './types';
|
||||
|
||||
/**
|
||||
* A JobDispatcher can be used to dispatch between multiple jobs.
|
||||
@ -62,7 +62,7 @@ export function createDispatcher<A extends JsonValue, I extends JsonValue, O ext
|
||||
},
|
||||
);
|
||||
|
||||
return (Object.assign(job, {
|
||||
return Object.assign(job, {
|
||||
setDefaultJob(name: JobName | null | JobHandler<JsonValue, JsonValue, JsonValue>) {
|
||||
if (isJobHandler(name)) {
|
||||
name = name.jobDescription.name === undefined ? null : name.jobDescription.name;
|
||||
@ -74,5 +74,5 @@ export function createDispatcher<A extends JsonValue, I extends JsonValue, O ext
|
||||
conditionalDelegateList.push([predicate, name]);
|
||||
},
|
||||
// TODO: Remove return-only generic from createDispatcher() API.
|
||||
}) as unknown) as JobDispatcher<A, I, O>;
|
||||
}) as unknown as JobDispatcher<A, I, O>;
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { JsonValue } from '../../json';
|
||||
import { JsonValue } from '@angular-devkit/core';
|
||||
import { JobHandler } from './api';
|
||||
import { createJobHandler } from './create-job-handler';
|
||||
import { createDispatcher } from './dispatcher';
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { BaseException } from '../../exception';
|
||||
import { BaseException } from '@angular-devkit/core';
|
||||
import { JobName } from './api';
|
||||
|
||||
export class JobNameAlreadyRegisteredException extends BaseException {
|
@ -6,9 +6,9 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { JsonValue } from '@angular-devkit/core';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { concatMap, first } from 'rxjs/operators';
|
||||
import { JsonValue } from '../../json';
|
||||
import { JobHandler, JobName, Registry } from './api';
|
||||
|
||||
/**
|
||||
@ -17,8 +17,9 @@ import { JobHandler, JobName, Registry } from './api';
|
||||
export class FallbackRegistry<
|
||||
MinimumArgumentValueT extends JsonValue = JsonValue,
|
||||
MinimumInputValueT extends JsonValue = JsonValue,
|
||||
MinimumOutputValueT extends JsonValue = JsonValue
|
||||
> implements Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT> {
|
||||
MinimumOutputValueT extends JsonValue = JsonValue,
|
||||
> implements Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT>
|
||||
{
|
||||
constructor(
|
||||
protected _fallbacks: Registry<
|
||||
MinimumArgumentValueT,
|
||||
@ -34,7 +35,7 @@ export class FallbackRegistry<
|
||||
get<
|
||||
A extends MinimumArgumentValueT = MinimumArgumentValueT,
|
||||
I extends MinimumInputValueT = MinimumInputValueT,
|
||||
O extends MinimumOutputValueT = MinimumOutputValueT
|
||||
O extends MinimumOutputValueT = MinimumOutputValueT,
|
||||
>(name: JobName): Observable<JobHandler<A, I, O> | null> {
|
||||
return from(this._fallbacks).pipe(
|
||||
concatMap((fb) => fb.get<A, I, O>(name)),
|
@ -6,8 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { JsonValue, schema } from '@angular-devkit/core';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { JsonValue, schema } from '../../json';
|
||||
import { JobDescription, JobHandler, JobName, Registry, isJobHandler } from './api';
|
||||
import { JobNameAlreadyRegisteredException } from './exception';
|
||||
|
||||
@ -23,8 +23,9 @@ export interface RegisterJobOptions extends Partial<JobDescription> {}
|
||||
export class SimpleJobRegistry<
|
||||
MinimumArgumentValueT extends JsonValue = JsonValue,
|
||||
MinimumInputValueT extends JsonValue = JsonValue,
|
||||
MinimumOutputValueT extends JsonValue = JsonValue
|
||||
> implements Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT> {
|
||||
MinimumOutputValueT extends JsonValue = JsonValue,
|
||||
> implements Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT>
|
||||
{
|
||||
private _jobNames = new Map<
|
||||
JobName,
|
||||
JobHandler<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT>
|
||||
@ -33,9 +34,9 @@ export class SimpleJobRegistry<
|
||||
get<
|
||||
A extends MinimumArgumentValueT = MinimumArgumentValueT,
|
||||
I extends MinimumInputValueT = MinimumInputValueT,
|
||||
O extends MinimumOutputValueT = MinimumOutputValueT
|
||||
O extends MinimumOutputValueT = MinimumOutputValueT,
|
||||
>(name: JobName): Observable<JobHandler<A, I, O> | null> {
|
||||
return of(((this._jobNames.get(name) as unknown) as JobHandler<A, I, O> | null) || null);
|
||||
return of((this._jobNames.get(name) as unknown as JobHandler<A, I, O> | null) || null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -48,7 +49,7 @@ export class SimpleJobRegistry<
|
||||
register<
|
||||
A extends MinimumArgumentValueT,
|
||||
I extends MinimumInputValueT,
|
||||
O extends MinimumOutputValueT
|
||||
O extends MinimumOutputValueT,
|
||||
>(name: JobName, handler: JobHandler<A, I, O>, options?: RegisterJobOptions): void;
|
||||
|
||||
/**
|
||||
@ -96,7 +97,7 @@ export class SimpleJobRegistry<
|
||||
protected _register<
|
||||
ArgumentT extends JsonValue,
|
||||
InputT extends JsonValue,
|
||||
OutputT extends JsonValue
|
||||
OutputT extends JsonValue,
|
||||
>(
|
||||
name: JobName,
|
||||
handler: JobHandler<ArgumentT, InputT, OutputT>,
|
||||
@ -120,9 +121,9 @@ export class SimpleJobRegistry<
|
||||
input,
|
||||
};
|
||||
|
||||
const jobHandler = (Object.assign(handler.bind(undefined), {
|
||||
const jobHandler = Object.assign(handler.bind(undefined), {
|
||||
jobDescription,
|
||||
}) as unknown) as JobHandler<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT>;
|
||||
}) as unknown as JobHandler<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT>;
|
||||
this._jobNames.set(name, jobHandler);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { JsonValue, schema } from '@angular-devkit/core';
|
||||
import {
|
||||
EMPTY,
|
||||
MonoTypeOperatorFunction,
|
||||
@ -28,7 +29,6 @@ import {
|
||||
switchMap,
|
||||
tap,
|
||||
} from 'rxjs/operators';
|
||||
import { JsonValue, schema } from '../../json';
|
||||
import {
|
||||
Job,
|
||||
JobDescription,
|
||||
@ -121,8 +121,9 @@ function _jobShare<T>(): MonoTypeOperatorFunction<T> {
|
||||
export class SimpleScheduler<
|
||||
MinimumArgumentT extends JsonValue = JsonValue,
|
||||
MinimumInputT extends JsonValue = JsonValue,
|
||||
MinimumOutputT extends JsonValue = JsonValue
|
||||
> implements Scheduler<MinimumArgumentT, MinimumInputT, MinimumOutputT> {
|
||||
MinimumOutputT extends JsonValue = JsonValue,
|
||||
> implements Scheduler<MinimumArgumentT, MinimumInputT, MinimumOutputT>
|
||||
{
|
||||
private _internalJobDescriptionMap = new Map<JobName, JobHandlerWithExtra>();
|
||||
private _queue: (() => void)[] = [];
|
||||
private _pauseCounter = 0;
|
||||
@ -447,7 +448,7 @@ export class SimpleScheduler<
|
||||
let maybeObservable = channels.get(name);
|
||||
if (!maybeObservable) {
|
||||
const s = new Subject<T>();
|
||||
channelsSubject.set(name, (s as unknown) as Subject<JsonValue>);
|
||||
channelsSubject.set(name, s as unknown as Subject<JsonValue>);
|
||||
channels.set(name, s.asObservable());
|
||||
|
||||
maybeObservable = s.asObservable();
|
||||
@ -486,7 +487,7 @@ export class SimpleScheduler<
|
||||
protected _scheduleJob<
|
||||
A extends MinimumArgumentT,
|
||||
I extends MinimumInputT,
|
||||
O extends MinimumOutputT
|
||||
O extends MinimumOutputT,
|
||||
>(
|
||||
name: JobName,
|
||||
argument: A,
|
@ -6,9 +6,9 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { JsonObject, JsonValue, isJsonObject } from '@angular-devkit/core';
|
||||
import { Observable, Subject, concat, of } from 'rxjs';
|
||||
import { finalize, ignoreElements, share, shareReplay, tap } from 'rxjs/operators';
|
||||
import { JsonObject, JsonValue, isJsonObject } from '../../json';
|
||||
import {
|
||||
JobDescription,
|
||||
JobHandler,
|
26
packages/angular_devkit/architect/src/jobs/types.ts
Normal file
26
packages/angular_devkit/architect/src/jobs/types.ts
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @license
|
||||
* 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
|
||||
*/
|
||||
|
||||
export type DeepReadonly<T> = T extends (infer R)[]
|
||||
? DeepReadonlyArray<R>
|
||||
: T extends Function
|
||||
? T
|
||||
: T extends object
|
||||
? DeepReadonlyObject<T>
|
||||
: T;
|
||||
|
||||
// This should be ReadonlyArray but it has implications.
|
||||
export type DeepReadonlyArray<T> = Array<DeepReadonly<T>>;
|
||||
|
||||
export type DeepReadonlyObject<T> = {
|
||||
readonly [P in keyof T]: DeepReadonly<T[P]>;
|
||||
};
|
||||
|
||||
export type Readwrite<T> = {
|
||||
-readonly [P in keyof T]: T[P];
|
||||
};
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { analytics, experimental, json, logging } from '@angular-devkit/core';
|
||||
import { analytics, json, logging } from '@angular-devkit/core';
|
||||
import { EMPTY, Subscription } from 'rxjs';
|
||||
import { catchError, first, ignoreElements, map, shareReplay } from 'rxjs/operators';
|
||||
import {
|
||||
@ -18,6 +18,7 @@ import {
|
||||
Target,
|
||||
targetStringFromTarget,
|
||||
} from './api';
|
||||
import { JobOutboundMessageKind, JobState, Scheduler } from './jobs';
|
||||
|
||||
const progressSchema = require('./progress-schema.json');
|
||||
|
||||
@ -28,7 +29,7 @@ export async function scheduleByName(
|
||||
buildOptions: json.JsonObject,
|
||||
options: {
|
||||
target?: Target;
|
||||
scheduler: experimental.jobs.Scheduler;
|
||||
scheduler: Scheduler;
|
||||
logger: logging.LoggerApi;
|
||||
workspaceRoot: string | Promise<string>;
|
||||
currentDirectory: string | Promise<string>;
|
||||
@ -57,10 +58,10 @@ export async function scheduleByName(
|
||||
};
|
||||
|
||||
// Wait for the job to be ready.
|
||||
if (job.state !== experimental.jobs.JobState.Started) {
|
||||
if (job.state !== JobState.Started) {
|
||||
stateSubscription = job.outboundBus.subscribe(
|
||||
(event) => {
|
||||
if (event.kind === experimental.jobs.JobOutboundMessageKind.Start) {
|
||||
if (event.kind === JobOutboundMessageKind.Start) {
|
||||
job.input.next(message);
|
||||
}
|
||||
},
|
||||
@ -139,7 +140,7 @@ export async function scheduleByTarget(
|
||||
target: Target,
|
||||
overrides: json.JsonObject,
|
||||
options: {
|
||||
scheduler: experimental.jobs.Scheduler;
|
||||
scheduler: Scheduler;
|
||||
logger: logging.LoggerApi;
|
||||
workspaceRoot: string | Promise<string>;
|
||||
currentDirectory: string | Promise<string>;
|
||||
|
@ -87,8 +87,6 @@ pkg_npm(
|
||||
":README.md",
|
||||
":core",
|
||||
":license",
|
||||
":src/experimental/jobs/README.md",
|
||||
":src/experimental/jobs/architecture.md",
|
||||
"//packages/angular_devkit/core/node",
|
||||
"//packages/angular_devkit/core/node:package.json",
|
||||
"//packages/angular_devkit/core/node/testing",
|
||||
|
@ -48,7 +48,6 @@ ts_library(
|
||||
deps = [
|
||||
":node",
|
||||
"//packages/angular_devkit/core",
|
||||
"//tests/angular_devkit/core/node/jobs:jobs_test_lib",
|
||||
"@npm//rxjs",
|
||||
],
|
||||
)
|
||||
|
@ -1,11 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* 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
|
||||
*/
|
||||
|
||||
import * as jobs from './jobs';
|
||||
|
||||
export { jobs };
|
@ -1,9 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* 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
|
||||
*/
|
||||
|
||||
export * from './job-registry';
|
@ -6,9 +6,5 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import * as experimental from './experimental/jobs/job-registry';
|
||||
|
||||
export * from './cli-logger';
|
||||
export * from './host';
|
||||
|
||||
export { experimental };
|
||||
|
@ -1,11 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* 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
|
||||
*/
|
||||
|
||||
import * as jobs from './experimental/jobs/index';
|
||||
|
||||
export { jobs };
|
@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
import * as analytics from './analytics';
|
||||
import * as experimental from './experimental';
|
||||
import * as json from './json/index';
|
||||
import * as logging from './logger/index';
|
||||
import * as workspaces from './workspace';
|
||||
@ -17,4 +16,4 @@ export * from './json/index';
|
||||
export * from './utils/index';
|
||||
export * from './virtual-fs/index';
|
||||
|
||||
export { analytics, experimental, json, logging, workspaces };
|
||||
export { analytics, json, logging, workspaces };
|
||||
|
@ -16,23 +16,3 @@ export * from './priority-queue';
|
||||
export * from './lang';
|
||||
|
||||
export { tags, strings };
|
||||
|
||||
export type DeepReadonly<T> = T extends (infer R)[]
|
||||
? DeepReadonlyArray<R>
|
||||
: T extends Function
|
||||
? T
|
||||
: T extends object
|
||||
? DeepReadonlyObject<T>
|
||||
: T;
|
||||
|
||||
// This should be ReadonlyArray but it has implications.
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface DeepReadonlyArray<T> extends Array<DeepReadonly<T>> {}
|
||||
|
||||
export type DeepReadonlyObject<T> = {
|
||||
readonly [P in keyof T]: DeepReadonly<T[P]>;
|
||||
};
|
||||
|
||||
export type Readwrite<T> = {
|
||||
-readonly [P in keyof T]: T[P];
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ ts_library(
|
||||
],
|
||||
),
|
||||
deps = [
|
||||
"//packages/angular_devkit/core",
|
||||
"//packages/angular_devkit/architect",
|
||||
"@npm//@types/node",
|
||||
],
|
||||
)
|
20
tests/angular_devkit/architect/node/jobs/add.ts
Normal file
20
tests/angular_devkit/architect/node/jobs/add.ts
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @license
|
||||
* 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
|
||||
*/
|
||||
|
||||
import { jobs } from '@angular-devkit/architect';
|
||||
|
||||
// Export the job using a createJob. We use our own spec file here to do the job.
|
||||
export default jobs.createJobHandler<number[], null, number>(
|
||||
(input) => {
|
||||
return input.reduce((a, c) => a + c, 0);
|
||||
},
|
||||
{
|
||||
input: { items: { type: 'number' } },
|
||||
output: { type: 'number' },
|
||||
},
|
||||
);
|
@ -1,19 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* 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
|
||||
*/
|
||||
|
||||
// tslint:disable:no-global-tslint-disable
|
||||
// tslint:disable:no-implicit-dependencies
|
||||
import { experimental } from '@angular-devkit/core';
|
||||
|
||||
// Export the job using a createJob. We use our own spec file here to do the job.
|
||||
export default experimental.jobs.createJobHandler<number[], null, number>(input => {
|
||||
return input.reduce((a, c) => a + c, 0);
|
||||
}, {
|
||||
input: { items: { type: 'number' } },
|
||||
output: { type: 'number' },
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user