style(biome): using biome for format, lint, check
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import type { Config } from "drizzle-kit";
|
||||
|
||||
export default {
|
||||
schema: "./src/schema.ts",
|
||||
out: "./migrations",
|
||||
dialect: "postgresql",
|
||||
dbCredentials: {
|
||||
url: process.env.DATABASE_URL!,
|
||||
},
|
||||
dialect: "postgresql",
|
||||
out: "./migrations",
|
||||
schema: "./src/schema.ts",
|
||||
} satisfies Config;
|
||||
|
||||
+12
-15
@@ -1,19 +1,4 @@
|
||||
{
|
||||
"name": "@basango/db",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"clean": "rm -rf .turbo node_modules",
|
||||
"format": "biome format --write .",
|
||||
"lint": "biome check .",
|
||||
"lint:fix": "biome check --write .",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"exports": {
|
||||
"./client": "./src/client.ts",
|
||||
"./schema": "./src/schema.ts",
|
||||
"./utils": "./src/utils/index.ts",
|
||||
"./queries": "./src/queries/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@basango/logger": "workspace:*",
|
||||
"@date-fns/utc": "^2.1.1",
|
||||
@@ -26,5 +11,17 @@
|
||||
"@types/pg": "^8.15.6",
|
||||
"drizzle-kit": "^0.31.6",
|
||||
"typescript": "catalog:"
|
||||
},
|
||||
"exports": {
|
||||
"./client": "./src/client.ts",
|
||||
"./queries": "./src/queries/index.ts",
|
||||
"./schema": "./src/schema.ts",
|
||||
"./utils": "./src/utils/index.ts"
|
||||
},
|
||||
"name": "@basango/db",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"clean": "rm -rf .turbo node_modules",
|
||||
"typecheck": "tsc --noEmit"
|
||||
}
|
||||
}
|
||||
|
||||
+13
-13
@@ -5,11 +5,11 @@ import * as schema from "@/schema";
|
||||
const isDevelopment = process.env.NODE_ENV === "development";
|
||||
|
||||
const connectionConfig = {
|
||||
max: isDevelopment ? 8 : 12,
|
||||
idleTimeoutMillis: isDevelopment ? 5_000 : 60_000,
|
||||
connectionTimeoutMillis: 15_000,
|
||||
maxUses: isDevelopment ? 100 : 0,
|
||||
allowExitOnIdle: true,
|
||||
connectionTimeoutMillis: 15_000,
|
||||
idleTimeoutMillis: isDevelopment ? 5_000 : 60_000,
|
||||
max: isDevelopment ? 8 : 12,
|
||||
maxUses: isDevelopment ? 100 : 0,
|
||||
};
|
||||
|
||||
const pool = new Pool({
|
||||
@@ -20,12 +20,12 @@ const pool = new Pool({
|
||||
// Lightweight connection pool monitoring (single pool)
|
||||
export const getConnectionPoolStats = () => {
|
||||
const stats = {
|
||||
active: Math.max(0, (pool.totalCount ?? 0) - (pool.idleCount ?? 0)),
|
||||
ended: (pool as any).ended ?? false,
|
||||
idle: pool.idleCount ?? 0,
|
||||
name: "primary",
|
||||
total: pool.options.max ?? 0,
|
||||
idle: pool.idleCount ?? 0,
|
||||
active: Math.max(0, (pool.totalCount ?? 0) - (pool.idleCount ?? 0)),
|
||||
waiting: pool.waitingCount ?? 0,
|
||||
ended: (pool as any).ended ?? false,
|
||||
};
|
||||
|
||||
const totalConnections = connectionConfig.max;
|
||||
@@ -33,23 +33,23 @@ export const getConnectionPoolStats = () => {
|
||||
totalConnections > 0 ? Math.round((stats.active / totalConnections) * 100) : 0;
|
||||
|
||||
return {
|
||||
timestamp: new Date().toISOString(),
|
||||
region: process.env.FLY_REGION || "unknown",
|
||||
instance: process.env.FLY_ALLOC_ID || "local",
|
||||
pools: { primary: stats },
|
||||
region: process.env.FLY_REGION || "unknown",
|
||||
summary: {
|
||||
totalConnections,
|
||||
totalActive: stats.active,
|
||||
totalWaiting: stats.waiting,
|
||||
hasExhaustedPools: stats.active >= totalConnections || (stats.waiting ?? 0) > 0,
|
||||
totalActive: stats.active,
|
||||
totalConnections,
|
||||
totalWaiting: stats.waiting,
|
||||
utilizationPercent: utilization,
|
||||
},
|
||||
timestamp: new Date().toISOString(),
|
||||
};
|
||||
};
|
||||
|
||||
export const db = drizzle(pool, {
|
||||
schema,
|
||||
casing: "snake_case",
|
||||
schema,
|
||||
});
|
||||
export const connectDb = async () => db;
|
||||
export type Database = Awaited<ReturnType<typeof connectDb>>;
|
||||
|
||||
@@ -133,16 +133,16 @@ export async function* getArticlesForExport(
|
||||
|
||||
let query = db
|
||||
.select({
|
||||
articleId: articles.id,
|
||||
articleTitle: articles.title,
|
||||
articleLink: articles.link,
|
||||
articleBody: articles.body,
|
||||
articleCategories: sql<string | null>`array_to_string
|
||||
(${articles.categories}, ',')`,
|
||||
articleBody: articles.body,
|
||||
articleSource: sources.name,
|
||||
articleHash: articles.hash,
|
||||
articlePublishedAt: articles.publishedAt,
|
||||
articleCrawledAt: articles.crawledAt,
|
||||
articleHash: articles.hash,
|
||||
articleId: articles.id,
|
||||
articleLink: articles.link,
|
||||
articlePublishedAt: articles.publishedAt,
|
||||
articleSource: sources.name,
|
||||
articleTitle: articles.title,
|
||||
})
|
||||
.from(articles)
|
||||
.innerJoin(sources, eq(articles.sourceId, sources.id));
|
||||
@@ -180,9 +180,9 @@ function normalizeArticleFilters(filters?: ArticleFilters): NormalizedArticleFil
|
||||
const trimmedCategory = filters?.category?.trim();
|
||||
|
||||
return {
|
||||
search: trimmedSearch && trimmedSearch.length > 0 ? trimmedSearch : undefined,
|
||||
category: trimmedCategory && trimmedCategory.length > 0 ? trimmedCategory : undefined,
|
||||
dateRange: filters?.dateRange ?? null,
|
||||
search: trimmedSearch && trimmedSearch.length > 0 ? trimmedSearch : undefined,
|
||||
sortDirection: filters?.sortDirection ?? "desc",
|
||||
};
|
||||
}
|
||||
@@ -255,22 +255,22 @@ async function fetchArticleOverview(
|
||||
const bookmarkExpression = buildBookmarkExistsExpression(options.userId);
|
||||
|
||||
const selectFields = {
|
||||
article_excerpt: articles.excerpt,
|
||||
article_id: articles.id,
|
||||
articleTitle: articles.title,
|
||||
articleLink: articles.link,
|
||||
article_image: articles.image,
|
||||
article_is_bookmarked: bookmarkExpression,
|
||||
article_published_at: articles.publishedAt,
|
||||
article_reading_time: articles.readingTime,
|
||||
articleCategories: sql<string | null>`array_to_string
|
||||
(${articles.categories}, ',')`,
|
||||
article_excerpt: articles.excerpt,
|
||||
article_published_at: articles.publishedAt,
|
||||
article_image: articles.image,
|
||||
article_reading_time: articles.readingTime,
|
||||
sourceId: sources.id,
|
||||
articleLink: articles.link,
|
||||
articleTitle: articles.title,
|
||||
source_created_at: sources.createdAt,
|
||||
source_display_name: sources.displayName,
|
||||
source_image: sql<string>`('${SOURCE_IMAGE_BASE}' || ${sources.name} || '.png')`,
|
||||
sourceUrl: sources.url,
|
||||
source_name: sources.name,
|
||||
source_created_at: sources.createdAt,
|
||||
article_is_bookmarked: bookmarkExpression,
|
||||
sourceId: sources.id,
|
||||
sourceUrl: sources.url,
|
||||
} satisfies Record<string, SQL | AnyColumn>;
|
||||
|
||||
let query = db
|
||||
@@ -321,8 +321,8 @@ async function fetchArticleOverview(
|
||||
const rows = await query.orderBy(...orderings).limit(options.page.limit + 1);
|
||||
|
||||
return buildPaginationResult(rows, options.page, {
|
||||
id: "article_id",
|
||||
date: "article_published_at",
|
||||
id: "article_id",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -338,9 +338,9 @@ export async function getArticleOverviewList(
|
||||
const filters = normalizeArticleFilters(params.filters);
|
||||
|
||||
return fetchArticleOverview(db, {
|
||||
userId: params.userId,
|
||||
page,
|
||||
filters,
|
||||
page,
|
||||
userId: params.userId,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -357,10 +357,10 @@ export async function getSourceArticleOverviewList(
|
||||
const filters = normalizeArticleFilters(params.filters);
|
||||
|
||||
return fetchArticleOverview(db, {
|
||||
userId: params.userId,
|
||||
page,
|
||||
filters,
|
||||
baseConditions: [eq(sources.id, params.sourceId)],
|
||||
filters,
|
||||
page,
|
||||
userId: params.userId,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -384,22 +384,22 @@ export async function getBookmarkedArticleList(
|
||||
];
|
||||
|
||||
const selectFields = {
|
||||
article_excerpt: articles.excerpt,
|
||||
article_id: articles.id,
|
||||
articleTitle: articles.title,
|
||||
articleLink: articles.link,
|
||||
article_image: articles.image,
|
||||
article_is_bookmarked: sql<boolean>`true`,
|
||||
article_published_at: articles.publishedAt,
|
||||
article_reading_time: articles.readingTime,
|
||||
articleCategories: sql<string | null>`array_to_string
|
||||
(${articles.categories}, ',')`,
|
||||
article_excerpt: articles.excerpt,
|
||||
article_published_at: articles.publishedAt,
|
||||
article_image: articles.image,
|
||||
article_reading_time: articles.readingTime,
|
||||
sourceId: sources.id,
|
||||
articleLink: articles.link,
|
||||
articleTitle: articles.title,
|
||||
source_created_at: sources.createdAt,
|
||||
source_display_name: sources.displayName,
|
||||
source_image: sql<string>`('${SOURCE_IMAGE_BASE}' || ${sources.name} || '.png')`,
|
||||
sourceUrl: sources.url,
|
||||
source_name: sources.name,
|
||||
source_created_at: sources.createdAt,
|
||||
article_is_bookmarked: sql<boolean>`true`,
|
||||
sourceId: sources.id,
|
||||
sourceUrl: sources.url,
|
||||
} satisfies Record<string, SQL | AnyColumn>;
|
||||
|
||||
let query = db
|
||||
@@ -452,8 +452,8 @@ export async function getBookmarkedArticleList(
|
||||
const rows = await query.orderBy(...orderings).limit(page.limit + 1);
|
||||
|
||||
return buildPaginationResult(rows, page, {
|
||||
id: "article_id",
|
||||
date: "article_published_at",
|
||||
id: "article_id",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -465,33 +465,33 @@ export async function getArticleDetails(
|
||||
|
||||
const [row] = await db
|
||||
.select({
|
||||
article_bias: articles.bias,
|
||||
article_crawled_at: articles.crawledAt,
|
||||
article_hash: articles.hash,
|
||||
article_id: articles.id,
|
||||
articleTitle: articles.title,
|
||||
articleLink: articles.link,
|
||||
article_is_bookmarked: bookmarkExpression,
|
||||
article_metadata: articles.metadata,
|
||||
article_published_at: articles.publishedAt,
|
||||
article_reading_time: articles.readingTime,
|
||||
article_reliability: articles.reliability,
|
||||
article_sentiment: articles.sentiment,
|
||||
article_transparency: articles.transparency,
|
||||
article_updated_at: articles.updatedAt,
|
||||
articleBody: articles.body,
|
||||
articleCategories: sql<string | null>`array_to_string
|
||||
(${articles.categories}, ',')`,
|
||||
articleBody: articles.body,
|
||||
article_hash: articles.hash,
|
||||
article_published_at: articles.publishedAt,
|
||||
article_crawled_at: articles.crawledAt,
|
||||
article_updated_at: articles.updatedAt,
|
||||
article_bias: articles.bias,
|
||||
article_reliability: articles.reliability,
|
||||
article_transparency: articles.transparency,
|
||||
article_sentiment: articles.sentiment,
|
||||
article_metadata: articles.metadata,
|
||||
article_reading_time: articles.readingTime,
|
||||
sourceId: sources.id,
|
||||
source_name: sources.name,
|
||||
source_description: sources.description,
|
||||
sourceUrl: sources.url,
|
||||
source_updated_at: sources.updatedAt,
|
||||
source_display_name: sources.displayName,
|
||||
articleLink: articles.link,
|
||||
articleTitle: articles.title,
|
||||
source_bias: sources.bias,
|
||||
source_description: sources.description,
|
||||
source_display_name: sources.displayName,
|
||||
source_image: sql<string>`('${SOURCE_IMAGE_BASE}' || ${sources.name} || '.png')`,
|
||||
source_name: sources.name,
|
||||
source_reliability: sources.reliability,
|
||||
source_transparency: sources.transparency,
|
||||
source_image: sql<string>`('${SOURCE_IMAGE_BASE}' || ${sources.name} || '.png')`,
|
||||
article_is_bookmarked: bookmarkExpression,
|
||||
source_updated_at: sources.updatedAt,
|
||||
sourceId: sources.id,
|
||||
sourceUrl: sources.url,
|
||||
})
|
||||
.from(articles)
|
||||
.innerJoin(sources, eq(articles.sourceId, sources.id))
|
||||
@@ -520,10 +520,10 @@ export async function getArticleCommentList(
|
||||
|
||||
let query = db
|
||||
.select({
|
||||
comment_id: comments.id,
|
||||
comment_content: comments.content,
|
||||
comment_sentiment: comments.sentiment,
|
||||
comment_created_at: comments.createdAt,
|
||||
comment_id: comments.id,
|
||||
comment_sentiment: comments.sentiment,
|
||||
user_id: users.id,
|
||||
user_name: users.name,
|
||||
})
|
||||
@@ -541,7 +541,7 @@ export async function getArticleCommentList(
|
||||
.limit(page.limit + 1);
|
||||
|
||||
return buildPaginationResult(rows, page, {
|
||||
id: "comment_id",
|
||||
date: "comment_created_at",
|
||||
id: "comment_id",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -40,13 +40,13 @@ export async function getBookmarkList(
|
||||
|
||||
let query = db
|
||||
.select({
|
||||
bookmark_id: bookmarks.id,
|
||||
bookmark_name: bookmarks.name,
|
||||
bookmark_description: bookmarks.description,
|
||||
bookmark_created_at: bookmarks.createdAt,
|
||||
bookmark_updated_at: bookmarks.updatedAt,
|
||||
bookmark_articles_count: sql<number>`count(${bookmarkArticles.articleId})`,
|
||||
bookmark_created_at: bookmarks.createdAt,
|
||||
bookmark_description: bookmarks.description,
|
||||
bookmark_id: bookmarks.id,
|
||||
bookmark_is_public: bookmarks.isPublic,
|
||||
bookmark_name: bookmarks.name,
|
||||
bookmark_updated_at: bookmarks.updatedAt,
|
||||
})
|
||||
.from(bookmarks)
|
||||
.leftJoin(bookmarkArticles, eq(bookmarkArticles.bookmarkId, bookmarks.id))
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { SQL } from "drizzle-orm";
|
||||
import { and, desc, eq, lt, or, sql } from "drizzle-orm";
|
||||
|
||||
import type { Database } from "@/client";
|
||||
import { PUBLICATION_GRAPH_DAYS, SOURCE_IMAGE_BASE } from "@/constant";
|
||||
import { articles, followedSources, sources } from "@/schema";
|
||||
import {
|
||||
buildPaginationResult,
|
||||
@@ -10,7 +11,6 @@ import {
|
||||
type PageRequest,
|
||||
type PaginationMeta,
|
||||
} from "@/utils/pagination";
|
||||
import { PUBLICATION_GRAPH_DAYS, SOURCE_IMAGE_BASE } from "@/constant";
|
||||
|
||||
export interface SourceOverviewRow {
|
||||
sourceId: string;
|
||||
@@ -70,14 +70,14 @@ export interface SourceStatisticsRow {
|
||||
export async function getSourceStatisticsList(db: Database): Promise<SourceStatisticsRow[]> {
|
||||
const rows = await db
|
||||
.select({
|
||||
sourceId: sources.id,
|
||||
sourceName: sources.name,
|
||||
sourceCrawledAt: sql<string | null>`max
|
||||
(${articles.crawledAt})`,
|
||||
articlesCount: sql<number>`count
|
||||
(${articles.id})`,
|
||||
articleMetadataAvailable: sql<number>`sum
|
||||
(CASE WHEN ${articles.metadata} IS NOT NULL THEN 1 ELSE 0 END)`,
|
||||
articlesCount: sql<number>`count
|
||||
(${articles.id})`,
|
||||
sourceCrawledAt: sql<string | null>`max
|
||||
(${articles.crawledAt})`,
|
||||
sourceId: sources.id,
|
||||
sourceName: sources.name,
|
||||
})
|
||||
.from(sources)
|
||||
.leftJoin(articles, eq(articles.sourceId, sources.id))
|
||||
@@ -85,11 +85,11 @@ export async function getSourceStatisticsList(db: Database): Promise<SourceStati
|
||||
.orderBy(sources.name.asc());
|
||||
|
||||
return rows.map((row) => ({
|
||||
articleMetadataAvailable: Number(row.articleMetadataAvailable ?? 0),
|
||||
articlesCount: Number(row.articlesCount ?? 0),
|
||||
sourceCrawledAt: row.sourceCrawledAt,
|
||||
sourceId: row.sourceId,
|
||||
sourceName: row.sourceName,
|
||||
sourceCrawledAt: row.sourceCrawledAt,
|
||||
articlesCount: Number(row.articlesCount ?? 0),
|
||||
articleMetadataAvailable: Number(row.articleMetadataAvailable ?? 0),
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -158,13 +158,13 @@ export async function getSourceOverviewList(
|
||||
|
||||
let query = db
|
||||
.select({
|
||||
sourceId: sources.id,
|
||||
source_created_at: sources.createdAt,
|
||||
source_display_name: sources.displayName,
|
||||
source_image: sql<string>`('${SOURCE_IMAGE_BASE}' || ${sources.name} || '.png')`,
|
||||
sourceUrl: sources.url,
|
||||
source_name: sources.name,
|
||||
source_created_at: sources.createdAt,
|
||||
source_is_followed: followExpression,
|
||||
source_name: sources.name,
|
||||
sourceId: sources.id,
|
||||
sourceUrl: sources.url,
|
||||
})
|
||||
.from(sources);
|
||||
|
||||
@@ -181,8 +181,8 @@ export async function getSourceOverviewList(
|
||||
const rows = await query.orderBy(desc(sources.createdAt), desc(sources.id)).limit(page.limit + 1);
|
||||
|
||||
return buildPaginationResult(rows, page, {
|
||||
id: "sourceId",
|
||||
date: "source_created_at",
|
||||
id: "sourceId",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ function createBackwardDateRange(days: number): { start: number; end: number } {
|
||||
const startDate = new Date(now.getTime() - days * 86_400_000);
|
||||
const start = Math.floor(startDate.getTime() / 1000);
|
||||
|
||||
return { start, end };
|
||||
return { end, start };
|
||||
}
|
||||
|
||||
async function fetchPublicationGraph(db: Database, sourceId: string): Promise<PublicationEntry[]> {
|
||||
@@ -200,10 +200,10 @@ async function fetchPublicationGraph(db: Database, sourceId: string): Promise<Pu
|
||||
|
||||
const rows = await db
|
||||
.select({
|
||||
day: sql<string>`date
|
||||
(${articles.publishedAt})`,
|
||||
count: sql<number>`count
|
||||
(${articles.id})`,
|
||||
day: sql<string>`date
|
||||
(${articles.publishedAt})`,
|
||||
})
|
||||
.from(articles)
|
||||
.where(eq(articles.sourceId, sourceId))
|
||||
@@ -233,7 +233,7 @@ async function fetchPublicationGraph(db: Database, sourceId: string): Promise<Pu
|
||||
|
||||
for (let date = new Date(start.getTime()); date < end; date.setUTCDate(date.getUTCDate() + 1)) {
|
||||
const day = date.toISOString().slice(0, 10);
|
||||
entries.push({ day, count: counts.get(day) ?? 0 });
|
||||
entries.push({ count: counts.get(day) ?? 0, day });
|
||||
}
|
||||
|
||||
return entries;
|
||||
@@ -278,20 +278,8 @@ export async function getSourceDetails(
|
||||
|
||||
const [row] = await db
|
||||
.select({
|
||||
sourceId: sources.id,
|
||||
source_name: sources.name,
|
||||
source_description: sources.description,
|
||||
sourceUrl: sources.url,
|
||||
source_updated_at: sources.updatedAt,
|
||||
source_display_name: sources.displayName,
|
||||
source_bias: sources.bias,
|
||||
source_reliability: sources.reliability,
|
||||
source_transparency: sources.transparency,
|
||||
source_image: sql<string>`('${SOURCE_IMAGE_BASE}' || ${sources.name} || '.png')`,
|
||||
articles_count: sql<number>`count
|
||||
(${articles.id})`,
|
||||
source_crawled_at: sql<string | null>`max
|
||||
(${articles.crawledAt})`,
|
||||
articles_metadata_available: sql<number>`count
|
||||
(*)
|
||||
FILTER (WHERE
|
||||
@@ -300,7 +288,19 @@ export async function getSourceDetails(
|
||||
NOT
|
||||
NULL
|
||||
)`,
|
||||
source_bias: sources.bias,
|
||||
source_crawled_at: sql<string | null>`max
|
||||
(${articles.crawledAt})`,
|
||||
source_description: sources.description,
|
||||
source_display_name: sources.displayName,
|
||||
source_image: sql<string>`('${SOURCE_IMAGE_BASE}' || ${sources.name} || '.png')`,
|
||||
source_is_followed: followExpression,
|
||||
source_name: sources.name,
|
||||
source_reliability: sources.reliability,
|
||||
source_transparency: sources.transparency,
|
||||
source_updated_at: sources.updatedAt,
|
||||
sourceId: sources.id,
|
||||
sourceUrl: sources.url,
|
||||
})
|
||||
.from(sources)
|
||||
.leftJoin(articles, eq(articles.sourceId, sources.id))
|
||||
@@ -328,12 +328,12 @@ export async function getSourceDetails(
|
||||
]);
|
||||
|
||||
return {
|
||||
categoryShares,
|
||||
publicationGraph,
|
||||
source: {
|
||||
...row,
|
||||
articles_count: Number(row.articles_count ?? 0),
|
||||
articles_metadata_available: Number(row.articles_metadata_available ?? 0),
|
||||
},
|
||||
publicationGraph,
|
||||
categoryShares,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@ export async function getUserProfile(
|
||||
): Promise<UserProfileRow | null> {
|
||||
const [row] = await db
|
||||
.select({
|
||||
user_created_at: users.createdAt,
|
||||
user_email: users.email,
|
||||
user_id: users.id,
|
||||
user_name: users.name,
|
||||
user_email: users.email,
|
||||
user_created_at: users.createdAt,
|
||||
user_updated_at: users.updatedAt,
|
||||
})
|
||||
.from(users)
|
||||
|
||||
+63
-63
@@ -5,9 +5,9 @@ import {
|
||||
doublePrecision,
|
||||
foreignKey,
|
||||
index,
|
||||
inet,
|
||||
integer,
|
||||
jsonb,
|
||||
inet,
|
||||
pgEnum,
|
||||
pgTable,
|
||||
primaryKey,
|
||||
@@ -75,16 +75,16 @@ export const verificationTokenPurposeEnum = pgEnum("verification_token_purpose",
|
||||
export const sources = pgTable(
|
||||
"source",
|
||||
{
|
||||
id: uuid("id").notNull().defaultRandom().primaryKey(),
|
||||
url: varchar("url", { length: 255 }).notNull(),
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
displayName: varchar("display_name", { length: 255 }),
|
||||
description: varchar("description", { length: 1024 }),
|
||||
createdAt: timestamp("created_at", { mode: "string" }).defaultNow().notNull(),
|
||||
updatedAt: timestamp("updated_at", { mode: "string" }),
|
||||
bias: biasEnum("bias").notNull().default("neutral"),
|
||||
createdAt: timestamp("created_at", { mode: "string" }).defaultNow().notNull(),
|
||||
description: varchar("description", { length: 1024 }),
|
||||
displayName: varchar("display_name", { length: 255 }),
|
||||
id: uuid("id").notNull().defaultRandom().primaryKey(),
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
reliability: reliabilityEnum("reliability").notNull().default("reliable"),
|
||||
transparency: transparencyEnum("transparency").notNull().default("medium"),
|
||||
updatedAt: timestamp("updated_at", { mode: "string" }),
|
||||
url: varchar("url", { length: 255 }).notNull(),
|
||||
},
|
||||
(table) => [
|
||||
uniqueIndex("unq_source_name").using(
|
||||
@@ -103,33 +103,33 @@ export const sources = pgTable(
|
||||
export const articles = pgTable(
|
||||
"article",
|
||||
{
|
||||
id: uuid("id").notNull().defaultRandom().primaryKey(),
|
||||
sourceId: uuid("sourceId").notNull(),
|
||||
title: varchar("title", { length: 1024 }).notNull(),
|
||||
bias: biasEnum("bias").notNull().default("neutral"),
|
||||
body: text("body").notNull(),
|
||||
hash: varchar("hash", { length: 32 }).notNull(),
|
||||
categories: text("categories").array(),
|
||||
sentiment: articleSentimentEnum("sentiment").notNull().default("neutral"),
|
||||
metadata: jsonb("metadata"),
|
||||
tokenStatistics: jsonb("token_statistics"),
|
||||
image: varchar("image", { length: 1024 }).generatedAlwaysAs(() => sql`(metadata->>'image')`),
|
||||
crawledAt: timestamp("crawled_at", { mode: "string" }).notNull(),
|
||||
excerpt: varchar("excerpt", { length: 255 }).generatedAlwaysAs(
|
||||
() => sql`((left(body, 200) || '...'))`,
|
||||
),
|
||||
publishedAt: timestamp("published_at", { mode: "string" }).notNull(),
|
||||
crawledAt: timestamp("crawled_at", { mode: "string" }).notNull(),
|
||||
updatedAt: timestamp("updated_at", { mode: "string" }),
|
||||
hash: varchar("hash", { length: 32 }).notNull(),
|
||||
id: uuid("id").notNull().defaultRandom().primaryKey(),
|
||||
image: varchar("image", { length: 1024 }).generatedAlwaysAs(() => sql`(metadata->>'image')`),
|
||||
link: varchar("link", { length: 1024 }).notNull(),
|
||||
bias: biasEnum("bias").notNull().default("neutral"),
|
||||
reliability: reliabilityEnum("reliability").notNull().default("reliable"),
|
||||
transparency: transparencyEnum("transparency").notNull().default("medium"),
|
||||
metadata: jsonb("metadata"),
|
||||
publishedAt: timestamp("published_at", { mode: "string" }).notNull(),
|
||||
readingTime: integer("reading_time").default(1),
|
||||
reliability: reliabilityEnum("reliability").notNull().default("reliable"),
|
||||
sentiment: articleSentimentEnum("sentiment").notNull().default("neutral"),
|
||||
sourceId: uuid("sourceId").notNull(),
|
||||
title: varchar("title", { length: 1024 }).notNull(),
|
||||
tokenStatistics: jsonb("token_statistics"),
|
||||
transparency: transparencyEnum("transparency").notNull().default("medium"),
|
||||
tsv: tsvector("tsv").generatedAlwaysAs(
|
||||
() => sql`(
|
||||
setweight(to_tsvector('french', coalesce(title, '')), 'A')
|
||||
|| setweight(to_tsvector('french', coalesce(body, '')), 'B')
|
||||
)`,
|
||||
),
|
||||
updatedAt: timestamp("updated_at", { mode: "string" }),
|
||||
},
|
||||
(table) => [
|
||||
index("article_sourceId_idx").on(table.sourceId),
|
||||
@@ -146,13 +146,13 @@ export const articles = pgTable(
|
||||
name: "article_sourceId_fkey",
|
||||
}).onDelete("cascade"),
|
||||
{
|
||||
kind: "check",
|
||||
expression: sql`reading_time >= 0`,
|
||||
kind: "check",
|
||||
name: "chk_article_reading_time",
|
||||
},
|
||||
{
|
||||
kind: "check",
|
||||
expression: sql`(metadata IS NULL OR jsonb_typeof(metadata) IN ('object','array'))`,
|
||||
kind: "check",
|
||||
name: "chk_article_metadata_json",
|
||||
},
|
||||
],
|
||||
@@ -161,22 +161,22 @@ export const articles = pgTable(
|
||||
export const users = pgTable(
|
||||
"user",
|
||||
{
|
||||
id: uuid("id").notNull().defaultRandom().primaryKey(),
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
email: varchar("email", { length: 255 }).notNull(),
|
||||
password: varchar("password", { length: 512 }).notNull(),
|
||||
isLocked: boolean("is_locked").notNull().default(false),
|
||||
isConfirmed: boolean("is_confirmed").notNull().default(false),
|
||||
createdAt: timestamp("created_at", { mode: "string" }).notNull(),
|
||||
updatedAt: timestamp("updated_at", { mode: "string" }),
|
||||
email: varchar("email", { length: 255 }).notNull(),
|
||||
id: uuid("id").notNull().defaultRandom().primaryKey(),
|
||||
isConfirmed: boolean("is_confirmed").notNull().default(false),
|
||||
isLocked: boolean("is_locked").notNull().default(false),
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
password: varchar("password", { length: 512 }).notNull(),
|
||||
roles: jsonb("roles").notNull(),
|
||||
updatedAt: timestamp("updated_at", { mode: "string" }),
|
||||
},
|
||||
(table) => [
|
||||
uniqueIndex("unq_user_email").using("btree", sql`lower (${table.email})`),
|
||||
{
|
||||
expression: sql`jsonb_typeof(roles) = 'array'`,
|
||||
kind: "check",
|
||||
name: "chk_user_roles_array",
|
||||
expression: sql`jsonb_typeof(roles) = 'array'`,
|
||||
},
|
||||
],
|
||||
);
|
||||
@@ -184,13 +184,13 @@ export const users = pgTable(
|
||||
export const bookmarks = pgTable(
|
||||
"bookmark",
|
||||
{
|
||||
id: uuid("id").notNull().defaultRandom().primaryKey(),
|
||||
userId: uuid("user_id").notNull(),
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
description: varchar("description", { length: 512 }),
|
||||
isPublic: boolean("is_public").notNull().default(false),
|
||||
createdAt: timestamp("created_at", { mode: "string" }).notNull(),
|
||||
description: varchar("description", { length: 512 }),
|
||||
id: uuid("id").notNull().defaultRandom().primaryKey(),
|
||||
isPublic: boolean("is_public").notNull().default(false),
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
updatedAt: timestamp("updated_at", { mode: "string" }),
|
||||
userId: uuid("user_id").notNull(),
|
||||
},
|
||||
(table) => [
|
||||
index("bookmark_user_id_idx").on(table.userId),
|
||||
@@ -206,8 +206,8 @@ export const bookmarks = pgTable(
|
||||
export const bookmarkArticles = pgTable(
|
||||
"bookmark_article",
|
||||
{
|
||||
bookmarkId: uuid("bookmark_id").notNull(),
|
||||
articleId: uuid("article_id").notNull(),
|
||||
bookmarkId: uuid("bookmark_id").notNull(),
|
||||
},
|
||||
(table) => [
|
||||
primaryKey({
|
||||
@@ -232,13 +232,13 @@ export const bookmarkArticles = pgTable(
|
||||
export const comments = pgTable(
|
||||
"comment",
|
||||
{
|
||||
id: uuid("id").notNull().defaultRandom().primaryKey(),
|
||||
userId: uuid("user_id").notNull(),
|
||||
articleId: uuid("article_id").notNull(),
|
||||
content: varchar("content", { length: 512 }).notNull(),
|
||||
sentiment: articleSentimentEnum("sentiment").notNull().default("neutral"),
|
||||
isSpam: boolean("is_spam").notNull().default(false),
|
||||
createdAt: timestamp("created_at", { mode: "string" }).notNull(),
|
||||
id: uuid("id").notNull().defaultRandom().primaryKey(),
|
||||
isSpam: boolean("is_spam").notNull().default(false),
|
||||
sentiment: articleSentimentEnum("sentiment").notNull().default("neutral"),
|
||||
userId: uuid("user_id").notNull(),
|
||||
},
|
||||
(table) => [
|
||||
index("comment_user_id_idx").on(table.userId),
|
||||
@@ -260,10 +260,10 @@ export const comments = pgTable(
|
||||
export const followedSources = pgTable(
|
||||
"followed_source",
|
||||
{
|
||||
id: uuid("id").notNull().defaultRandom().primaryKey(),
|
||||
followerId: uuid("follower_id").notNull(),
|
||||
sourceId: uuid("sourceId").notNull(),
|
||||
createdAt: timestamp("created_at", { mode: "string" }).notNull(),
|
||||
followerId: uuid("follower_id").notNull(),
|
||||
id: uuid("id").notNull().defaultRandom().primaryKey(),
|
||||
sourceId: uuid("sourceId").notNull(),
|
||||
},
|
||||
(table) => [
|
||||
index("followed_source_follower_idx").on(table.followerId),
|
||||
@@ -289,9 +289,9 @@ export const followedSources = pgTable(
|
||||
export const loginAttempts = pgTable(
|
||||
"login_attempt",
|
||||
{
|
||||
createdAt: timestamp("created_at", { mode: "string" }).notNull(),
|
||||
id: uuid("id").notNull().defaultRandom().primaryKey(),
|
||||
userId: uuid("user_id").notNull(),
|
||||
createdAt: timestamp("created_at", { mode: "string" }).notNull(),
|
||||
},
|
||||
(table) => [
|
||||
index("login_attempt_user_id_idx").on(table.userId),
|
||||
@@ -307,18 +307,18 @@ export const loginAttempts = pgTable(
|
||||
export const loginHistories = pgTable(
|
||||
"login_history",
|
||||
{
|
||||
id: uuid("id").notNull().defaultRandom().primaryKey(),
|
||||
userId: uuid("user_id").notNull(),
|
||||
ipAddress: inet("ip_address"),
|
||||
createdAt: timestamp("created_at", { mode: "string" }).notNull(),
|
||||
deviceOperatingSystem: varchar("device_operating_system", { length: 255 }),
|
||||
deviceClient: varchar("device_client", { length: 255 }),
|
||||
deviceDevice: varchar("device_device", { length: 255 }),
|
||||
deviceIsBot: boolean("device_is_bot").notNull().default(false),
|
||||
locationTimeZone: varchar("location_time_zone", { length: 255 }),
|
||||
locationLongitude: doublePrecision("location_longitude"),
|
||||
locationLatitude: doublePrecision("location_latitude"),
|
||||
deviceOperatingSystem: varchar("device_operating_system", { length: 255 }),
|
||||
id: uuid("id").notNull().defaultRandom().primaryKey(),
|
||||
ipAddress: inet("ip_address"),
|
||||
locationAccuracyRadius: integer("location_accuracy_radius"),
|
||||
locationLatitude: doublePrecision("location_latitude"),
|
||||
locationLongitude: doublePrecision("location_longitude"),
|
||||
locationTimeZone: varchar("location_time_zone", { length: 255 }),
|
||||
userId: uuid("user_id").notNull(),
|
||||
},
|
||||
(table) => [
|
||||
index("login_history_user_id_idx").on(table.userId),
|
||||
@@ -346,11 +346,11 @@ export const refreshTokens = pgTable(
|
||||
export const verificationTokens = pgTable(
|
||||
"verification_token",
|
||||
{
|
||||
createdAt: timestamp("created_at", { mode: "string" }).notNull(),
|
||||
id: uuid("id").notNull().defaultRandom().primaryKey(),
|
||||
userId: uuid("user_id").notNull(),
|
||||
purpose: verificationTokenPurposeEnum("purpose").notNull(),
|
||||
token: varchar("token", { length: 60 }),
|
||||
createdAt: timestamp("created_at", { mode: "string" }).notNull(),
|
||||
userId: uuid("user_id").notNull(),
|
||||
},
|
||||
(table) => [
|
||||
index("verification_token_user_id_idx").on(table.userId),
|
||||
@@ -374,40 +374,40 @@ export const sourcesRelations = relations(sources, ({ many }) => ({
|
||||
}));
|
||||
|
||||
export const articlesRelations = relations(articles, ({ one, many }) => ({
|
||||
bookmarkLinks: many(bookmarkArticles),
|
||||
comments: many(comments),
|
||||
source: one(sources, {
|
||||
fields: [articles.sourceId],
|
||||
references: [sources.id],
|
||||
}),
|
||||
bookmarkLinks: many(bookmarkArticles),
|
||||
comments: many(comments),
|
||||
}));
|
||||
|
||||
export const appUsersRelations = relations(users, ({ many }) => ({
|
||||
bookmarks: many(bookmarks),
|
||||
comments: many(comments),
|
||||
followedSources: many(followedSources),
|
||||
loginAttempts: many(loginAttempts),
|
||||
loginHistories: many(loginHistories),
|
||||
verificationTokens: many(verificationTokens),
|
||||
followedSources: many(followedSources),
|
||||
}));
|
||||
|
||||
export const bookmarksRelations = relations(bookmarks, ({ one, many }) => ({
|
||||
articles: many(bookmarkArticles),
|
||||
user: one(users, {
|
||||
fields: [bookmarks.userId],
|
||||
references: [users.id],
|
||||
}),
|
||||
articles: many(bookmarkArticles),
|
||||
}));
|
||||
|
||||
export const bookmarkArticlesRelations = relations(bookmarkArticles, ({ one }) => ({
|
||||
bookmark: one(bookmarks, {
|
||||
fields: [bookmarkArticles.bookmarkId],
|
||||
references: [bookmarks.id],
|
||||
}),
|
||||
article: one(articles, {
|
||||
fields: [bookmarkArticles.articleId],
|
||||
references: [articles.id],
|
||||
}),
|
||||
bookmark: one(bookmarks, {
|
||||
fields: [bookmarkArticles.bookmarkId],
|
||||
references: [bookmarks.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const commentsRelations = relations(comments, ({ one }) => ({
|
||||
|
||||
@@ -53,7 +53,7 @@ export function createPageState(request: PageRequest = {}): PageState {
|
||||
const cursor = request.cursor ?? null;
|
||||
const offset = (page - 1) * limit;
|
||||
|
||||
return { page, limit, cursor, offset };
|
||||
return { cursor, limit, offset, page };
|
||||
}
|
||||
|
||||
export function encodeCursor(
|
||||
@@ -111,9 +111,9 @@ export function buildPaginationResult<T extends Record<string, unknown>>(
|
||||
data,
|
||||
pagination: {
|
||||
current: page.page,
|
||||
limit: page.limit,
|
||||
cursor,
|
||||
hasNext,
|
||||
limit: page.limit,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"extends": "@basango/typescript-config/base.json",
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules"],
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"exclude": ["node_modules"],
|
||||
"extends": "@basango/tsconfig/base.json",
|
||||
"include": ["src"]
|
||||
}
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
{
|
||||
"name": "@basango/logger",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"scripts": {
|
||||
"clean": "rm -rf .turbo node_modules",
|
||||
"format": "biome format --write .",
|
||||
"lint": "biome check .",
|
||||
"lint:fix": "biome check --write .",
|
||||
"typecheck": "tsc --noEmit"
|
||||
"dependencies": {
|
||||
"pino": "^10.1.0",
|
||||
"pino-pretty": "^13.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "catalog:"
|
||||
},
|
||||
"dependencies": {
|
||||
"pino": "^10.1.0",
|
||||
"pino-pretty": "^13.1.2"
|
||||
}
|
||||
"main": "src/index.ts",
|
||||
"name": "@basango/logger",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"clean": "rm -rf .turbo node_modules",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"type": "module",
|
||||
"types": "src/index.ts"
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@ export const logger = pino({
|
||||
// Use pretty printing in development, structured JSON in production
|
||||
...(process.env.NODE_ENV !== "production" && {
|
||||
transport: {
|
||||
target: "pino-pretty",
|
||||
options: {
|
||||
colorize: true,
|
||||
translateTime: "HH:MM:ss",
|
||||
hideObject: false,
|
||||
ignore: "pid,hostname",
|
||||
messageFormat: true,
|
||||
hideObject: false,
|
||||
translateTime: "HH:MM:ss",
|
||||
},
|
||||
target: "pino-pretty",
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "@basango/typescript-config/base.json",
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules"]
|
||||
"exclude": ["node_modules"],
|
||||
"extends": "@basango/tsconfig/base.json",
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"display": "Default",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
@@ -16,5 +15,6 @@
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"target": "ES2022"
|
||||
}
|
||||
},
|
||||
"display": "Default"
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"display": "Next.js",
|
||||
"extends": "./base.json",
|
||||
"compilerOptions": {
|
||||
"plugins": [{ "name": "next" }],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"allowJs": true,
|
||||
"jsx": "preserve",
|
||||
"noEmit": true
|
||||
}
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"noEmit": true,
|
||||
"plugins": [{ "name": "next" }]
|
||||
},
|
||||
"display": "Next.js",
|
||||
"extends": "./base.json"
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@basango/typescript-config",
|
||||
"private": true,
|
||||
"license": "PROPRIETARY",
|
||||
"name": "@basango/tsconfig",
|
||||
"private": true,
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"display": "React Library",
|
||||
"extends": "./base.json",
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx"
|
||||
}
|
||||
},
|
||||
"display": "React Library",
|
||||
"extends": "./base.json"
|
||||
}
|
||||
+13
-13
@@ -1,20 +1,20 @@
|
||||
{
|
||||
"$schema": "https://ui.shadcn.com/schema.json",
|
||||
"style": "new-york",
|
||||
"rsc": true,
|
||||
"tsx": true,
|
||||
"tailwind": {
|
||||
"config": "",
|
||||
"css": "src/styles/globals.css",
|
||||
"baseColor": "neutral",
|
||||
"cssVariables": true
|
||||
},
|
||||
"iconLibrary": "lucide",
|
||||
"aliases": {
|
||||
"components": "@basango/ui/components",
|
||||
"utils": "@basango/ui/lib/utils",
|
||||
"hooks": "@basango/ui/hooks",
|
||||
"lib": "@basango/ui/lib",
|
||||
"ui": "@basango/ui/components"
|
||||
}
|
||||
"ui": "@basango/ui/components",
|
||||
"utils": "@basango/ui/lib/utils"
|
||||
},
|
||||
"iconLibrary": "lucide",
|
||||
"rsc": true,
|
||||
"style": "new-york",
|
||||
"tailwind": {
|
||||
"baseColor": "neutral",
|
||||
"config": "",
|
||||
"css": "src/styles/globals.css",
|
||||
"cssVariables": true
|
||||
},
|
||||
"tsx": true
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** @type {import('postcss-load-config').Config} */
|
||||
const config = {
|
||||
plugins: { "@tailwindcss/postcss": {} },
|
||||
plugins: { "@tailwindcss/postcss": {} },
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
||||
@@ -1,59 +1,55 @@
|
||||
import * as React from "react"
|
||||
import { Slot } from "@radix-ui/react-slot"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { cn } from "@basango/ui/lib/utils"
|
||||
import { cn } from "@basango/ui/lib/utils";
|
||||
import { Slot } from "@radix-ui/react-slot";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import * as React from "react";
|
||||
|
||||
const buttonVariants = cva(
|
||||
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
||||
{
|
||||
defaultVariants: {
|
||||
size: "default",
|
||||
variant: "default",
|
||||
},
|
||||
variants: {
|
||||
variant: {
|
||||
default:
|
||||
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
|
||||
destructive:
|
||||
"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
||||
outline:
|
||||
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
||||
secondary:
|
||||
"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
|
||||
ghost:
|
||||
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
||||
link: "text-primary underline-offset-4 hover:underline",
|
||||
},
|
||||
size: {
|
||||
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
||||
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
||||
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
||||
icon: "size-9",
|
||||
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
||||
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
||||
},
|
||||
variant: {
|
||||
default: "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
|
||||
destructive:
|
||||
"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
||||
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
||||
link: "text-primary underline-offset-4 hover:underline",
|
||||
outline:
|
||||
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
||||
secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
},
|
||||
);
|
||||
|
||||
function Button({
|
||||
className,
|
||||
variant,
|
||||
size,
|
||||
asChild = false,
|
||||
...props
|
||||
}: React.ComponentProps<"button"> &
|
||||
className,
|
||||
variant,
|
||||
size,
|
||||
asChild = false,
|
||||
...props
|
||||
}: React.ComponentProps<"button"> &
|
||||
VariantProps<typeof buttonVariants> & {
|
||||
asChild?: boolean
|
||||
}) {
|
||||
const Comp = asChild ? Slot : "button"
|
||||
asChild?: boolean;
|
||||
}) {
|
||||
const Comp = asChild ? Slot : "button";
|
||||
|
||||
return (
|
||||
<Comp
|
||||
className={cn(buttonVariants({ className, size, variant }))}
|
||||
data-slot="button"
|
||||
className={cn(buttonVariants({ variant, size, className }))}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export { Button, buttonVariants }
|
||||
export { Button, buttonVariants };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { clsx, type ClassValue } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
import { type ClassValue, clsx } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
{
|
||||
"name": "@basango/ui",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"lint": "eslint . --max-warnings 0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@radix-ui/react-slot": "^1.2.3",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
@@ -18,20 +12,26 @@
|
||||
"zod": "^3.25.76"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@basango/tsconfig": "workspace:*",
|
||||
"@tailwindcss/postcss": "^4.1.11",
|
||||
"@turbo/gen": "^2.5.5",
|
||||
"@types/node": "catalog:",
|
||||
"@types/react": "catalog:",
|
||||
"@types/react-dom": "catalog:",
|
||||
"@basango/typescript-config": "workspace:*",
|
||||
"tailwindcss": "^4.1.11",
|
||||
"typescript": "catalog:"
|
||||
},
|
||||
"exports": {
|
||||
"./globals.css": "./src/styles/globals.css",
|
||||
"./postcss.config": "./postcss.config.mjs",
|
||||
"./lib/*": "./src/lib/*.ts",
|
||||
"./components/*": "./src/components/*.tsx",
|
||||
"./hooks/*": "./src/hooks/*.ts"
|
||||
}
|
||||
"./globals.css": "./src/styles/globals.css",
|
||||
"./hooks/*": "./src/hooks/*.ts",
|
||||
"./lib/*": "./src/lib/*.ts",
|
||||
"./postcss.config": "./postcss.config.mjs"
|
||||
},
|
||||
"name": "@basango/ui",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"lint": "eslint . --max-warnings 0"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
+109
-109
@@ -1,127 +1,127 @@
|
||||
@import "tailwindcss";
|
||||
@import "tw-animate-css";
|
||||
|
||||
@source "../../../apps/**/*.{ts,tsx}";
|
||||
@source "../../../components/**/*.{ts,tsx}";
|
||||
@source "../**/*.{ts,tsx}";
|
||||
|
||||
@import "tw-animate-css";
|
||||
|
||||
@custom-variant dark (&:is(.dark *));
|
||||
|
||||
:root {
|
||||
--background: oklch(1 0 0);
|
||||
--foreground: oklch(0.145 0 0);
|
||||
--card: oklch(1 0 0);
|
||||
--card-foreground: oklch(0.145 0 0);
|
||||
--popover: oklch(1 0 0);
|
||||
--popover-foreground: oklch(0.145 0 0);
|
||||
--primary: oklch(0.205 0 0);
|
||||
--primary-foreground: oklch(0.985 0 0);
|
||||
--secondary: oklch(0.97 0 0);
|
||||
--secondary-foreground: oklch(0.205 0 0);
|
||||
--muted: oklch(0.97 0 0);
|
||||
--muted-foreground: oklch(0.556 0 0);
|
||||
--accent: oklch(0.97 0 0);
|
||||
--accent-foreground: oklch(0.205 0 0);
|
||||
--destructive: oklch(0.577 0.245 27.325);
|
||||
--destructive-foreground: oklch(0.577 0.245 27.325);
|
||||
--border: oklch(0.922 0 0);
|
||||
--input: oklch(0.922 0 0);
|
||||
--ring: oklch(0.708 0 0);
|
||||
--chart-1: oklch(0.646 0.222 41.116);
|
||||
--chart-2: oklch(0.6 0.118 184.704);
|
||||
--chart-3: oklch(0.398 0.07 227.392);
|
||||
--chart-4: oklch(0.828 0.189 84.429);
|
||||
--chart-5: oklch(0.769 0.188 70.08);
|
||||
--radius: 0.625rem;
|
||||
--sidebar: oklch(0.985 0 0);
|
||||
--sidebar-foreground: oklch(0.145 0 0);
|
||||
--sidebar-primary: oklch(0.205 0 0);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.97 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.205 0 0);
|
||||
--sidebar-border: oklch(0.922 0 0);
|
||||
--sidebar-ring: oklch(0.708 0 0);
|
||||
--background: oklch(1 0 0);
|
||||
--foreground: oklch(0.145 0 0);
|
||||
--card: oklch(1 0 0);
|
||||
--card-foreground: oklch(0.145 0 0);
|
||||
--popover: oklch(1 0 0);
|
||||
--popover-foreground: oklch(0.145 0 0);
|
||||
--primary: oklch(0.205 0 0);
|
||||
--primary-foreground: oklch(0.985 0 0);
|
||||
--secondary: oklch(0.97 0 0);
|
||||
--secondary-foreground: oklch(0.205 0 0);
|
||||
--muted: oklch(0.97 0 0);
|
||||
--muted-foreground: oklch(0.556 0 0);
|
||||
--accent: oklch(0.97 0 0);
|
||||
--accent-foreground: oklch(0.205 0 0);
|
||||
--destructive: oklch(0.577 0.245 27.325);
|
||||
--destructive-foreground: oklch(0.577 0.245 27.325);
|
||||
--border: oklch(0.922 0 0);
|
||||
--input: oklch(0.922 0 0);
|
||||
--ring: oklch(0.708 0 0);
|
||||
--chart-1: oklch(0.646 0.222 41.116);
|
||||
--chart-2: oklch(0.6 0.118 184.704);
|
||||
--chart-3: oklch(0.398 0.07 227.392);
|
||||
--chart-4: oklch(0.828 0.189 84.429);
|
||||
--chart-5: oklch(0.769 0.188 70.08);
|
||||
--radius: 0.625rem;
|
||||
--sidebar: oklch(0.985 0 0);
|
||||
--sidebar-foreground: oklch(0.145 0 0);
|
||||
--sidebar-primary: oklch(0.205 0 0);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.97 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.205 0 0);
|
||||
--sidebar-border: oklch(0.922 0 0);
|
||||
--sidebar-ring: oklch(0.708 0 0);
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: oklch(0.145 0 0);
|
||||
--foreground: oklch(0.985 0 0);
|
||||
--card: oklch(0.145 0 0);
|
||||
--card-foreground: oklch(0.985 0 0);
|
||||
--popover: oklch(0.145 0 0);
|
||||
--popover-foreground: oklch(0.985 0 0);
|
||||
--primary: oklch(0.985 0 0);
|
||||
--primary-foreground: oklch(0.205 0 0);
|
||||
--secondary: oklch(0.269 0 0);
|
||||
--secondary-foreground: oklch(0.985 0 0);
|
||||
--muted: oklch(0.269 0 0);
|
||||
--muted-foreground: oklch(0.708 0 0);
|
||||
--accent: oklch(0.269 0 0);
|
||||
--accent-foreground: oklch(0.985 0 0);
|
||||
--destructive: oklch(0.396 0.141 25.723);
|
||||
--destructive-foreground: oklch(0.637 0.237 25.331);
|
||||
--border: oklch(0.269 0 0);
|
||||
--input: oklch(0.269 0 0);
|
||||
--ring: oklch(0.556 0 0);
|
||||
--chart-1: oklch(0.488 0.243 264.376);
|
||||
--chart-2: oklch(0.696 0.17 162.48);
|
||||
--chart-3: oklch(0.769 0.188 70.08);
|
||||
--chart-4: oklch(0.627 0.265 303.9);
|
||||
--chart-5: oklch(0.645 0.246 16.439);
|
||||
--sidebar: oklch(0.205 0 0);
|
||||
--sidebar-foreground: oklch(0.985 0 0);
|
||||
--sidebar-primary: oklch(0.488 0.243 264.376);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.269 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.985 0 0);
|
||||
--sidebar-border: oklch(0.269 0 0);
|
||||
--sidebar-ring: oklch(0.439 0 0);
|
||||
--background: oklch(0.145 0 0);
|
||||
--foreground: oklch(0.985 0 0);
|
||||
--card: oklch(0.145 0 0);
|
||||
--card-foreground: oklch(0.985 0 0);
|
||||
--popover: oklch(0.145 0 0);
|
||||
--popover-foreground: oklch(0.985 0 0);
|
||||
--primary: oklch(0.985 0 0);
|
||||
--primary-foreground: oklch(0.205 0 0);
|
||||
--secondary: oklch(0.269 0 0);
|
||||
--secondary-foreground: oklch(0.985 0 0);
|
||||
--muted: oklch(0.269 0 0);
|
||||
--muted-foreground: oklch(0.708 0 0);
|
||||
--accent: oklch(0.269 0 0);
|
||||
--accent-foreground: oklch(0.985 0 0);
|
||||
--destructive: oklch(0.396 0.141 25.723);
|
||||
--destructive-foreground: oklch(0.637 0.237 25.331);
|
||||
--border: oklch(0.269 0 0);
|
||||
--input: oklch(0.269 0 0);
|
||||
--ring: oklch(0.556 0 0);
|
||||
--chart-1: oklch(0.488 0.243 264.376);
|
||||
--chart-2: oklch(0.696 0.17 162.48);
|
||||
--chart-3: oklch(0.769 0.188 70.08);
|
||||
--chart-4: oklch(0.627 0.265 303.9);
|
||||
--chart-5: oklch(0.645 0.246 16.439);
|
||||
--sidebar: oklch(0.205 0 0);
|
||||
--sidebar-foreground: oklch(0.985 0 0);
|
||||
--sidebar-primary: oklch(0.488 0.243 264.376);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.269 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.985 0 0);
|
||||
--sidebar-border: oklch(0.269 0 0);
|
||||
--sidebar-ring: oklch(0.439 0 0);
|
||||
}
|
||||
|
||||
@theme inline {
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--color-card: var(--card);
|
||||
--color-card-foreground: var(--card-foreground);
|
||||
--color-popover: var(--popover);
|
||||
--color-popover-foreground: var(--popover-foreground);
|
||||
--color-primary: var(--primary);
|
||||
--color-primary-foreground: var(--primary-foreground);
|
||||
--color-secondary: var(--secondary);
|
||||
--color-secondary-foreground: var(--secondary-foreground);
|
||||
--color-muted: var(--muted);
|
||||
--color-muted-foreground: var(--muted-foreground);
|
||||
--color-accent: var(--accent);
|
||||
--color-accent-foreground: var(--accent-foreground);
|
||||
--color-destructive: var(--destructive);
|
||||
--color-destructive-foreground: var(--destructive-foreground);
|
||||
--color-border: var(--border);
|
||||
--color-input: var(--input);
|
||||
--color-ring: var(--ring);
|
||||
--color-chart-1: var(--chart-1);
|
||||
--color-chart-2: var(--chart-2);
|
||||
--color-chart-3: var(--chart-3);
|
||||
--color-chart-4: var(--chart-4);
|
||||
--color-chart-5: var(--chart-5);
|
||||
--radius-sm: calc(var(--radius) - 4px);
|
||||
--radius-md: calc(var(--radius) - 2px);
|
||||
--radius-lg: var(--radius);
|
||||
--radius-xl: calc(var(--radius) + 4px);
|
||||
--color-sidebar: var(--sidebar);
|
||||
--color-sidebar-foreground: var(--sidebar-foreground);
|
||||
--color-sidebar-primary: var(--sidebar-primary);
|
||||
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
||||
--color-sidebar-accent: var(--sidebar-accent);
|
||||
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
||||
--color-sidebar-border: var(--sidebar-border);
|
||||
--color-sidebar-ring: var(--sidebar-ring);
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--color-card: var(--card);
|
||||
--color-card-foreground: var(--card-foreground);
|
||||
--color-popover: var(--popover);
|
||||
--color-popover-foreground: var(--popover-foreground);
|
||||
--color-primary: var(--primary);
|
||||
--color-primary-foreground: var(--primary-foreground);
|
||||
--color-secondary: var(--secondary);
|
||||
--color-secondary-foreground: var(--secondary-foreground);
|
||||
--color-muted: var(--muted);
|
||||
--color-muted-foreground: var(--muted-foreground);
|
||||
--color-accent: var(--accent);
|
||||
--color-accent-foreground: var(--accent-foreground);
|
||||
--color-destructive: var(--destructive);
|
||||
--color-destructive-foreground: var(--destructive-foreground);
|
||||
--color-border: var(--border);
|
||||
--color-input: var(--input);
|
||||
--color-ring: var(--ring);
|
||||
--color-chart-1: var(--chart-1);
|
||||
--color-chart-2: var(--chart-2);
|
||||
--color-chart-3: var(--chart-3);
|
||||
--color-chart-4: var(--chart-4);
|
||||
--color-chart-5: var(--chart-5);
|
||||
--radius-sm: calc(var(--radius) - 4px);
|
||||
--radius-md: calc(var(--radius) - 2px);
|
||||
--radius-lg: var(--radius);
|
||||
--radius-xl: calc(var(--radius) + 4px);
|
||||
--color-sidebar: var(--sidebar);
|
||||
--color-sidebar-foreground: var(--sidebar-foreground);
|
||||
--color-sidebar-primary: var(--sidebar-primary);
|
||||
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
||||
--color-sidebar-accent: var(--sidebar-accent);
|
||||
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
||||
--color-sidebar-border: var(--sidebar-border);
|
||||
--color-sidebar-ring: var(--sidebar-ring);
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* {
|
||||
@apply border-border outline-ring/50;
|
||||
}
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
* {
|
||||
@apply border-border outline-ring/50;
|
||||
}
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"extends": "@basango/typescript-config/react-library.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@basango/ui/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["."],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
"exclude": ["node_modules", "dist"],
|
||||
"extends": "@basango/tsconfig/react-library.json",
|
||||
"include": ["."]
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"extends": "@basango/typescript-config/react-library.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": ["src", "turbo"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
"exclude": ["node_modules", "dist"],
|
||||
"extends": "@basango/tsconfig/react-library.json",
|
||||
"include": ["src", "turbo"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user