Merge pull request #1069 from nktnet1/accessed-typo

chore: typo "accesed" changed to "accessed" for TS code
This commit is contained in:
Mauricio Siu
2025-01-18 17:35:04 -06:00
committed by GitHub
4 changed files with 48 additions and 48 deletions

View File

@@ -30,8 +30,8 @@ import { toast } from "sonner";
import { z } from "zod"; import { z } from "zod";
const addPermissions = z.object({ const addPermissions = z.object({
accesedProjects: z.array(z.string()).optional(), accessedProjects: z.array(z.string()).optional(),
accesedServices: z.array(z.string()).optional(), accessedServices: z.array(z.string()).optional(),
canCreateProjects: z.boolean().optional().default(false), canCreateProjects: z.boolean().optional().default(false),
canCreateServices: z.boolean().optional().default(false), canCreateServices: z.boolean().optional().default(false),
canDeleteProjects: z.boolean().optional().default(false), canDeleteProjects: z.boolean().optional().default(false),
@@ -66,8 +66,8 @@ export const AddUserPermissions = ({ userId }: Props) => {
const form = useForm<AddPermissions>({ const form = useForm<AddPermissions>({
defaultValues: { defaultValues: {
accesedProjects: [], accessedProjects: [],
accesedServices: [], accessedServices: [],
}, },
resolver: zodResolver(addPermissions), resolver: zodResolver(addPermissions),
}); });
@@ -75,8 +75,8 @@ export const AddUserPermissions = ({ userId }: Props) => {
useEffect(() => { useEffect(() => {
if (data) { if (data) {
form.reset({ form.reset({
accesedProjects: data.accesedProjects || [], accessedProjects: data.accessedProjects || [],
accesedServices: data.accesedServices || [], accessedServices: data.accessedServices || [],
canCreateProjects: data.canCreateProjects, canCreateProjects: data.canCreateProjects,
canCreateServices: data.canCreateServices, canCreateServices: data.canCreateServices,
canDeleteProjects: data.canDeleteProjects, canDeleteProjects: data.canDeleteProjects,
@@ -98,8 +98,8 @@ export const AddUserPermissions = ({ userId }: Props) => {
canDeleteServices: data.canDeleteServices, canDeleteServices: data.canDeleteServices,
canDeleteProjects: data.canDeleteProjects, canDeleteProjects: data.canDeleteProjects,
canAccessToTraefikFiles: data.canAccessToTraefikFiles, canAccessToTraefikFiles: data.canAccessToTraefikFiles,
accesedProjects: data.accesedProjects || [], accessedProjects: data.accessedProjects || [],
accesedServices: data.accesedServices || [], accessedServices: data.accessedServices || [],
canAccessToDocker: data.canAccessToDocker, canAccessToDocker: data.canAccessToDocker,
canAccessToAPI: data.canAccessToAPI, canAccessToAPI: data.canAccessToAPI,
canAccessToSSHKeys: data.canAccessToSSHKeys, canAccessToSSHKeys: data.canAccessToSSHKeys,
@@ -318,7 +318,7 @@ export const AddUserPermissions = ({ userId }: Props) => {
/> />
<FormField <FormField
control={form.control} control={form.control}
name="accesedProjects" name="accessedProjects"
render={() => ( render={() => (
<FormItem className="md:col-span-2"> <FormItem className="md:col-span-2">
<div className="mb-4"> <div className="mb-4">
@@ -339,7 +339,7 @@ export const AddUserPermissions = ({ userId }: Props) => {
<FormField <FormField
key={`project-${index}`} key={`project-${index}`}
control={form.control} control={form.control}
name="accesedProjects" name="accessedProjects"
render={({ field }) => { render={({ field }) => {
return ( return (
<FormItem <FormItem
@@ -380,7 +380,7 @@ export const AddUserPermissions = ({ userId }: Props) => {
<FormField <FormField
key={`project-${index}`} key={`project-${index}`}
control={form.control} control={form.control}
name="accesedServices" name="accessedServices"
render={({ field }) => { render={({ field }) => {
return ( return (
<FormItem <FormItem

View File

@@ -68,7 +68,7 @@ export const projectRouter = createTRPCRouter({
.input(apiFindOneProject) .input(apiFindOneProject)
.query(async ({ input, ctx }) => { .query(async ({ input, ctx }) => {
if (ctx.user.rol === "user") { if (ctx.user.rol === "user") {
const { accesedServices } = await findUserByAuthId(ctx.user.authId); const { accessedServices } = await findUserByAuthId(ctx.user.authId);
await checkProjectAccess(ctx.user.authId, "access", input.projectId); await checkProjectAccess(ctx.user.authId, "access", input.projectId);
@@ -79,28 +79,28 @@ export const projectRouter = createTRPCRouter({
), ),
with: { with: {
compose: { compose: {
where: buildServiceFilter(compose.composeId, accesedServices), where: buildServiceFilter(compose.composeId, accessedServices),
}, },
applications: { applications: {
where: buildServiceFilter( where: buildServiceFilter(
applications.applicationId, applications.applicationId,
accesedServices, accessedServices,
), ),
}, },
mariadb: { mariadb: {
where: buildServiceFilter(mariadb.mariadbId, accesedServices), where: buildServiceFilter(mariadb.mariadbId, accessedServices),
}, },
mongo: { mongo: {
where: buildServiceFilter(mongo.mongoId, accesedServices), where: buildServiceFilter(mongo.mongoId, accessedServices),
}, },
mysql: { mysql: {
where: buildServiceFilter(mysql.mysqlId, accesedServices), where: buildServiceFilter(mysql.mysqlId, accessedServices),
}, },
postgres: { postgres: {
where: buildServiceFilter(postgres.postgresId, accesedServices), where: buildServiceFilter(postgres.postgresId, accessedServices),
}, },
redis: { redis: {
where: buildServiceFilter(redis.redisId, accesedServices), where: buildServiceFilter(redis.redisId, accessedServices),
}, },
}, },
}); });
@@ -125,18 +125,18 @@ export const projectRouter = createTRPCRouter({
}), }),
all: protectedProcedure.query(async ({ ctx }) => { all: protectedProcedure.query(async ({ ctx }) => {
if (ctx.user.rol === "user") { if (ctx.user.rol === "user") {
const { accesedProjects, accesedServices } = await findUserByAuthId( const { accessedProjects, accessedServices } = await findUserByAuthId(
ctx.user.authId, ctx.user.authId,
); );
if (accesedProjects.length === 0) { if (accessedProjects.length === 0) {
return []; return [];
} }
const query = await db.query.projects.findMany({ const query = await db.query.projects.findMany({
where: and( where: and(
sql`${projects.projectId} IN (${sql.join( sql`${projects.projectId} IN (${sql.join(
accesedProjects.map((projectId) => sql`${projectId}`), accessedProjects.map((projectId) => sql`${projectId}`),
sql`, `, sql`, `,
)})`, )})`,
eq(projects.adminId, ctx.user.adminId), eq(projects.adminId, ctx.user.adminId),
@@ -145,27 +145,27 @@ export const projectRouter = createTRPCRouter({
applications: { applications: {
where: buildServiceFilter( where: buildServiceFilter(
applications.applicationId, applications.applicationId,
accesedServices, accessedServices,
), ),
with: { domains: true }, with: { domains: true },
}, },
mariadb: { mariadb: {
where: buildServiceFilter(mariadb.mariadbId, accesedServices), where: buildServiceFilter(mariadb.mariadbId, accessedServices),
}, },
mongo: { mongo: {
where: buildServiceFilter(mongo.mongoId, accesedServices), where: buildServiceFilter(mongo.mongoId, accessedServices),
}, },
mysql: { mysql: {
where: buildServiceFilter(mysql.mysqlId, accesedServices), where: buildServiceFilter(mysql.mysqlId, accessedServices),
}, },
postgres: { postgres: {
where: buildServiceFilter(postgres.postgresId, accesedServices), where: buildServiceFilter(postgres.postgresId, accessedServices),
}, },
redis: { redis: {
where: buildServiceFilter(redis.redisId, accesedServices), where: buildServiceFilter(redis.redisId, accessedServices),
}, },
compose: { compose: {
where: buildServiceFilter(compose.composeId, accesedServices), where: buildServiceFilter(compose.composeId, accessedServices),
with: { domains: true }, with: { domains: true },
}, },
}, },
@@ -239,10 +239,10 @@ export const projectRouter = createTRPCRouter({
} }
}), }),
}); });
function buildServiceFilter(fieldName: AnyPgColumn, accesedServices: string[]) { function buildServiceFilter(fieldName: AnyPgColumn, accessedServices: string[]) {
return accesedServices.length > 0 return accessedServices.length > 0
? sql`${fieldName} IN (${sql.join( ? sql`${fieldName} IN (${sql.join(
accesedServices.map((serviceId) => sql`${serviceId}`), accessedServices.map((serviceId) => sql`${serviceId}`),
sql`, `, sql`, `,
)})` )})`
: sql`1 = 0`; : sql`1 = 0`;

View File

@@ -40,11 +40,11 @@ export const users = pgTable("user", {
canAccessToTraefikFiles: boolean("canAccessToTraefikFiles") canAccessToTraefikFiles: boolean("canAccessToTraefikFiles")
.notNull() .notNull()
.default(false), .default(false),
accesedProjects: text("accesedProjects") accessedProjects: text("accesedProjects")
.array() .array()
.notNull() .notNull()
.default(sql`ARRAY[]::text[]`), .default(sql`ARRAY[]::text[]`),
accesedServices: text("accesedServices") accessedServices: text("accesedServices")
.array() .array()
.notNull() .notNull()
.default(sql`ARRAY[]::text[]`), .default(sql`ARRAY[]::text[]`),
@@ -73,8 +73,8 @@ const createSchema = createInsertSchema(users, {
token: z.string().min(1), token: z.string().min(1),
isRegistered: z.boolean().optional(), isRegistered: z.boolean().optional(),
adminId: z.string(), adminId: z.string(),
accesedProjects: z.array(z.string()).optional(), accessedProjects: z.array(z.string()).optional(),
accesedServices: z.array(z.string()).optional(), accessedServices: z.array(z.string()).optional(),
canCreateProjects: z.boolean().optional(), canCreateProjects: z.boolean().optional(),
canCreateServices: z.boolean().optional(), canCreateServices: z.boolean().optional(),
canDeleteProjects: z.boolean().optional(), canDeleteProjects: z.boolean().optional(),
@@ -106,8 +106,8 @@ export const apiAssignPermissions = createSchema
canCreateServices: true, canCreateServices: true,
canDeleteProjects: true, canDeleteProjects: true,
canDeleteServices: true, canDeleteServices: true,
accesedProjects: true, accessedProjects: true,
accesedServices: true, accessedServices: true,
canAccessToTraefikFiles: true, canAccessToTraefikFiles: true,
canAccessToDocker: true, canAccessToDocker: true,
canAccessToAPI: true, canAccessToAPI: true,

View File

@@ -54,7 +54,7 @@ export const addNewProject = async (authId: string, projectId: string) => {
await db await db
.update(users) .update(users)
.set({ .set({
accesedProjects: [...user.accesedProjects, projectId], accessedProjects: [...user.accessedProjects, projectId],
}) })
.where(eq(users.authId, authId)); .where(eq(users.authId, authId));
}; };
@@ -64,7 +64,7 @@ export const addNewService = async (authId: string, serviceId: string) => {
await db await db
.update(users) .update(users)
.set({ .set({
accesedServices: [...user.accesedServices, serviceId], accessedServices: [...user.accessedServices, serviceId],
}) })
.where(eq(users.authId, authId)); .where(eq(users.authId, authId));
}; };
@@ -73,8 +73,8 @@ export const canPerformCreationService = async (
userId: string, userId: string,
projectId: string, projectId: string,
) => { ) => {
const { accesedProjects, canCreateServices } = await findUserByAuthId(userId); const { accessedProjects, canCreateServices } = await findUserByAuthId(userId);
const haveAccessToProject = accesedProjects.includes(projectId); const haveAccessToProject = accessedProjects.includes(projectId);
if (canCreateServices && haveAccessToProject) { if (canCreateServices && haveAccessToProject) {
return true; return true;
@@ -87,8 +87,8 @@ export const canPerformAccessService = async (
userId: string, userId: string,
serviceId: string, serviceId: string,
) => { ) => {
const { accesedServices } = await findUserByAuthId(userId); const { accessedServices } = await findUserByAuthId(userId);
const haveAccessToService = accesedServices.includes(serviceId); const haveAccessToService = accessedServices.includes(serviceId);
if (haveAccessToService) { if (haveAccessToService) {
return true; return true;
@@ -101,8 +101,8 @@ export const canPeformDeleteService = async (
authId: string, authId: string,
serviceId: string, serviceId: string,
) => { ) => {
const { accesedServices, canDeleteServices } = await findUserByAuthId(authId); const { accessedServices, canDeleteServices } = await findUserByAuthId(authId);
const haveAccessToService = accesedServices.includes(serviceId); const haveAccessToService = accessedServices.includes(serviceId);
if (canDeleteServices && haveAccessToService) { if (canDeleteServices && haveAccessToService) {
return true; return true;
@@ -135,9 +135,9 @@ export const canPerformAccessProject = async (
authId: string, authId: string,
projectId: string, projectId: string,
) => { ) => {
const { accesedProjects } = await findUserByAuthId(authId); const { accessedProjects } = await findUserByAuthId(authId);
const haveAccessToProject = accesedProjects.includes(projectId); const haveAccessToProject = accessedProjects.includes(projectId);
if (haveAccessToProject) { if (haveAccessToProject) {
return true; return true;