Skip to content

Commit 722f079

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 bd9e4a4 commit 722f079

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-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: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ export class SimpleScheduler<
145145
return of(null);
146146
}
147147

148+
console.log(handler.jobDescription.input);
148149
const description: JobDescription = {
149150
// Make a copy of it to be sure it's proper JSON.
150151
...(JSON.parse(JSON.stringify(handler.jobDescription)) as JobDescription),
@@ -155,11 +156,22 @@ export class SimpleScheduler<
155156
channels: handler.jobDescription.channels || {},
156157
};
157158

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

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

0 commit comments

Comments
 (0)