core: schemastery validator

This commit is contained in:
undefined committed 2022-07-31 23:53:49 +08:00
1 parent 2d4d99c80c
commit 1f113e7a08
17 files changed
+145 -136

No files matched your search

+6 -10
View File
@@ -1,6 +1,7 @@
/* eslint-disable no-await-in-loop */
import { omit } from 'lodash';
import { Index, MeiliSearch } from 'meilisearch';
import { addScript, Schema } from 'hydrooj';
import DomainModel from 'hydrooj/src/model/domain';
import ProblemModel from 'hydrooj/src/model/problem';
import * as system from 'hydrooj/src/model/system';
@@ -50,15 +51,6 @@ global.Hydro.lib.problemSearch = async (domainId, q, opts) => {
};
};
export const description = 'Meilisearch reindex';
export const validate = {
$or: [
{ domainId: 'string' },
{ domainId: 'undefined' },
],
};
async function waitForTask(id: number) {
// eslint-disable-next-line no-constant-condition
while (true) {
@@ -109,4 +101,8 @@ export async function run(_, report) {
return true;
}
global.Hydro.script.ensureMeiliSearch = { run, description, validate };
addScript('ensureMeiliSearch', 'Meilisearch reindex')
.args(Schema.object({
domainId: Schema.string(),
}))
.action(run);