From 9420461711725ae7c041259c3ab6ef34477fcf57 Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Fri, 23 May 2025 09:45:38 +0000 Subject: [PATCH] refactor(@angular-devkit/architect): remove redundant internal job schema validation Removed JSON schema-based validation for internal job arguments, inputs, and outputs in architect builder jobs. This validation applied to internal architect values. Builder option validation remains unaffected. Eliminating this validation reduces overhead from costly RxJS operations, improving performance, especially for builders producing large outputs that were previously delayed by this processing. --- .../angular_devkit/architect/src/architect.ts | 22 +++-------------- .../architect/src/jobs/simple-scheduler.ts | 24 ++++++++++++++++--- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/packages/angular_devkit/architect/src/architect.ts b/packages/angular_devkit/architect/src/architect.ts index aecbeb06ea05..6dbf97cb5179 100644 --- a/packages/angular_devkit/architect/src/architect.ts +++ b/packages/angular_devkit/architect/src/architect.ts @@ -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, @@ -60,9 +57,9 @@ function _createJobHandlerFromBuilderInfo( ): Observable { const jobDescription: BuilderDescription = { name: target ? `{${targetStringFromTarget(target)}}` : info.builderName, - argument: { type: 'object' }, - input: inputSchema, - output: outputSchema, + argument: true, + input: true, + output: true, info, }; @@ -279,8 +276,6 @@ function _getTargetOptionsFactory(host: ArchitectHost) { }, { name: '..getTargetOptions', - output: { type: 'object' }, - argument: inputSchema.properties.target, }, ); } @@ -298,10 +293,6 @@ function _getProjectMetadataFactory(host: ArchitectHost) { }, { name: '..getProjectMetadata', - output: { type: 'object' }, - argument: { - oneOf: [{ type: 'string' }, inputSchema.properties.target], - }, }, ); } @@ -318,8 +309,6 @@ function _getBuilderNameForTargetFactory(host: ArchitectHost) { }, { name: '..getBuilderNameForTarget', - output: { type: 'string' }, - argument: inputSchema.properties.target, }, ); } @@ -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' }], - }, }, ); } diff --git a/packages/angular_devkit/architect/src/jobs/simple-scheduler.ts b/packages/angular_devkit/architect/src/jobs/simple-scheduler.ts index 2c82b0d90052..8dacbbe687f8 100644 --- a/packages/angular_devkit/architect/src/jobs/simple-scheduler.ts +++ b/packages/angular_devkit/architect/src/jobs/simple-scheduler.ts @@ -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); @@ -546,3 +557,10 @@ export class SimpleScheduler< return this._createJob(name, argument, handler, inboundBus, outboundBus); } } + +async function noopSchemaValidator(): Promise { + return async (data: JsonValue) => ({ + data, + success: true, + }); +}