mirror of
https://github.com/hanzoai/captable.git
synced 2026-10-16 14:21:29 +00:00
refactor: imports
This commit is contained in:
@@ -2,13 +2,8 @@
|
||||
|
||||
import Modal from "@/components/common/push-modal";
|
||||
|
||||
import {
|
||||
ACTIONS,
|
||||
SUBJECTS,
|
||||
type TActions,
|
||||
type TSubjects,
|
||||
} from "@/lib/rbac/constants";
|
||||
|
||||
import { ACTIONS, type TActions } from "@/lib/rbac/actions";
|
||||
import { SUBJECTS, type TSubjects } from "@/lib/rbac/subjects";
|
||||
import { api } from "@/trpc/react";
|
||||
import {
|
||||
type TypeZodCreateRoleMutationSchema,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { TActions, TSubjects } from "@/lib/rbac/constants";
|
||||
import type { TActions } from "@/lib/rbac/actions";
|
||||
import type { TSubjects } from "@/lib/rbac/subjects";
|
||||
import { useRoles } from "@/providers/roles-provider";
|
||||
|
||||
export interface useAllowedOptions {
|
||||
|
||||
@@ -4,8 +4,6 @@ import {
|
||||
ADMIN_PERMISSION,
|
||||
ADMIN_ROLE_ID,
|
||||
DEFAULT_PERMISSION,
|
||||
type TActions,
|
||||
type TSubjects,
|
||||
} from "@/lib/rbac/constants";
|
||||
import { Roles } from "@/prisma/enums";
|
||||
import { checkMembership, withServerComponentSession } from "@/server/auth";
|
||||
@@ -16,7 +14,9 @@ import { z } from "zod";
|
||||
import { RBAC, type addPolicyOption } from ".";
|
||||
import { Err, Ok, wrap } from "../error";
|
||||
import { BaseError } from "../error/errors/base";
|
||||
import type { TActions } from "./actions";
|
||||
import { permissionSchema } from "./schema";
|
||||
import type { TSubjects } from "./subjects";
|
||||
|
||||
export interface checkMembershipOptions {
|
||||
session: Session;
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
export const ACTIONS = ["create", "read", "update", "delete", "*"] as const;
|
||||
export type TActions = (typeof ACTIONS)[number];
|
||||
@@ -1,8 +1,7 @@
|
||||
import type { TPermission } from "@/lib/rbac/schema";
|
||||
import type { Roles } from "@/prisma/enums";
|
||||
|
||||
export const ACTIONS = ["create", "read", "update", "delete", "*"] as const;
|
||||
export const SUBJECTS = ["billing", "members", "stakeholder", "roles"] as const;
|
||||
import type { TActions } from "./actions";
|
||||
import { SUBJECTS } from "./subjects";
|
||||
|
||||
export const ADMIN_PERMISSION = SUBJECTS.map((item) => ({
|
||||
actions: ["*" as TActions],
|
||||
@@ -39,6 +38,4 @@ export type RoleList = {
|
||||
}
|
||||
);
|
||||
|
||||
export type TSubjects = (typeof SUBJECTS)[number];
|
||||
export type TActions = (typeof ACTIONS)[number];
|
||||
type DefaultRoles = Exclude<Roles, "CUSTOM">;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { TActions, TSubjects } from "@/lib/rbac/constants";
|
||||
import { Ok, type Result } from "../error";
|
||||
import type { TActions } from "./actions";
|
||||
import type { TPermission } from "./schema";
|
||||
import type { TSubjects } from "./subjects";
|
||||
|
||||
type Effect = "allow" | "deny";
|
||||
|
||||
|
||||
@@ -32,11 +32,11 @@ describe("evaluating a query", () => {
|
||||
valid: true,
|
||||
permissions: [
|
||||
{ subject: "billing", actions: ["read", "update", "delete"] },
|
||||
{ subject: "invite", actions: ["read", "update"] },
|
||||
{ subject: "roles", actions: ["read", "update"] },
|
||||
],
|
||||
policies: {
|
||||
billing: { allow: ["read", "update"] },
|
||||
invite: { allow: ["read"] },
|
||||
roles: { allow: ["read"] },
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -44,11 +44,11 @@ describe("evaluating a query", () => {
|
||||
valid: false,
|
||||
permissions: [
|
||||
{ subject: "billing", actions: ["read", "update", "delete"] },
|
||||
{ subject: "invite", actions: ["read", "update"] },
|
||||
{ subject: "roles", actions: ["read", "update"] },
|
||||
],
|
||||
policies: {
|
||||
billing: { allow: ["read", "update"] },
|
||||
invite: { allow: ["delete"] },
|
||||
roles: { allow: ["delete"] },
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ACTIONS, SUBJECTS, type TActions } from "@/lib/rbac/constants";
|
||||
import { z } from "zod";
|
||||
import { ACTIONS } from "./actions";
|
||||
import { SUBJECTS } from "./subjects";
|
||||
|
||||
export const permissionSchema = z.object({
|
||||
actions: z.array(z.enum(ACTIONS)),
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
export const SUBJECTS = ["billing", "members", "stakeholder", "roles"] as const;
|
||||
export type TSubjects = (typeof SUBJECTS)[number];
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { TActions, TSubjects } from "@/lib/rbac/constants";
|
||||
import type { TActions } from "@/lib/rbac/actions";
|
||||
import type { TPermission } from "@/lib/rbac/schema";
|
||||
import type { TSubjects } from "@/lib/rbac/subjects";
|
||||
import { withAccessControl } from "@/trpc/api/trpc";
|
||||
import {
|
||||
type TypeZodCreateRoleMutationSchema,
|
||||
|
||||
Reference in New Issue
Block a user