feat(阶段1): monorepo 骨架与 @oj2/contract 契约包

This commit is contained in:
2026-08-06 20:39:39 -06:00
parent 39ad431e31
commit 9bfe629cd7
8 changed files with 99 additions and 0 deletions

35
bun.lock Normal file
View File

@@ -0,0 +1,35 @@
{
"lockfileVersion": 1,
"configVersion": 1,
"workspaces": {
"": {
"name": "oj2",
"devDependencies": {
"@types/bun": "latest",
"typescript": "^5.7.0",
},
},
"packages/contract": {
"name": "@oj2/contract",
"version": "0.0.0",
"dependencies": {
"zod": "^4.0.0",
},
},
},
"packages": {
"@oj2/contract": ["@oj2/contract@workspace:packages/contract"],
"@types/bun": ["@types/bun@1.3.14", "", { "dependencies": { "bun-types": "1.3.14" } }, "sha512-h1hFqFVcvAvD9j9K7ZW7vd82aSA+rTdznZa+5bwvCwqSB1jmmfLcbIWhOLx1/+boy/xmjgCs/OMUL8hRJSmnPw=="],
"@types/node": ["@types/node@26.1.2", "", { "dependencies": { "undici-types": "~8.3.0" } }, "sha512-Vu4a5UFA9rIIFJ7rB/Vaafh9lrCQszopTCx6KjFboXTGQbPNasehVR5TEiithSDGyd1DEiUByggTZsg8jukeIg=="],
"bun-types": ["bun-types@1.3.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-4N0ig0fEomHt5R0KCFWjovxow98rIoRwKolrYdCcknNwMekCXRnWEUvgu5soYV8QXtVsrUD8B95MBOZGPvr6KQ=="],
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
"undici-types": ["undici-types@8.3.0", "", {}, "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ=="],
"zod": ["zod@4.4.3", "", {}, "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ=="],
}
}

3
bunfig.toml Normal file
View File

@@ -0,0 +1,3 @@
[install]
# workspace 内部依赖走本地链接,不去 registry 找
linker = "hoisted"

17
package.json Normal file
View File

@@ -0,0 +1,17 @@
{
"name": "oj2",
"private": true,
"type": "module",
"workspaces": ["apps/*", "packages/*"],
"scripts": {
"dev": "bun run --filter '*' dev",
"dev:api": "bun run --filter '@oj2/api' dev",
"dev:web": "bun run --filter '@oj2/web' dev",
"db:up": "docker compose -f docker/compose.dev.yml up -d",
"db:down": "docker compose -f docker/compose.dev.yml down"
},
"devDependencies": {
"typescript": "^5.7.0",
"@types/bun": "latest"
}
}

View File

@@ -0,0 +1,12 @@
{
"name": "@oj2/contract",
"version": "0.0.0",
"private": true,
"type": "module",
"main": "./src/index.ts",
"types": "./src/index.ts",
"exports": { ".": "./src/index.ts" },
"dependencies": {
"zod": "^4.0.0"
}
}

View File

@@ -0,0 +1 @@
export * from "./problem"

View File

@@ -0,0 +1,13 @@
import { z } from "zod"
/** 题目列表项。字段取自 problem 表,只含列表页需要的列。 */
export const problemSummarySchema = z.object({
id: z.number().int(),
_id: z.string(), // 展示用编号,与自增 id 不同
title: z.string(),
difficulty: z.string(),
submissionNumber: z.number().int(),
acceptedNumber: z.number().int(),
})
export type ProblemSummary = z.infer<typeof problemSummarySchema>

View File

@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["src"]
}

14
tsconfig.base.json Normal file
View File

@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"lib": ["ESNext", "DOM"],
"strict": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"types": ["bun"]
}
}