From 0cc18448e4852e2f6b9080289a615bf0b96373ab Mon Sep 17 00:00:00 2001 From: alikia2x Date: Mon, 8 Dec 2025 19:31:26 +0800 Subject: [PATCH] ref: format --- packages/core/db/dbNew.ts | 2 +- packages/core/drizzle.config.ts | 2 +- packages/core/drizzle/index.ts | 2 +- packages/core/drizzle/main/relations.ts | 40 +- packages/core/drizzle/main/schema.ts | 886 +++++++----- packages/core/lib/index.ts | 2 +- packages/core/lib/math.ts | 3 +- packages/core/lib/type.ts | 2 +- packages/core/net/delegate.ts | 10 +- packages/core/test/netDelegate.test.ts | 7 +- packages/crawler/mq/task/collectSongs.ts | 2 +- packages/crawler/mq/task/getVideoStats.ts | 2 +- packages/palette/.vercel/project.json | 6 +- packages/palette/index.html | 5 +- packages/palette/src/App.tsx | 12 +- packages/palette/src/Switch.tsx | 16 +- .../palette/src/components/ColorBlock.tsx | 12 +- .../palette/src/components/Components.tsx | 18 +- .../palette/src/components/Picker/Picker.tsx | 12 +- .../palette/src/components/Picker/Slider.tsx | 8 +- .../temp_frontend/app/components/Search.tsx | 4 +- .../app/components/SearchResults.tsx | 2 +- .../app/components/ui/alert-dialog.tsx | 212 ++- .../temp_frontend/app/components/ui/card.tsx | 105 +- .../temp_frontend/app/components/ui/chart.tsx | 555 ++++---- .../app/components/ui/dialog.tsx | 206 ++- .../temp_frontend/app/components/ui/label.tsx | 33 +- .../app/components/ui/progress.tsx | 43 +- .../app/components/ui/select.tsx | 285 ++-- .../app/components/ui/skeleton.tsx | 12 +- .../temp_frontend/app/components/ui/table.tsx | 137 +- packages/temp_frontend/app/root.tsx | 2 +- .../app/routes/home/MilestoneVideoCard.tsx | 4 +- .../routes/labelling/LabelInstructions.tsx | 16 +- .../app/routes/labelling/VideoInfo.tsx | 1 - packages/temp_frontend/app/routes/login.tsx | 2 +- .../app/routes/video/[id]/info/index.tsx | 15 +- .../temp_frontend/public/site.webmanifest | 12 +- packages/temp_frontend/wrangler.jsonc | 4 +- packages/tracker/app/admin/users.tsx | 109 +- packages/tracker/app/app.css | 32 +- .../app/components/project/ProjectDialog.tsx | 29 +- .../app/components/project/UserSearch.tsx | 1 - .../tracker/app/components/task/TaskForm.tsx | 4 +- .../app/components/ui/alert-dialog.tsx | 212 ++- packages/tracker/app/components/ui/badge.tsx | 70 +- packages/tracker/app/components/ui/button.tsx | 100 +- .../tracker/app/components/ui/calendar.tsx | 364 +++-- packages/tracker/app/components/ui/card.tsx | 124 +- .../tracker/app/components/ui/checkbox.tsx | 49 +- packages/tracker/app/components/ui/dialog.tsx | 204 ++- packages/tracker/app/components/ui/input.tsx | 32 +- packages/tracker/app/components/ui/label.tsx | 33 +- .../tracker/app/components/ui/popover.tsx | 64 +- .../tracker/app/components/ui/scroll-area.tsx | 90 +- packages/tracker/app/components/ui/select.tsx | 283 ++-- .../tracker/app/components/ui/separator.tsx | 42 +- packages/tracker/app/components/ui/sheet.tsx | 199 ++- .../tracker/app/components/ui/sidebar.tsx | 1192 ++++++++--------- .../tracker/app/components/ui/skeleton.tsx | 18 +- packages/tracker/app/components/ui/sonner.tsx | 68 +- .../tracker/app/components/ui/spinner.tsx | 22 +- packages/tracker/app/components/ui/table.tsx | 156 +-- .../tracker/app/components/ui/textarea.tsx | 26 +- .../tracker/app/components/ui/tooltip.tsx | 88 +- packages/tracker/app/home/home.tsx | 12 +- packages/tracker/app/hooks/use-mobile.ts | 26 +- packages/tracker/app/lib/utils.ts | 6 +- packages/tracker/app/login/action.ts | 4 +- packages/tracker/app/login/page.tsx | 2 +- .../tracker/app/projects/projectPageAction.ts | 2 +- packages/tracker/app/root.tsx | 2 +- packages/tracker/app/routes.ts | 4 +- packages/tracker/app/setup/setup.tsx | 17 +- packages/tracker/components.json | 40 +- packages/tracker/drizzle.config.ts | 2 +- packages/tracker/lib/auth-utils.ts | 2 +- packages/tracker/lib/auth.ts | 16 +- packages/tracker/lib/db/index.ts | 1 - packages/tracker/public/site.webmanifest | 12 +- 80 files changed, 3229 insertions(+), 3229 deletions(-) diff --git a/packages/core/db/dbNew.ts b/packages/core/db/dbNew.ts index 15e537d..0493ab0 100644 --- a/packages/core/db/dbNew.ts +++ b/packages/core/db/dbNew.ts @@ -1,4 +1,4 @@ import postgres from "postgres"; import { postgresConfig } from "./pgConfigNew"; -export const sql = postgres(postgresConfig); \ No newline at end of file +export const sql = postgres(postgresConfig); diff --git a/packages/core/drizzle.config.ts b/packages/core/drizzle.config.ts index 56da063..712f00d 100644 --- a/packages/core/drizzle.config.ts +++ b/packages/core/drizzle.config.ts @@ -7,5 +7,5 @@ export default defineConfig({ dbCredentials: { url: process.env.DATABASE_URL_MAIN! }, - schemaFilter: ["public", "credentials", "internal"] + schemaFilter: ["public", "credentials", "internal"] }); diff --git a/packages/core/drizzle/index.ts b/packages/core/drizzle/index.ts index 34d947f..be32725 100644 --- a/packages/core/drizzle/index.ts +++ b/packages/core/drizzle/index.ts @@ -5,4 +5,4 @@ import { sql } from "@core/db/dbNew"; export const db = drizzle(sql); export * from "./main/schema"; -export * from "./type"; \ No newline at end of file +export * from "./type"; diff --git a/packages/core/drizzle/main/relations.ts b/packages/core/drizzle/main/relations.ts index 6ec9fdc..a9fd6e2 100644 --- a/packages/core/drizzle/main/relations.ts +++ b/packages/core/drizzle/main/relations.ts @@ -1,31 +1,39 @@ import { relations } from "drizzle-orm/relations"; -import { usersInCredentials, history, songs, relationsProducer, singer, relationSinger, videoTypeLabelInInternal } from "./schema"; +import { + usersInCredentials, + history, + songs, + relationsProducer, + singer, + relationSinger, + videoTypeLabelInInternal +} from "./schema"; -export const historyRelations = relations(history, ({one}) => ({ +export const historyRelations = relations(history, ({ one }) => ({ usersInCredential: one(usersInCredentials, { fields: [history.changedBy], references: [usersInCredentials.unqId] - }), + }) })); -export const usersInCredentialsRelations = relations(usersInCredentials, ({many}) => ({ +export const usersInCredentialsRelations = relations(usersInCredentials, ({ many }) => ({ histories: many(history), - videoTypeLabelInInternals: many(videoTypeLabelInInternal), + videoTypeLabelInInternals: many(videoTypeLabelInInternal) })); -export const relationsProducerRelations = relations(relationsProducer, ({one}) => ({ +export const relationsProducerRelations = relations(relationsProducer, ({ one }) => ({ song: one(songs, { fields: [relationsProducer.songId], references: [songs.id] - }), + }) })); -export const songsRelations = relations(songs, ({many}) => ({ +export const songsRelations = relations(songs, ({ many }) => ({ relationsProducers: many(relationsProducer), - relationSingers: many(relationSinger), + relationSingers: many(relationSinger) })); -export const relationSingerRelations = relations(relationSinger, ({one}) => ({ +export const relationSingerRelations = relations(relationSinger, ({ one }) => ({ singer: one(singer, { fields: [relationSinger.singerId], references: [singer.id] @@ -33,16 +41,16 @@ export const relationSingerRelations = relations(relationSinger, ({one}) => ({ song: one(songs, { fields: [relationSinger.songId], references: [songs.id] - }), + }) })); -export const singerRelations = relations(singer, ({many}) => ({ - relationSingers: many(relationSinger), +export const singerRelations = relations(singer, ({ many }) => ({ + relationSingers: many(relationSinger) })); -export const videoTypeLabelInInternalRelations = relations(videoTypeLabelInInternal, ({one}) => ({ +export const videoTypeLabelInInternalRelations = relations(videoTypeLabelInInternal, ({ one }) => ({ usersInCredential: one(usersInCredentials, { fields: [videoTypeLabelInInternal.user], references: [usersInCredentials.unqId] - }), -})); \ No newline at end of file + }) +})); diff --git a/packages/core/drizzle/main/schema.ts b/packages/core/drizzle/main/schema.ts index 8da0a25..1331adc 100644 --- a/packages/core/drizzle/main/schema.ts +++ b/packages/core/drizzle/main/schema.ts @@ -1,351 +1,617 @@ -import { pgTable, pgSchema, uniqueIndex, check, integer, text, timestamp, foreignKey, serial, bigint, jsonb, index, inet, varchar, smallint, real, boolean, bigserial, unique, pgSequence } from "drizzle-orm/pg-core" -import { sql } from "drizzle-orm" +import { + pgTable, + pgSchema, + uniqueIndex, + check, + integer, + text, + timestamp, + foreignKey, + serial, + bigint, + jsonb, + index, + inet, + varchar, + smallint, + real, + boolean, + bigserial, + unique, + pgSequence +} from "drizzle-orm/pg-core"; +import { sql } from "drizzle-orm"; export const credentials = pgSchema("credentials"); export const internal = pgSchema("internal"); -export const userRoleInCredentials = credentials.enum("user_role", ['ADMIN', 'USER', 'OWNER']) +export const userRoleInCredentials = credentials.enum("user_role", ["ADMIN", "USER", "OWNER"]); -export const usersIdSeqInCredentials = credentials.sequence("users_id_seq", { startWith: "1", increment: "1", minValue: "1", maxValue: "2147483647", cache: "1", cycle: false }) -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 relationSingerIdSeq = pgSequence("relation_singer_id_seq", { startWith: "1", increment: "1", minValue: "1", maxValue: "2147483647", cache: "1", cycle: false }) -export const relationsProducerIdSeq = pgSequence("relations_producer_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 usersIdSeqInCredentials = credentials.sequence("users_id_seq", { + startWith: "1", + increment: "1", + minValue: "1", + maxValue: "2147483647", + cache: "1", + cycle: false +}); +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 relationSingerIdSeq = pgSequence("relation_singer_id_seq", { + startWith: "1", + increment: "1", + minValue: "1", + maxValue: "2147483647", + cache: "1", + cycle: false +}); +export const relationsProducerIdSeq = pgSequence("relations_producer_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 usersInCredentials = credentials.table("users", { - id: integer().default(sql`nextval('credentials.users_id_seq'::regclass)`).notNull(), - nickname: text(), - username: text().notNull(), - password: text().notNull(), - unqId: text("unq_id").notNull(), - role: userRoleInCredentials().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_username_key").using("btree", table.username.asc().nullsLast().op("text_ops")), - check("users_id_not_null", sql`NOT NULL id`), - check("users_username_not_null", sql`NOT NULL username`), - check("users_password_not_null", sql`NOT NULL password`), - check("users_unq_id_not_null", sql`NOT NULL unq_id`), - check("users_role_not_null", sql`NOT NULL role`), - check("users_created_at_not_null", sql`NOT NULL created_at`), -]); +export const usersInCredentials = credentials.table( + "users", + { + id: integer() + .default(sql`nextval('credentials.users_id_seq'::regclass)`) + .notNull(), + nickname: text(), + username: text().notNull(), + password: text().notNull(), + unqId: text("unq_id").notNull(), + role: userRoleInCredentials().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_username_key").using( + "btree", + table.username.asc().nullsLast().op("text_ops") + ), + check("users_id_not_null", sql`NOT NULL id`), + check("users_username_not_null", sql`NOT NULL username`), + check("users_password_not_null", sql`NOT NULL password`), + check("users_unq_id_not_null", sql`NOT NULL unq_id`), + check("users_role_not_null", sql`NOT NULL role`), + check("users_created_at_not_null", sql`NOT NULL created_at`) + ] +); -export const history = pgTable("history", { - id: serial().primaryKey().notNull(), - // You can use { mode: "bigint" } if numbers are exceeding js number limitations - objectId: bigint("object_id", { mode: "number" }).notNull(), - changeType: text("change_type").notNull(), - changedAt: timestamp("changed_at", { withTimezone: true, mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), - changedBy: text("changed_by").notNull(), - data: jsonb(), -}, (table) => [ - foreignKey({ +export const history = pgTable( + "history", + { + id: serial().primaryKey().notNull(), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + objectId: bigint("object_id", { mode: "number" }).notNull(), + changeType: text("change_type").notNull(), + changedAt: timestamp("changed_at", { withTimezone: true, mode: "string" }) + .default(sql`CURRENT_TIMESTAMP`) + .notNull(), + changedBy: text("changed_by").notNull(), + data: jsonb() + }, + (table) => [ + foreignKey({ columns: [table.changedBy], foreignColumns: [usersInCredentials.unqId], name: "rel_history_changed_by" }), - check("history_id_not_null", sql`NOT NULL id`), - check("history_object_id_not_null", sql`NOT NULL object_id`), - check("history_change_type_not_null", sql`NOT NULL change_type`), - check("history_changed_at_not_null", sql`NOT NULL changed_at`), - check("history_changed_by_not_null", sql`NOT NULL changed_by`), -]); + check("history_id_not_null", sql`NOT NULL id`), + check("history_object_id_not_null", sql`NOT NULL object_id`), + check("history_change_type_not_null", sql`NOT NULL change_type`), + check("history_changed_at_not_null", sql`NOT NULL changed_at`), + check("history_changed_by_not_null", sql`NOT NULL changed_by`) + ] +); -export const loginSessionsInCredentials = credentials.table("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")), - check("login_sessions_id_not_null", sql`NOT NULL id`), - check("login_sessions_uid_not_null", sql`NOT NULL uid`), - check("login_sessions_created_at_not_null", sql`NOT NULL created_at`), -]); +export const loginSessionsInCredentials = credentials.table( + "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") + ), + check("login_sessions_id_not_null", sql`NOT NULL id`), + check("login_sessions_uid_not_null", sql`NOT NULL uid`), + check("login_sessions_created_at_not_null", sql`NOT NULL created_at`) + ] +); -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")), - check("bilibili_metadata_id_not_null", sql`NOT NULL id`), - check("bilibili_metadata_aid_not_null", sql`NOT NULL aid`), - check("bilibili_metadata_status_not_null", sql`NOT NULL status`), -]); +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")), + check("bilibili_metadata_id_not_null", sql`NOT NULL id`), + check("bilibili_metadata_aid_not_null", sql`NOT NULL aid`), + check("bilibili_metadata_status_not_null", sql`NOT NULL status`) + ] +); -export const humanClassifiedLables = pgTable("human_classified_lables", { - id: serial().primaryKey().notNull(), - // You can use { mode: "bigint" } if numbers are exceeding js number limitations - aid: bigint({ mode: "number" }).notNull(), - uid: integer().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.uid.asc().nullsLast().op("int4_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")), - check("human_classified_lables_id_not_null", sql`NOT NULL id`), - check("human_classified_lables_aid_not_null", sql`NOT NULL aid`), - check("human_classified_lables_uid_not_null", sql`NOT NULL uid`), - check("human_classified_lables_label_not_null", sql`NOT NULL label`), - check("human_classified_lables_created_at_not_null", sql`NOT NULL created_at`), -]); +export const humanClassifiedLables = pgTable( + "human_classified_lables", + { + id: serial().primaryKey().notNull(), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + aid: bigint({ mode: "number" }).notNull(), + uid: integer().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.uid.asc().nullsLast().op("int4_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") + ), + check("human_classified_lables_id_not_null", sql`NOT NULL id`), + check("human_classified_lables_aid_not_null", sql`NOT NULL aid`), + check("human_classified_lables_uid_not_null", sql`NOT NULL uid`), + check("human_classified_lables_label_not_null", sql`NOT NULL label`), + check("human_classified_lables_created_at_not_null", sql`NOT NULL created_at`) + ] +); -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(), - likes: integer(), - favorites: integer(), - shares: integer(), - danmakus: integer(), - // You can use { mode: "bigint" } if numbers are exceeding js number limitations - aid: bigint({ mode: "number" }).notNull(), - replies: integer(), -}, (table) => [ - index("idx_vid_snapshot_aid_created_at").using("btree", table.aid.asc().nullsLast().op("int8_ops"), table.createdAt.asc().nullsLast().op("int8_ops")), - index("idx_vid_snapshot_time").using("btree", table.createdAt.asc().nullsLast().op("timestamptz_ops")), - check("video_snapshot_id_not_null", sql`NOT NULL id`), - check("video_snapshot_created_at_not_null", sql`NOT NULL created_at`), - check("video_snapshot_views_not_null", sql`NOT NULL views`), - check("video_snapshot_aid_not_null", sql`NOT NULL aid`), -]); +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(), + likes: integer(), + favorites: integer(), + shares: integer(), + danmakus: integer(), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + aid: bigint({ mode: "number" }).notNull(), + replies: integer() + }, + (table) => [ + index("idx_vid_snapshot_aid_created_at").using( + "btree", + table.aid.asc().nullsLast().op("int8_ops"), + table.createdAt.asc().nullsLast().op("int8_ops") + ), + index("idx_vid_snapshot_time").using( + "btree", + table.createdAt.asc().nullsLast().op("timestamptz_ops") + ), + check("video_snapshot_id_not_null", sql`NOT NULL id`), + check("video_snapshot_created_at_not_null", sql`NOT NULL created_at`), + check("video_snapshot_views_not_null", sql`NOT NULL views`), + check("video_snapshot_aid_not_null", sql`NOT NULL aid`) + ] +); -export const producer = pgTable("producer", { - id: integer().primaryKey().notNull(), - name: text().notNull(), -}, (table) => [ - check("producer_id_not_null", sql`NOT NULL id`), - check("producer_name_not_null", sql`NOT NULL name`), -]); +export const producer = pgTable( + "producer", + { + id: integer().primaryKey().notNull(), + name: text().notNull() + }, + (table) => [ + check("producer_id_not_null", sql`NOT NULL id`), + check("producer_name_not_null", sql`NOT NULL name`) + ] +); -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")), - check("labelling_result_id_not_null", sql`NOT NULL id`), - check("labelling_result_aid_not_null", sql`NOT NULL aid`), - check("labelling_result_label_not_null", sql`NOT NULL label`), - check("labelling_result_model_version_not_null", sql`NOT NULL model_version`), - check("labelling_result_created_at_not_null", sql`NOT NULL created_at`), -]); +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") + ), + check("labelling_result_id_not_null", sql`NOT NULL id`), + check("labelling_result_aid_not_null", sql`NOT NULL aid`), + check("labelling_result_label_not_null", sql`NOT NULL label`), + check("labelling_result_model_version_not_null", sql`NOT NULL model_version`), + check("labelling_result_created_at_not_null", sql`NOT NULL created_at`) + ] +); -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")), - check("latest_video_snapshot_aid_not_null", sql`NOT NULL aid`), - check("latest_video_snapshot_time_not_null", sql`NOT NULL "time"`), - check("latest_video_snapshot_views_not_null", sql`NOT NULL views`), - check("latest_video_snapshot_coins_not_null", sql`NOT NULL coins`), - check("latest_video_snapshot_likes_not_null", sql`NOT NULL likes`), - check("latest_video_snapshot_favorites_not_null", sql`NOT NULL favorites`), - check("latest_video_snapshot_replies_not_null", sql`NOT NULL replies`), - check("latest_video_snapshot_danmakus_not_null", sql`NOT NULL danmakus`), - check("latest_video_snapshot_shares_not_null", sql`NOT NULL shares`), -]); +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") + ), + check("latest_video_snapshot_aid_not_null", sql`NOT NULL aid`), + check("latest_video_snapshot_time_not_null", sql`NOT NULL "time"`), + check("latest_video_snapshot_views_not_null", sql`NOT NULL views`), + check("latest_video_snapshot_coins_not_null", sql`NOT NULL coins`), + check("latest_video_snapshot_likes_not_null", sql`NOT NULL likes`), + check("latest_video_snapshot_favorites_not_null", sql`NOT NULL favorites`), + check("latest_video_snapshot_replies_not_null", sql`NOT NULL replies`), + check("latest_video_snapshot_danmakus_not_null", sql`NOT NULL danmakus`), + check("latest_video_snapshot_shares_not_null", sql`NOT NULL shares`) + ] +); -export const relationsProducer = pgTable("relations_producer", { - id: integer().default(sql`nextval('relations_producer_id_seq'::regclass)`).primaryKey().notNull(), - // You can use { mode: "bigint" } if numbers are exceeding js number limitations - songId: bigint("song_id", { mode: "number" }).notNull(), - createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), - producerId: integer("producer_id").notNull(), - updatedAt: timestamp("updated_at", { withTimezone: true, mode: 'string' }).default(sql`CURRENT_TIMESTAMP`).notNull(), -}, (table) => [ - foreignKey({ +export const relationsProducer = pgTable( + "relations_producer", + { + id: integer() + .default(sql`nextval('relations_producer_id_seq'::regclass)`) + .primaryKey() + .notNull(), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + songId: bigint("song_id", { mode: "number" }).notNull(), + createdAt: timestamp("created_at", { withTimezone: true, mode: "string" }) + .default(sql`CURRENT_TIMESTAMP`) + .notNull(), + producerId: integer("producer_id").notNull(), + updatedAt: timestamp("updated_at", { withTimezone: true, mode: "string" }) + .default(sql`CURRENT_TIMESTAMP`) + .notNull() + }, + (table) => [ + foreignKey({ columns: [table.songId], foreignColumns: [songs.id], name: "fkey_relations_producer_songs_id" }), - check("relations_producer_id_not_null", sql`NOT NULL id`), - check("relations_producer_song_id_not_null", sql`NOT NULL song_id`), - check("relations_producer_created_at_not_null", sql`NOT NULL created_at`), - check("relations_producer_producer_id_not_null", sql`NOT NULL producer_id`), - check("relations_producer_updated_at_not_null", sql`NOT NULL updated_at`), -]); + check("relations_producer_id_not_null", sql`NOT NULL id`), + check("relations_producer_song_id_not_null", sql`NOT NULL song_id`), + check("relations_producer_created_at_not_null", sql`NOT NULL created_at`), + check("relations_producer_producer_id_not_null", sql`NOT NULL producer_id`), + check("relations_producer_updated_at_not_null", sql`NOT NULL updated_at`) + ] +); -export const eta = pgTable("eta", { - // You can use { mode: "bigint" } if numbers are exceeding js number limitations - aid: bigint({ mode: "number" }).primaryKey().notNull(), - eta: real().notNull(), - speed: real().notNull(), - currentViews: integer("current_views").notNull(), - updatedAt: timestamp("updated_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), -}, (table) => [ - index("idx_eta_eta_current_views").using("btree", table.eta.asc().nullsLast().op("int4_ops"), table.currentViews.asc().nullsLast().op("int4_ops")), - check("eta_aid_not_null", sql`NOT NULL aid`), - check("eta_eta_not_null", sql`NOT NULL eta`), - check("eta_speed_not_null", sql`NOT NULL speed`), - check("eta_current_views_not_null", sql`NOT NULL current_views`), - check("eta_updated_at_not_null", sql`NOT NULL updated_at`), -]); +export const eta = pgTable( + "eta", + { + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + aid: bigint({ mode: "number" }).primaryKey().notNull(), + eta: real().notNull(), + speed: real().notNull(), + currentViews: integer("current_views").notNull(), + updatedAt: timestamp("updated_at", { withTimezone: true, mode: "string" }) + .defaultNow() + .notNull() + }, + (table) => [ + index("idx_eta_eta_current_views").using( + "btree", + table.eta.asc().nullsLast().op("int4_ops"), + table.currentViews.asc().nullsLast().op("int4_ops") + ), + check("eta_aid_not_null", sql`NOT NULL aid`), + check("eta_eta_not_null", sql`NOT NULL eta`), + check("eta_speed_not_null", sql`NOT NULL speed`), + check("eta_current_views_not_null", sql`NOT NULL current_views`), + check("eta_updated_at_not_null", sql`NOT NULL updated_at`) + ] +); -export const singer = pgTable("singer", { - id: serial().primaryKey().notNull(), - name: text().notNull(), -}, (table) => [ - check("singer_id_not_null", sql`NOT NULL id`), - check("singer_name_not_null", sql`NOT NULL name`), -]); +export const singer = pgTable( + "singer", + { + id: serial().primaryKey().notNull(), + name: text().notNull() + }, + (table) => [ + check("singer_id_not_null", sql`NOT NULL id`), + check("singer_name_not_null", sql`NOT NULL name`) + ] +); -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(), - // 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(), - producer: text(), -}, (table) => [ - 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_songs_name").using("gin", table.name.asc().nullsLast().op("gin_trgm_ops")), - index("idx_type").using("btree", table.type.asc().nullsLast().op("int2_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")), - check("songs_id_not_null", sql`NOT NULL id`), - check("songs_created_at_not_null", sql`NOT NULL created_at`), - check("songs_updated_at_not_null", sql`NOT NULL updated_at`), - check("songs_deleted_not_null", sql`NOT NULL deleted`), -]); +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(), + // 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(), + producer: text() + }, + (table) => [ + 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_songs_name").using("gin", table.name.asc().nullsLast().op("gin_trgm_ops")), + index("idx_type").using("btree", table.type.asc().nullsLast().op("int2_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") + ), + check("songs_id_not_null", sql`NOT NULL id`), + check("songs_created_at_not_null", sql`NOT NULL created_at`), + check("songs_updated_at_not_null", sql`NOT NULL updated_at`), + check("songs_deleted_not_null", sql`NOT NULL deleted`) + ] +); -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_status_type").using("btree", table.aid.asc().nullsLast().op("int8_ops"), table.status.asc().nullsLast().op("text_ops"), table.type.asc().nullsLast().op("text_ops")), - index("idx_snapshot_schedule_status_started_at").using("btree", table.status.asc().nullsLast().op("timestamptz_ops"), table.startedAt.asc().nullsLast().op("text_ops")), - uniqueIndex("snapshot_schedule_pkey").using("btree", table.id.asc().nullsLast().op("int8_ops")), - check("snapshot_schedule_id_not_null", sql`NOT NULL id`), - check("snapshot_schedule_aid_not_null", sql`NOT NULL aid`), - check("snapshot_schedule_created_at_not_null", sql`NOT NULL created_at`), - check("snapshot_schedule_status_not_null", sql`NOT NULL status`), -]); +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_status_type").using( + "btree", + table.aid.asc().nullsLast().op("int8_ops"), + table.status.asc().nullsLast().op("text_ops"), + table.type.asc().nullsLast().op("text_ops") + ), + index("idx_snapshot_schedule_status_started_at").using( + "btree", + table.status.asc().nullsLast().op("timestamptz_ops"), + table.startedAt.asc().nullsLast().op("text_ops") + ), + uniqueIndex("snapshot_schedule_pkey").using( + "btree", + table.id.asc().nullsLast().op("int8_ops") + ), + check("snapshot_schedule_id_not_null", sql`NOT NULL id`), + check("snapshot_schedule_aid_not_null", sql`NOT NULL aid`), + check("snapshot_schedule_created_at_not_null", sql`NOT NULL created_at`), + check("snapshot_schedule_status_not_null", sql`NOT NULL status`) + ] +); -export const relationSinger = pgTable("relation_singer", { - id: integer().default(sql`nextval('relation_singer_id_seq'::regclass)`).primaryKey().notNull(), - // You can use { mode: "bigint" } if numbers are exceeding js number limitations - songId: bigint("song_id", { mode: "number" }).notNull(), - singerId: integer("singer_id").notNull(), - 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(), -}, (table) => [ - foreignKey({ +export const relationSinger = pgTable( + "relation_singer", + { + id: integer() + .default(sql`nextval('relation_singer_id_seq'::regclass)`) + .primaryKey() + .notNull(), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + songId: bigint("song_id", { mode: "number" }).notNull(), + singerId: integer("singer_id").notNull(), + 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() + }, + (table) => [ + foreignKey({ columns: [table.singerId], foreignColumns: [singer.id], name: "fkey_singer_id" }), - foreignKey({ + foreignKey({ columns: [table.songId], foreignColumns: [songs.id], name: "fkey_song_id" }), - check("relation_singer_id_not_null", sql`NOT NULL id`), - check("relation_singer_song_id_not_null", sql`NOT NULL song_id`), - check("relation_singer_singer_id_not_null", sql`NOT NULL singer_id`), - check("relation_singer_created_at_not_null", sql`NOT NULL created_at`), - check("relation_singer_updated_at_not_null", sql`NOT NULL updated_at`), -]); + check("relation_singer_id_not_null", sql`NOT NULL id`), + check("relation_singer_song_id_not_null", sql`NOT NULL song_id`), + check("relation_singer_singer_id_not_null", sql`NOT NULL singer_id`), + check("relation_singer_created_at_not_null", sql`NOT NULL created_at`), + check("relation_singer_updated_at_not_null", sql`NOT NULL updated_at`) + ] +); -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(), - 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(), - avatar: text(), -}, (table) => [ - index("idx_bili-user_uid").using("btree", table.uid.asc().nullsLast().op("int8_ops")), - unique("unq_bili-user_uid").on(table.uid), - check("bilibili_user_id_not_null", sql`NOT NULL id`), - check("bilibili_user_uid_not_null", sql`NOT NULL uid`), - check("bilibili_user_username_not_null", sql`NOT NULL username`), - check("bilibili_user_desc_not_null", sql`NOT NULL "desc"`), - check("bilibili_user_fans_not_null", sql`NOT NULL fans`), - check("bilibili_user_created_at_not_null", sql`NOT NULL created_at`), - check("bilibili_user_updated_at_not_null", sql`NOT NULL updated_at`), -]); +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(), + 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(), + avatar: text() + }, + (table) => [ + index("idx_bili-user_uid").using("btree", table.uid.asc().nullsLast().op("int8_ops")), + unique("unq_bili-user_uid").on(table.uid), + check("bilibili_user_id_not_null", sql`NOT NULL id`), + check("bilibili_user_uid_not_null", sql`NOT NULL uid`), + check("bilibili_user_username_not_null", sql`NOT NULL username`), + check("bilibili_user_desc_not_null", sql`NOT NULL "desc"`), + check("bilibili_user_fans_not_null", sql`NOT NULL fans`), + check("bilibili_user_created_at_not_null", sql`NOT NULL created_at`), + check("bilibili_user_updated_at_not_null", sql`NOT NULL updated_at`) + ] +); -export const videoTypeLabelInInternal = internal.table("video_type_label", { - id: serial().primaryKey().notNull(), - // You can use { mode: "bigint" } if numbers are exceeding js number limitations - aid: bigint({ mode: "number" }).notNull(), - label: boolean().notNull(), - user: text().default('i3wW8JdZ9sT3ASkk').notNull(), -}, (table) => [ - foreignKey({ +export const videoTypeLabelInInternal = internal.table( + "video_type_label", + { + id: serial().primaryKey().notNull(), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + aid: bigint({ mode: "number" }).notNull(), + label: boolean().notNull(), + user: text().default("i3wW8JdZ9sT3ASkk").notNull() + }, + (table) => [ + foreignKey({ columns: [table.user], foreignColumns: [usersInCredentials.unqId], name: "fkey_video_type_label_user" }), - check("video_type_label_id_not_null", sql`NOT NULL id`), - check("video_type_label_aid_not_null", sql`NOT NULL aid`), - check("video_type_label_label_not_null", sql`NOT NULL label`), - check("video_type_label_user_not_null", sql`NOT NULL "user"`), -]); + check("video_type_label_id_not_null", sql`NOT NULL id`), + check("video_type_label_aid_not_null", sql`NOT NULL aid`), + check("video_type_label_label_not_null", sql`NOT NULL label`), + check("video_type_label_user_not_null", sql`NOT NULL "user"`) + ] +); diff --git a/packages/core/lib/index.ts b/packages/core/lib/index.ts index 4bf52b9..999a8bf 100644 --- a/packages/core/lib/index.ts +++ b/packages/core/lib/index.ts @@ -2,4 +2,4 @@ export * from "./math"; export * from "./milestone"; export * from "./randomID"; export * from "./time"; -export * from "./type"; \ No newline at end of file +export * from "./type"; diff --git a/packages/core/lib/math.ts b/packages/core/lib/math.ts index f81bc2d..20e9b3b 100644 --- a/packages/core/lib/math.ts +++ b/packages/core/lib/math.ts @@ -1,3 +1,4 @@ export const log = (value: number, base: number = 10) => Math.log(value) / Math.log(base); -export const truncate = (num: number, min: number, max: number) => Math.max(min, Math.min(num, max)); +export const truncate = (num: number, min: number, max: number) => + Math.max(min, Math.min(num, max)); diff --git a/packages/core/lib/type.ts b/packages/core/lib/type.ts index c68be82..ce7e0b4 100644 --- a/packages/core/lib/type.ts +++ b/packages/core/lib/type.ts @@ -1 +1 @@ -export type PartialBy = Omit & Partial>; \ No newline at end of file +export type PartialBy = Omit & Partial>; diff --git a/packages/core/net/delegate.ts b/packages/core/net/delegate.ts index eec7f73..4a458b5 100644 --- a/packages/core/net/delegate.ts +++ b/packages/core/net/delegate.ts @@ -168,7 +168,10 @@ class NetworkDelegate { * - The alicloud-fc threw an error: with error code `ALICLOUD_FC_ERROR` * - The proxy type is not supported: with error code `NOT_IMPLEMENTED` */ - async request(url: string, task: string): Promise<{ + async request( + url: string, + task: string + ): Promise<{ data: R; time: number; }> { @@ -221,7 +224,10 @@ class NetworkDelegate { return result; } - private async makeRequest(url: string, proxy: Proxy): Promise<{ + private async makeRequest( + url: string, + proxy: Proxy + ): Promise<{ data: R; time: number; }> { diff --git a/packages/core/test/netDelegate.test.ts b/packages/core/test/netDelegate.test.ts index d531b3c..598c4bf 100644 --- a/packages/core/test/netDelegate.test.ts +++ b/packages/core/test/netDelegate.test.ts @@ -3,7 +3,10 @@ import { test, expect, describe } from "bun:test"; describe("proxying requests", () => { test("Alibaba Cloud FC", async () => { - const { res } = await networkDelegate.request("https://postman-echo.com/get", "test") as any; - expect(res.headers.referer).toBe('https://www.bilibili.com/'); + const { res } = (await networkDelegate.request( + "https://postman-echo.com/get", + "test" + )) as any; + expect(res.headers.referer).toBe("https://www.bilibili.com/"); }); }); diff --git a/packages/crawler/mq/task/collectSongs.ts b/packages/crawler/mq/task/collectSongs.ts index 8ce4a0d..579b463 100644 --- a/packages/crawler/mq/task/collectSongs.ts +++ b/packages/crawler/mq/task/collectSongs.ts @@ -51,7 +51,7 @@ export async function insertIntoSongs(aid: number) { ) ON CONFLICT DO NOTHING RETURNING * - ` + `; return data; } diff --git a/packages/crawler/mq/task/getVideoStats.ts b/packages/crawler/mq/task/getVideoStats.ts index c6d02e0..b231c98 100644 --- a/packages/crawler/mq/task/getVideoStats.ts +++ b/packages/crawler/mq/task/getVideoStats.ts @@ -53,7 +53,7 @@ export async function takeVideoSnapshot( danmakus, replies, aid - }) + }); logger.log(`Taken snapshot for video ${aid}.`, "net", "fn:insertVideoSnapshot"); diff --git a/packages/palette/.vercel/project.json b/packages/palette/.vercel/project.json index 6abfb75..438087b 100644 --- a/packages/palette/.vercel/project.json +++ b/packages/palette/.vercel/project.json @@ -1 +1,5 @@ -{"projectId":"prj_a2fcj6ZRTyTlllCd2rFJm7kPLEOc","orgId":"team_DiIY95BaFppaGJqqgrXYNt5O","projectName":"cvsa-theme"} \ No newline at end of file +{ + "projectId": "prj_a2fcj6ZRTyTlllCd2rFJm7kPLEOc", + "orgId": "team_DiIY95BaFppaGJqqgrXYNt5O", + "projectName": "cvsa-theme" +} diff --git a/packages/palette/index.html b/packages/palette/index.html index eed7c89..a297b0a 100644 --- a/packages/palette/index.html +++ b/packages/palette/index.html @@ -6,7 +6,10 @@ CVSA Color Palette Generator - +
diff --git a/packages/palette/src/App.tsx b/packages/palette/src/App.tsx index 3ca7be5..cf64564 100644 --- a/packages/palette/src/App.tsx +++ b/packages/palette/src/App.tsx @@ -60,16 +60,22 @@ function App() { return (
-

CVSA Color Palette Generator

+

+ CVSA Color Palette Generator +

{/* Left Column - Color Picker */}
-

Color Selection

+

+ Color Selection +

- +
= ({ checked, onChange, disabled = false, className = "", label }) => { +export const Switch: React.FC = ({ + checked, + onChange, + disabled = false, + className = "", + label +}) => { const handleToggle = () => { if (!disabled) { onChange(!checked); @@ -22,7 +28,9 @@ export const Switch: React.FC = ({ checked, onChange, disabled = fa disabled={disabled} className={`relative flex items-center justify-center w-12 h-6 rounded-full transition-all duration-300 focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2 ${ - disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer hover:scale-105" + disabled + ? "cursor-not-allowed opacity-50" + : "cursor-pointer hover:scale-105" } ${checked ? "bg-green-500" : "bg-zinc-300 dark:bg-zinc-600"}`} aria-checked={checked} aria-disabled={disabled} @@ -40,7 +48,9 @@ export const Switch: React.FC = ({ checked, onChange, disabled = fa {label && (
); @@ -53,19 +54,28 @@ const Buttons = ({ baseColor }: { baseColor: Oklch }) => { > diff --git a/packages/palette/src/components/Picker/Picker.tsx b/packages/palette/src/components/Picker/Picker.tsx index 5d583cd..b29ec3a 100644 --- a/packages/palette/src/components/Picker/Picker.tsx +++ b/packages/palette/src/components/Picker/Picker.tsx @@ -34,13 +34,17 @@ const Preview = ({ color, i18n }: { color: Oklch; i18n: I18nProvider }) => { className="w-full h-20 mb-5 rounded-lg flex items-center justify-center border border-dashed border-gray-300 dark:border-gray-500" > - {i18n("unsupported")} + + {i18n("unsupported")} +
- {i18n("fallback")} + + {i18n("fallback")} +
); @@ -59,7 +63,9 @@ const Preview = ({ color, i18n }: { color: Oklch; i18n: I18nProvider }) => { className="w-full h-20 mb-5 rounded-lg flex items-end justify-center" style={{ backgroundColor: hex }} > - {i18n("fallback")} + + {i18n("fallback")} +
); diff --git a/packages/palette/src/components/Picker/Slider.tsx b/packages/palette/src/components/Picker/Slider.tsx index 21c76f4..39954cb 100644 --- a/packages/palette/src/components/Picker/Slider.tsx +++ b/packages/palette/src/components/Picker/Slider.tsx @@ -22,7 +22,13 @@ export const Slider = ({ useP3, channel, color, onChange, i18nProvider }: Slider }, [color.l, color.c, color.h]); const canvasRef = useRef(null); - useOklchCanvas({ channel: channel, max: maxValue[channel], canvasRef: canvasRef, color, useP3 }); + useOklchCanvas({ + channel: channel, + max: maxValue[channel], + canvasRef: canvasRef, + color, + useP3 + }); const getSliderPosition = (value: number, max: number) => { return (value / max) * 100; diff --git a/packages/temp_frontend/app/components/Search.tsx b/packages/temp_frontend/app/components/Search.tsx index 5c913e4..bb9126c 100644 --- a/packages/temp_frontend/app/components/Search.tsx +++ b/packages/temp_frontend/app/components/Search.tsx @@ -38,7 +38,5 @@ export function SearchBox({ query = "", setQuery, onSearch, className, ...rest } export function Search(props: React.ComponentProps<"div">) { const [query, setQuery] = useState(""); let navigate = useNavigate(); - return ( - navigate(`/search?q=${query}`)} {...props} /> - ); + return navigate(`/search?q=${query}`)} {...props} />; } diff --git a/packages/temp_frontend/app/components/SearchResults.tsx b/packages/temp_frontend/app/components/SearchResults.tsx index 7ac66e8..026f34e 100644 --- a/packages/temp_frontend/app/components/SearchResults.tsx +++ b/packages/temp_frontend/app/components/SearchResults.tsx @@ -40,7 +40,7 @@ export function SearchResults({ results, query }: SearchResultsProps) {
); } - + const SearchResultItem = ({ result }: { result: Exclude["data"][number] }) => { switch (result.type) { case "song": diff --git a/packages/temp_frontend/app/components/ui/alert-dialog.tsx b/packages/temp_frontend/app/components/ui/alert-dialog.tsx index 646aac2..37e4b15 100644 --- a/packages/temp_frontend/app/components/ui/alert-dialog.tsx +++ b/packages/temp_frontend/app/components/ui/alert-dialog.tsx @@ -1,155 +1,111 @@ -import * as React from "react" -import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" +import * as React from "react"; +import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"; -import { cn } from "@/lib//utils" -import { buttonVariants } from "@/components/ui//button" +import { cn } from "@/lib//utils"; +import { buttonVariants } from "@/components/ui//button"; -function AlertDialog({ - ...props -}: React.ComponentProps) { - return +function AlertDialog({ ...props }: React.ComponentProps) { + return ; } -function AlertDialogTrigger({ - ...props -}: React.ComponentProps) { - return ( - - ) +function AlertDialogTrigger({ ...props }: React.ComponentProps) { + return ; } -function AlertDialogPortal({ - ...props -}: React.ComponentProps) { - return ( - - ) +function AlertDialogPortal({ ...props }: React.ComponentProps) { + return ; } -function AlertDialogOverlay({ - className, - ...props -}: React.ComponentProps) { - return ( - - ) +function AlertDialogOverlay({ className, ...props }: React.ComponentProps) { + return ( + + ); } -function AlertDialogContent({ - className, - ...props -}: React.ComponentProps) { - return ( - - - - - ) +function AlertDialogContent({ className, ...props }: React.ComponentProps) { + return ( + + + + + ); } -function AlertDialogHeader({ - className, - ...props -}: React.ComponentProps<"div">) { - return ( -
- ) +function AlertDialogHeader({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ); } -function AlertDialogFooter({ - className, - ...props -}: React.ComponentProps<"div">) { - return ( -
- ) +function AlertDialogFooter({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ); } -function AlertDialogTitle({ - className, - ...props -}: React.ComponentProps) { - return ( - - ) +function AlertDialogTitle({ className, ...props }: React.ComponentProps) { + return ( + + ); } function AlertDialogDescription({ - className, - ...props + className, + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ); } -function AlertDialogAction({ - className, - ...props -}: React.ComponentProps) { - return ( - - ) +function AlertDialogAction({ className, ...props }: React.ComponentProps) { + return ; } -function AlertDialogCancel({ - className, - ...props -}: React.ComponentProps) { - return ( - - ) +function AlertDialogCancel({ className, ...props }: React.ComponentProps) { + return ; } export { - AlertDialog, - AlertDialogPortal, - AlertDialogOverlay, - AlertDialogTrigger, - AlertDialogContent, - AlertDialogHeader, - AlertDialogFooter, - AlertDialogTitle, - AlertDialogDescription, - AlertDialogAction, - AlertDialogCancel, -} + AlertDialog, + AlertDialogPortal, + AlertDialogOverlay, + AlertDialogTrigger, + AlertDialogContent, + AlertDialogHeader, + AlertDialogFooter, + AlertDialogTitle, + AlertDialogDescription, + AlertDialogAction, + AlertDialogCancel, +}; diff --git a/packages/temp_frontend/app/components/ui/card.tsx b/packages/temp_frontend/app/components/ui/card.tsx index be0ded3..9899559 100644 --- a/packages/temp_frontend/app/components/ui/card.tsx +++ b/packages/temp_frontend/app/components/ui/card.tsx @@ -1,92 +1,59 @@ -import * as React from "react" +import * as React from "react"; -import { cn } from "@/lib//utils" +import { cn } from "@/lib//utils"; function Card({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) + return ( +
+ ); } function CardHeader({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) + return ( +
+ ); } function CardTitle({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) + return
; } function CardDescription({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) + return
; } function CardAction({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) + return ( +
+ ); } function CardContent({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) + return
; } function CardFooter({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) + return ( +
+ ); } -export { - Card, - CardHeader, - CardFooter, - CardTitle, - CardAction, - CardDescription, - CardContent, -} +export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent }; diff --git a/packages/temp_frontend/app/components/ui/chart.tsx b/packages/temp_frontend/app/components/ui/chart.tsx index 1b1e75f..c0046b2 100644 --- a/packages/temp_frontend/app/components/ui/chart.tsx +++ b/packages/temp_frontend/app/components/ui/chart.tsx @@ -1,355 +1,312 @@ -import * as React from "react" -import * as RechartsPrimitive from "recharts" +import * as React from "react"; +import * as RechartsPrimitive from "recharts"; -import { cn } from "@/lib//utils" +import { cn } from "@/lib//utils"; // Format: { THEME_NAME: CSS_SELECTOR } -const THEMES = { light: "", dark: ".dark" } as const +const THEMES = { light: "", dark: ".dark" } as const; export type ChartConfig = { - [k in string]: { - label?: React.ReactNode - icon?: React.ComponentType - } & ( - | { color?: string; theme?: never } - | { color?: never; theme: Record } - ) -} + [k in string]: { + label?: React.ReactNode; + icon?: React.ComponentType; + } & ({ color?: string; theme?: never } | { color?: never; theme: Record }); +}; type ChartContextProps = { - config: ChartConfig -} + config: ChartConfig; +}; -const ChartContext = React.createContext(null) +const ChartContext = React.createContext(null); function useChart() { - const context = React.useContext(ChartContext) + const context = React.useContext(ChartContext); - if (!context) { - throw new Error("useChart must be used within a ") - } + if (!context) { + throw new Error("useChart must be used within a "); + } - return context + return context; } function ChartContainer({ - id, - className, - children, - config, - ...props + id, + className, + children, + config, + ...props }: React.ComponentProps<"div"> & { - config: ChartConfig - children: React.ComponentProps< - typeof RechartsPrimitive.ResponsiveContainer - >["children"] + config: ChartConfig; + children: React.ComponentProps["children"]; }) { - const uniqueId = React.useId() - const chartId = `chart-${id || uniqueId.replace(/:/g, "")}` + const uniqueId = React.useId(); + const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`; - return ( - -
- - - {children} - -
-
- ) + return ( + +
+ + {children} +
+
+ ); } const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => { - const colorConfig = Object.entries(config).filter( - ([, config]) => config.theme || config.color - ) + const colorConfig = Object.entries(config).filter(([, config]) => config.theme || config.color); - if (!colorConfig.length) { - return null - } + if (!colorConfig.length) { + return null; + } - return ( -