From 394b73505effcc973569d7c22c495849968d6c30 Mon Sep 17 00:00:00 2001 From: alikia2x Date: Fri, 19 Sep 2025 21:31:55 +0800 Subject: [PATCH] add: the drizzle stuff into @core and a todo for new bilibili API, update the .gitignore. --- .gitignore | 4 +- bun.lock | 77 +- .../drizzle/cred/0000_moaning_shotgun.sql | 44 + .../core/drizzle/cred/meta/0000_snapshot.json | 350 +++++ packages/core/drizzle/cred/meta/_journal.json | 13 + packages/core/drizzle/cred/relations.ts | 2 + packages/core/drizzle/cred/schema.ts | 93 ++ packages/core/drizzle/drizzle-cred.config.ts | 9 + packages/core/drizzle/drizzle-main.config.ts | 10 + packages/core/drizzle/index.ts | 7 + .../main/0000_aspiring_mikhail_rasputin.sql | 153 ++ .../core/drizzle/main/meta/0000_snapshot.json | 1388 +++++++++++++++++ packages/core/drizzle/main/meta/_journal.json | 13 + packages/core/drizzle/main/relations.ts | 3 + packages/core/drizzle/main/schema.ts | 174 +++ packages/core/drizzle/outerSchema.d.ts | 10 + packages/core/package.json | 4 +- packages/crawler/net/bulkGetVideoStats.ts | 1 + .../.react-router/types/+future.ts | 9 + .../.react-router/types/+routes.ts | 36 + .../.react-router/types/+server-build.d.ts | 17 + .../.react-router/types/app/+types/root.ts | 59 + .../types/app/routes/+types/home.ts | 62 + .../types/app/routes/song/[id]/+types/info.ts | 62 + packages/temp_frontend/meili/VERSION | 1 + packages/temp_frontend/meili/auth/data.mdb | Bin 0 -> 229376 bytes packages/temp_frontend/meili/auth/lock.mdb | Bin 0 -> 8192 bytes packages/temp_frontend/meili/instance-uid | 1 + packages/temp_frontend/meili/tasks/data.mdb | Bin 0 -> 147456 bytes packages/temp_frontend/meili/tasks/lock.mdb | Bin 0 -> 8192 bytes 30 files changed, 2597 insertions(+), 5 deletions(-) create mode 100644 packages/core/drizzle/cred/0000_moaning_shotgun.sql create mode 100644 packages/core/drizzle/cred/meta/0000_snapshot.json create mode 100644 packages/core/drizzle/cred/meta/_journal.json create mode 100644 packages/core/drizzle/cred/relations.ts create mode 100644 packages/core/drizzle/cred/schema.ts create mode 100644 packages/core/drizzle/drizzle-cred.config.ts create mode 100644 packages/core/drizzle/drizzle-main.config.ts create mode 100644 packages/core/drizzle/index.ts create mode 100644 packages/core/drizzle/main/0000_aspiring_mikhail_rasputin.sql create mode 100644 packages/core/drizzle/main/meta/0000_snapshot.json create mode 100644 packages/core/drizzle/main/meta/_journal.json create mode 100644 packages/core/drizzle/main/relations.ts create mode 100644 packages/core/drizzle/main/schema.ts create mode 100644 packages/core/drizzle/outerSchema.d.ts create mode 100644 packages/temp_frontend/.react-router/types/+future.ts create mode 100644 packages/temp_frontend/.react-router/types/+routes.ts create mode 100644 packages/temp_frontend/.react-router/types/+server-build.d.ts create mode 100644 packages/temp_frontend/.react-router/types/app/+types/root.ts create mode 100644 packages/temp_frontend/.react-router/types/app/routes/+types/home.ts create mode 100644 packages/temp_frontend/.react-router/types/app/routes/song/[id]/+types/info.ts create mode 100644 packages/temp_frontend/meili/VERSION create mode 100644 packages/temp_frontend/meili/auth/data.mdb create mode 100644 packages/temp_frontend/meili/auth/lock.mdb create mode 100644 packages/temp_frontend/meili/instance-uid create mode 100644 packages/temp_frontend/meili/tasks/data.mdb create mode 100644 packages/temp_frontend/meili/tasks/lock.mdb diff --git a/.gitignore b/.gitignore index c0bff53..5dd5b52 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,6 @@ build/ docker-compose.yml -ucaptcha-config.yaml \ No newline at end of file +ucaptcha-config.yaml + +temp/ \ No newline at end of file diff --git a/bun.lock b/bun.lock index d5c519a..aaf7cb5 100644 --- a/bun.lock +++ b/bun.lock @@ -17,7 +17,7 @@ }, "packages/backend": { "name": "@cvsa/backend", - "version": "0.5.3", + "version": "0.6.0", "dependencies": { "@koshnic/ratelimit": "^1.0.3", "@rabbit-company/argon2id": "^2.1.0", @@ -38,10 +38,11 @@ }, "packages/core": { "name": "@cvsa/core", - "version": "0.0.5", + "version": "0.0.10", "dependencies": { "@koshnic/ratelimit": "^1.0.3", "chalk": "^5.4.1", + "drizzle-orm": "^0.44.4", "ioredis": "^5.6.1", "logform": "^2.7.0", "postgres": "^3.4.5", @@ -49,10 +50,12 @@ }, "devDependencies": { "@types/ioredis": "^5.0.0", + "drizzle-kit": "^0.31.4", }, }, "packages/crawler": { "name": "crawler", + "version": "1.3.0", "dependencies": { "@bull-board/api": "^6.9.5", "@bull-board/express": "^6.9.5", @@ -69,7 +72,7 @@ }, "packages/frontend": { "name": "frontend", - "version": "0.0.1", + "version": "1.9.0", "dependencies": { "@astrojs/node": "^9.1.3", "@astrojs/svelte": "^7.0.9", @@ -135,8 +138,14 @@ "@dabh/diagnostics": ["@dabh/diagnostics@2.0.3", "", { "dependencies": { "colorspace": "1.1.x", "enabled": "2.0.x", "kuler": "^2.0.0" } }, "sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA=="], + "@drizzle-team/brocli": ["@drizzle-team/brocli@0.10.2", "", {}, "sha512-z33Il7l5dKjUgGULTqBsQBQwckHh5AbIuxhdsIxDDiZAzBOrZO6q9ogcWC65kU382AfynTfgNumVcNIjuIua6w=="], + "@emnapi/runtime": ["@emnapi/runtime@1.4.3", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-pBPWdu6MLKROBX05wSNKcNb++m5Er+KQ9QkB+WVM+pW2Kx9hoSrVTnu3BdkI5eBLZoKu/J6mW/B6i6bJB2ytXQ=="], + "@esbuild-kit/core-utils": ["@esbuild-kit/core-utils@3.3.2", "", { "dependencies": { "esbuild": "~0.18.20", "source-map-support": "^0.5.21" } }, "sha512-sPRAnw9CdSsRmEtnsl2WXWdyquogVpB3yZ3dgwJfe8zrOzTsV7cJvmwrKVa+0ma5BoiGJ+BoqkMvawbayKUsqQ=="], + + "@esbuild-kit/esm-loader": ["@esbuild-kit/esm-loader@2.6.5", "", { "dependencies": { "@esbuild-kit/core-utils": "^3.3.2", "get-tsconfig": "^4.7.0" } }, "sha512-FxEMIkJKnodyA1OaCUoEvbYRkoZlLZ4d/eXFu9Fh8CbBBgP5EmZxrfTRyN0qpXZ4vOvqnE5YdRdcrmUUXuU+dA=="], + "@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.25.5", "", { "os": "aix", "cpu": "ppc64" }, "sha512-9o3TMmpmftaCMepOdA5k/yDw8SfInyzWWTjYTFCX3kPSDJMROQTb8jg+h9Cnwnmm1vOzvxN7gIfB5V2ewpjtGA=="], "@esbuild/android-arm": ["@esbuild/android-arm@0.25.5", "", { "os": "android", "cpu": "arm" }, "sha512-AdJKSPeEHgi7/ZhuIPtcQKr5RQdo6OO2IL87JkianiMYMPbCtot9fxPbrMiBADOWWm3T2si9stAiVsGbTQFkbA=="], @@ -503,6 +512,8 @@ "browserslist": ["browserslist@4.25.0", "", { "dependencies": { "caniuse-lite": "^1.0.30001718", "electron-to-chromium": "^1.5.160", "node-releases": "^2.0.19", "update-browserslist-db": "^1.1.3" }, "bin": { "browserslist": "cli.js" } }, "sha512-PJ8gYKeS5e/whHBh8xrwYK+dAvEj7JXtz6uTucnMRB8OiGTsKccFekoRrjajPBHV8oOY+2tI4uxeceSimKwMFA=="], + "buffer-from": ["buffer-from@1.1.2", "", {}, "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="], + "bullmq": ["bullmq@5.53.2", "", { "dependencies": { "cron-parser": "^4.9.0", "ioredis": "^5.4.1", "msgpackr": "^1.11.2", "node-abort-controller": "^3.1.1", "semver": "^7.5.4", "tslib": "^2.0.0", "uuid": "^9.0.0" } }, "sha512-xHgxrP/yNJHD7VCw1h+eRBh+2TCPBCM39uC9gCyksYc6ufcJP+HTZ/A2lzB2x7qMFWrvsX7tM40AT2BmdkYL/Q=="], "bun-types": ["bun-types@1.2.15", "", { "dependencies": { "@types/node": "*" } }, "sha512-NarRIaS+iOaQU1JPfyKhZm4AsUOrwUOqRNHY0XxI8GI8jYxiLXLcdjYMG9UKS+fwWasc1uw1htV9AX24dD+p4w=="], @@ -643,6 +654,10 @@ "dlv": ["dlv@1.1.3", "", {}, "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA=="], + "drizzle-kit": ["drizzle-kit@0.31.4", "", { "dependencies": { "@drizzle-team/brocli": "^0.10.2", "@esbuild-kit/esm-loader": "^2.5.5", "esbuild": "^0.25.4", "esbuild-register": "^3.5.0" }, "bin": { "drizzle-kit": "bin.cjs" } }, "sha512-tCPWVZWZqWVx2XUsVpJRnH9Mx0ClVOf5YUHerZ5so1OKSlqww4zy1R5ksEdGRcO3tM3zj0PYN6V48TbQCL1RfA=="], + + "drizzle-orm": ["drizzle-orm@0.44.5", "", { "peerDependencies": { "@aws-sdk/client-rds-data": ">=3", "@cloudflare/workers-types": ">=4", "@electric-sql/pglite": ">=0.2.0", "@libsql/client": ">=0.10.0", "@libsql/client-wasm": ">=0.10.0", "@neondatabase/serverless": ">=0.10.0", "@op-engineering/op-sqlite": ">=2", "@opentelemetry/api": "^1.4.1", "@planetscale/database": ">=1.13", "@prisma/client": "*", "@tidbcloud/serverless": "*", "@types/better-sqlite3": "*", "@types/pg": "*", "@types/sql.js": "*", "@upstash/redis": ">=1.34.7", "@vercel/postgres": ">=0.8.0", "@xata.io/client": "*", "better-sqlite3": ">=7", "bun-types": "*", "expo-sqlite": ">=14.0.0", "gel": ">=2", "knex": "*", "kysely": "*", "mysql2": ">=2", "pg": ">=8", "postgres": ">=3", "sql.js": ">=1", "sqlite3": ">=5" }, "optionalPeers": ["@aws-sdk/client-rds-data", "@cloudflare/workers-types", "@electric-sql/pglite", "@libsql/client", "@libsql/client-wasm", "@neondatabase/serverless", "@op-engineering/op-sqlite", "@opentelemetry/api", "@planetscale/database", "@prisma/client", "@tidbcloud/serverless", "@types/better-sqlite3", "@types/pg", "@types/sql.js", "@upstash/redis", "@vercel/postgres", "@xata.io/client", "better-sqlite3", "bun-types", "expo-sqlite", "gel", "knex", "kysely", "mysql2", "pg", "postgres", "sql.js", "sqlite3"] }, "sha512-jBe37K7d8ZSKptdKfakQFdeljtu3P2Cbo7tJoJSVZADzIKOBo9IAJPOmMsH2bZl90bZgh8FQlD8BjxXA/zuBkQ=="], + "dset": ["dset@3.1.4", "", {}, "sha512-2QF/g9/zTaPDc3BjNcVTGoBbXBgYfMTTceLaYcFJ/W9kggFUkhxD/hMEeuLKbugyef9SqAx8cpgwlIP/jinUTA=="], "dunder-proto": ["dunder-proto@1.0.1", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.1", "es-errors": "^1.3.0", "gopd": "^1.2.0" } }, "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A=="], @@ -679,6 +694,8 @@ "esbuild": ["esbuild@0.25.5", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.25.5", "@esbuild/android-arm": "0.25.5", "@esbuild/android-arm64": "0.25.5", "@esbuild/android-x64": "0.25.5", "@esbuild/darwin-arm64": "0.25.5", "@esbuild/darwin-x64": "0.25.5", "@esbuild/freebsd-arm64": "0.25.5", "@esbuild/freebsd-x64": "0.25.5", "@esbuild/linux-arm": "0.25.5", "@esbuild/linux-arm64": "0.25.5", "@esbuild/linux-ia32": "0.25.5", "@esbuild/linux-loong64": "0.25.5", "@esbuild/linux-mips64el": "0.25.5", "@esbuild/linux-ppc64": "0.25.5", "@esbuild/linux-riscv64": "0.25.5", "@esbuild/linux-s390x": "0.25.5", "@esbuild/linux-x64": "0.25.5", "@esbuild/netbsd-arm64": "0.25.5", "@esbuild/netbsd-x64": "0.25.5", "@esbuild/openbsd-arm64": "0.25.5", "@esbuild/openbsd-x64": "0.25.5", "@esbuild/sunos-x64": "0.25.5", "@esbuild/win32-arm64": "0.25.5", "@esbuild/win32-ia32": "0.25.5", "@esbuild/win32-x64": "0.25.5" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-P8OtKZRv/5J5hhz0cUAdu/cLuPIKXpQl1R9pZtvmHWQvrAUVd0UNIPT4IB4W3rNOqVO0rlqHmCIbSwxh/c9yUQ=="], + "esbuild-register": ["esbuild-register@3.6.0", "", { "dependencies": { "debug": "^4.3.4" }, "peerDependencies": { "esbuild": ">=0.12 <1" } }, "sha512-H2/S7Pm8a9CL1uhp9OvjwrBh5Pvx0H8qVOxNu8Wed9Y7qv56MPtq+GGM8RJpq6glYJn9Wspr8uw7l55uyinNeg=="], + "escalade": ["escalade@3.2.0", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="], "escape-html": ["escape-html@1.0.3", "", {}, "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="], @@ -757,6 +774,8 @@ "get-proto": ["get-proto@1.0.1", "", { "dependencies": { "dunder-proto": "^1.0.1", "es-object-atoms": "^1.0.0" } }, "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g=="], + "get-tsconfig": ["get-tsconfig@4.10.1", "", { "dependencies": { "resolve-pkg-maps": "^1.0.0" } }, "sha512-auHyJ4AgMz7vgS8Hp3N6HXSmlMdUyhSUrfBF16w153rxtLIEOE+HGqaBppczZvnHLqQJfiHotCYpNhl0lUROFQ=="], + "github-slugger": ["github-slugger@2.0.0", "", {}, "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw=="], "glob": ["glob@8.1.0", "", { "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^5.0.1", "once": "^1.3.0" } }, "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ=="], @@ -1249,6 +1268,8 @@ "require-directory": ["require-directory@2.1.1", "", {}, "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q=="], + "resolve-pkg-maps": ["resolve-pkg-maps@1.0.0", "", {}, "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw=="], + "restructure": ["restructure@3.0.2", "", {}, "sha512-gSfoiOEA0VPE6Tukkrr7I0RBdE0s7H1eFCDBk05l1KIQT1UIKNc5JZy6jdyW6eYH3aR3g5b3PuL77rq0hvwtAw=="], "retext": ["retext@9.0.0", "", { "dependencies": { "@types/nlcst": "^2.0.0", "retext-latin": "^4.0.0", "retext-stringify": "^4.0.0", "unified": "^11.0.0" } }, "sha512-sbMDcpHCNjvlheSgMfEcVrZko3cDzdbe1x/e7G66dFp0Ff7Mldvi2uv6JkJQzdRcvLYE8CA8Oe8siQx8ZOgTcA=="], @@ -1319,8 +1340,12 @@ "smol-toml": ["smol-toml@1.3.4", "", {}, "sha512-UOPtVuYkzYGee0Bd2Szz8d2G3RfMfJ2t3qVdZUAozZyAk+a0Sxa+QKix0YCwjL/A1RR0ar44nCxaoN9FxdJGwA=="], + "source-map": ["source-map@0.6.1", "", {}, "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="], + "source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="], + "source-map-support": ["source-map-support@0.5.21", "", { "dependencies": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" } }, "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w=="], + "space-separated-tokens": ["space-separated-tokens@2.0.2", "", {}, "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q=="], "split2": ["split2@4.2.0", "", {}, "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg=="], @@ -1547,6 +1572,8 @@ "zwitch": ["zwitch@2.0.4", "", {}, "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A=="], + "@esbuild-kit/core-utils/esbuild": ["esbuild@0.18.20", "", { "optionalDependencies": { "@esbuild/android-arm": "0.18.20", "@esbuild/android-arm64": "0.18.20", "@esbuild/android-x64": "0.18.20", "@esbuild/darwin-arm64": "0.18.20", "@esbuild/darwin-x64": "0.18.20", "@esbuild/freebsd-arm64": "0.18.20", "@esbuild/freebsd-x64": "0.18.20", "@esbuild/linux-arm": "0.18.20", "@esbuild/linux-arm64": "0.18.20", "@esbuild/linux-ia32": "0.18.20", "@esbuild/linux-loong64": "0.18.20", "@esbuild/linux-mips64el": "0.18.20", "@esbuild/linux-ppc64": "0.18.20", "@esbuild/linux-riscv64": "0.18.20", "@esbuild/linux-s390x": "0.18.20", "@esbuild/linux-x64": "0.18.20", "@esbuild/netbsd-x64": "0.18.20", "@esbuild/openbsd-x64": "0.18.20", "@esbuild/sunos-x64": "0.18.20", "@esbuild/win32-arm64": "0.18.20", "@esbuild/win32-ia32": "0.18.20", "@esbuild/win32-x64": "0.18.20" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA=="], + "@huggingface/transformers/onnxruntime-node": ["onnxruntime-node@1.21.0", "", { "dependencies": { "global-agent": "^3.0.0", "onnxruntime-common": "1.21.0", "tar": "^7.0.1" }, "os": [ "linux", "win32", "darwin", ] }, "sha512-NeaCX6WW2L8cRCSqy3bInlo5ojjQqu2fD3D+9W5qb5irwxhEyWKXeH2vZ8W9r6VxaMPUan+4/7NDwZMtouZxEw=="], "@isaacs/cliui/string-width": ["string-width@5.1.2", "", { "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", "strip-ansi": "^7.0.1" } }, "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA=="], @@ -1633,6 +1660,50 @@ "yargs-unparser/camelcase": ["camelcase@6.3.0", "", {}, "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA=="], + "@esbuild-kit/core-utils/esbuild/@esbuild/android-arm": ["@esbuild/android-arm@0.18.20", "", { "os": "android", "cpu": "arm" }, "sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/android-arm64": ["@esbuild/android-arm64@0.18.20", "", { "os": "android", "cpu": "arm64" }, "sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/android-x64": ["@esbuild/android-x64@0.18.20", "", { "os": "android", "cpu": "x64" }, "sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/darwin-arm64": ["@esbuild/darwin-arm64@0.18.20", "", { "os": "darwin", "cpu": "arm64" }, "sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/darwin-x64": ["@esbuild/darwin-x64@0.18.20", "", { "os": "darwin", "cpu": "x64" }, "sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/freebsd-arm64": ["@esbuild/freebsd-arm64@0.18.20", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/freebsd-x64": ["@esbuild/freebsd-x64@0.18.20", "", { "os": "freebsd", "cpu": "x64" }, "sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/linux-arm": ["@esbuild/linux-arm@0.18.20", "", { "os": "linux", "cpu": "arm" }, "sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/linux-arm64": ["@esbuild/linux-arm64@0.18.20", "", { "os": "linux", "cpu": "arm64" }, "sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/linux-ia32": ["@esbuild/linux-ia32@0.18.20", "", { "os": "linux", "cpu": "ia32" }, "sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/linux-loong64": ["@esbuild/linux-loong64@0.18.20", "", { "os": "linux", "cpu": "none" }, "sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/linux-mips64el": ["@esbuild/linux-mips64el@0.18.20", "", { "os": "linux", "cpu": "none" }, "sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/linux-ppc64": ["@esbuild/linux-ppc64@0.18.20", "", { "os": "linux", "cpu": "ppc64" }, "sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/linux-riscv64": ["@esbuild/linux-riscv64@0.18.20", "", { "os": "linux", "cpu": "none" }, "sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/linux-s390x": ["@esbuild/linux-s390x@0.18.20", "", { "os": "linux", "cpu": "s390x" }, "sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/linux-x64": ["@esbuild/linux-x64@0.18.20", "", { "os": "linux", "cpu": "x64" }, "sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/netbsd-x64": ["@esbuild/netbsd-x64@0.18.20", "", { "os": "none", "cpu": "x64" }, "sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/openbsd-x64": ["@esbuild/openbsd-x64@0.18.20", "", { "os": "openbsd", "cpu": "x64" }, "sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/sunos-x64": ["@esbuild/sunos-x64@0.18.20", "", { "os": "sunos", "cpu": "x64" }, "sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/win32-arm64": ["@esbuild/win32-arm64@0.18.20", "", { "os": "win32", "cpu": "arm64" }, "sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/win32-ia32": ["@esbuild/win32-ia32@0.18.20", "", { "os": "win32", "cpu": "ia32" }, "sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g=="], + + "@esbuild-kit/core-utils/esbuild/@esbuild/win32-x64": ["@esbuild/win32-x64@0.18.20", "", { "os": "win32", "cpu": "x64" }, "sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ=="], + "@huggingface/transformers/onnxruntime-node/onnxruntime-common": ["onnxruntime-common@1.21.0", "", {}, "sha512-Q632iLLrtCAVOTO65dh2+mNbQir/QNTVBG3h/QdZBpns7mZ0RYbLRBgGABPbpU9351AgYy7SJf1WaeVwMrBFPQ=="], "@isaacs/cliui/string-width/emoji-regex": ["emoji-regex@9.2.2", "", {}, "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="], diff --git a/packages/core/drizzle/cred/0000_moaning_shotgun.sql b/packages/core/drizzle/cred/0000_moaning_shotgun.sql new file mode 100644 index 0000000..d371bc5 --- /dev/null +++ b/packages/core/drizzle/cred/0000_moaning_shotgun.sql @@ -0,0 +1,44 @@ +-- Current sql file was generated after introspecting the database +-- If you want to run this migration please uncomment this code before executing migrations +/* +CREATE SEQUENCE "public"."captcha_difficulty_settings_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1;--> statement-breakpoint +CREATE SEQUENCE "public"."users_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1;--> statement-breakpoint +CREATE TABLE "captcha_difficulty_settings" ( + "id" integer DEFAULT nextval('captcha_difficulty_settings_id_seq'::regclass) NOT NULL, + "method" text NOT NULL, + "path" text NOT NULL, + "duration" real NOT NULL, + "threshold" integer NOT NULL, + "difficulty" integer NOT NULL, + "global" boolean NOT NULL +); +--> statement-breakpoint +CREATE TABLE "login_sessions" ( + "id" text NOT NULL, + "uid" integer NOT NULL, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "expire_at" timestamp with time zone, + "last_used_at" timestamp with time zone, + "ip_address" "inet", + "user_agent" text, + "deactivated_at" timestamp with time zone +); +--> statement-breakpoint +CREATE TABLE "users" ( + "id" integer DEFAULT nextval('users_id_seq'::regclass) NOT NULL, + "nickname" text, + "username" text NOT NULL, + "password" text NOT NULL, + "unq_id" text DEFAULT gen_random_uuid() NOT NULL, + "role" text DEFAULT 'USER' NOT NULL, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); +--> statement-breakpoint +CREATE UNIQUE INDEX "captcha_difficulty_settings_pkey" ON "captcha_difficulty_settings" USING btree ("id" int4_ops);--> statement-breakpoint +CREATE INDEX "inx_login-sessions_uid" ON "login_sessions" USING btree ("uid" int4_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "login_sessions_pkey" ON "login_sessions" USING btree ("id" text_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "users_pkey" ON "users" USING btree ("id" int4_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "users_pkey1" ON "users" USING btree ("id" int4_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "users_unq_id_key" ON "users" USING btree ("unq_id" text_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "users_username_key" ON "users" USING btree ("username" text_ops); +*/ \ No newline at end of file diff --git a/packages/core/drizzle/cred/meta/0000_snapshot.json b/packages/core/drizzle/cred/meta/0000_snapshot.json new file mode 100644 index 0000000..a420ac1 --- /dev/null +++ b/packages/core/drizzle/cred/meta/0000_snapshot.json @@ -0,0 +1,350 @@ +{ + "id": "00000000-0000-0000-0000-000000000000", + "prevId": "", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.captcha_difficulty_settings": { + "name": "captcha_difficulty_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": "nextval('captcha_difficulty_settings_id_seq'::regclass)" + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "duration": { + "name": "duration", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "threshold": { + "name": "threshold", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "difficulty": { + "name": "difficulty", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "global": { + "name": "global", + "type": "boolean", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "captcha_difficulty_settings_pkey": { + "name": "captcha_difficulty_settings_pkey", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "int4_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.login_sessions": { + "name": "login_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "uid": { + "name": "uid", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "expire_at": { + "name": "expire_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "ip_address": { + "name": "ip_address", + "type": "inet", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deactivated_at": { + "name": "deactivated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "inx_login-sessions_uid": { + "name": "inx_login-sessions_uid", + "columns": [ + { + "expression": "uid", + "asc": true, + "nulls": "last", + "opclass": "int4_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "login_sessions_pkey": { + "name": "login_sessions_pkey", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": "nextval('users_id_seq'::regclass)" + }, + "nickname": { + "name": "nickname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unq_id": { + "name": "unq_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'USER'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "users_pkey": { + "name": "users_pkey", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "int4_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_pkey1": { + "name": "users_pkey1", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "int4_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_unq_id_key": { + "name": "users_unq_id_key", + "columns": [ + { + "expression": "unq_id", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_username_key": { + "name": "users_username_key", + "columns": [ + { + "expression": "username", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": { + "public.captcha_difficulty_settings_id_seq": { + "name": "captcha_difficulty_settings_id_seq", + "schema": "public", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "increment": "1", + "cycle": false, + "cache": "1" + }, + "public.users_id_seq": { + "name": "users_id_seq", + "schema": "public", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "increment": "1", + "cycle": false, + "cache": "1" + } + }, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": { + "captcha_difficulty_settings": { + "columns": { + "id": { + "isDefaultAnExpression": true + } + } + }, + "users": { + "columns": { + "id": { + "isDefaultAnExpression": true + } + } + } + } + } +} diff --git a/packages/core/drizzle/cred/meta/_journal.json b/packages/core/drizzle/cred/meta/_journal.json new file mode 100644 index 0000000..574cfc3 --- /dev/null +++ b/packages/core/drizzle/cred/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "7", + "dialect": "postgresql", + "entries": [ + { + "idx": 0, + "version": "7", + "when": 1750513073792, + "tag": "0000_moaning_shotgun", + "breakpoints": true + } + ] +} diff --git a/packages/core/drizzle/cred/relations.ts b/packages/core/drizzle/cred/relations.ts new file mode 100644 index 0000000..0ed80c7 --- /dev/null +++ b/packages/core/drizzle/cred/relations.ts @@ -0,0 +1,2 @@ +import { relations } from "drizzle-orm/relations"; +import {} from "./schema"; diff --git a/packages/core/drizzle/cred/schema.ts b/packages/core/drizzle/cred/schema.ts new file mode 100644 index 0000000..0b9e7b1 --- /dev/null +++ b/packages/core/drizzle/cred/schema.ts @@ -0,0 +1,93 @@ +import { + pgTable, + uniqueIndex, + integer, + text, + real, + boolean, + index, + timestamp, + inet, + pgSequence +} from "drizzle-orm/pg-core"; +import { sql } from "drizzle-orm"; + +export const captchaDifficultySettingsIdSeq = pgSequence("captcha_difficulty_settings_id_seq", { + startWith: "1", + increment: "1", + minValue: "1", + maxValue: "2147483647", + cache: "1", + cycle: false +}); +export const usersIdSeq = pgSequence("users_id_seq", { + startWith: "1", + increment: "1", + minValue: "1", + maxValue: "2147483647", + cache: "1", + cycle: false +}); + +export const captchaDifficultySettings = pgTable( + "captcha_difficulty_settings", + { + id: integer() + .default(sql`nextval('captcha_difficulty_settings_id_seq'::regclass)`) + .notNull(), + method: text().notNull(), + path: text().notNull(), + duration: real().notNull(), + threshold: integer().notNull(), + difficulty: integer().notNull(), + global: boolean().notNull() + }, + (table) => [ + uniqueIndex("captcha_difficulty_settings_pkey").using("btree", table.id.asc().nullsLast().op("int4_ops")) + ] +); + +export const loginSessions = pgTable( + "login_sessions", + { + id: text().notNull(), + uid: integer().notNull(), + createdAt: timestamp("created_at", { withTimezone: true, mode: "string" }) + .default(sql`CURRENT_TIMESTAMP`) + .notNull(), + expireAt: timestamp("expire_at", { withTimezone: true, mode: "string" }), + lastUsedAt: timestamp("last_used_at", { withTimezone: true, mode: "string" }), + ipAddress: inet("ip_address"), + userAgent: text("user_agent"), + deactivatedAt: timestamp("deactivated_at", { withTimezone: true, mode: "string" }) + }, + (table) => [ + index("inx_login-sessions_uid").using("btree", table.uid.asc().nullsLast().op("int4_ops")), + uniqueIndex("login_sessions_pkey").using("btree", table.id.asc().nullsLast().op("text_ops")) + ] +); + +export const users = pgTable( + "users", + { + id: integer() + .default(sql`nextval('users_id_seq'::regclass)`) + .notNull(), + nickname: text(), + username: text().notNull(), + password: text().notNull(), + unqId: text("unq_id") + .default(sql`gen_random_uuid()`) + .notNull(), + role: text().default("USER").notNull(), + createdAt: timestamp("created_at", { withTimezone: true, mode: "string" }) + .default(sql`CURRENT_TIMESTAMP`) + .notNull() + }, + (table) => [ + uniqueIndex("users_pkey").using("btree", table.id.asc().nullsLast().op("int4_ops")), + uniqueIndex("users_pkey1").using("btree", table.id.asc().nullsLast().op("int4_ops")), + uniqueIndex("users_unq_id_key").using("btree", table.unqId.asc().nullsLast().op("text_ops")), + uniqueIndex("users_username_key").using("btree", table.username.asc().nullsLast().op("text_ops")) + ] +); diff --git a/packages/core/drizzle/drizzle-cred.config.ts b/packages/core/drizzle/drizzle-cred.config.ts new file mode 100644 index 0000000..90fc57a --- /dev/null +++ b/packages/core/drizzle/drizzle-cred.config.ts @@ -0,0 +1,9 @@ +import { defineConfig } from "drizzle-kit"; + +export default defineConfig({ + out: "./cred", + dialect: "postgresql", + dbCredentials: { + url: process.env.DATABASE_URL_CRED! + } +}); diff --git a/packages/core/drizzle/drizzle-main.config.ts b/packages/core/drizzle/drizzle-main.config.ts new file mode 100644 index 0000000..1634ecc --- /dev/null +++ b/packages/core/drizzle/drizzle-main.config.ts @@ -0,0 +1,10 @@ +import "dotenv/config"; +import { defineConfig } from "drizzle-kit"; + +export default defineConfig({ + out: "./drizzle/main", + dialect: "postgresql", + dbCredentials: { + url: process.env.DATABASE_URL_MAIN! + } +}); diff --git a/packages/core/drizzle/index.ts b/packages/core/drizzle/index.ts new file mode 100644 index 0000000..73dd076 --- /dev/null +++ b/packages/core/drizzle/index.ts @@ -0,0 +1,7 @@ +"use server"; + +import { drizzle } from "drizzle-orm/postgres-js"; +import { sqlCred, sql } from "@cvsa/core"; + +export const dbMain = drizzle(sql); +export const dbCred = drizzle(sqlCred); diff --git a/packages/core/drizzle/main/0000_aspiring_mikhail_rasputin.sql b/packages/core/drizzle/main/0000_aspiring_mikhail_rasputin.sql new file mode 100644 index 0000000..13d1fda --- /dev/null +++ b/packages/core/drizzle/main/0000_aspiring_mikhail_rasputin.sql @@ -0,0 +1,153 @@ +-- Current sql file was generated after introspecting the database +-- If you want to run this migration please uncomment this code before executing migrations +/* +CREATE SEQUENCE "public"."all_data_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1;--> statement-breakpoint +CREATE SEQUENCE "public"."labeling_result_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1;--> statement-breakpoint +CREATE SEQUENCE "public"."songs_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1;--> statement-breakpoint +CREATE SEQUENCE "public"."video_snapshot_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1;--> statement-breakpoint +CREATE SEQUENCE "public"."views_increment_rate_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1;--> statement-breakpoint +CREATE TABLE "bilibili_metadata" ( + "id" integer DEFAULT nextval('all_data_id_seq'::regclass) NOT NULL, + "aid" bigint NOT NULL, + "bvid" varchar(12), + "description" text, + "uid" bigint, + "tags" text, + "title" text, + "published_at" timestamp with time zone, + "duration" integer, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP, + "status" integer DEFAULT 0 NOT NULL, + "cover_url" text +); +--> statement-breakpoint +CREATE TABLE "bilibili_user" ( + "id" serial PRIMARY KEY NOT NULL, + "uid" bigint NOT NULL, + "username" text NOT NULL, + "desc" text NOT NULL, + "fans" integer NOT NULL, + CONSTRAINT "unq_bili-user_uid" UNIQUE("uid") +); +--> statement-breakpoint +CREATE TABLE "labelling_result" ( + "id" integer DEFAULT nextval('labeling_result_id_seq'::regclass) NOT NULL, + "aid" bigint NOT NULL, + "label" smallint NOT NULL, + "model_version" text NOT NULL, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "logits" smallint[] +); +--> statement-breakpoint +CREATE TABLE "latest_video_snapshot" ( + "aid" bigint PRIMARY KEY NOT NULL, + "time" timestamp with time zone NOT NULL, + "views" integer NOT NULL, + "coins" integer NOT NULL, + "likes" integer NOT NULL, + "favorites" integer NOT NULL, + "replies" integer NOT NULL, + "danmakus" integer NOT NULL, + "shares" integer NOT NULL +); +--> statement-breakpoint +CREATE TABLE "video_snapshot" ( + "id" integer DEFAULT nextval('video_snapshot_id_seq'::regclass) NOT NULL, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "views" integer NOT NULL, + "coins" integer NOT NULL, + "likes" integer NOT NULL, + "favorites" integer NOT NULL, + "shares" integer NOT NULL, + "danmakus" integer NOT NULL, + "aid" bigint NOT NULL, + "replies" integer NOT NULL +); +--> statement-breakpoint +CREATE TABLE "songs" ( + "id" integer DEFAULT nextval('songs_id_seq'::regclass) NOT NULL, + "name" text, + "aid" bigint, + "published_at" timestamp with time zone, + "duration" integer, + "type" smallint, + "romanized_name" text, + "netease_id" bigint, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "deleted" boolean DEFAULT false NOT NULL, + "image" text +); +--> statement-breakpoint +CREATE TABLE "singer" ( + "id" serial PRIMARY KEY NOT NULL, + "name" text NOT NULL +); +--> statement-breakpoint +CREATE TABLE "relations" ( + "id" serial PRIMARY KEY NOT NULL, + "source_id" bigint NOT NULL, + "source_type" text NOT NULL, + "target_id" bigint NOT NULL, + "target_type" text NOT NULL, + "relation" text NOT NULL, + CONSTRAINT "unq_relations" UNIQUE("source_id","source_type","target_id","target_type","relation") +); +--> statement-breakpoint +CREATE TABLE "snapshot_schedule" ( + "id" bigserial NOT NULL, + "aid" bigint NOT NULL, + "type" text, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "started_at" timestamp with time zone, + "finished_at" timestamp with time zone, + "status" text DEFAULT 'pending' NOT NULL +); +--> statement-breakpoint +CREATE TABLE "classified_labels_human" ( + "id" serial PRIMARY KEY NOT NULL, + "aid" bigint NOT NULL, + "author" uuid NOT NULL, + "label" smallint NOT NULL, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); +--> statement-breakpoint +CREATE UNIQUE INDEX "all_data_pkey" ON "bilibili_metadata" USING btree ("id" int4_ops);--> statement-breakpoint +CREATE INDEX "idx_all-data_aid" ON "bilibili_metadata" USING btree ("aid" int8_ops);--> statement-breakpoint +CREATE INDEX "idx_all-data_bvid" ON "bilibili_metadata" USING btree ("bvid" text_ops);--> statement-breakpoint +CREATE INDEX "idx_all-data_uid" ON "bilibili_metadata" USING btree ("uid" int8_ops);--> statement-breakpoint +CREATE INDEX "idx_bili-meta_status" ON "bilibili_metadata" USING btree ("status" int4_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "unq_all-data_aid" ON "bilibili_metadata" USING btree ("aid" int8_ops);--> statement-breakpoint +CREATE INDEX "idx_bili-user_uid" ON "bilibili_user" USING btree ("uid" int8_ops);--> statement-breakpoint +CREATE INDEX "idx_labeling_label_model-version" ON "labelling_result" USING btree ("label" int2_ops,"model_version" int2_ops);--> statement-breakpoint +CREATE INDEX "idx_labeling_model-version" ON "labelling_result" USING btree ("model_version" text_ops);--> statement-breakpoint +CREATE INDEX "idx_labelling_aid-label" ON "labelling_result" USING btree ("aid" int2_ops,"label" int2_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "labeling_result_pkey" ON "labelling_result" USING btree ("id" int4_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "unq_labelling-result_aid_model-version" ON "labelling_result" USING btree ("aid" int8_ops,"model_version" int8_ops);--> statement-breakpoint +CREATE INDEX "idx_latest-video-snapshot_time" ON "latest_video_snapshot" USING btree ("time" timestamptz_ops);--> statement-breakpoint +CREATE INDEX "idx_latest-video-snapshot_views" ON "latest_video_snapshot" USING btree ("views" int4_ops);--> statement-breakpoint +CREATE INDEX "idx_vid_snapshot_aid" ON "video_snapshot" USING btree ("aid" int8_ops);--> statement-breakpoint +CREATE INDEX "idx_vid_snapshot_aid_created_at" ON "video_snapshot" USING btree ("aid" timestamptz_ops,"created_at" timestamptz_ops);--> statement-breakpoint +CREATE INDEX "idx_vid_snapshot_time" ON "video_snapshot" USING btree ("created_at" timestamptz_ops);--> statement-breakpoint +CREATE INDEX "idx_vid_snapshot_views" ON "video_snapshot" USING btree ("views" int4_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "video_snapshot_pkey" ON "video_snapshot" USING btree ("id" int4_ops);--> statement-breakpoint +CREATE INDEX "idx_aid" ON "songs" USING btree ("aid" int8_ops);--> statement-breakpoint +CREATE INDEX "idx_hash_songs_aid" ON "songs" USING hash ("aid" int8_ops);--> statement-breakpoint +CREATE INDEX "idx_netease_id" ON "songs" USING btree ("netease_id" int8_ops);--> statement-breakpoint +CREATE INDEX "idx_published_at" ON "songs" USING btree ("published_at" timestamptz_ops);--> statement-breakpoint +CREATE INDEX "idx_type" ON "songs" USING btree ("type" int2_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "songs_pkey" ON "songs" USING btree ("id" int4_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "unq_songs_aid" ON "songs" USING btree ("aid" int8_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "unq_songs_netease_id" ON "songs" USING btree ("netease_id" int8_ops);--> statement-breakpoint +CREATE INDEX "idx_relations_source_id_source_type_relation" ON "relations" USING btree ("source_id" int8_ops,"source_type" int8_ops,"relation" text_ops);--> statement-breakpoint +CREATE INDEX "idx_relations_target_id_target_type_relation" ON "relations" USING btree ("target_id" text_ops,"target_type" text_ops,"relation" text_ops);--> statement-breakpoint +CREATE INDEX "idx_snapshot_schedule_aid" ON "snapshot_schedule" USING btree ("aid" int8_ops);--> statement-breakpoint +CREATE INDEX "idx_snapshot_schedule_started_at" ON "snapshot_schedule" USING btree ("started_at" timestamptz_ops);--> statement-breakpoint +CREATE INDEX "idx_snapshot_schedule_status" ON "snapshot_schedule" USING btree ("status" text_ops);--> statement-breakpoint +CREATE INDEX "idx_snapshot_schedule_type" ON "snapshot_schedule" USING btree ("type" text_ops);--> statement-breakpoint +CREATE UNIQUE INDEX "snapshot_schedule_pkey" ON "snapshot_schedule" USING btree ("id" int8_ops);--> statement-breakpoint +CREATE INDEX "idx_classified-labels-human_aid" ON "classified_labels_human" USING btree ("aid" int8_ops);--> statement-breakpoint +CREATE INDEX "idx_classified-labels-human_author" ON "classified_labels_human" USING btree ("author" uuid_ops);--> statement-breakpoint +CREATE INDEX "idx_classified-labels-human_created-at" ON "classified_labels_human" USING btree ("created_at" timestamptz_ops);--> statement-breakpoint +CREATE INDEX "idx_classified-labels-human_label" ON "classified_labels_human" USING btree ("label" int2_ops); +*/ \ No newline at end of file diff --git a/packages/core/drizzle/main/meta/0000_snapshot.json b/packages/core/drizzle/main/meta/0000_snapshot.json new file mode 100644 index 0000000..8119076 --- /dev/null +++ b/packages/core/drizzle/main/meta/0000_snapshot.json @@ -0,0 +1,1388 @@ +{ + "id": "00000000-0000-0000-0000-000000000000", + "prevId": "", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.bilibili_metadata": { + "name": "bilibili_metadata", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": "nextval('all_data_id_seq'::regclass)" + }, + "aid": { + "name": "aid", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "bvid": { + "name": "bvid", + "type": "varchar(12)", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "uid": { + "name": "uid", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "duration": { + "name": "duration", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "CURRENT_TIMESTAMP" + }, + "status": { + "name": "status", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "cover_url": { + "name": "cover_url", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "all_data_pkey": { + "name": "all_data_pkey", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "int4_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_all-data_aid": { + "name": "idx_all-data_aid", + "columns": [ + { + "expression": "aid", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_all-data_bvid": { + "name": "idx_all-data_bvid", + "columns": [ + { + "expression": "bvid", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_all-data_uid": { + "name": "idx_all-data_uid", + "columns": [ + { + "expression": "uid", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_bili-meta_status": { + "name": "idx_bili-meta_status", + "columns": [ + { + "expression": "status", + "asc": true, + "nulls": "last", + "opclass": "int4_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "unq_all-data_aid": { + "name": "unq_all-data_aid", + "columns": [ + { + "expression": "aid", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.bilibili_user": { + "name": "bilibili_user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "uid": { + "name": "uid", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "desc": { + "name": "desc", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "fans": { + "name": "fans", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "idx_bili-user_uid": { + "name": "idx_bili-user_uid", + "columns": [ + { + "expression": "uid", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unq_bili-user_uid": { + "columns": [ + "uid" + ], + "nullsNotDistinct": false, + "name": "unq_bili-user_uid" + } + }, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.labelling_result": { + "name": "labelling_result", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": "nextval('labeling_result_id_seq'::regclass)" + }, + "aid": { + "name": "aid", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "model_version": { + "name": "model_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "logits": { + "name": "logits", + "type": "smallint[]", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_labeling_label_model-version": { + "name": "idx_labeling_label_model-version", + "columns": [ + { + "expression": "label", + "asc": true, + "nulls": "last", + "opclass": "int2_ops", + "isExpression": false + }, + { + "expression": "model_version", + "asc": true, + "nulls": "last", + "opclass": "int2_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_labeling_model-version": { + "name": "idx_labeling_model-version", + "columns": [ + { + "expression": "model_version", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_labelling_aid-label": { + "name": "idx_labelling_aid-label", + "columns": [ + { + "expression": "aid", + "asc": true, + "nulls": "last", + "opclass": "int2_ops", + "isExpression": false + }, + { + "expression": "label", + "asc": true, + "nulls": "last", + "opclass": "int2_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "labeling_result_pkey": { + "name": "labeling_result_pkey", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "int4_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "unq_labelling-result_aid_model-version": { + "name": "unq_labelling-result_aid_model-version", + "columns": [ + { + "expression": "aid", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + }, + { + "expression": "model_version", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.latest_video_snapshot": { + "name": "latest_video_snapshot", + "schema": "", + "columns": { + "aid": { + "name": "aid", + "type": "bigint", + "primaryKey": true, + "notNull": true + }, + "time": { + "name": "time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "views": { + "name": "views", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coins": { + "name": "coins", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "likes": { + "name": "likes", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "favorites": { + "name": "favorites", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "replies": { + "name": "replies", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "danmakus": { + "name": "danmakus", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "shares": { + "name": "shares", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "idx_latest-video-snapshot_time": { + "name": "idx_latest-video-snapshot_time", + "columns": [ + { + "expression": "time", + "asc": true, + "nulls": "last", + "opclass": "timestamptz_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_latest-video-snapshot_views": { + "name": "idx_latest-video-snapshot_views", + "columns": [ + { + "expression": "views", + "asc": true, + "nulls": "last", + "opclass": "int4_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.video_snapshot": { + "name": "video_snapshot", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": "nextval('video_snapshot_id_seq'::regclass)" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "views": { + "name": "views", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coins": { + "name": "coins", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "likes": { + "name": "likes", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "favorites": { + "name": "favorites", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "shares": { + "name": "shares", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "danmakus": { + "name": "danmakus", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "aid": { + "name": "aid", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "replies": { + "name": "replies", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "idx_vid_snapshot_aid": { + "name": "idx_vid_snapshot_aid", + "columns": [ + { + "expression": "aid", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_vid_snapshot_aid_created_at": { + "name": "idx_vid_snapshot_aid_created_at", + "columns": [ + { + "expression": "aid", + "asc": true, + "nulls": "last", + "opclass": "timestamptz_ops", + "isExpression": false + }, + { + "expression": "created_at", + "asc": true, + "nulls": "last", + "opclass": "timestamptz_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_vid_snapshot_time": { + "name": "idx_vid_snapshot_time", + "columns": [ + { + "expression": "created_at", + "asc": true, + "nulls": "last", + "opclass": "timestamptz_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_vid_snapshot_views": { + "name": "idx_vid_snapshot_views", + "columns": [ + { + "expression": "views", + "asc": true, + "nulls": "last", + "opclass": "int4_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "video_snapshot_pkey": { + "name": "video_snapshot_pkey", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "int4_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.songs": { + "name": "songs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": "nextval('songs_id_seq'::regclass)" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "aid": { + "name": "aid", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "duration": { + "name": "duration", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "romanized_name": { + "name": "romanized_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "netease_id": { + "name": "netease_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "deleted": { + "name": "deleted", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_aid": { + "name": "idx_aid", + "columns": [ + { + "expression": "aid", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_hash_songs_aid": { + "name": "idx_hash_songs_aid", + "columns": [ + { + "expression": "aid", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "hash", + "with": {} + }, + "idx_netease_id": { + "name": "idx_netease_id", + "columns": [ + { + "expression": "netease_id", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_published_at": { + "name": "idx_published_at", + "columns": [ + { + "expression": "published_at", + "asc": true, + "nulls": "last", + "opclass": "timestamptz_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_type": { + "name": "idx_type", + "columns": [ + { + "expression": "type", + "asc": true, + "nulls": "last", + "opclass": "int2_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "songs_pkey": { + "name": "songs_pkey", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "int4_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "unq_songs_aid": { + "name": "unq_songs_aid", + "columns": [ + { + "expression": "aid", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "unq_songs_netease_id": { + "name": "unq_songs_netease_id", + "columns": [ + { + "expression": "netease_id", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.singer": { + "name": "singer", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.relations": { + "name": "relations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "source_id": { + "name": "source_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "source_type": { + "name": "source_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "relation": { + "name": "relation", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "idx_relations_source_id_source_type_relation": { + "name": "idx_relations_source_id_source_type_relation", + "columns": [ + { + "expression": "source_id", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + }, + { + "expression": "source_type", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + }, + { + "expression": "relation", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_relations_target_id_target_type_relation": { + "name": "idx_relations_target_id_target_type_relation", + "columns": [ + { + "expression": "target_id", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "target_type", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "relation", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unq_relations": { + "columns": [ + "source_id", + "source_type", + "target_id", + "target_type", + "relation" + ], + "nullsNotDistinct": false, + "name": "unq_relations" + } + }, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.snapshot_schedule": { + "name": "snapshot_schedule", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigserial", + "primaryKey": false, + "notNull": true + }, + "aid": { + "name": "aid", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": { + "idx_snapshot_schedule_aid": { + "name": "idx_snapshot_schedule_aid", + "columns": [ + { + "expression": "aid", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_snapshot_schedule_started_at": { + "name": "idx_snapshot_schedule_started_at", + "columns": [ + { + "expression": "started_at", + "asc": true, + "nulls": "last", + "opclass": "timestamptz_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_snapshot_schedule_status": { + "name": "idx_snapshot_schedule_status", + "columns": [ + { + "expression": "status", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_snapshot_schedule_type": { + "name": "idx_snapshot_schedule_type", + "columns": [ + { + "expression": "type", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "snapshot_schedule_pkey": { + "name": "snapshot_schedule_pkey", + "columns": [ + { + "expression": "id", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + }, + "public.classified_labels_human": { + "name": "classified_labels_human", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "aid": { + "name": "aid", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "author": { + "name": "author", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "idx_classified-labels-human_aid": { + "name": "idx_classified-labels-human_aid", + "columns": [ + { + "expression": "aid", + "asc": true, + "nulls": "last", + "opclass": "int8_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_classified-labels-human_author": { + "name": "idx_classified-labels-human_author", + "columns": [ + { + "expression": "author", + "asc": true, + "nulls": "last", + "opclass": "uuid_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_classified-labels-human_created-at": { + "name": "idx_classified-labels-human_created-at", + "columns": [ + { + "expression": "created_at", + "asc": true, + "nulls": "last", + "opclass": "timestamptz_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_classified-labels-human_label": { + "name": "idx_classified-labels-human_label", + "columns": [ + { + "expression": "label", + "asc": true, + "nulls": "last", + "opclass": "int2_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {}, + "policies": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": { + "public.all_data_id_seq": { + "name": "all_data_id_seq", + "schema": "public", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "increment": "1", + "cycle": false, + "cache": "1" + }, + "public.labeling_result_id_seq": { + "name": "labeling_result_id_seq", + "schema": "public", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "increment": "1", + "cycle": false, + "cache": "1" + }, + "public.songs_id_seq": { + "name": "songs_id_seq", + "schema": "public", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "increment": "1", + "cycle": false, + "cache": "1" + }, + "public.video_snapshot_id_seq": { + "name": "video_snapshot_id_seq", + "schema": "public", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "increment": "1", + "cycle": false, + "cache": "1" + }, + "public.views_increment_rate_id_seq": { + "name": "views_increment_rate_id_seq", + "schema": "public", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854775807", + "increment": "1", + "cycle": false, + "cache": "1" + } + }, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": { + "bilibili_metadata": { + "columns": { + "id": { + "isDefaultAnExpression": true + } + } + }, + "labelling_result": { + "columns": { + "id": { + "isDefaultAnExpression": true + }, + "logits": { + "isArray": true, + "dimensions": 1, + "rawType": "smallint" + } + } + }, + "video_snapshot": { + "columns": { + "id": { + "isDefaultAnExpression": true + } + } + }, + "songs": { + "columns": { + "id": { + "isDefaultAnExpression": true + } + } + } + } + } +} \ No newline at end of file diff --git a/packages/core/drizzle/main/meta/_journal.json b/packages/core/drizzle/main/meta/_journal.json new file mode 100644 index 0000000..ba0a0af --- /dev/null +++ b/packages/core/drizzle/main/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "7", + "dialect": "postgresql", + "entries": [ + { + "idx": 0, + "version": "7", + "when": 1758438506680, + "tag": "0000_aspiring_mikhail_rasputin", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/packages/core/drizzle/main/relations.ts b/packages/core/drizzle/main/relations.ts new file mode 100644 index 0000000..80768e2 --- /dev/null +++ b/packages/core/drizzle/main/relations.ts @@ -0,0 +1,3 @@ +import { relations } from "drizzle-orm/relations"; +import { } from "./schema"; + diff --git a/packages/core/drizzle/main/schema.ts b/packages/core/drizzle/main/schema.ts new file mode 100644 index 0000000..bd05189 --- /dev/null +++ b/packages/core/drizzle/main/schema.ts @@ -0,0 +1,174 @@ +import { pgTable, uniqueIndex, index, integer, bigint, varchar, text, timestamp, unique, serial, smallint, boolean, bigserial, uuid, pgSequence } from "drizzle-orm/pg-core" +import { sql } from "drizzle-orm" + + +export const allDataIdSeq = pgSequence("all_data_id_seq", { startWith: "1", increment: "1", minValue: "1", maxValue: "2147483647", cache: "1", cycle: false }) +export const labelingResultIdSeq = pgSequence("labeling_result_id_seq", { startWith: "1", increment: "1", minValue: "1", maxValue: "2147483647", cache: "1", cycle: false }) +export const songsIdSeq = pgSequence("songs_id_seq", { startWith: "1", increment: "1", minValue: "1", maxValue: "2147483647", cache: "1", cycle: false }) +export const videoSnapshotIdSeq = pgSequence("video_snapshot_id_seq", { startWith: "1", increment: "1", minValue: "1", maxValue: "2147483647", cache: "1", cycle: false }) +export const viewsIncrementRateIdSeq = pgSequence("views_increment_rate_id_seq", { startWith: "1", increment: "1", minValue: "1", maxValue: "9223372036854775807", cache: "1", cycle: false }) + +export const bilibiliMetadata = pgTable("bilibili_metadata", { + id: integer().default(sql`nextval('all_data_id_seq'::regclass)`).notNull(), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + aid: bigint({ mode: "number" }).notNull(), + bvid: varchar({ length: 12 }), + description: text(), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + uid: bigint({ mode: "number" }), + tags: text(), + title: text(), + publishedAt: timestamp("published_at", { withTimezone: true, mode: 'string' }), + duration: integer(), + createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).default(sql`CURRENT_TIMESTAMP`), + status: integer().default(0).notNull(), + coverUrl: text("cover_url"), +}, (table) => [ + uniqueIndex("all_data_pkey").using("btree", table.id.asc().nullsLast().op("int4_ops")), + index("idx_all-data_aid").using("btree", table.aid.asc().nullsLast().op("int8_ops")), + index("idx_all-data_bvid").using("btree", table.bvid.asc().nullsLast().op("text_ops")), + index("idx_all-data_uid").using("btree", table.uid.asc().nullsLast().op("int8_ops")), + index("idx_bili-meta_status").using("btree", table.status.asc().nullsLast().op("int4_ops")), + uniqueIndex("unq_all-data_aid").using("btree", table.aid.asc().nullsLast().op("int8_ops")), +]); + +export const bilibiliUser = pgTable("bilibili_user", { + id: serial().primaryKey().notNull(), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + uid: bigint({ mode: "number" }).notNull(), + username: text().notNull(), + desc: text().notNull(), + fans: integer().notNull(), +}, (table) => [ + index("idx_bili-user_uid").using("btree", table.uid.asc().nullsLast().op("int8_ops")), + unique("unq_bili-user_uid").on(table.uid), +]); + +export const labellingResult = pgTable("labelling_result", { + id: integer().default(sql`nextval('labeling_result_id_seq'::regclass)`).notNull(), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + aid: bigint({ mode: "number" }).notNull(), + label: smallint().notNull(), + modelVersion: text("model_version").notNull(), + createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + logits: smallint().array(), +}, (table) => [ + index("idx_labeling_label_model-version").using("btree", table.label.asc().nullsLast().op("int2_ops"), table.modelVersion.asc().nullsLast().op("int2_ops")), + index("idx_labeling_model-version").using("btree", table.modelVersion.asc().nullsLast().op("text_ops")), + index("idx_labelling_aid-label").using("btree", table.aid.asc().nullsLast().op("int2_ops"), table.label.asc().nullsLast().op("int2_ops")), + uniqueIndex("labeling_result_pkey").using("btree", table.id.asc().nullsLast().op("int4_ops")), + uniqueIndex("unq_labelling-result_aid_model-version").using("btree", table.aid.asc().nullsLast().op("int8_ops"), table.modelVersion.asc().nullsLast().op("int8_ops")), +]); + +export const latestVideoSnapshot = pgTable("latest_video_snapshot", { + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + aid: bigint({ mode: "number" }).primaryKey().notNull(), + time: timestamp({ withTimezone: true, mode: 'string' }).notNull(), + views: integer().notNull(), + coins: integer().notNull(), + likes: integer().notNull(), + favorites: integer().notNull(), + replies: integer().notNull(), + danmakus: integer().notNull(), + shares: integer().notNull(), +}, (table) => [ + index("idx_latest-video-snapshot_time").using("btree", table.time.asc().nullsLast().op("timestamptz_ops")), + index("idx_latest-video-snapshot_views").using("btree", table.views.asc().nullsLast().op("int4_ops")), +]); + +export const videoSnapshot = pgTable("video_snapshot", { + id: integer().default(sql`nextval('video_snapshot_id_seq'::regclass)`).notNull(), + createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + views: integer().notNull(), + coins: integer().notNull(), + likes: integer().notNull(), + favorites: integer().notNull(), + shares: integer().notNull(), + danmakus: integer().notNull(), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + aid: bigint({ mode: "number" }).notNull(), + replies: integer().notNull(), +}, (table) => [ + index("idx_vid_snapshot_aid").using("btree", table.aid.asc().nullsLast().op("int8_ops")), + index("idx_vid_snapshot_aid_created_at").using("btree", table.aid.asc().nullsLast().op("timestamptz_ops"), table.createdAt.asc().nullsLast().op("timestamptz_ops")), + index("idx_vid_snapshot_time").using("btree", table.createdAt.asc().nullsLast().op("timestamptz_ops")), + index("idx_vid_snapshot_views").using("btree", table.views.asc().nullsLast().op("int4_ops")), + uniqueIndex("video_snapshot_pkey").using("btree", table.id.asc().nullsLast().op("int4_ops")), +]); + +export const songs = pgTable("songs", { + id: integer().default(sql`nextval('songs_id_seq'::regclass)`).notNull(), + name: text(), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + aid: bigint({ mode: "number" }), + publishedAt: timestamp("published_at", { withTimezone: true, mode: 'string' }), + duration: integer(), + type: smallint(), + romanizedName: text("romanized_name"), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + neteaseId: bigint("netease_id", { mode: "number" }), + createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + updatedAt: timestamp("updated_at", { withTimezone: true, mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + deleted: boolean().default(false).notNull(), + image: text(), +}, (table) => [ + index("idx_aid").using("btree", table.aid.asc().nullsLast().op("int8_ops")), + index("idx_hash_songs_aid").using("hash", table.aid.asc().nullsLast().op("int8_ops")), + index("idx_netease_id").using("btree", table.neteaseId.asc().nullsLast().op("int8_ops")), + index("idx_published_at").using("btree", table.publishedAt.asc().nullsLast().op("timestamptz_ops")), + index("idx_type").using("btree", table.type.asc().nullsLast().op("int2_ops")), + uniqueIndex("songs_pkey").using("btree", table.id.asc().nullsLast().op("int4_ops")), + uniqueIndex("unq_songs_aid").using("btree", table.aid.asc().nullsLast().op("int8_ops")), + uniqueIndex("unq_songs_netease_id").using("btree", table.neteaseId.asc().nullsLast().op("int8_ops")), +]); + +export const singer = pgTable("singer", { + id: serial().primaryKey().notNull(), + name: text().notNull(), +}); + +export const relations = pgTable("relations", { + id: serial().primaryKey().notNull(), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + sourceId: bigint("source_id", { mode: "number" }).notNull(), + sourceType: text("source_type").notNull(), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + targetId: bigint("target_id", { mode: "number" }).notNull(), + targetType: text("target_type").notNull(), + relation: text().notNull(), +}, (table) => [ + index("idx_relations_source_id_source_type_relation").using("btree", table.sourceId.asc().nullsLast().op("int8_ops"), table.sourceType.asc().nullsLast().op("int8_ops"), table.relation.asc().nullsLast().op("text_ops")), + index("idx_relations_target_id_target_type_relation").using("btree", table.targetId.asc().nullsLast().op("text_ops"), table.targetType.asc().nullsLast().op("text_ops"), table.relation.asc().nullsLast().op("text_ops")), + unique("unq_relations").on(table.sourceId, table.sourceType, table.targetId, table.targetType, table.relation), +]); + +export const snapshotSchedule = pgTable("snapshot_schedule", { + id: bigserial({ mode: "bigint" }).notNull(), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + aid: bigint({ mode: "number" }).notNull(), + type: text(), + createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), + startedAt: timestamp("started_at", { withTimezone: true, mode: 'string' }), + finishedAt: timestamp("finished_at", { withTimezone: true, mode: 'string' }), + status: text().default('pending').notNull(), +}, (table) => [ + index("idx_snapshot_schedule_aid").using("btree", table.aid.asc().nullsLast().op("int8_ops")), + index("idx_snapshot_schedule_started_at").using("btree", table.startedAt.asc().nullsLast().op("timestamptz_ops")), + index("idx_snapshot_schedule_status").using("btree", table.status.asc().nullsLast().op("text_ops")), + index("idx_snapshot_schedule_type").using("btree", table.type.asc().nullsLast().op("text_ops")), + uniqueIndex("snapshot_schedule_pkey").using("btree", table.id.asc().nullsLast().op("int8_ops")), +]); + +export const classifiedLabelsHuman = pgTable("classified_labels_human", { + id: serial().primaryKey().notNull(), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + aid: bigint({ mode: "number" }).notNull(), + author: uuid().notNull(), + label: smallint().notNull(), + createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), +}, (table) => [ + index("idx_classified-labels-human_aid").using("btree", table.aid.asc().nullsLast().op("int8_ops")), + index("idx_classified-labels-human_author").using("btree", table.author.asc().nullsLast().op("uuid_ops")), + index("idx_classified-labels-human_created-at").using("btree", table.createdAt.asc().nullsLast().op("timestamptz_ops")), + index("idx_classified-labels-human_label").using("btree", table.label.asc().nullsLast().op("int2_ops")), +]); diff --git a/packages/core/drizzle/outerSchema.d.ts b/packages/core/drizzle/outerSchema.d.ts new file mode 100644 index 0000000..bfc0436 --- /dev/null +++ b/packages/core/drizzle/outerSchema.d.ts @@ -0,0 +1,10 @@ +import type { InferSelectModel } from "drizzle-orm"; +import { users } from "~db/cred/schema"; +import { bilibiliMetadata, latestVideoSnapshot, songs, videoSnapshot } from "~db/main/schema"; + +export type UserType = InferSelectModel; +export type SensitiveUserFields = "password" | "unqId"; +export type BilibiliMetadataType = InferSelectModel; +export type VideoSnapshotType = InferSelectModel; +export type LatestVideoSnapshotType = InferSelectModel; +export type SongType = InferSelectModel; \ No newline at end of file diff --git a/packages/core/package.json b/packages/core/package.json index 786828f..5e26518 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -12,10 +12,12 @@ "ioredis": "^5.6.1", "logform": "^2.7.0", "postgres": "^3.4.5", + "drizzle-orm": "^0.44.4", "winston": "^3.17.0" }, "devDependencies": { - "@types/ioredis": "^5.0.0" + "@types/ioredis": "^5.0.0", + "drizzle-kit": "^0.31.4" }, "main": "./dist/index.js", "types": "./types.d.ts" diff --git a/packages/crawler/net/bulkGetVideoStats.ts b/packages/crawler/net/bulkGetVideoStats.ts index bd586c9..dede37f 100644 --- a/packages/crawler/net/bulkGetVideoStats.ts +++ b/packages/crawler/net/bulkGetVideoStats.ts @@ -12,6 +12,7 @@ import logger from "@core/log/logger.ts"; * - The alicloud-fc threw an error: with error code `ALICLOUD_FC_ERROR` */ export async function bulkGetVideoStats(aids: number[]): Promise { + // TODO: https://api.bilibili.com/x/v3/fav/resource/infos?resources=20:2 let url = `https://api.bilibili.com/medialist/gateway/base/resource/infos?resources=`; for (const aid of aids) { url += `${aid}:2,`; diff --git a/packages/temp_frontend/.react-router/types/+future.ts b/packages/temp_frontend/.react-router/types/+future.ts new file mode 100644 index 0000000..7f4533c --- /dev/null +++ b/packages/temp_frontend/.react-router/types/+future.ts @@ -0,0 +1,9 @@ +// Generated by React Router + +import "react-router"; + +declare module "react-router" { + interface Future { + v8_middleware: false + } +} \ No newline at end of file diff --git a/packages/temp_frontend/.react-router/types/+routes.ts b/packages/temp_frontend/.react-router/types/+routes.ts new file mode 100644 index 0000000..3115f67 --- /dev/null +++ b/packages/temp_frontend/.react-router/types/+routes.ts @@ -0,0 +1,36 @@ +// Generated by React Router + +import "react-router" + +declare module "react-router" { + interface Register { + pages: Pages + routeFiles: RouteFiles + } +} + +type Pages = { + "/": { + params: {}; + }; + "/song/:id/info": { + params: { + "id": string; + }; + }; +}; + +type RouteFiles = { + "root.tsx": { + id: "root"; + page: "/" | "/song/:id/info"; + }; + "routes/home.tsx": { + id: "routes/home"; + page: "/"; + }; + "routes/song/[id]/info.tsx": { + id: "routes/song/[id]/info"; + page: "/song/:id/info"; + }; +}; \ No newline at end of file diff --git a/packages/temp_frontend/.react-router/types/+server-build.d.ts b/packages/temp_frontend/.react-router/types/+server-build.d.ts new file mode 100644 index 0000000..b4b4237 --- /dev/null +++ b/packages/temp_frontend/.react-router/types/+server-build.d.ts @@ -0,0 +1,17 @@ +// Generated by React Router + +declare module "virtual:react-router/server-build" { + import { ServerBuild } from "react-router"; + export const assets: ServerBuild["assets"]; + export const assetsBuildDirectory: ServerBuild["assetsBuildDirectory"]; + export const basename: ServerBuild["basename"]; + export const entry: ServerBuild["entry"]; + export const future: ServerBuild["future"]; + export const isSpaMode: ServerBuild["isSpaMode"]; + export const prerender: ServerBuild["prerender"]; + export const publicPath: ServerBuild["publicPath"]; + export const routeDiscovery: ServerBuild["routeDiscovery"]; + export const routes: ServerBuild["routes"]; + export const ssr: ServerBuild["ssr"]; + export const unstable_getCriticalCss: ServerBuild["unstable_getCriticalCss"]; +} \ No newline at end of file diff --git a/packages/temp_frontend/.react-router/types/app/+types/root.ts b/packages/temp_frontend/.react-router/types/app/+types/root.ts new file mode 100644 index 0000000..5bd414e --- /dev/null +++ b/packages/temp_frontend/.react-router/types/app/+types/root.ts @@ -0,0 +1,59 @@ +// Generated by React Router + +import type { GetInfo, GetAnnotations } from "react-router/internal"; + +type Module = typeof import("../root.js") + +type Info = GetInfo<{ + file: "root.tsx", + module: Module +}> + +type Matches = [{ + id: "root"; + module: typeof import("../root.js"); +}]; + +type Annotations = GetAnnotations; + +export namespace Route { + // links + export type LinkDescriptors = Annotations["LinkDescriptors"]; + export type LinksFunction = Annotations["LinksFunction"]; + + // meta + export type MetaArgs = Annotations["MetaArgs"]; + export type MetaDescriptors = Annotations["MetaDescriptors"]; + export type MetaFunction = Annotations["MetaFunction"]; + + // headers + export type HeadersArgs = Annotations["HeadersArgs"]; + export type HeadersFunction = Annotations["HeadersFunction"]; + + // middleware + export type MiddlewareFunction = Annotations["MiddlewareFunction"]; + + // clientMiddleware + export type ClientMiddlewareFunction = Annotations["ClientMiddlewareFunction"]; + + // loader + export type LoaderArgs = Annotations["LoaderArgs"]; + + // clientLoader + export type ClientLoaderArgs = Annotations["ClientLoaderArgs"]; + + // action + export type ActionArgs = Annotations["ActionArgs"]; + + // clientAction + export type ClientActionArgs = Annotations["ClientActionArgs"]; + + // HydrateFallback + export type HydrateFallbackProps = Annotations["HydrateFallbackProps"]; + + // Component + export type ComponentProps = Annotations["ComponentProps"]; + + // ErrorBoundary + export type ErrorBoundaryProps = Annotations["ErrorBoundaryProps"]; +} \ No newline at end of file diff --git a/packages/temp_frontend/.react-router/types/app/routes/+types/home.ts b/packages/temp_frontend/.react-router/types/app/routes/+types/home.ts new file mode 100644 index 0000000..e49d62a --- /dev/null +++ b/packages/temp_frontend/.react-router/types/app/routes/+types/home.ts @@ -0,0 +1,62 @@ +// Generated by React Router + +import type { GetInfo, GetAnnotations } from "react-router/internal"; + +type Module = typeof import("../home.js") + +type Info = GetInfo<{ + file: "routes/home.tsx", + module: Module +}> + +type Matches = [{ + id: "root"; + module: typeof import("../../root.js"); +}, { + id: "routes/home"; + module: typeof import("../home.js"); +}]; + +type Annotations = GetAnnotations; + +export namespace Route { + // links + export type LinkDescriptors = Annotations["LinkDescriptors"]; + export type LinksFunction = Annotations["LinksFunction"]; + + // meta + export type MetaArgs = Annotations["MetaArgs"]; + export type MetaDescriptors = Annotations["MetaDescriptors"]; + export type MetaFunction = Annotations["MetaFunction"]; + + // headers + export type HeadersArgs = Annotations["HeadersArgs"]; + export type HeadersFunction = Annotations["HeadersFunction"]; + + // middleware + export type MiddlewareFunction = Annotations["MiddlewareFunction"]; + + // clientMiddleware + export type ClientMiddlewareFunction = Annotations["ClientMiddlewareFunction"]; + + // loader + export type LoaderArgs = Annotations["LoaderArgs"]; + + // clientLoader + export type ClientLoaderArgs = Annotations["ClientLoaderArgs"]; + + // action + export type ActionArgs = Annotations["ActionArgs"]; + + // clientAction + export type ClientActionArgs = Annotations["ClientActionArgs"]; + + // HydrateFallback + export type HydrateFallbackProps = Annotations["HydrateFallbackProps"]; + + // Component + export type ComponentProps = Annotations["ComponentProps"]; + + // ErrorBoundary + export type ErrorBoundaryProps = Annotations["ErrorBoundaryProps"]; +} \ No newline at end of file diff --git a/packages/temp_frontend/.react-router/types/app/routes/song/[id]/+types/info.ts b/packages/temp_frontend/.react-router/types/app/routes/song/[id]/+types/info.ts new file mode 100644 index 0000000..dd52e12 --- /dev/null +++ b/packages/temp_frontend/.react-router/types/app/routes/song/[id]/+types/info.ts @@ -0,0 +1,62 @@ +// Generated by React Router + +import type { GetInfo, GetAnnotations } from "react-router/internal"; + +type Module = typeof import("../info.js") + +type Info = GetInfo<{ + file: "routes/song/[id]/info.tsx", + module: Module +}> + +type Matches = [{ + id: "root"; + module: typeof import("../../../../root.js"); +}, { + id: "routes/song/[id]/info"; + module: typeof import("../info.js"); +}]; + +type Annotations = GetAnnotations; + +export namespace Route { + // links + export type LinkDescriptors = Annotations["LinkDescriptors"]; + export type LinksFunction = Annotations["LinksFunction"]; + + // meta + export type MetaArgs = Annotations["MetaArgs"]; + export type MetaDescriptors = Annotations["MetaDescriptors"]; + export type MetaFunction = Annotations["MetaFunction"]; + + // headers + export type HeadersArgs = Annotations["HeadersArgs"]; + export type HeadersFunction = Annotations["HeadersFunction"]; + + // middleware + export type MiddlewareFunction = Annotations["MiddlewareFunction"]; + + // clientMiddleware + export type ClientMiddlewareFunction = Annotations["ClientMiddlewareFunction"]; + + // loader + export type LoaderArgs = Annotations["LoaderArgs"]; + + // clientLoader + export type ClientLoaderArgs = Annotations["ClientLoaderArgs"]; + + // action + export type ActionArgs = Annotations["ActionArgs"]; + + // clientAction + export type ClientActionArgs = Annotations["ClientActionArgs"]; + + // HydrateFallback + export type HydrateFallbackProps = Annotations["HydrateFallbackProps"]; + + // Component + export type ComponentProps = Annotations["ComponentProps"]; + + // ErrorBoundary + export type ErrorBoundaryProps = Annotations["ErrorBoundaryProps"]; +} \ No newline at end of file diff --git a/packages/temp_frontend/meili/VERSION b/packages/temp_frontend/meili/VERSION new file mode 100644 index 0000000..e4264e9 --- /dev/null +++ b/packages/temp_frontend/meili/VERSION @@ -0,0 +1 @@ +1.21.0 \ No newline at end of file diff --git a/packages/temp_frontend/meili/auth/data.mdb b/packages/temp_frontend/meili/auth/data.mdb new file mode 100644 index 0000000000000000000000000000000000000000..506637a9bc7a81c2565a6d58919944d4ec59bd32 GIT binary patch literal 229376 zcmeI*U5p#$y~pv1lPpVKAWPGfmZqHyfh5b$c07I?+q-tcE>gowiBdp_KO~cys_I3>kq~MT7jS0A z_HI4M&)LI?js$#jk!L)==NZp@{MgCO|9LcR_-8UX`17Uz`p-?nQ~maE(nNnxYU|1R zQNL5B-)K7rZNFLXwSF|(KRs^C$ar2LfB*srAbsMbt>US8{{cj%hAFdm)b!0p*5I_I{1Q0*~0R#|0009ILKmY**5I_I{ z1Q0*~0R#|0009ILKmY**5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q0*~0R#|0009IL z_;Lsg>+m%#qwUsC)i2dg)xR81&Ql_Q00IagfB*srAbxm~{#`t87|7!UTO?uUBV*4-r$>LT#;o)leo zNpE)B%X+vZ6zGwDNn||QQ)22M#@w+1K z*QZIIDLGs}>L+*h8*Rs+9b9!%6CK}-t{lBj{AYdG`cXgG+;6n)gLe3u`u_n44FU)t zfB*srAb0UJyY^IV(Xr+yDu0>plwY4eJO8(`F?VO> zPtKOPpOr7n|G3hcKVJT8b$2zW{&Ma&)qhkjR{mJ|-u&UYo916EpRfF|@}s$9)t@*& zt?nuR&iP>OSI(6=yZWK?gSj`$`z!f!!+E3n+qvPh(IS8V0tg_000IagfB*srAbF?$krDnSu?Tx+~F8RU9XjAlP+jGCC2kmIX z^x<~t?T+kkRX(dPh?RKH@_qVZJLwZWQoFy+dOL^)bXFQI-&Jg@e#Be$gHP?N?h3cq z%sbJR>g8N1LT(CE)c`baiMZ4&1%y-cB%*lc8<@YW$r>@@J zdG^pd``Q}%Q}h@_X3E#GzFcH6yPvIYH*H51J~Z*l*_ZAc@9)O5S_Iy3LN~kZ zHb5QMLG;7uw66mW;nPy(ql4KMz^U$rd&^efwR{e6qHXKve(#3+;C2-TG_w+a103 za*Y)LKKuWO7>NJ^2q1s}0tg_000IagfB*srAb8sxq~d>69|vu1qJD={J<=v@-p+GTp6A zv&!^7=H%DovHH05MrAq?r;Fpp?u^sMxOA)X%A4bKZGD#X3I?Nd zBb|=^@~6|$*`7|5=Nm!lcvD zS(i>n=T$l#o$cv#^gEbd17UPNr_=r?II;HMhm5vcd#?UQ{ki(uDGm@o009ILKmY** z5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q0*~0R#|0 z009ILKmY**5I_I{1Q6Juz=2J1$6Z>wy8UUxlRdZVcS64%7!~8ep49zN58JxCBtl&T zp5Bw9>n`cdZhKh|mt=epgfj4q86yzOG8(ifn_{IE>I?CZBgc;F_sG>KUGcprwCtQ+ zb_VYW3r%S@yoN9fMXT5-Iig|b<4XxQzJs2oSJbBub zr#pUE#Qn5`$#YL?Ta#8BtdgK@@JdG^pd``eJ6XPa>AINJt@QJR9tbM96mNts`V*?U}sMkQEjwPp-Adh}3w z$r;18?1E{PO*{KQHdo2zE0!~x&E|61N22SlbRvTd^gN>-82D%G^ABH{zU$*xFFrK! z%GsCh8}IKfiBK1Tr}w1jx=XR!a)KWn1fdMP==}q+ERBk>D4SxX73vG|kR!*A>i5Xi z`0ji!3N1Tlm)(M6dPQ59`9f2g4X+{0LeVNVN{(nmcu{BJ#-Cuq62J38d%4q+{ZlhW z{}y7cYocd4*}?|-`d!a_vbK0UJyY^J=^Y#7YZV^BL0R#|0009ILKmY**5I_I{1Q0*~0R#|0009ILKmY**5I_I{ z1Q0*~0R#|0009ILKmY**5I_I{1Q0*~0R#|0009ILKmdWykHD7XR;RS|3IW|hkwP)(@*G|=U z)oZnLwb}Z;^|xzJ)z$`ZfB*srAbZ6OdeDvvribOy?T+kvj+g=&UqazN;v!KH@F=!Kdn~UEvm+c_%8VF6T;SKHC(g$mgWl zEP1xD3zl?qjnTU5q+t4gDxjV*+^!U%^pcWl!?x^#X_ZYo`#?5V$>l4SGn>s8?V|HY zT;bjEHrDmb$${_X_bxQ2uHM~w_Ru@~-#T&b@)+N!{ye%1PxpgJdO2~_h1+fSdPxcT zlS}QE)T8$n4bhWhg``56$r=ol4C5IcRVBgROkjrH^=%4gFqkUQG|2L#(IoZMn`TAYY ze6nNh_avkJTw8SBt-n^+YcJQv*Z(g%*8D`}FY}%9>+@&l|5i5U?yUUD*)sRD@`d>y zS6cJO%YUuzt_Ia#&i$tPkIKc$A1mLRKRkES{EOxDl^<4qG}myAI$yA zxiV*0KXiUD_hxy2C0}khZ&ZIfw{}Y$Ab=G`WGjI= zTgvnXWx7|HeodL)tW5VP)0>p(L1n5d)2}E~Lz#Y6nOe$pN||m~rjyF_8_INAnSNWD z?pCH*WqLrF-lj}%QKp;X^y;|Zy06EnJ}$jcnNGy%;<&Lp{Vt@_(O=PYIy&pp>F9SqosRzIq|?!V7t-nI ztV^e(^D3Q=&h~UV`W?*J=O4Z@eb>jYUVLccm9sD1H#(owY5x=4x%RJqM%%4DSAV1a zTz%~n2M8d500IagfB*srAbKRo&aKyL9Rp$8E-;A^`#f2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5O_cWv2H(vR@e#i z(R}oPUf!z`AV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5;&FC_3H&(jK>aGg$P7`8G9@m zW&Qu{=vMuIq!9@aAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!Cs(7uYT{w!?WcE;b1$_6680F13q~@@R#f zFdxm;|3?s!009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF+*#m7-m?`t;X0kp#ur6te|{9z{nfE-t)4%M z9Ttr|%TBl*-KzhOG$H{41PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oSilz+LPAx66#}aGs2dO#+I20rrYZ zTg69t6!rf%qZ{@A5kw?FfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009DP3p^_`bVIAo6yxS+=bgnjwZbs$ z4n7Y5Jo<3(%|UDU-SG0@*WvTgr^D|D?+&M<{lia#cZ26gr$@Vk9}a&zn%gO0VW&ZW z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&U_FPyMEo@^%1HJPs8zPlJ#e4mW?Mr%^GIuh4JJh zecPX9N!B#S(>lj_a(S6QO2a4lI=o7<(F@7hS-+gG^xi3I zlU`VVrk{j$=eQTvpWR+KPA13cS$gv0t6%OrDGQDD*G4-uUlm)0WaIVlxLgnGtn2-H zRc06cGEKkXk4d#Y_d@zM|9u^wr;{u>>%UI(SDQ9oshx0L{8nE~s=3`*O!2a{dgoE> z(T$CKr-0q?esnW>udaV#qCtQF0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0tEhB;8}UO8#e3PtvYViv0ca5 LFW!&w^Kt(GUvNwF literal 0 HcmV?d00001 diff --git a/packages/temp_frontend/meili/tasks/lock.mdb b/packages/temp_frontend/meili/tasks/lock.mdb new file mode 100644 index 0000000000000000000000000000000000000000..93c4213e0aeb03df6664efe794435f62fa0eaf3e GIT binary patch literal 8192 zcmeIuI}v~|5CqVCI+WlD7x=&hN|-3Y0yqdT$xzeKy=```+MBnRV@vBY=Fk%F8ba#V y|5bb5rE{8}AA|q_0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBoLE^q;y01jOM literal 0 HcmV?d00001