mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Ready for 1.1.2-rc.1
This commit is contained in:
+1
-1
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
import { userAction } from "@/safe-actions";
|
||||
import { z } from "zod";
|
||||
import { EmailFormSchema } from "@/components/wrappers/dashboard/admin/admin-email-tab/email-form/email-form.schema";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db } from "@/db";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
|
||||
export const updateEmailSettingsAction = userAction
|
||||
.schema(
|
||||
|
||||
+1
-1
@@ -1,11 +1,11 @@
|
||||
"use server";
|
||||
|
||||
import { userAction } from "@/safe-actions";
|
||||
import { z } from "zod";
|
||||
import { db } from "@/db";
|
||||
import { S3FormSchema, StorageSwitchSchema } from "@/components/wrappers/dashboard/admin/admin-storage-tab/storage-s3/s3-form.schema";
|
||||
import { eq } from "drizzle-orm";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
|
||||
export const updateS3SettingsAction = userAction
|
||||
.schema(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use server";
|
||||
import {ActionError, userAction} from "@/safe-actions";
|
||||
import {ActionError, userAction} from "@/lib/safe-actions/actions";
|
||||
import {AgentSchema} from "@/components/wrappers/dashboard/agent/agent-form/agent-form.schema";
|
||||
import {z} from "zod";
|
||||
import {eq, and, ne, count} from "drizzle-orm";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use server";
|
||||
|
||||
import {userAction} from "@/safe-actions";
|
||||
import {z} from "zod";
|
||||
import {v4 as uuidv4} from "uuid";
|
||||
import {ServerActionResult} from "@/types/action-type";
|
||||
@@ -8,6 +7,7 @@ import {eq} from "drizzle-orm";
|
||||
import {db} from "@/db";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {Agent} from "@/db/schema/08_agent";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
|
||||
export const deleteAgentAction = userAction.schema(z.string()).action(async ({parsedInput}): Promise<ServerActionResult<Agent>> => {
|
||||
try {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"use server";
|
||||
|
||||
import {z} from "zod";
|
||||
import {userAction} from "@/safe-actions";
|
||||
import {db} from "@/db";
|
||||
import {ServerActionResult} from "@/types/action-type";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {Backup} from "@/db/schema/07_database";
|
||||
import {withUpdatedAt} from "@/db/utils";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
|
||||
export const backupButtonAction = userAction.schema(z.string()).action(async ({parsedInput}): Promise<ServerActionResult<Backup>> => {
|
||||
try {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import {userAction} from "@/safe-actions";
|
||||
import {z} from "zod";
|
||||
import {db} from "@/db";
|
||||
import {eq} from "drizzle-orm";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
|
||||
export const updateDatabaseBackupPolicyAction = userAction
|
||||
.schema(
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
"use server";
|
||||
|
||||
import { z } from "zod";
|
||||
import { userAction } from "@/safe-actions";
|
||||
import { db } from "@/db";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { DatabaseSchema } from "@/components/wrappers/dashboard/database/database-form/form-database.schema";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
import {Database} from "@/db/schema/07_database";
|
||||
|
||||
export const updateDatabaseAction = userAction
|
||||
.schema(
|
||||
|
||||
+1
-1
@@ -1,6 +1,5 @@
|
||||
"use server"
|
||||
|
||||
import {userAction} from "@/safe-actions"
|
||||
import {z} from "zod"
|
||||
import {db} from "@/db"
|
||||
import {eq} from "drizzle-orm"
|
||||
@@ -8,6 +7,7 @@ import * as drizzleDb from "@/db";
|
||||
import {
|
||||
RetentionSettingsSchema
|
||||
} from "@/components/wrappers/dashboard/database/retention-policy/backup-retention-settings.schema";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
|
||||
|
||||
export const updateOrCreateBackupRetentionPolicyAction = userAction
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use server";
|
||||
|
||||
import {userAction} from "@/safe-actions";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
import {OrganizationSchema} from "@/components/wrappers/dashboard/organization/organization.schema";
|
||||
import {ServerActionResult} from "@/types/action-type";
|
||||
import {z} from "zod";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use server";
|
||||
import { db } from "@/db";
|
||||
import { userAction } from "@/safe-actions";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { z } from "zod";
|
||||
import * as drizzleDb from "@/db";
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
"use server";
|
||||
import { userAction } from "@/safe-actions";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
import { z } from "zod";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { db } from "@/db";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use server";
|
||||
import { userAction } from "@/safe-actions";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
import { z } from "zod";
|
||||
import { UserSchema } from "@/components/wrappers/dashboard/profile/user-form/user-form.schema";
|
||||
import { db } from "@/db";
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
"use server";
|
||||
|
||||
import {userAction} from "@/safe-actions";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
import {z} from "zod";
|
||||
import {v4 as uuidv4} from "uuid";
|
||||
import {ServerActionResult} from "@/types/action-type";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use server";
|
||||
|
||||
import { userAction } from "@/safe-actions";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
import { ProjectSchema } from "@/components/wrappers/dashboard/projects/project-form/project-form.schema";
|
||||
import { z } from "zod";
|
||||
import { ServerActionResult } from "@/types/action-type";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use server";
|
||||
import {userAction} from "@/safe-actions";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
import {z} from "zod";
|
||||
import {auth} from "@/lib/auth/auth";
|
||||
import {ServerActionResult} from "@/types/action-type";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use server"
|
||||
import {userAction} from "@/safe-actions";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
import {z} from "zod";
|
||||
import {ServerActionResult} from "@/types/action-type";
|
||||
import * as drizzleDb from "@/db";
|
||||
|
||||
@@ -6,10 +6,10 @@ import * as fs from "node:fs";
|
||||
import {getServerUrl} from "@/utils/get-server-url";
|
||||
import {createPresignedUrlToDownload, deleteFileFromBucket, saveFileInBucket} from "@/utils/s3-file-management";
|
||||
import {env} from "@/env.mjs";
|
||||
import {action} from "@/safe-actions";
|
||||
import {z} from "zod";
|
||||
import {ServerActionResult} from "@/types/action-type";
|
||||
import {unlink} from "fs/promises";
|
||||
import {action} from "@/lib/safe-actions/actions";
|
||||
|
||||
const privateLocalDir = "private/uploads/files/";
|
||||
const privateS3Dir = "backups/";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use server";
|
||||
import { userAction } from "@/safe-actions";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
import { z } from "zod";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { mkdir, writeFile } from "fs/promises";
|
||||
|
||||
@@ -8,7 +8,7 @@ import {admin as adminPlugin, openAPI, Organization, organization} from "better-
|
||||
import {ac, admin, orgAdmin, orgMember, orgOwner, pending, superadmin, user} from "@/lib/auth/permissions";
|
||||
import {headers} from "next/headers";
|
||||
import {count, eq} from "drizzle-orm";
|
||||
import {OrganizationWithMembers, OrganizationWithMembersAndUsers} from "@/db/schema/03_organization";
|
||||
import {OrganizationWithMembersAndUsers} from "@/db/schema/03_organization";
|
||||
|
||||
export const auth = betterAuth({
|
||||
database: drizzleAdapter(db, {
|
||||
@@ -81,8 +81,6 @@ export const auth = betterAuth({
|
||||
async before(user, context) {
|
||||
const userCount = (await db.select({count: count()}).from(drizzleDb.schemas.user))[0].count;
|
||||
const role = userCount === 0 ? "superadmin" : "pending";
|
||||
|
||||
|
||||
return {
|
||||
data: {
|
||||
...user,
|
||||
@@ -335,15 +333,15 @@ export const getOrganization = async ({
|
||||
} = {}): Promise<OrganizationWithMembersAndUsers | null> => {
|
||||
const query =
|
||||
organizationId != null
|
||||
? { organizationId }
|
||||
? {organizationId}
|
||||
: organizationSlug != null
|
||||
? { organizationSlug }
|
||||
? {organizationSlug}
|
||||
: undefined;
|
||||
|
||||
try {
|
||||
const response = await auth.api.getFullOrganization({
|
||||
headers: await headers(),
|
||||
...(query ? { query } : {}),
|
||||
...(query ? {query} : {}),
|
||||
});
|
||||
|
||||
return response as OrganizationWithMembersAndUsers;
|
||||
@@ -382,7 +380,7 @@ export const getLastOrganizationOrFirst = async (userId: string) => {
|
||||
export const createOrganization = async (name: string, slug: string) => {
|
||||
try {
|
||||
return await auth.api.createOrganization({
|
||||
headers: await headers(),
|
||||
headers: await headers(),
|
||||
body: {
|
||||
name,
|
||||
slug,
|
||||
@@ -465,13 +463,12 @@ export const getActiveMember = async () => {
|
||||
|
||||
export const setActiveOrganization = async (slug: string) => {
|
||||
try {
|
||||
const organization = await auth.api.setActiveOrganization({
|
||||
return await auth.api.setActiveOrganization({
|
||||
headers: await headers(),
|
||||
body: {
|
||||
organizationSlug: slug,
|
||||
},
|
||||
});
|
||||
return organization;
|
||||
} catch (e) {
|
||||
console.log("error", e);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createSafeActionClient } from "next-safe-action";
|
||||
import { currentUser } from "./lib/auth/current-user";
|
||||
import {createSafeActionClient} from "next-safe-action";
|
||||
import {currentUser} from "@/lib/auth/current-user";
|
||||
|
||||
export class ActionError extends Error {
|
||||
constructor(message: string) {
|
||||
@@ -20,11 +20,10 @@ export const action = createSafeActionClient({
|
||||
handleServerError: handleReturnedServerError,
|
||||
});
|
||||
|
||||
export const userAction = action.use(async ({ next, ctx }) => {
|
||||
export const userAction = action.use(async ({next, ctx}) => {
|
||||
const user = await currentUser();
|
||||
|
||||
if (!user) {
|
||||
throw new ActionError("You must be logged in");
|
||||
}
|
||||
return next({ ctx: { user } });
|
||||
return next({ctx: {user}});
|
||||
});
|
||||
@@ -3,7 +3,7 @@ import {enforceRetentionCount} from "@/lib/tasks/database/retention-count";
|
||||
import {enforceRetentionDays} from "@/lib/tasks/database/retention-days";
|
||||
import {enforceRetentionGFS} from "@/lib/tasks/database/retention-gsf";
|
||||
import {retentionPolicy} from "@/db/schema/07_database";
|
||||
import {eq, isNull} from "drizzle-orm";
|
||||
import {isNull} from "drizzle-orm";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {eventEmitter} from "../../../../app/api/events/route";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use server"
|
||||
import {action, userAction} from "@/safe-actions";
|
||||
import {action} from "@/lib/safe-actions/actions";
|
||||
import {z} from "zod";
|
||||
import {ServerActionResult} from "@/types/action-type";
|
||||
import {Backup} from "@/db/schema/07_database";
|
||||
|
||||
Reference in New Issue
Block a user