Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions packages/angular_devkit/architect/src/architect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ import {
import { mergeOptions } from './options';
import { scheduleByName, scheduleByTarget } from './schedule-by-name';

const inputSchema = require('./input-schema.json');
const outputSchema = require('./output-schema.json');

function _createJobHandlerFromBuilderInfo(
info: BuilderInfo,
target: Target | undefined,
Expand All @@ -60,9 +57,9 @@ function _createJobHandlerFromBuilderInfo(
): Observable<BuilderJobHandler> {
const jobDescription: BuilderDescription = {
name: target ? `{${targetStringFromTarget(target)}}` : info.builderName,
argument: { type: 'object' },
input: inputSchema,
output: outputSchema,
argument: true,
input: true,
output: true,
info,
};

Expand Down Expand Up @@ -279,8 +276,6 @@ function _getTargetOptionsFactory(host: ArchitectHost) {
},
{
name: '..getTargetOptions',
output: { type: 'object' },
argument: inputSchema.properties.target,
},
);
}
Expand All @@ -298,10 +293,6 @@ function _getProjectMetadataFactory(host: ArchitectHost) {
},
{
name: '..getProjectMetadata',
output: { type: 'object' },
argument: {
oneOf: [{ type: 'string' }, inputSchema.properties.target],
},
},
);
}
Expand All @@ -318,8 +309,6 @@ function _getBuilderNameForTargetFactory(host: ArchitectHost) {
},
{
name: '..getBuilderNameForTarget',
output: { type: 'string' },
argument: inputSchema.properties.target,
},
);
}
Expand All @@ -344,11 +333,6 @@ function _validateOptionsFactory(host: ArchitectHost, registry: json.schema.Sche
},
{
name: '..validateOptions',
output: { type: 'object' },
argument: {
type: 'array',
items: [{ type: 'string' }, { type: 'object' }],
},
},
);
}
Expand Down
24 changes: 21 additions & 3 deletions packages/angular_devkit/architect/src/jobs/simple-scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,22 @@ export class SimpleScheduler<
channels: handler.jobDescription.channels || {},
};

const noopValidator = noopSchemaValidator();

const handlerWithExtra = Object.assign(handler.bind(undefined), {
jobDescription: description,
argumentV: this._schemaRegistry.compile(description.argument),
inputV: this._schemaRegistry.compile(description.input),
outputV: this._schemaRegistry.compile(description.output),
argumentV:
description.argument === true
? noopValidator
: this._schemaRegistry.compile(description.argument),
inputV:
description.input === true
? noopValidator
: this._schemaRegistry.compile(description.input),
outputV:
description.output === true
? noopValidator
: this._schemaRegistry.compile(description.output),
}) as JobHandlerWithExtra;
this._internalJobDescriptionMap.set(name, handlerWithExtra);

Expand Down Expand Up @@ -546,3 +557,10 @@ export class SimpleScheduler<
return this._createJob(name, argument, handler, inboundBus, outboundBus);
}
}

async function noopSchemaValidator(): Promise<schema.SchemaValidator> {
return async (data: JsonValue) => ({
data,
success: true,
});
}