Skip to content

Commit bf2f5a8

Browse files
committed
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.
1 parent c4efd74 commit bf2f5a8

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

packages/angular_devkit/architect/src/architect.ts

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ import {
4848
import { mergeOptions } from './options';
4949
import { scheduleByName, scheduleByTarget } from './schedule-by-name';
5050

51-
const inputSchema = require('./input-schema.json');
52-
const outputSchema = require('./output-schema.json');
53-
5451
function _createJobHandlerFromBuilderInfo(
5552
info: BuilderInfo,
5653
target: Target | undefined,
@@ -60,9 +57,9 @@ function _createJobHandlerFromBuilderInfo(
6057
): Observable<BuilderJobHandler> {
6158
const jobDescription: BuilderDescription = {
6259
name: target ? `{${targetStringFromTarget(target)}}` : info.builderName,
63-
argument: { type: 'object' },
64-
input: inputSchema,
65-
output: outputSchema,
60+
argument: true,
61+
input: true,
62+
output: true,
6663
info,
6764
};
6865

@@ -279,8 +276,6 @@ function _getTargetOptionsFactory(host: ArchitectHost) {
279276
},
280277
{
281278
name: '..getTargetOptions',
282-
output: { type: 'object' },
283-
argument: inputSchema.properties.target,
284279
},
285280
);
286281
}
@@ -298,10 +293,6 @@ function _getProjectMetadataFactory(host: ArchitectHost) {
298293
},
299294
{
300295
name: '..getProjectMetadata',
301-
output: { type: 'object' },
302-
argument: {
303-
oneOf: [{ type: 'string' }, inputSchema.properties.target],
304-
},
305296
},
306297
);
307298
}
@@ -318,8 +309,6 @@ function _getBuilderNameForTargetFactory(host: ArchitectHost) {
318309
},
319310
{
320311
name: '..getBuilderNameForTarget',
321-
output: { type: 'string' },
322-
argument: inputSchema.properties.target,
323312
},
324313
);
325314
}
@@ -344,11 +333,6 @@ function _validateOptionsFactory(host: ArchitectHost, registry: json.schema.Sche
344333
},
345334
{
346335
name: '..validateOptions',
347-
output: { type: 'object' },
348-
argument: {
349-
type: 'array',
350-
items: [{ type: 'string' }, { type: 'object' }],
351-
},
352336
},
353337
);
354338
}

packages/angular_devkit/architect/src/jobs/simple-scheduler.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,22 @@ export class SimpleScheduler<
155155
channels: handler.jobDescription.channels || {},
156156
};
157157

158+
const noopValidator = noopSchemaValidator();
159+
158160
const handlerWithExtra = Object.assign(handler.bind(undefined), {
159161
jobDescription: description,
160-
argumentV: this._schemaRegistry.compile(description.argument),
161-
inputV: this._schemaRegistry.compile(description.input),
162-
outputV: this._schemaRegistry.compile(description.output),
162+
argumentV:
163+
description.argument === true
164+
? noopValidator
165+
: this._schemaRegistry.compile(description.argument),
166+
inputV:
167+
description.input === true
168+
? noopValidator
169+
: this._schemaRegistry.compile(description.input),
170+
outputV:
171+
description.output === true
172+
? noopValidator
173+
: this._schemaRegistry.compile(description.output),
163174
}) as JobHandlerWithExtra;
164175
this._internalJobDescriptionMap.set(name, handlerWithExtra);
165176

@@ -546,3 +557,10 @@ export class SimpleScheduler<
546557
return this._createJob(name, argument, handler, inboundBus, outboundBus);
547558
}
548559
}
560+
561+
async function noopSchemaValidator(): Promise<schema.SchemaValidator> {
562+
return async (data: JsonValue) => ({
563+
data,
564+
success: true,
565+
});
566+
}

0 commit comments

Comments
 (0)