mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 00:18:19 +01:00
refactor(database): 🔥 Always import SQL operators directly from drizzle
Some checks failed
CodeQL Scan / Analyze (javascript-typescript) (push) Failing after 0s
Build Docker Images / lint (push) Failing after 7s
Build Docker Images / tests (push) Failing after 7s
Deploy Docs to GitHub Pages / build (push) Failing after 0s
Build Docker Images / build (server, Dockerfile, ${{ github.repository_owner }}/server) (push) Has been skipped
Build Docker Images / build (worker, Worker.Dockerfile, ${{ github.repository_owner }}/worker) (push) Has been skipped
Deploy Docs to GitHub Pages / Deploy (push) Has been skipped
Mirror to Codeberg / Mirror (push) Failing after 0s
Nix Build / check (push) Failing after 0s
Test Publish / build (client) (push) Failing after 0s
Test Publish / build (sdk) (push) Failing after 0s
Build Docker Images / check (push) Failing after 7s
Some checks failed
CodeQL Scan / Analyze (javascript-typescript) (push) Failing after 0s
Build Docker Images / lint (push) Failing after 7s
Build Docker Images / tests (push) Failing after 7s
Deploy Docs to GitHub Pages / build (push) Failing after 0s
Build Docker Images / build (server, Dockerfile, ${{ github.repository_owner }}/server) (push) Has been skipped
Build Docker Images / build (worker, Worker.Dockerfile, ${{ github.repository_owner }}/worker) (push) Has been skipped
Deploy Docs to GitHub Pages / Deploy (push) Has been skipped
Mirror to Codeberg / Mirror (push) Failing after 0s
Nix Build / check (push) Failing after 0s
Test Publish / build (client) (push) Failing after 0s
Test Publish / build (sdk) (push) Failing after 0s
Build Docker Images / check (push) Failing after 7s
This commit is contained in:
parent
d3f411915f
commit
9eac364e01
|
|
@ -76,7 +76,7 @@ export default apiRoute((app) => {
|
||||||
|
|
||||||
if (timeline.includes("home")) {
|
if (timeline.includes("home")) {
|
||||||
const found = await db.query.Markers.findFirst({
|
const found = await db.query.Markers.findFirst({
|
||||||
where: (marker, { and, eq }): SQL | undefined =>
|
where: (marker): SQL | undefined =>
|
||||||
and(
|
and(
|
||||||
eq(marker.userId, user.id),
|
eq(marker.userId, user.id),
|
||||||
eq(marker.timeline, "home"),
|
eq(marker.timeline, "home"),
|
||||||
|
|
@ -102,7 +102,7 @@ export default apiRoute((app) => {
|
||||||
|
|
||||||
if (timeline.includes("notifications")) {
|
if (timeline.includes("notifications")) {
|
||||||
const found = await db.query.Markers.findFirst({
|
const found = await db.query.Markers.findFirst({
|
||||||
where: (marker, { and, eq }): SQL | undefined =>
|
where: (marker): SQL | undefined =>
|
||||||
and(
|
and(
|
||||||
eq(marker.userId, user.id),
|
eq(marker.userId, user.id),
|
||||||
eq(marker.timeline, "notifications"),
|
eq(marker.timeline, "notifications"),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { RolePermission, Status as StatusSchema } from "@versia/client/schemas";
|
import { RolePermission, Status as StatusSchema } from "@versia/client/schemas";
|
||||||
import { db } from "@versia/kit/db";
|
import { db } from "@versia/kit/db";
|
||||||
import type { SQL } from "drizzle-orm";
|
import { and, eq, type SQL } from "drizzle-orm";
|
||||||
import { describeRoute } from "hono-openapi";
|
import { describeRoute } from "hono-openapi";
|
||||||
import { resolver } from "hono-openapi/zod";
|
import { resolver } from "hono-openapi/zod";
|
||||||
import { apiRoute, auth, withNoteParam } from "@/api";
|
import { apiRoute, auth, withNoteParam } from "@/api";
|
||||||
|
|
@ -51,7 +51,7 @@ export default apiRoute((app) =>
|
||||||
|
|
||||||
if (
|
if (
|
||||||
await db.query.UserToPinnedNotes.findFirst({
|
await db.query.UserToPinnedNotes.findFirst({
|
||||||
where: (userPinnedNote, { and, eq }): SQL | undefined =>
|
where: (userPinnedNote): SQL | undefined =>
|
||||||
and(
|
and(
|
||||||
eq(userPinnedNote.noteId, note.data.id),
|
eq(userPinnedNote.noteId, note.data.id),
|
||||||
eq(userPinnedNote.userId, user.id),
|
eq(userPinnedNote.userId, user.id),
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ export default apiRoute((app) => {
|
||||||
const { id } = context.req.valid("param");
|
const { id } = context.req.valid("param");
|
||||||
|
|
||||||
const userFilter = await db.query.Filters.findFirst({
|
const userFilter = await db.query.Filters.findFirst({
|
||||||
where: (filter, { eq, and }): SQL | undefined =>
|
where: (filter): SQL | undefined =>
|
||||||
and(eq(filter.userId, user.id), eq(filter.id, id)),
|
and(eq(filter.userId, user.id), eq(filter.id, id)),
|
||||||
with: {
|
with: {
|
||||||
keywords: true,
|
keywords: true,
|
||||||
|
|
@ -224,7 +224,7 @@ export default apiRoute((app) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedFilter = await db.query.Filters.findFirst({
|
const updatedFilter = await db.query.Filters.findFirst({
|
||||||
where: (filter, { eq, and }): SQL | undefined =>
|
where: (filter): SQL | undefined =>
|
||||||
and(eq(filter.userId, user.id), eq(filter.id, id)),
|
and(eq(filter.userId, user.id), eq(filter.id, id)),
|
||||||
with: {
|
with: {
|
||||||
keywords: true,
|
keywords: true,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import {
|
||||||
import { db } from "@versia/kit/db";
|
import { db } from "@versia/kit/db";
|
||||||
import { FilterKeywords, Filters } from "@versia/kit/tables";
|
import { FilterKeywords, Filters } from "@versia/kit/tables";
|
||||||
import { randomUUIDv7 } from "bun";
|
import { randomUUIDv7 } from "bun";
|
||||||
import type { SQL } from "drizzle-orm";
|
import { eq, type SQL } from "drizzle-orm";
|
||||||
import { describeRoute } from "hono-openapi";
|
import { describeRoute } from "hono-openapi";
|
||||||
import { resolver, validator } from "hono-openapi/zod";
|
import { resolver, validator } from "hono-openapi/zod";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
@ -44,8 +44,7 @@ export default apiRoute((app) => {
|
||||||
const { user } = context.get("auth");
|
const { user } = context.get("auth");
|
||||||
|
|
||||||
const userFilters = await db.query.Filters.findMany({
|
const userFilters = await db.query.Filters.findMany({
|
||||||
where: (filter, { eq }): SQL | undefined =>
|
where: (filter): SQL | undefined => eq(filter.userId, user.id),
|
||||||
eq(filter.userId, user.id),
|
|
||||||
with: {
|
with: {
|
||||||
keywords: true,
|
keywords: true,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
2
bun.lock
2
bun.lock
|
|
@ -86,7 +86,7 @@
|
||||||
},
|
},
|
||||||
"packages/client": {
|
"packages/client": {
|
||||||
"name": "@versia/client",
|
"name": "@versia/client",
|
||||||
"version": "0.2.0-alpha.1",
|
"version": "0.2.0-alpha.3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@badgateway/oauth2-client": "^3.0.0",
|
"@badgateway/oauth2-client": "^3.0.0",
|
||||||
"iso-639-1": "^3.1.5",
|
"iso-639-1": "^3.1.5",
|
||||||
|
|
|
||||||
|
|
@ -261,7 +261,7 @@ export class Note extends BaseInterface<typeof Notes, NoteTypeWithRelations> {
|
||||||
{
|
{
|
||||||
with: {
|
with: {
|
||||||
relationships: {
|
relationships: {
|
||||||
where: (relationship, { eq, and }): SQL | undefined =>
|
where: (relationship): SQL | undefined =>
|
||||||
and(
|
and(
|
||||||
eq(relationship.subjectId, this.data.authorId),
|
eq(relationship.subjectId, this.data.authorId),
|
||||||
eq(relationship.following, true),
|
eq(relationship.following, true),
|
||||||
|
|
@ -597,7 +597,7 @@ export class Note extends BaseInterface<typeof Notes, NoteTypeWithRelations> {
|
||||||
if (this.data.visibility === "private") {
|
if (this.data.visibility === "private") {
|
||||||
return user
|
return user
|
||||||
? !!(await db.query.Relationships.findFirst({
|
? !!(await db.query.Relationships.findFirst({
|
||||||
where: (relationship, { and, eq }): SQL | undefined =>
|
where: (relationship): SQL | undefined =>
|
||||||
and(
|
and(
|
||||||
eq(relationship.ownerId, user?.id),
|
eq(relationship.ownerId, user?.id),
|
||||||
eq(relationship.subjectId, Notes.authorId),
|
eq(relationship.subjectId, Notes.authorId),
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@ export class Relationship extends BaseInterface<
|
||||||
ownerId: string;
|
ownerId: string;
|
||||||
}): Promise<RelationshipType> {
|
}): Promise<RelationshipType> {
|
||||||
let output = await db.query.Relationships.findFirst({
|
let output = await db.query.Relationships.findFirst({
|
||||||
where: (rel, { and, eq }): SQL | undefined =>
|
where: (rel): SQL | undefined =>
|
||||||
and(
|
and(
|
||||||
eq(rel.ownerId, oppositeTo.subjectId),
|
eq(rel.ownerId, oppositeTo.subjectId),
|
||||||
eq(rel.subjectId, oppositeTo.ownerId),
|
eq(rel.subjectId, oppositeTo.ownerId),
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,7 @@ export class Role extends BaseInterface<typeof Roles> {
|
||||||
): Promise<Role[]> {
|
): Promise<Role[]> {
|
||||||
return (
|
return (
|
||||||
await db.query.RoleToUsers.findMany({
|
await db.query.RoleToUsers.findMany({
|
||||||
where: (role, { eq }): SQL | undefined =>
|
where: (role): SQL | undefined => eq(role.userId, userId),
|
||||||
eq(role.userId, userId),
|
|
||||||
with: {
|
with: {
|
||||||
role: true,
|
role: true,
|
||||||
user: {
|
user: {
|
||||||
|
|
|
||||||
|
|
@ -464,7 +464,7 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
|
||||||
> {
|
> {
|
||||||
// Get all linked accounts
|
// Get all linked accounts
|
||||||
const accounts = await db.query.OpenIdAccounts.findMany({
|
const accounts = await db.query.OpenIdAccounts.findMany({
|
||||||
where: (User, { eq }): SQL | undefined => eq(User.userId, this.id),
|
where: (User): SQL | undefined => eq(User.userId, this.id),
|
||||||
});
|
});
|
||||||
|
|
||||||
return accounts
|
return accounts
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ export default (plugin: PluginType): void => {
|
||||||
|
|
||||||
// Check if account is already linked
|
// Check if account is already linked
|
||||||
const account = await db.query.OpenIdAccounts.findFirst({
|
const account = await db.query.OpenIdAccounts.findFirst({
|
||||||
where: (account, { eq, and }): SQL | undefined =>
|
where: (account): SQL | undefined =>
|
||||||
and(
|
and(
|
||||||
eq(account.serverId, sub),
|
eq(account.serverId, sub),
|
||||||
eq(account.issuerId, issuer.id),
|
eq(account.issuerId, issuer.id),
|
||||||
|
|
@ -195,7 +195,7 @@ export default (plugin: PluginType): void => {
|
||||||
|
|
||||||
let userId = (
|
let userId = (
|
||||||
await db.query.OpenIdAccounts.findFirst({
|
await db.query.OpenIdAccounts.findFirst({
|
||||||
where: (account, { eq, and }): SQL | undefined =>
|
where: (account): SQL | undefined =>
|
||||||
and(
|
and(
|
||||||
eq(account.serverId, sub),
|
eq(account.serverId, sub),
|
||||||
eq(account.issuerId, issuer.id),
|
eq(account.issuerId, issuer.id),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { RolePermission } from "@versia/client/schemas";
|
import { RolePermission } from "@versia/client/schemas";
|
||||||
import { db } from "@versia/kit/db";
|
import { db } from "@versia/kit/db";
|
||||||
import { eq, type SQL } from "@versia/kit/drizzle";
|
import { and, eq, type SQL } from "@versia/kit/drizzle";
|
||||||
import { OpenIdAccounts } from "@versia/kit/tables";
|
import { OpenIdAccounts } from "@versia/kit/tables";
|
||||||
import { describeRoute } from "hono-openapi";
|
import { describeRoute } from "hono-openapi";
|
||||||
import { resolver, validator } from "hono-openapi/zod";
|
import { resolver, validator } from "hono-openapi/zod";
|
||||||
|
|
@ -58,7 +58,7 @@ export default (plugin: PluginType): void => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const account = await db.query.OpenIdAccounts.findFirst({
|
const account = await db.query.OpenIdAccounts.findFirst({
|
||||||
where: (account, { eq, and }): SQL | undefined =>
|
where: (account): SQL | undefined =>
|
||||||
and(
|
and(
|
||||||
eq(account.userId, user.id),
|
eq(account.userId, user.id),
|
||||||
eq(account.issuerId, issuerId),
|
eq(account.issuerId, issuerId),
|
||||||
|
|
@ -127,7 +127,7 @@ export default (plugin: PluginType): void => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const account = await db.query.OpenIdAccounts.findFirst({
|
const account = await db.query.OpenIdAccounts.findFirst({
|
||||||
where: (account, { eq, and }): SQL | undefined =>
|
where: (account): SQL | undefined =>
|
||||||
and(
|
and(
|
||||||
eq(account.userId, user.id),
|
eq(account.userId, user.id),
|
||||||
eq(account.issuerId, issuerId),
|
eq(account.issuerId, issuerId),
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { type Application, db } from "@versia/kit/db";
|
import { type Application, db } from "@versia/kit/db";
|
||||||
import type { InferSelectModel, SQL } from "@versia/kit/drizzle";
|
import { eq, type InferSelectModel, type SQL } from "@versia/kit/drizzle";
|
||||||
import type { OpenIdLoginFlows } from "@versia/kit/tables";
|
import type { OpenIdLoginFlows } from "@versia/kit/tables";
|
||||||
import {
|
import {
|
||||||
type AuthorizationResponseError,
|
type AuthorizationResponseError,
|
||||||
|
|
@ -39,7 +39,7 @@ const getFlow = (
|
||||||
| undefined
|
| undefined
|
||||||
> => {
|
> => {
|
||||||
return db.query.OpenIdLoginFlows.findFirst({
|
return db.query.OpenIdLoginFlows.findFirst({
|
||||||
where: (flow, { eq }): SQL | undefined => eq(flow.id, flowId),
|
where: (flow): SQL | undefined => eq(flow.id, flowId),
|
||||||
with: {
|
with: {
|
||||||
application: true,
|
application: true,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
//"isolatedDeclarations": true,
|
//"isolatedDeclarations": true,
|
||||||
"verbatimModuleSyntax": true,
|
"verbatimModuleSyntax": true,
|
||||||
"moduleDetection": "force",
|
"moduleDetection": "force",
|
||||||
"target": "esnext",
|
"target": "ESNext",
|
||||||
"jsx": "preserve",
|
"jsx": "preserve",
|
||||||
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
||||||
"composite": true,
|
"composite": true,
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ export const checkRouteNeedsChallenge = async (
|
||||||
}
|
}
|
||||||
|
|
||||||
const challenge = await db.query.Challenges.findFirst({
|
const challenge = await db.query.Challenges.findFirst({
|
||||||
where: (c, { eq }): SQL | undefined => eq(c.id, challenge_id),
|
where: (c): SQL | undefined => eq(c.id, challenge_id),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!challenge) {
|
if (!challenge) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue