Skip to content

Commit

Permalink
refactor: update validation package
Browse files Browse the repository at this point in the history
  • Loading branch information
devcatalin committed Oct 24, 2023
1 parent 95f254b commit 895d6cf
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 51 deletions.
86 changes: 60 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"@kubernetes/client-node": "0.19.0",
"@monokle/components": "1.7.0",
"@monokle/synchronizer": "^0.6.0",
"@monokle/validation": "0.24.2",
"@monokle/validation": "0.31.5",
"@open-policy-agent/opa-wasm": "1.8.0",
"@reduxjs/toolkit": "1.9.5",
"@rjsf/antd": "5.8.1",
Expand Down
6 changes: 0 additions & 6 deletions src/redux/validation/validation.loader.ts

This file was deleted.

7 changes: 2 additions & 5 deletions src/redux/validation/validation.worker.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/// <reference lib="webworker" />
import {WorkerMessage, matchWorkerEvent} from '@utils/worker';

import {ResourceParser, SchemaLoader, createExtensibleMonokleValidator} from '@monokle/validation';
import {createDefaultMonokleValidator} from '@monokle/validation';

import {validationCustomPluginLoader} from './validation.loader';
import {
LoadValidationMessage,
LoadValidationMessageType,
Expand All @@ -13,9 +12,7 @@ import {
RunValidationMessageType,
} from './validation.worker.types';

const RESOURCE_PARSER = new ResourceParser();
const SCHEMA_LOADER = new SchemaLoader();
const VALIDATOR = createExtensibleMonokleValidator(RESOURCE_PARSER, SCHEMA_LOADER, validationCustomPluginLoader);
const VALIDATOR = createDefaultMonokleValidator();

const handleEvent = <Message extends WorkerMessage>(
event: MessageEvent,
Expand Down
15 changes: 2 additions & 13 deletions src/redux/validation/validator.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import log from 'loglevel';

import {RESOURCE_PARSER} from '@redux/parsing/resourceParser';

import {createWorkerEventPromise} from '@utils/worker';

import {CustomSchema, MonokleValidator, SchemaLoader, createExtensibleMonokleValidator} from '@monokle/validation';
import {CustomSchema, MonokleValidator, SchemaLoader, createDefaultMonokleValidator} from '@monokle/validation';

import {validationCustomPluginLoader} from './validation.loader';
import {
LoadValidationMessage,
LoadValidationMessageType,
Expand All @@ -24,11 +21,7 @@ class ValidationWorker {

constructor() {
this.#worker = new Worker(new URL('./validation.worker', import.meta.url));
this.#validator = createExtensibleMonokleValidator(
RESOURCE_PARSER.getParser(),
SCHEMA_LOADER,
validationCustomPluginLoader
);
this.#validator = createDefaultMonokleValidator();
}

get metadata() {
Expand Down Expand Up @@ -73,10 +66,6 @@ class ValidationWorker {
});
}

isRuleEnabled(rule: string) {
return this.#validator.isRuleEnabled(rule);
}

getPlugin(name: string) {
return this.#validator.getPlugin(name);
}
Expand Down

0 comments on commit 895d6cf

Please sign in to comment.