All files / commands/validation validate-profile.ts

0% Statements 0/9
0% Branches 0/2
0% Functions 0/1
0% Lines 0/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                                                                 
import { container } from 'tsyringe';
import { IWorkspaceFileService, IWorkspaceIndexerService } from '@src/services/core';
import { ServiceToken } from '@src/services/tokens';
import { ShaclValidationService } from '@src/services/validation/shacl-validation-service';
import { reportProfileValidation } from './shacl-validation-report';
 
/**
 * Validates every workspace file matched by a single validation profile against
 * that profile's shape graphs. Invoked from the play button on a profile row.
 */
export const validateProfile = {
	id: 'mentor.command.validateProfile',
	handler: async (profileId: string) => {
		if (!profileId) {
			return;
		}
 
		// Wait for background indexing so shape graphs and document contexts exist.
		const indexerService = container.resolve<IWorkspaceIndexerService>(ServiceToken.WorkspaceIndexerService);
		await indexerService.waitForIndexed();
 
		const validationService = container.resolve<ShaclValidationService>(ServiceToken.ShaclValidationService);
		const fileService = container.resolve<IWorkspaceFileService>(ServiceToken.WorkspaceFileService);
 
		// Progress and cancellation are shown on the validation status bar item; here we just
		// run the batch and report the final outcome. Explicit runs validate every matched
		// file regardless of size (skipLargeGraphs: false).
		const summary = await validationService.validateProfile(profileId, fileService.files, { skipLargeGraphs: false });
 
		await reportProfileValidation(summary, 'SHACL validation: no files match this profile.');
	}
};