core: add contest/edit and contest/del hook

This commit is contained in:
undefined committed 2024-07-23 01:40:39 +08:00
1 parent c9d10a97a2
commit 413464163c
7 files changed
+21 -16

No files matched your search

+3 -3
View File
@@ -5,14 +5,14 @@
"main": "react.yaml",
"dependencies": {
"@stylistic/eslint-plugin": "^2.3.0",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-plugin-github": "^5.0.1",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jsx-a11y": "^6.9.0",
"eslint-plugin-react": "^7.34.4",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-simple-import-sort": "^12.1.1"
},
+1 -1
View File
@@ -7,7 +7,7 @@
"node": ">=16"
},
"dependencies": {
"esbuild": "0.21.4",
"esbuild": "0.23.0",
"source-map-support": "^0.5.21"
},
"devDependencies": {
+3 -3
View File
@@ -44,18 +44,18 @@
"chai": "^5.1.1",
"cross-env": "^7.0.3",
"cross-spawn": "^7.0.3",
"esbuild": "0.21.4",
"esbuild": "0.23.0",
"eslint": "^8.57.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-import-resolver-webpack": "^0.13.8",
"fs-extra": "^11.2.0",
"globby": "^14.0.2",
"inspectpack": "^4.7.1",
"mongodb-memory-server": "^9.4.1",
"mongodb-memory-server": "^10.0.0",
"nyc": "^17.0.0",
"ora": "^8.0.1",
"package-json": "^10.0.1",
"semver": "^7.6.2",
"semver": "^7.6.3",
"simple-git": "^3.25.0",
"supertest": "^7.0.0",
"typescript": "5.3.3",
+2 -2
View File
@@ -22,10 +22,10 @@ if (!argv.args[0] || argv.args[0] === 'cli') {
const addons = getAddons();
for (const i of addons) {
try {
require(`${i}/command.ts`).apply(cli);
require(`${i}/command.ts`).register(cli);
} catch (e) {
try {
require(`${i}/command.js`).apply(cli);
require(`${i}/command.js`).register(cli);
} catch (err) { }
}
}
+6 -6
View File
@@ -12,10 +12,10 @@
},
"preferUnplugged": true,
"dependencies": {
"@aws-sdk/client-s3": "3.614.0",
"@aws-sdk/lib-storage": "3.614.0",
"@aws-sdk/s3-presigned-post": "3.614.0",
"@aws-sdk/s3-request-presigner": "3.614.0",
"@aws-sdk/client-s3": "3.616.0",
"@aws-sdk/lib-storage": "3.616.0",
"@aws-sdk/s3-presigned-post": "3.616.0",
"@aws-sdk/s3-request-presigner": "3.616.0",
"@graphql-tools/schema": "^10.0.4",
"@hydrooj/framework": "workspace:^",
"@hydrooj/utils": "workspace:^",
@@ -46,7 +46,7 @@
"sanitize-filename": "^1.6.3",
"saslprep": "^1.0.3",
"schemastery": "^3.14.6",
"semver": "^7.6.2",
"semver": "^7.6.3",
"shorty.js": "^1.0.1",
"superagent": "^9.0.2",
"tar": "6.2.1",
@@ -57,7 +57,7 @@
"@types/fs-extra": "^11.0.4",
"@types/js-yaml": "^4.0.9",
"@types/koa-static-cache": "^5.1.4",
"@types/lodash": "^4.17.6",
"@types/lodash": "^4.17.7",
"@types/mime-types": "^2.1.4",
"@types/mongodb-uri": "^0.9.4",
"@types/nodemailer": "^6.4.15",
+4 -1
View File
@@ -795,11 +795,14 @@ export async function edit(domainId: string, tid: ObjectId, $set: Partial<Tdoc>)
const tdoc = await document.get(domainId, document.TYPE_CONTEST, tid);
if (!tdoc) throw new ContestNotFoundError(domainId, tid);
RULES[$set.rule || tdoc.rule].check(Object.assign(tdoc, $set));
return await document.set(domainId, document.TYPE_CONTEST, tid, $set);
const res = await document.set(domainId, document.TYPE_CONTEST, tid, $set);
await bus.parallel('contest/edit', res);
return res;
}
export async function del(domainId: string, tid: ObjectId) {
await Promise.all([
bus.parallel('contest/del', domainId, tid),
document.deleteOne(domainId, document.TYPE_CONTEST, tid),
document.deleteMultiStatus(domainId, document.TYPE_CONTEST, { docId: tid }),
]);
+2
View File
@@ -83,9 +83,11 @@ export interface EventMap extends KnownHandlerEvents {
'contest/before-add': (payload: Partial<Tdoc>) => VoidReturn
'contest/add': (payload: Partial<Tdoc>, id: ObjectId) => VoidReturn
'contest/edit': (payload: Tdoc) => VoidReturn
'contest/list': (query: Filter<Tdoc>, handler: any) => VoidReturn
'contest/scoreboard': (tdoc: Tdoc, rows: ScoreboardRow[], udict: BaseUserDict, pdict: ProblemDict) => VoidReturn
'contest/balloon': (domainId: string, tid: ObjectId, bdoc: ContestBalloonDoc) => VoidReturn
'contest/del': (domainId: string, tid: ObjectId) => VoidReturn
'oplog/log': (type: string, handler: Handler, args: any, data: any) => VoidReturn;