Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat: workspace RBAC with custom roles and instance admin

Andrej039f4bb00f0b
diff --git a/apps/api/drizzle/0029_smart_umar.sql b/apps/api/drizzle/0029_smart_umar.sql
new file mode 100644
index 000000000..7c4d35055
--- /dev/null
+++ b/apps/api/drizzle/0029_smart_umar.sql
@@ -0,0 +1,12 @@
+CREATE TABLE "workspace_role" (
+ "id" text PRIMARY KEY NOT NULL,
+ "workspace_id" text NOT NULL,
+ "role" text NOT NULL,
+ "permission" text NOT NULL,
+ "created_at" timestamp DEFAULT now() NOT NULL,
+ "updated_at" timestamp
+);
+--> statement-breakpoint
+ALTER TABLE "workspace_role" ADD CONSTRAINT "workspace_role_workspace_id_workspace_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspace"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+CREATE INDEX "workspace_role_workspaceId_idx" ON "workspace_role" USING btree ("workspace_id");--> statement-breakpoint
+CREATE INDEX "workspace_role_role_idx" ON "workspace_role" USING btree ("role");
\ No newline at end of file
diff --git a/apps/api/drizzle/0030_strong_colleen_wing.sql b/apps/api/drizzle/0030_strong_colleen_wing.sql
new file mode 100644
index 000000000..d8b78c0aa
--- /dev/null
+++ b/apps/api/drizzle/0030_strong_colleen_wing.sql
@@ -0,0 +1,5 @@
+ALTER TABLE "session" ADD COLUMN "impersonated_by" text;--> statement-breakpoint
+ALTER TABLE "user" ADD COLUMN "role" text;--> statement-breakpoint
+ALTER TABLE "user" ADD COLUMN "banned" boolean DEFAULT false;--> statement-breakpoint
+ALTER TABLE "user" ADD COLUMN "ban_reason" text;--> statement-breakpoint
+ALTER TABLE "user" ADD COLUMN "ban_expires" timestamp;
\ No newline at end of file
diff --git a/apps/api/drizzle/meta/0029_snapshot.json b/apps/api/drizzle/meta/0029_snapshot.json
new file mode 100644
index 000000000..acd386630
--- /dev/null
+++ b/apps/api/drizzle/meta/0029_snapshot.json
@@ -0,0 +1,3375 @@
+{
+ "id": "005da2f9-7439-4ae4-8bdb-71b60095d4fb",
+ "prevId": "b7c8d9e0-f1a2-4b3c-9d0e-abcdef012345",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "account_userId_idx": {
+ "name": "account_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.activity": {
+ "name": "activity",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "event_data": {
+ "name": "event_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_user_name": {
+ "name": "external_user_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_user_avatar": {
+ "name": "external_user_avatar",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_source": {
+ "name": "external_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_url": {
+ "name": "external_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "activity_task_id_idx": {
+ "name": "activity_task_id_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "activity_task_id_task_id_fk": {
+ "name": "activity_task_id_task_id_fk",
+ "tableFrom": "activity",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "activity_user_id_user_id_fk": {
+ "name": "activity_user_id_user_id_fk",
+ "tableFrom": "activity",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "activity_task_external_source_external_url_unique": {
+ "name": "activity_task_external_source_external_url_unique",
+ "nullsNotDistinct": false,
+ "columns": ["task_id", "external_source", "external_url"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.apikey": {
+ "name": "apikey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'default'"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start": {
+ "name": "start",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prefix": {
+ "name": "prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refill_interval": {
+ "name": "refill_interval",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refill_amount": {
+ "name": "refill_amount",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_refill_at": {
+ "name": "last_refill_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "rate_limit_enabled": {
+ "name": "rate_limit_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "rate_limit_time_window": {
+ "name": "rate_limit_time_window",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 86400000
+ },
+ "rate_limit_max": {
+ "name": "rate_limit_max",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 10
+ },
+ "request_count": {
+ "name": "request_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "remaining": {
+ "name": "remaining",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_request": {
+ "name": "last_request",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "apikey_configId_idx": {
+ "name": "apikey_configId_idx",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_key_idx": {
+ "name": "apikey_key_idx",
+ "columns": [
+ {
+ "expression": "key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_referenceId_idx": {
+ "name": "apikey_referenceId_idx",
+ "columns": [
+ {
+ "expression": "reference_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_userId_idx": {
+ "name": "apikey_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "apikey_reference_id_user_id_fk": {
+ "name": "apikey_reference_id_user_id_fk",
+ "tableFrom": "apikey",
+ "tableTo": "user",
+ "columnsFrom": ["reference_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "apikey_user_id_user_id_fk": {
+ "name": "apikey_user_id_user_id_fk",
+ "tableFrom": "apikey",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.asset": {
+ "name": "asset",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "activity_id": {
+ "name": "activity_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "object_key": {
+ "name": "object_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mime_type": {
+ "name": "mime_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size": {
+ "name": "size",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'image'"
+ },
+ "surface": {
+ "name": "surface",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'description'"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "asset_workspaceId_idx": {
+ "name": "asset_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "asset_projectId_idx": {
+ "name": "asset_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "asset_taskId_idx": {
+ "name": "asset_taskId_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "asset_activityId_idx": {
+ "name": "asset_activityId_idx",
+ "columns": [
+ {
+ "expression": "activity_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "asset_workspace_id_workspace_id_fk": {
+ "name": "asset_workspace_id_workspace_id_fk",
+ "tableFrom": "asset",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "asset_project_id_project_id_fk": {
+ "name": "asset_project_id_project_id_fk",
+ "tableFrom": "asset",
+ "tableTo": "project",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "asset_task_id_task_id_fk": {
+ "name": "asset_task_id_task_id_fk",
+ "tableFrom": "asset",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "asset_activity_id_activity_id_fk": {
+ "name": "asset_activity_id_activity_id_fk",
+ "tableFrom": "asset",
+ "tableTo": "activity",
+ "columnsFrom": ["activity_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "asset_created_by_user_id_fk": {
+ "name": "asset_created_by_user_id_fk",
+ "tableFrom": "asset",
+ "tableTo": "user",
+ "columnsFrom": ["created_by"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "asset_object_key_unique": {
+ "name": "asset_object_key_unique",
+ "nullsNotDistinct": false,
+ "columns": ["object_key"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.column": {
+ "name": "column",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_final": {
+ "name": "is_final",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "column_projectId_idx": {
+ "name": "column_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "column_project_id_project_id_fk": {
+ "name": "column_project_id_project_id_fk",
+ "tableFrom": "column",
+ "tableTo": "project",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.comment": {
+ "name": "comment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "comment_task_idx": {
+ "name": "comment_task_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "comment_user_idx": {
+ "name": "comment_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "comment_task_id_task_id_fk": {
+ "name": "comment_task_id_task_id_fk",
+ "tableFrom": "comment",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "comment_user_id_user_id_fk": {
+ "name": "comment_user_id_user_id_fk",
+ "tableFrom": "comment",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.device_code": {
+ "name": "device_code",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "device_code": {
+ "name": "device_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_code": {
+ "name": "user_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_polled_at": {
+ "name": "last_polled_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "polling_interval": {
+ "name": "polling_interval",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "device_code_device_code_uidx": {
+ "name": "device_code_device_code_uidx",
+ "columns": [
+ {
+ "expression": "device_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "device_code_user_code_uidx": {
+ "name": "device_code_user_code_uidx",
+ "columns": [
+ {
+ "expression": "user_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "device_code_user_id_idx": {
+ "name": "device_code_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "device_code_user_id_user_id_fk": {
+ "name": "device_code_user_id_user_id_fk",
+ "tableFrom": "device_code",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.external_link": {
+ "name": "external_link",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "integration_id": {
+ "name": "integration_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_type": {
+ "name": "resource_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "external_link_taskId_idx": {
+ "name": "external_link_taskId_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "external_link_integrationId_idx": {
+ "name": "external_link_integrationId_idx",
+ "columns": [
+ {
+ "expression": "integration_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "external_link_externalId_idx": {
+ "name": "external_link_externalId_idx",
+ "columns": [
+ {
+ "expression": "external_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "external_link_resourceType_idx": {
+ "name": "external_link_resourceType_idx",
+ "columns": [
+ {
+ "expression": "resource_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "external_link_task_id_task_id_fk": {
+ "name": "external_link_task_id_task_id_fk",
+ "tableFrom": "external_link",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "external_link_integration_id_integration_id_fk": {
+ "name": "external_link_integration_id_integration_id_fk",
+ "tableFrom": "external_link",
+ "tableTo": "integration",
+ "columnsFrom": ["integration_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_integration": {
+ "name": "github_integration",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_owner": {
+ "name": "repository_owner",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_name": {
+ "name": "repository_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "installation_id": {
+ "name": "installation_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "github_integration_project_id_project_id_fk": {
+ "name": "github_integration_project_id_project_id_fk",
+ "tableFrom": "github_integration",
+ "tableTo": "project",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "github_integration_project_id_unique": {
+ "name": "github_integration_project_id_unique",
+ "nullsNotDistinct": false,
+ "columns": ["project_id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.integration": {
+ "name": "integration",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config": {
+ "name": "config",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "integration_projectId_idx": {
+ "name": "integration_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "integration_type_idx": {
+ "name": "integration_type_idx",
+ "columns": [
+ {
+ "expression": "type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "integration_project_id_project_id_fk": {
+ "name": "integration_project_id_project_id_fk",
+ "tableFrom": "integration",
+ "tableTo": "project",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "integration_project_type_unique": {
+ "name": "integration_project_type_unique",
+ "nullsNotDistinct": false,
+ "columns": ["project_id", "type"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.invitation": {
+ "name": "invitation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "inviter_id": {
+ "name": "inviter_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "invitation_workspaceId_idx": {
+ "name": "invitation_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "invitation_email_idx": {
+ "name": "invitation_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "invitation_workspace_id_workspace_id_fk": {
+ "name": "invitation_workspace_id_workspace_id_fk",
+ "tableFrom": "invitation",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "invitation_inviter_id_user_id_fk": {
+ "name": "invitation_inviter_id_user_id_fk",
+ "tableFrom": "invitation",
+ "tableTo": "user",
+ "columnsFrom": ["inviter_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.label": {
+ "name": "label",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "label_task_id_idx": {
+ "name": "label_task_id_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "label_workspace_id_idx": {
+ "name": "label_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "label_workspace_name_unique": {
+ "name": "label_workspace_name_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"label\".\"task_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "label_task_id_task_id_fk": {
+ "name": "label_task_id_task_id_fk",
+ "tableFrom": "label",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "label_workspace_id_workspace_id_fk": {
+ "name": "label_workspace_id_workspace_id_fk",
+ "tableFrom": "label",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "label_task_name_unique": {
+ "name": "label_task_name_unique",
+ "nullsNotDistinct": false,
+ "columns": ["task_id", "name"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.notification": {
+ "name": "notification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'info'"
+ },
+ "event_data": {
+ "name": "event_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_read": {
+ "name": "is_read",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resource_type": {
+ "name": "resource_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "notification_user_id_user_id_fk": {
+ "name": "notification_user_id_user_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_role": {
+ "name": "workspace_role",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permission": {
+ "name": "permission",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "workspace_role_workspaceId_idx": {
+ "name": "workspace_role_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_role_role_idx": {
+ "name": "workspace_role_role_idx",
+ "columns": [
+ {
+ "expression": "role",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_role_workspace_id_workspace_id_fk": {
+ "name": "workspace_role_workspace_id_workspace_id_fk",
+ "tableFrom": "workspace_role",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project": {
+ "name": "project",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'Layout'"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_public": {
+ "name": "is_public",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_workspace_id_workspace_id_fk": {
+ "name": "project_workspace_id_workspace_id_fk",
+ "tableFrom": "project",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_workspace_id_id_unique": {
+ "name": "project_workspace_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": ["workspace_id", "id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active_organization_id": {
+ "name": "active_organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_team_id": {
+ "name": "active_team_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "session_userId_idx": {
+ "name": "session_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": ["token"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.task_relation": {
+ "name": "task_relation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "source_task_id": {
+ "name": "source_task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_task_id": {
+ "name": "target_task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relation_type": {
+ "name": "relation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "task_relation_source_idx": {
+ "name": "task_relation_source_idx",
+ "columns": [
+ {
+ "expression": "source_task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_relation_target_idx": {
+ "name": "task_relation_target_idx",
+ "columns": [
+ {
+ "expression": "target_task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "task_relation_source_task_id_task_id_fk": {
+ "name": "task_relation_source_task_id_task_id_fk",
+ "tableFrom": "task_relation",
+ "tableTo": "task",
+ "columnsFrom": ["source_task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "task_relation_target_task_id_task_id_fk": {
+ "name": "task_relation_target_task_id_task_id_fk",
+ "tableFrom": "task_relation",
+ "tableTo": "task",
+ "columnsFrom": ["target_task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.task_reminder_sent": {
+ "name": "task_reminder_sent",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reminder_type": {
+ "name": "reminder_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "task_reminder_sent_taskId_idx": {
+ "name": "task_reminder_sent_taskId_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "task_reminder_sent_task_id_task_id_fk": {
+ "name": "task_reminder_sent_task_id_task_id_fk",
+ "tableFrom": "task_reminder_sent",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "task_reminder_sent_task_type_unique": {
+ "name": "task_reminder_sent_task_type_unique",
+ "nullsNotDistinct": false,
+ "columns": ["task_id", "reminder_type"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.task": {
+ "name": "task",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "number": {
+ "name": "number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 1
+ },
+ "assignee_id": {
+ "name": "assignee_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'to-do'"
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'low'"
+ },
+ "start_date": {
+ "name": "start_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "due_date": {
+ "name": "due_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "task_projectId_idx": {
+ "name": "task_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_dueDate_idx": {
+ "name": "task_dueDate_idx",
+ "columns": [
+ {
+ "expression": "due_date",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "task_project_id_project_id_fk": {
+ "name": "task_project_id_project_id_fk",
+ "tableFrom": "task",
+ "tableTo": "project",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "task_assignee_id_user_id_fk": {
+ "name": "task_assignee_id_user_id_fk",
+ "tableFrom": "task",
+ "tableTo": "user",
+ "columnsFrom": ["assignee_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "task_column_id_column_id_fk": {
+ "name": "task_column_id_column_id_fk",
+ "tableFrom": "task",
+ "tableTo": "column",
+ "columnsFrom": ["column_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "task_project_number_unique": {
+ "name": "task_project_number_unique",
+ "nullsNotDistinct": false,
+ "columns": ["project_id", "number"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team": {
+ "name": "team",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "team_workspaceId_idx": {
+ "name": "team_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "team_workspace_id_workspace_id_fk": {
+ "name": "team_workspace_id_workspace_id_fk",
+ "tableFrom": "team",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_member": {
+ "name": "team_member",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "teamMember_teamId_idx": {
+ "name": "teamMember_teamId_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "teamMember_userId_idx": {
+ "name": "teamMember_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "team_member_team_id_team_id_fk": {
+ "name": "team_member_team_id_team_id_fk",
+ "tableFrom": "team_member",
+ "tableTo": "team",
+ "columnsFrom": ["team_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "team_member_user_id_user_id_fk": {
+ "name": "team_member_user_id_user_id_fk",
+ "tableFrom": "team_member",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.time_entry": {
+ "name": "time_entry",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start_time": {
+ "name": "start_time",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "end_time": {
+ "name": "end_time",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "duration": {
+ "name": "duration",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "time_entry_task_id_task_id_fk": {
+ "name": "time_entry_task_id_task_id_fk",
+ "tableFrom": "time_entry",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "time_entry_user_id_user_id_fk": {
+ "name": "time_entry_user_id_user_id_fk",
+ "tableFrom": "time_entry",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "locale": {
+ "name": "locale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_anonymous": {
+ "name": "is_anonymous",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": ["email"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_notification_preference": {
+ "name": "user_notification_preference",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_enabled": {
+ "name": "email_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ntfy_enabled": {
+ "name": "ntfy_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ntfy_server_url": {
+ "name": "ntfy_server_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ntfy_topic": {
+ "name": "ntfy_topic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ntfy_token": {
+ "name": "ntfy_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gotify_enabled": {
+ "name": "gotify_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "gotify_server_url": {
+ "name": "gotify_server_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gotify_token": {
+ "name": "gotify_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "webhook_enabled": {
+ "name": "webhook_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "webhook_url": {
+ "name": "webhook_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "webhook_secret": {
+ "name": "webhook_secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_notification_preference_user_id_user_id_fk": {
+ "name": "user_notification_preference_user_id_user_id_fk",
+ "tableFrom": "user_notification_preference",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_notification_preference_user_id_unique": {
+ "name": "user_notification_preference_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": ["user_id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_notification_workspace_project": {
+ "name": "user_notification_workspace_project",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_rule_id": {
+ "name": "workspace_rule_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_notification_workspace_project_ruleId_idx": {
+ "name": "user_notification_workspace_project_ruleId_idx",
+ "columns": [
+ {
+ "expression": "workspace_rule_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_notification_workspace_project_projectId_idx": {
+ "name": "user_notification_workspace_project_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_notification_workspace_project_workspace_id_workspace_id_fk": {
+ "name": "user_notification_workspace_project_workspace_id_workspace_id_fk",
+ "tableFrom": "user_notification_workspace_project",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "user_notification_workspace_project_workspace_id_workspace_rule_id_user_notification_workspace_rule_workspace_id_id_fk": {
+ "name": "user_notification_workspace_project_workspace_id_workspace_rule_id_user_notification_workspace_rule_workspace_id_id_fk",
+ "tableFrom": "user_notification_workspace_project",
+ "tableTo": "user_notification_workspace_rule",
+ "columnsFrom": ["workspace_id", "workspace_rule_id"],
+ "columnsTo": ["workspace_id", "id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "user_notification_workspace_project_workspace_id_project_id_project_workspace_id_id_fk": {
+ "name": "user_notification_workspace_project_workspace_id_project_id_project_workspace_id_id_fk",
+ "tableFrom": "user_notification_workspace_project",
+ "tableTo": "project",
+ "columnsFrom": ["workspace_id", "project_id"],
+ "columnsTo": ["workspace_id", "id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_notification_workspace_project_rule_project_unique": {
+ "name": "user_notification_workspace_project_rule_project_unique",
+ "nullsNotDistinct": false,
+ "columns": ["workspace_rule_id", "project_id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_notification_workspace_rule": {
+ "name": "user_notification_workspace_rule",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "email_enabled": {
+ "name": "email_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ntfy_enabled": {
+ "name": "ntfy_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "gotify_enabled": {
+ "name": "gotify_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "webhook_enabled": {
+ "name": "webhook_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "project_mode": {
+ "name": "project_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'all'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_notification_workspace_rule_userId_idx": {
+ "name": "user_notification_workspace_rule_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_notification_workspace_rule_workspaceId_idx": {
+ "name": "user_notification_workspace_rule_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_notification_workspace_rule_user_id_user_id_fk": {
+ "name": "user_notification_workspace_rule_user_id_user_id_fk",
+ "tableFrom": "user_notification_workspace_rule",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "user_notification_workspace_rule_workspace_id_workspace_id_fk": {
+ "name": "user_notification_workspace_rule_workspace_id_workspace_id_fk",
+ "tableFrom": "user_notification_workspace_rule",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_notification_workspace_rule_user_workspace_unique": {
+ "name": "user_notification_workspace_rule_user_workspace_unique",
+ "nullsNotDistinct": false,
+ "columns": ["user_id", "workspace_id"]
+ },
+ "user_notification_workspace_rule_workspace_id_id_unique": {
+ "name": "user_notification_workspace_rule_workspace_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": ["workspace_id", "id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verification": {
+ "name": "verification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verification_identifier_idx": {
+ "name": "verification_identifier_idx",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workflow_rule": {
+ "name": "workflow_rule",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "integration_type": {
+ "name": "integration_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workflow_rule_projectId_idx": {
+ "name": "workflow_rule_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workflow_rule_project_id_project_id_fk": {
+ "name": "workflow_rule_project_id_project_id_fk",
+ "tableFrom": "workflow_rule",
+ "tableTo": "project",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "workflow_rule_column_id_column_id_fk": {
+ "name": "workflow_rule_column_id_column_id_fk",
+ "tableFrom": "workflow_rule",
+ "tableTo": "column",
+ "columnsFrom": ["column_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace": {
+ "name": "workspace",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "logo": {
+ "name": "logo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_slug_unique": {
+ "name": "workspace_slug_unique",
+ "nullsNotDistinct": false,
+ "columns": ["slug"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_member": {
+ "name": "workspace_member",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "workspace_member_workspaceId_idx": {
+ "name": "workspace_member_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_member_userId_idx": {
+ "name": "workspace_member_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_member_workspace_id_workspace_id_fk": {
+ "name": "workspace_member_workspace_id_workspace_id_fk",
+ "tableFrom": "workspace_member",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_member_user_id_user_id_fk": {
+ "name": "workspace_member_user_id_user_id_fk",
+ "tableFrom": "workspace_member",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
diff --git a/apps/api/drizzle/meta/0030_snapshot.json b/apps/api/drizzle/meta/0030_snapshot.json
new file mode 100644
index 000000000..d9729e1a8
--- /dev/null
+++ b/apps/api/drizzle/meta/0030_snapshot.json
@@ -0,0 +1,3406 @@
+{
+ "id": "ea3cbcd5-1a1f-458a-b43b-de4cdb405154",
+ "prevId": "005da2f9-7439-4ae4-8bdb-71b60095d4fb",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "account_userId_idx": {
+ "name": "account_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.activity": {
+ "name": "activity",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "event_data": {
+ "name": "event_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_user_name": {
+ "name": "external_user_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_user_avatar": {
+ "name": "external_user_avatar",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_source": {
+ "name": "external_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_url": {
+ "name": "external_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "activity_task_id_idx": {
+ "name": "activity_task_id_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "activity_task_id_task_id_fk": {
+ "name": "activity_task_id_task_id_fk",
+ "tableFrom": "activity",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "activity_user_id_user_id_fk": {
+ "name": "activity_user_id_user_id_fk",
+ "tableFrom": "activity",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "activity_task_external_source_external_url_unique": {
+ "name": "activity_task_external_source_external_url_unique",
+ "nullsNotDistinct": false,
+ "columns": ["task_id", "external_source", "external_url"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.apikey": {
+ "name": "apikey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'default'"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start": {
+ "name": "start",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prefix": {
+ "name": "prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refill_interval": {
+ "name": "refill_interval",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refill_amount": {
+ "name": "refill_amount",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_refill_at": {
+ "name": "last_refill_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "rate_limit_enabled": {
+ "name": "rate_limit_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "rate_limit_time_window": {
+ "name": "rate_limit_time_window",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 86400000
+ },
+ "rate_limit_max": {
+ "name": "rate_limit_max",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 10
+ },
+ "request_count": {
+ "name": "request_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "remaining": {
+ "name": "remaining",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_request": {
+ "name": "last_request",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "apikey_configId_idx": {
+ "name": "apikey_configId_idx",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_key_idx": {
+ "name": "apikey_key_idx",
+ "columns": [
+ {
+ "expression": "key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_referenceId_idx": {
+ "name": "apikey_referenceId_idx",
+ "columns": [
+ {
+ "expression": "reference_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_userId_idx": {
+ "name": "apikey_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "apikey_reference_id_user_id_fk": {
+ "name": "apikey_reference_id_user_id_fk",
+ "tableFrom": "apikey",
+ "tableTo": "user",
+ "columnsFrom": ["reference_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "apikey_user_id_user_id_fk": {
+ "name": "apikey_user_id_user_id_fk",
+ "tableFrom": "apikey",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.asset": {
+ "name": "asset",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "activity_id": {
+ "name": "activity_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "object_key": {
+ "name": "object_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mime_type": {
+ "name": "mime_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size": {
+ "name": "size",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'image'"
+ },
+ "surface": {
+ "name": "surface",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'description'"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "asset_workspaceId_idx": {
+ "name": "asset_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "asset_projectId_idx": {
+ "name": "asset_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "asset_taskId_idx": {
+ "name": "asset_taskId_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "asset_activityId_idx": {
+ "name": "asset_activityId_idx",
+ "columns": [
+ {
+ "expression": "activity_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "asset_workspace_id_workspace_id_fk": {
+ "name": "asset_workspace_id_workspace_id_fk",
+ "tableFrom": "asset",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "asset_project_id_project_id_fk": {
+ "name": "asset_project_id_project_id_fk",
+ "tableFrom": "asset",
+ "tableTo": "project",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "asset_task_id_task_id_fk": {
+ "name": "asset_task_id_task_id_fk",
+ "tableFrom": "asset",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "asset_activity_id_activity_id_fk": {
+ "name": "asset_activity_id_activity_id_fk",
+ "tableFrom": "asset",
+ "tableTo": "activity",
+ "columnsFrom": ["activity_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "asset_created_by_user_id_fk": {
+ "name": "asset_created_by_user_id_fk",
+ "tableFrom": "asset",
+ "tableTo": "user",
+ "columnsFrom": ["created_by"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "asset_object_key_unique": {
+ "name": "asset_object_key_unique",
+ "nullsNotDistinct": false,
+ "columns": ["object_key"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.column": {
+ "name": "column",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_final": {
+ "name": "is_final",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "column_projectId_idx": {
+ "name": "column_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "column_project_id_project_id_fk": {
+ "name": "column_project_id_project_id_fk",
+ "tableFrom": "column",
+ "tableTo": "project",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.comment": {
+ "name": "comment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "comment_task_idx": {
+ "name": "comment_task_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "comment_user_idx": {
+ "name": "comment_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "comment_task_id_task_id_fk": {
+ "name": "comment_task_id_task_id_fk",
+ "tableFrom": "comment",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "comment_user_id_user_id_fk": {
+ "name": "comment_user_id_user_id_fk",
+ "tableFrom": "comment",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.device_code": {
+ "name": "device_code",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "device_code": {
+ "name": "device_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_code": {
+ "name": "user_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_polled_at": {
+ "name": "last_polled_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "polling_interval": {
+ "name": "polling_interval",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "device_code_device_code_uidx": {
+ "name": "device_code_device_code_uidx",
+ "columns": [
+ {
+ "expression": "device_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "device_code_user_code_uidx": {
+ "name": "device_code_user_code_uidx",
+ "columns": [
+ {
+ "expression": "user_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "device_code_user_id_idx": {
+ "name": "device_code_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "device_code_user_id_user_id_fk": {
+ "name": "device_code_user_id_user_id_fk",
+ "tableFrom": "device_code",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.external_link": {
+ "name": "external_link",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "integration_id": {
+ "name": "integration_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_type": {
+ "name": "resource_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "external_link_taskId_idx": {
+ "name": "external_link_taskId_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "external_link_integrationId_idx": {
+ "name": "external_link_integrationId_idx",
+ "columns": [
+ {
+ "expression": "integration_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "external_link_externalId_idx": {
+ "name": "external_link_externalId_idx",
+ "columns": [
+ {
+ "expression": "external_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "external_link_resourceType_idx": {
+ "name": "external_link_resourceType_idx",
+ "columns": [
+ {
+ "expression": "resource_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "external_link_task_id_task_id_fk": {
+ "name": "external_link_task_id_task_id_fk",
+ "tableFrom": "external_link",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "external_link_integration_id_integration_id_fk": {
+ "name": "external_link_integration_id_integration_id_fk",
+ "tableFrom": "external_link",
+ "tableTo": "integration",
+ "columnsFrom": ["integration_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_integration": {
+ "name": "github_integration",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_owner": {
+ "name": "repository_owner",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_name": {
+ "name": "repository_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "installation_id": {
+ "name": "installation_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "github_integration_project_id_project_id_fk": {
+ "name": "github_integration_project_id_project_id_fk",
+ "tableFrom": "github_integration",
+ "tableTo": "project",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "github_integration_project_id_unique": {
+ "name": "github_integration_project_id_unique",
+ "nullsNotDistinct": false,
+ "columns": ["project_id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.integration": {
+ "name": "integration",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config": {
+ "name": "config",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "integration_projectId_idx": {
+ "name": "integration_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "integration_type_idx": {
+ "name": "integration_type_idx",
+ "columns": [
+ {
+ "expression": "type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "integration_project_id_project_id_fk": {
+ "name": "integration_project_id_project_id_fk",
+ "tableFrom": "integration",
+ "tableTo": "project",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "integration_project_type_unique": {
+ "name": "integration_project_type_unique",
+ "nullsNotDistinct": false,
+ "columns": ["project_id", "type"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.invitation": {
+ "name": "invitation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "inviter_id": {
+ "name": "inviter_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "invitation_workspaceId_idx": {
+ "name": "invitation_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "invitation_email_idx": {
+ "name": "invitation_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "invitation_workspace_id_workspace_id_fk": {
+ "name": "invitation_workspace_id_workspace_id_fk",
+ "tableFrom": "invitation",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "invitation_inviter_id_user_id_fk": {
+ "name": "invitation_inviter_id_user_id_fk",
+ "tableFrom": "invitation",
+ "tableTo": "user",
+ "columnsFrom": ["inviter_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.label": {
+ "name": "label",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "label_task_id_idx": {
+ "name": "label_task_id_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "label_workspace_id_idx": {
+ "name": "label_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "label_workspace_name_unique": {
+ "name": "label_workspace_name_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"label\".\"task_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "label_task_id_task_id_fk": {
+ "name": "label_task_id_task_id_fk",
+ "tableFrom": "label",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "label_workspace_id_workspace_id_fk": {
+ "name": "label_workspace_id_workspace_id_fk",
+ "tableFrom": "label",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "label_task_name_unique": {
+ "name": "label_task_name_unique",
+ "nullsNotDistinct": false,
+ "columns": ["task_id", "name"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.notification": {
+ "name": "notification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'info'"
+ },
+ "event_data": {
+ "name": "event_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_read": {
+ "name": "is_read",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resource_type": {
+ "name": "resource_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "notification_user_id_user_id_fk": {
+ "name": "notification_user_id_user_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_role": {
+ "name": "workspace_role",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permission": {
+ "name": "permission",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "workspace_role_workspaceId_idx": {
+ "name": "workspace_role_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_role_role_idx": {
+ "name": "workspace_role_role_idx",
+ "columns": [
+ {
+ "expression": "role",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_role_workspace_id_workspace_id_fk": {
+ "name": "workspace_role_workspace_id_workspace_id_fk",
+ "tableFrom": "workspace_role",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project": {
+ "name": "project",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'Layout'"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_public": {
+ "name": "is_public",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_workspace_id_workspace_id_fk": {
+ "name": "project_workspace_id_workspace_id_fk",
+ "tableFrom": "project",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_workspace_id_id_unique": {
+ "name": "project_workspace_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": ["workspace_id", "id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active_organization_id": {
+ "name": "active_organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_team_id": {
+ "name": "active_team_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impersonated_by": {
+ "name": "impersonated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "session_userId_idx": {
+ "name": "session_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": ["token"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.task_relation": {
+ "name": "task_relation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "source_task_id": {
+ "name": "source_task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_task_id": {
+ "name": "target_task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relation_type": {
+ "name": "relation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "task_relation_source_idx": {
+ "name": "task_relation_source_idx",
+ "columns": [
+ {
+ "expression": "source_task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_relation_target_idx": {
+ "name": "task_relation_target_idx",
+ "columns": [
+ {
+ "expression": "target_task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "task_relation_source_task_id_task_id_fk": {
+ "name": "task_relation_source_task_id_task_id_fk",
+ "tableFrom": "task_relation",
+ "tableTo": "task",
+ "columnsFrom": ["source_task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "task_relation_target_task_id_task_id_fk": {
+ "name": "task_relation_target_task_id_task_id_fk",
+ "tableFrom": "task_relation",
+ "tableTo": "task",
+ "columnsFrom": ["target_task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.task_reminder_sent": {
+ "name": "task_reminder_sent",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reminder_type": {
+ "name": "reminder_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "task_reminder_sent_taskId_idx": {
+ "name": "task_reminder_sent_taskId_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "task_reminder_sent_task_id_task_id_fk": {
+ "name": "task_reminder_sent_task_id_task_id_fk",
+ "tableFrom": "task_reminder_sent",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "task_reminder_sent_task_type_unique": {
+ "name": "task_reminder_sent_task_type_unique",
+ "nullsNotDistinct": false,
+ "columns": ["task_id", "reminder_type"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.task": {
+ "name": "task",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "number": {
+ "name": "number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 1
+ },
+ "assignee_id": {
+ "name": "assignee_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'to-do'"
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'low'"
+ },
+ "start_date": {
+ "name": "start_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "due_date": {
+ "name": "due_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "task_projectId_idx": {
+ "name": "task_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_dueDate_idx": {
+ "name": "task_dueDate_idx",
+ "columns": [
+ {
+ "expression": "due_date",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "task_project_id_project_id_fk": {
+ "name": "task_project_id_project_id_fk",
+ "tableFrom": "task",
+ "tableTo": "project",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "task_assignee_id_user_id_fk": {
+ "name": "task_assignee_id_user_id_fk",
+ "tableFrom": "task",
+ "tableTo": "user",
+ "columnsFrom": ["assignee_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "task_column_id_column_id_fk": {
+ "name": "task_column_id_column_id_fk",
+ "tableFrom": "task",
+ "tableTo": "column",
+ "columnsFrom": ["column_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "task_project_number_unique": {
+ "name": "task_project_number_unique",
+ "nullsNotDistinct": false,
+ "columns": ["project_id", "number"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team": {
+ "name": "team",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "team_workspaceId_idx": {
+ "name": "team_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "team_workspace_id_workspace_id_fk": {
+ "name": "team_workspace_id_workspace_id_fk",
+ "tableFrom": "team",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_member": {
+ "name": "team_member",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "teamMember_teamId_idx": {
+ "name": "teamMember_teamId_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "teamMember_userId_idx": {
+ "name": "teamMember_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "team_member_team_id_team_id_fk": {
+ "name": "team_member_team_id_team_id_fk",
+ "tableFrom": "team_member",
+ "tableTo": "team",
+ "columnsFrom": ["team_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "team_member_user_id_user_id_fk": {
+ "name": "team_member_user_id_user_id_fk",
+ "tableFrom": "team_member",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.time_entry": {
+ "name": "time_entry",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start_time": {
+ "name": "start_time",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "end_time": {
+ "name": "end_time",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "duration": {
+ "name": "duration",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "time_entry_task_id_task_id_fk": {
+ "name": "time_entry_task_id_task_id_fk",
+ "tableFrom": "time_entry",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "time_entry_user_id_user_id_fk": {
+ "name": "time_entry_user_id_user_id_fk",
+ "tableFrom": "time_entry",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "locale": {
+ "name": "locale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_anonymous": {
+ "name": "is_anonymous",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "banned": {
+ "name": "banned",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "ban_reason": {
+ "name": "ban_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ban_expires": {
+ "name": "ban_expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": ["email"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_notification_preference": {
+ "name": "user_notification_preference",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_enabled": {
+ "name": "email_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ntfy_enabled": {
+ "name": "ntfy_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ntfy_server_url": {
+ "name": "ntfy_server_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ntfy_topic": {
+ "name": "ntfy_topic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ntfy_token": {
+ "name": "ntfy_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gotify_enabled": {
+ "name": "gotify_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "gotify_server_url": {
+ "name": "gotify_server_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gotify_token": {
+ "name": "gotify_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "webhook_enabled": {
+ "name": "webhook_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "webhook_url": {
+ "name": "webhook_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "webhook_secret": {
+ "name": "webhook_secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_notification_preference_user_id_user_id_fk": {
+ "name": "user_notification_preference_user_id_user_id_fk",
+ "tableFrom": "user_notification_preference",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_notification_preference_user_id_unique": {
+ "name": "user_notification_preference_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": ["user_id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_notification_workspace_project": {
+ "name": "user_notification_workspace_project",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_rule_id": {
+ "name": "workspace_rule_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_notification_workspace_project_ruleId_idx": {
+ "name": "user_notification_workspace_project_ruleId_idx",
+ "columns": [
+ {
+ "expression": "workspace_rule_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_notification_workspace_project_projectId_idx": {
+ "name": "user_notification_workspace_project_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_notification_workspace_project_workspace_id_workspace_id_fk": {
+ "name": "user_notification_workspace_project_workspace_id_workspace_id_fk",
+ "tableFrom": "user_notification_workspace_project",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "user_notification_workspace_project_workspace_id_workspace_rule_id_user_notification_workspace_rule_workspace_id_id_fk": {
+ "name": "user_notification_workspace_project_workspace_id_workspace_rule_id_user_notification_workspace_rule_workspace_id_id_fk",
+ "tableFrom": "user_notification_workspace_project",
+ "tableTo": "user_notification_workspace_rule",
+ "columnsFrom": ["workspace_id", "workspace_rule_id"],
+ "columnsTo": ["workspace_id", "id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "user_notification_workspace_project_workspace_id_project_id_project_workspace_id_id_fk": {
+ "name": "user_notification_workspace_project_workspace_id_project_id_project_workspace_id_id_fk",
+ "tableFrom": "user_notification_workspace_project",
+ "tableTo": "project",
+ "columnsFrom": ["workspace_id", "project_id"],
+ "columnsTo": ["workspace_id", "id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_notification_workspace_project_rule_project_unique": {
+ "name": "user_notification_workspace_project_rule_project_unique",
+ "nullsNotDistinct": false,
+ "columns": ["workspace_rule_id", "project_id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_notification_workspace_rule": {
+ "name": "user_notification_workspace_rule",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "email_enabled": {
+ "name": "email_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ntfy_enabled": {
+ "name": "ntfy_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "gotify_enabled": {
+ "name": "gotify_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "webhook_enabled": {
+ "name": "webhook_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "project_mode": {
+ "name": "project_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'all'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_notification_workspace_rule_userId_idx": {
+ "name": "user_notification_workspace_rule_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_notification_workspace_rule_workspaceId_idx": {
+ "name": "user_notification_workspace_rule_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_notification_workspace_rule_user_id_user_id_fk": {
+ "name": "user_notification_workspace_rule_user_id_user_id_fk",
+ "tableFrom": "user_notification_workspace_rule",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "user_notification_workspace_rule_workspace_id_workspace_id_fk": {
+ "name": "user_notification_workspace_rule_workspace_id_workspace_id_fk",
+ "tableFrom": "user_notification_workspace_rule",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_notification_workspace_rule_user_workspace_unique": {
+ "name": "user_notification_workspace_rule_user_workspace_unique",
+ "nullsNotDistinct": false,
+ "columns": ["user_id", "workspace_id"]
+ },
+ "user_notification_workspace_rule_workspace_id_id_unique": {
+ "name": "user_notification_workspace_rule_workspace_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": ["workspace_id", "id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verification": {
+ "name": "verification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verification_identifier_idx": {
+ "name": "verification_identifier_idx",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workflow_rule": {
+ "name": "workflow_rule",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "integration_type": {
+ "name": "integration_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workflow_rule_projectId_idx": {
+ "name": "workflow_rule_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workflow_rule_project_id_project_id_fk": {
+ "name": "workflow_rule_project_id_project_id_fk",
+ "tableFrom": "workflow_rule",
+ "tableTo": "project",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "workflow_rule_column_id_column_id_fk": {
+ "name": "workflow_rule_column_id_column_id_fk",
+ "tableFrom": "workflow_rule",
+ "tableTo": "column",
+ "columnsFrom": ["column_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace": {
+ "name": "workspace",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "logo": {
+ "name": "logo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_slug_unique": {
+ "name": "workspace_slug_unique",
+ "nullsNotDistinct": false,
+ "columns": ["slug"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_member": {
+ "name": "workspace_member",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "workspace_member_workspaceId_idx": {
+ "name": "workspace_member_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_member_userId_idx": {
+ "name": "workspace_member_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_member_workspace_id_workspace_id_fk": {
+ "name": "workspace_member_workspace_id_workspace_id_fk",
+ "tableFrom": "workspace_member",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_member_user_id_user_id_fk": {
+ "name": "workspace_member_user_id_user_id_fk",
+ "tableFrom": "workspace_member",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
diff --git a/apps/api/drizzle/meta/_journal.json b/apps/api/drizzle/meta/_journal.json
index 134e1c462..8b0feeac1 100644
--- a/apps/api/drizzle/meta/_journal.json
+++ b/apps/api/drizzle/meta/_journal.json
@@ -204,6 +204,20 @@
"when": 1777245262351,
"tag": "0028_apikey_user_id_nullable",
"breakpoints": true
+ },
+ {
+ "idx": 29,
+ "version": "7",
+ "when": 1778334176370,
+ "tag": "0029_smart_umar",
+ "breakpoints": true
+ },
+ {
+ "idx": 30,
+ "version": "7",
+ "when": 1778335540111,
+ "tag": "0030_strong_colleen_wing",
+ "breakpoints": true
}
]
}
diff --git a/apps/api/package.json b/apps/api/package.json
index c77cb926e..42c77e853 100644
--- a/apps/api/package.json
+++ b/apps/api/package.json
@@ -35,6 +35,7 @@
"@hono/node-ws": "^1.3.0",
"@hono/standard-validator": "^0.2.2",
"@kaneo/email": "workspace:*",
+ "@kaneo/permissions": "workspace:*",
"@modelcontextprotocol/sdk": "^1.26.0",
"@octokit/webhooks": "^14.2.0",
"@oslojs/crypto": "^1.0.1",
diff --git a/apps/api/src/activity/index.ts b/apps/api/src/activity/index.ts
index 299700ed8..cf387985c 100644
--- a/apps/api/src/activity/index.ts
+++ b/apps/api/src/activity/index.ts
@@ -3,6 +3,7 @@ import { describeRoute, resolver, validator } from "hono-openapi";
import * as v from "valibot";
import { subscribeToEvent } from "../events";
import { activitySchema } from "../schemas";
+import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { workspaceAccess } from "../utils/workspace-access-middleware";
import createActivity from "./controllers/create-activity";
import createComment from "./controllers/create-comment";
@@ -64,6 +65,7 @@ const activity = new Hono<{
}),
),
workspaceAccess.fromTaskId(),
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const { taskId, userId, message, type, eventData } = c.req.valid("json");
const activity = await createActivity(
@@ -99,6 +101,7 @@ const activity = new Hono<{
}),
),
workspaceAccess.fromTaskId(),
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const { taskId, comment } = c.req.valid("json");
const userId = c.get("userId");
diff --git a/apps/api/src/auth.ts b/apps/api/src/auth.ts
index f0dcd3ff0..c12d0d0c1 100644
--- a/apps/api/src/auth.ts
+++ b/apps/api/src/auth.ts
@@ -4,11 +4,13 @@ import {
sendOtpEmail,
sendWorkspaceInvitationEmail,
} from "@kaneo/email";
+import { ac, admin, member, owner, viewer } from "@kaneo/permissions";
import bcrypt from "bcrypt";
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { APIError, createAuthMiddleware } from "better-auth/api";
import {
+ admin as adminPlugin,
anonymous,
bearer,
deviceAuthorization,
@@ -20,7 +22,7 @@ import {
organization,
} from "better-auth/plugins";
import { config } from "dotenv-mono";
-import { eq } from "drizzle-orm";
+import { count, eq } from "drizzle-orm";
import db, { schema } from "./database";
import { publishEvent } from "./events";
import { checkRegistrationAllowed } from "./utils/check-registration-allowed";
@@ -147,6 +149,7 @@ export const auth = betterAuth({
workspace: schema.workspaceTable,
workspace_member: schema.workspaceUserTable,
invitation: schema.invitationTable,
+ workspace_role: schema.workspaceRoleTable,
team: schema.teamTable,
teamMember: schema.teamMemberTable,
apikey: schema.apikeyTable,
@@ -226,8 +229,12 @@ export const auth = betterAuth({
},
}),
organization({
- // creatorRole: "admin", // maybe will want this "The role of the user who creates the organization."
- // invitationLimit and other fields like this may be beneficial as well
+ ac,
+ roles: { viewer, member, admin, owner },
+ dynamicAccessControl: {
+ enabled: true,
+ maximumRolesPerOrganization: 25,
+ },
teams: {
enabled: true,
maximumTeams: 10,
@@ -258,6 +265,12 @@ export const auth = betterAuth({
organizationId: "workspaceId",
},
},
+ organizationRole: {
+ modelName: "workspace_role",
+ fields: {
+ organizationId: "workspaceId",
+ },
+ },
team: {
modelName: "team",
fields: {
@@ -341,6 +354,10 @@ export const auth = betterAuth({
validateClient: async (clientId) =>
getDeviceAuthClientIds().has(clientId),
}),
+ adminPlugin({
+ defaultRole: "user",
+ adminRoles: ["admin"],
+ }),
openAPI(),
],
session: {
@@ -353,6 +370,15 @@ export const auth = betterAuth({
user: {
create: {
before: async (user) => {
+ const userCountRows = await db
+ .select({ value: count() })
+ .from(schema.userTable);
+ const existingUserCount = userCountRows[0]?.value ?? 0;
+
+ if (existingUserCount === 0) {
+ return { data: { ...user, role: "admin" } };
+ }
+
const result = await checkRegistrationAllowed(user.email);
if (!result.allowed) {
throw new APIError("FORBIDDEN", {
@@ -374,8 +400,14 @@ export const auth = betterAuth({
return;
}
+ const userCountRows = await db
+ .select({ value: count() })
+ .from(schema.userTable);
+ const existingUserCount = userCountRows[0]?.value ?? 0;
+ const isInstanceAdminSetup = existingUserCount === 0;
+
if (ctx.path === "/sign-up/email") {
- if (isPasswordRegistrationDisabled) {
+ if (isPasswordRegistrationDisabled && !isInstanceAdminSetup) {
throw new APIError("FORBIDDEN", {
message:
"Password registration is currently disabled. Please use a configured social or OIDC sign-in method.",
@@ -383,7 +415,7 @@ export const auth = betterAuth({
}
}
- if (!isRegistrationDisabled) {
+ if (!isRegistrationDisabled || isInstanceAdminSetup) {
return;
}
diff --git a/apps/api/src/column/index.ts b/apps/api/src/column/index.ts
index f0e6ae1f6..6faf1213e 100644
--- a/apps/api/src/column/index.ts
+++ b/apps/api/src/column/index.ts
@@ -1,6 +1,7 @@
import { Hono } from "hono";
import { describeRoute, resolver, validator } from "hono-openapi";
import * as v from "valibot";
+import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { workspaceAccess } from "../utils/workspace-access-middleware";
import createColumn from "./controllers/create-column";
import deleteColumn from "./controllers/delete-column";
@@ -62,6 +63,7 @@ const column = new Hono<{
}),
),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ project: ["update"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const { name, icon, color, isFinal } = c.req.valid("json");
@@ -103,6 +105,7 @@ const column = new Hono<{
}),
),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ project: ["update"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const { columns } = c.req.valid("json");
@@ -136,6 +139,7 @@ const column = new Hono<{
}),
),
workspaceAccess.fromColumn("id"),
+ requireWorkspacePermission({ project: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const data = c.req.valid("json");
@@ -160,6 +164,7 @@ const column = new Hono<{
}),
validator("param", v.object({ id: v.string() })),
workspaceAccess.fromColumn("id"),
+ requireWorkspacePermission({ project: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const result = await deleteColumn(id);
diff --git a/apps/api/src/comment/index.ts b/apps/api/src/comment/index.ts
index 92cd1ba3e..61ec9c6cf 100644
--- a/apps/api/src/comment/index.ts
+++ b/apps/api/src/comment/index.ts
@@ -2,6 +2,7 @@ import { Hono } from "hono";
import { describeRoute, resolver, validator } from "hono-openapi";
import * as v from "valibot";
import { commentSchema } from "../schemas";
+import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { workspaceAccess } from "../utils/workspace-access-middleware";
import createComment from "./controllers/create-comment";
import deleteComment from "./controllers/delete-comment";
@@ -59,6 +60,7 @@ const comment = new Hono<{
v.object({ content: v.pipe(v.string(), v.minLength(1)) }),
),
workspaceAccess.fromTaskId(),
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const { taskId } = c.req.valid("param");
const { content } = c.req.valid("json");
diff --git a/apps/api/src/database/index.ts b/apps/api/src/database/index.ts
index 7b7864d2a..b146a24e5 100644
--- a/apps/api/src/database/index.ts
+++ b/apps/api/src/database/index.ts
@@ -27,6 +27,7 @@ import {
userTableRelations,
verificationTableRelations,
workflowRuleTableRelations,
+ workspaceRoleTableRelations,
workspaceTableRelations,
workspaceUserTableRelations,
} from "./relations";
@@ -57,6 +58,7 @@ import {
userTable,
verificationTable,
workflowRuleTable,
+ workspaceRoleTable,
workspaceTable,
workspaceUserTable,
} from "./schema";
@@ -96,6 +98,7 @@ export const schema = {
userNotificationWorkspaceRuleTable,
verificationTable,
workflowRuleTable,
+ workspaceRoleTable,
workspaceTable,
workspaceUserTable,
accountTableRelations,
@@ -123,6 +126,7 @@ export const schema = {
userNotificationWorkspaceRuleTableRelations,
verificationTableRelations,
workflowRuleTableRelations,
+ workspaceRoleTableRelations,
workspaceTableRelations,
workspaceUserTableRelations,
};
diff --git a/apps/api/src/database/relations.ts b/apps/api/src/database/relations.ts
index 3eb62504f..76098a344 100644
--- a/apps/api/src/database/relations.ts
+++ b/apps/api/src/database/relations.ts
@@ -26,6 +26,7 @@ import {
userTable,
verificationTable,
workflowRuleTable,
+ workspaceRoleTable,
workspaceTable,
workspaceUserTable,
} from "./schema";
@@ -313,6 +314,16 @@ export const invitationTableRelations = relations(
}),
);
+export const workspaceRoleTableRelations = relations(
+ workspaceRoleTable,
+ ({ one }) => ({
+ workspace: one(workspaceTable, {
+ fields: [workspaceRoleTable.workspaceId],
+ references: [workspaceTable.id],
+ }),
+ }),
+);
+
export const apikeyTableRelations = relations(apikeyTable, ({ one }) => ({
user: one(userTable, {
fields: [apikeyTable.referenceId],
diff --git a/apps/api/src/database/schema.ts b/apps/api/src/database/schema.ts
index 0dbf45bb1..37a2d9f91 100644
--- a/apps/api/src/database/schema.ts
+++ b/apps/api/src/database/schema.ts
@@ -30,6 +30,10 @@ export const userTable = pgTable("user", {
.$onUpdate(() => /* @__PURE__ */ new Date())
.notNull(),
isAnonymous: boolean("is_anonymous").default(false),
+ role: text("role"),
+ banned: boolean("banned").default(false),
+ banReason: text("ban_reason"),
+ banExpires: timestamp("ban_expires", { mode: "date" }),
});
export const sessionTable = pgTable(
@@ -49,6 +53,7 @@ export const sessionTable = pgTable(
.references(() => userTable.id, { onDelete: "cascade" }),
activeOrganizationId: text("active_organization_id"),
activeTeamId: text("active_team_id"),
+ impersonatedBy: text("impersonated_by"),
},
(table) => [index("session_userId_idx").on(table.userId)],
);
@@ -197,6 +202,28 @@ export const invitationTable = pgTable(
],
);
+export const workspaceRoleTable = pgTable(
+ "workspace_role",
+ {
+ id: text("id")
+ .$defaultFn(() => createId())
+ .primaryKey(),
+ workspaceId: text("workspace_id")
+ .notNull()
+ .references(() => workspaceTable.id, { onDelete: "cascade" }),
+ role: text("role").notNull(),
+ permission: text("permission").notNull(),
+ createdAt: timestamp("created_at", { mode: "date" }).defaultNow().notNull(),
+ updatedAt: timestamp("updated_at", { mode: "date" }).$onUpdate(
+ () => new Date(),
+ ),
+ },
+ (table) => [
+ index("workspace_role_workspaceId_idx").on(table.workspaceId),
+ index("workspace_role_role_idx").on(table.role),
+ ],
+);
+
export const projectTable = pgTable(
"project",
{
@@ -861,6 +888,7 @@ export const team = teamTable;
export const teamMember = teamMemberTable;
export const workspace_member = workspaceUserTable;
export const invitation = invitationTable;
+export const organizationRole = workspaceRoleTable;
export const apikey = apikeyTable;
export const deviceCode = deviceCodeTable;
@@ -936,3 +964,13 @@ export const invitationRelations = relations(invitation, ({ one }) => ({
references: [user.id],
}),
}));
+
+export const organizationRoleRelations = relations(
+ organizationRole,
+ ({ one }) => ({
+ workspace: one(workspace, {
+ fields: [organizationRole.workspaceId],
+ references: [workspace.id],
+ }),
+ }),
+);
diff --git a/apps/api/src/discord-integration/index.ts b/apps/api/src/discord-integration/index.ts
index ef13da27b..55ab4807f 100644
--- a/apps/api/src/discord-integration/index.ts
+++ b/apps/api/src/discord-integration/index.ts
@@ -12,6 +12,7 @@ import {
validateDiscordConfig,
} from "../plugins/discord/config";
import { discordIntegrationSchema } from "../schemas";
+import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { workspaceAccess } from "../utils/workspace-access-middleware";
const discordIntegration = new Hono<{
@@ -148,6 +149,7 @@ discordIntegration
}),
),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const body = c.req.valid("json");
@@ -212,6 +214,7 @@ discordIntegration
}),
),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const body = c.req.valid("json");
@@ -286,6 +289,7 @@ discordIntegration
}),
validator("param", v.object({ projectId: v.string() })),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
diff --git a/apps/api/src/generic-webhook-integration/index.ts b/apps/api/src/generic-webhook-integration/index.ts
index d03212faf..133c94bf9 100644
--- a/apps/api/src/generic-webhook-integration/index.ts
+++ b/apps/api/src/generic-webhook-integration/index.ts
@@ -12,6 +12,7 @@ import {
validateGenericWebhookConfig,
} from "../plugins/generic-webhook/config";
import { genericWebhookIntegrationSchema } from "../schemas";
+import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { workspaceAccess } from "../utils/workspace-access-middleware";
const genericWebhookIntegration = new Hono<{
@@ -140,6 +141,7 @@ genericWebhookIntegration
}),
),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const body = c.req.valid("json");
@@ -213,6 +215,7 @@ genericWebhookIntegration
}),
),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const body = c.req.valid("json");
@@ -286,6 +289,7 @@ genericWebhookIntegration
}),
validator("param", v.object({ projectId: v.string() })),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
diff --git a/apps/api/src/gitea-integration/index.ts b/apps/api/src/gitea-integration/index.ts
index c20db5fa0..1f3b6e518 100644
--- a/apps/api/src/gitea-integration/index.ts
+++ b/apps/api/src/gitea-integration/index.ts
@@ -9,6 +9,7 @@ import { integrationTable, projectTable } from "../database/schema";
import { type GiteaConfig, validateGiteaConfig } from "../plugins/gitea/config";
import { handleGiteaWebhookRequest } from "../plugins/gitea/webhook-handler";
import { giteaIntegrationSchema } from "../schemas";
+import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { validateWorkspaceAccess } from "../utils/validate-workspace-access";
import { workspaceAccess } from "../utils/workspace-access-middleware";
import createGiteaIntegration from "./controllers/create-gitea-integration";
@@ -180,6 +181,7 @@ const giteaIntegration = new Hono<{
}),
),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const body = c.req.valid("json");
@@ -223,6 +225,7 @@ const giteaIntegration = new Hono<{
}),
),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const body = c.req.valid("json");
@@ -307,6 +310,7 @@ const giteaIntegration = new Hono<{
}),
validator("param", v.object({ projectId: v.string() })),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const result = await deleteGiteaIntegration(projectId);
@@ -362,6 +366,7 @@ const giteaIntegration = new Hono<{
return next();
},
+ requireWorkspacePermission({ task: ["create"] }),
async (c) => {
const { projectId } = c.req.valid("json");
const result = await importGiteaIssues(projectId);
diff --git a/apps/api/src/github-integration/index.ts b/apps/api/src/github-integration/index.ts
index ac12451d1..39feb4c0d 100644
--- a/apps/api/src/github-integration/index.ts
+++ b/apps/api/src/github-integration/index.ts
@@ -12,6 +12,7 @@ import {
} from "../plugins/github/config";
import { handleGitHubWebhook } from "../plugins/github/webhook-handler";
import { githubIntegrationSchema } from "../schemas";
+import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { validateWorkspaceAccess } from "../utils/validate-workspace-access";
import { workspaceAccess } from "../utils/workspace-access-middleware";
import createGithubIntegration from "./controllers/create-github-integration";
@@ -181,6 +182,7 @@ const githubIntegration = new Hono<{
}),
),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const { repositoryOwner, repositoryName } = c.req.valid("json");
@@ -226,6 +228,7 @@ const githubIntegration = new Hono<{
}),
),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const body = c.req.valid("json");
@@ -300,6 +303,7 @@ const githubIntegration = new Hono<{
}),
validator("param", v.object({ projectId: v.string() })),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const result = await deleteGithubIntegration(projectId);
@@ -353,6 +357,7 @@ const githubIntegration = new Hono<{
return next();
},
+ requireWorkspacePermission({ task: ["create"] }),
async (c) => {
const { projectId } = c.req.valid("json");
const result = await importIssues(projectId);
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index 989969185..fac7dfb24 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -3,7 +3,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
import { serve } from "@hono/node-server";
import { createNodeWebSocket } from "@hono/node-ws";
import type { Session, User } from "better-auth/types";
-import { eq } from "drizzle-orm";
+import { count, eq } from "drizzle-orm";
import { migrate } from "drizzle-orm/node-postgres/migrator";
import { Hono } from "hono";
import { cors } from "hono/cors";
@@ -162,6 +162,44 @@ export function createApp() {
return c.json({ status: "ok" });
});
+ api.get(
+ "/instance/status",
+ describeRoute({
+ operationId: "getInstanceStatus",
+ tags: ["Instance"],
+ description:
+ "Public instance setup status. When hasUsers is false the next signup becomes the instance admin.",
+ security: [],
+ responses: {
+ 200: {
+ description: "Instance status",
+ content: {
+ "application/json": {
+ schema: resolver(
+ v.object({
+ hasUsers: v.boolean(),
+ hasAdmin: v.boolean(),
+ }),
+ ),
+ },
+ },
+ },
+ },
+ }),
+ async (c) => {
+ const totalRows = await db
+ .select({ value: count() })
+ .from(schema.userTable);
+ const adminRows = await db
+ .select({ value: count() })
+ .from(schema.userTable)
+ .where(eq(schema.userTable.role, "admin"));
+ const total = totalRows[0]?.value ?? 0;
+ const admins = adminRows[0]?.value ?? 0;
+ return c.json({ hasUsers: total > 0, hasAdmin: admins > 0 });
+ },
+ );
+
const publicProjectApi = api.get("/public-project/:id", async (c) => {
const { id } = c.req.param();
const project = await getPublicProject(id);
diff --git a/apps/api/src/label/index.ts b/apps/api/src/label/index.ts
index 6f33e80b2..68aa8ebb1 100644
--- a/apps/api/src/label/index.ts
+++ b/apps/api/src/label/index.ts
@@ -2,6 +2,7 @@ import { Hono } from "hono";
import { describeRoute, resolver, validator } from "hono-openapi";
import * as v from "valibot";
import { labelSchema } from "../schemas";
+import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { workspaceAccess } from "../utils/workspace-access-middleware";
import assignLabelToTask from "./controllers/assign-label-to-task";
import createLabel from "./controllers/create-label";
@@ -88,6 +89,7 @@ const label = new Hono<{
}),
),
workspaceAccess.fromBody(),
+ requireWorkspacePermission({ project: ["update"] }),
async (c) => {
const { name, color, workspaceId, taskId } = c.req.valid("json");
const userId = c.get("userId");
@@ -136,6 +138,7 @@ const label = new Hono<{
validator("param", v.object({ id: v.string() })),
validator("json", v.object({ taskId: v.string() })),
workspaceAccess.fromLabel(),
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const { taskId } = c.req.valid("json");
@@ -161,6 +164,7 @@ const label = new Hono<{
}),
validator("param", v.object({ id: v.string() })),
workspaceAccess.fromLabel(),
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const userId = c.get("userId");
@@ -192,6 +196,7 @@ const label = new Hono<{
}),
),
workspaceAccess.fromLabel(),
+ requireWorkspacePermission({ project: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const { name, color } = c.req.valid("json");
@@ -216,6 +221,7 @@ const label = new Hono<{
}),
validator("param", v.object({ id: v.string() })),
workspaceAccess.fromLabel(),
+ requireWorkspacePermission({ project: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const userId = c.get("userId");
diff --git a/apps/api/src/project/index.ts b/apps/api/src/project/index.ts
index c902dd804..31aff229c 100644
--- a/apps/api/src/project/index.ts
+++ b/apps/api/src/project/index.ts
@@ -2,6 +2,7 @@ import { Hono } from "hono";
import { describeRoute, resolver, validator } from "hono-openapi";
import * as v from "valibot";
import { projectSchema } from "../schemas";
+import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { workspaceAccess } from "../utils/workspace-access-middleware";
import archiveProjectCtrl from "./controllers/archive-project";
import createProjectCtrl from "./controllers/create-project";
@@ -75,6 +76,7 @@ const project = new Hono<{
}),
),
workspaceAccess.fromBody(),
+ requireWorkspacePermission({ project: ["create"] }),
async (c) => {
const { name, icon, slug } = c.req.valid("json");
const workspaceId = c.get("workspaceId");
@@ -133,6 +135,7 @@ const project = new Hono<{
}),
),
workspaceAccess.fromProject(),
+ requireWorkspacePermission({ project: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const { name, icon, slug, description, isPublic } = c.req.valid("json");
@@ -166,6 +169,7 @@ const project = new Hono<{
}),
validator("param", v.object({ id: v.string() })),
workspaceAccess.fromProject(),
+ requireWorkspacePermission({ project: ["delete"] }),
async (c) => {
const { id } = c.req.valid("param");
const workspaceId = c.get("workspaceId");
@@ -190,6 +194,7 @@ const project = new Hono<{
}),
validator("param", v.object({ id: v.string() })),
workspaceAccess.fromProject(),
+ requireWorkspacePermission({ project: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const workspaceId = c.get("workspaceId");
@@ -214,6 +219,7 @@ const project = new Hono<{
}),
validator("param", v.object({ id: v.string() })),
workspaceAccess.fromProject(),
+ requireWorkspacePermission({ project: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const workspaceId = c.get("workspaceId");
diff --git a/apps/api/src/slack-integration/index.ts b/apps/api/src/slack-integration/index.ts
index 3557b3ccc..2eeb9ade6 100644
--- a/apps/api/src/slack-integration/index.ts
+++ b/apps/api/src/slack-integration/index.ts
@@ -12,6 +12,7 @@ import {
validateSlackConfig,
} from "../plugins/slack/config";
import { slackIntegrationSchema } from "../schemas";
+import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { workspaceAccess } from "../utils/workspace-access-middleware";
const slackIntegration = new Hono<{
@@ -144,6 +145,7 @@ slackIntegration
}),
),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const body = c.req.valid("json");
@@ -225,6 +227,7 @@ slackIntegration
}),
),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const body = c.req.valid("json");
@@ -299,6 +302,7 @@ slackIntegration
}),
validator("param", v.object({ projectId: v.string() })),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
diff --git a/apps/api/src/task-relation/index.ts b/apps/api/src/task-relation/index.ts
index b5cb481c8..dcc03f836 100644
--- a/apps/api/src/task-relation/index.ts
+++ b/apps/api/src/task-relation/index.ts
@@ -5,6 +5,7 @@ import { describeRoute, resolver, validator } from "hono-openapi";
import * as v from "valibot";
import db from "../database";
import { projectTable, taskRelationTable, taskTable } from "../database/schema";
+import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { validateWorkspaceAccess } from "../utils/validate-workspace-access";
import { workspaceAccess } from "../utils/workspace-access-middleware";
import createTaskRelation from "./controllers/create-task-relation";
@@ -22,6 +23,7 @@ const taskRelationSchema = v.object({
const taskRelation = new Hono<{
Variables: {
userId: string;
+ workspaceId: string;
};
}>()
.get(
@@ -86,8 +88,10 @@ const taskRelation = new Hono<{
throw new HTTPException(404, { message: "Source task not found" });
}
await validateWorkspaceAccess(userId, task.workspaceId);
+ c.set("workspaceId", task.workspaceId);
return next();
},
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const userId = c.get("userId");
const { sourceTaskId, targetTaskId, relationType } = c.req.valid("json");
@@ -140,8 +144,10 @@ const taskRelation = new Hono<{
throw new HTTPException(404, { message: "Task not found" });
}
await validateWorkspaceAccess(userId, task.workspaceId);
+ c.set("workspaceId", task.workspaceId);
return next();
},
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const userId = c.get("userId");
const { id } = c.req.valid("param");
diff --git a/apps/api/src/task/index.ts b/apps/api/src/task/index.ts
index a1ed37776..9a275d917 100644
--- a/apps/api/src/task/index.ts
+++ b/apps/api/src/task/index.ts
@@ -17,6 +17,7 @@ import {
isImageContentType,
validateTaskAssetUploadInput,
} from "../storage/s3";
+import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { workspaceAccess } from "../utils/workspace-access-middleware";
import bulkUpdateTasks from "./controllers/bulk-update-tasks";
import createTask from "./controllers/create-task";
@@ -185,6 +186,7 @@ const task = new Hono<{
}),
),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ task: ["create"] }),
async (c) => {
const { projectId } = c.req.param();
const {
@@ -269,6 +271,7 @@ const task = new Hono<{
}),
),
workspaceAccess.fromTask(),
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const { destinationProjectId, destinationStatus } = c.req.valid("json");
@@ -315,6 +318,7 @@ const task = new Hono<{
}),
),
workspaceAccess.fromTask(),
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const {
@@ -406,6 +410,7 @@ const task = new Hono<{
}),
),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ task: ["create"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const { tasks } = c.req.valid("json");
@@ -433,6 +438,7 @@ const task = new Hono<{
}),
validator("param", v.object({ id: v.string() })),
workspaceAccess.fromTask(),
+ requireWorkspacePermission({ task: ["delete"] }),
async (c) => {
const { id } = c.req.valid("param");
@@ -460,6 +466,7 @@ const task = new Hono<{
validator("param", v.object({ id: v.string() })),
validator("json", v.object({ status: v.string() })),
workspaceAccess.fromTask(),
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const { status } = c.req.valid("json");
@@ -488,6 +495,7 @@ const task = new Hono<{
validator("param", v.object({ id: v.string() })),
validator("json", v.object({ priority: v.picklist(VALID_PRIORITIES) })),
workspaceAccess.fromTask(),
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const { priority } = c.req.valid("json");
@@ -516,6 +524,7 @@ const task = new Hono<{
validator("param", v.object({ id: v.string() })),
validator("json", v.object({ userId: v.string() })),
workspaceAccess.fromTask(),
+ requireWorkspacePermission({ task: ["assign"] }),
async (c) => {
const { id } = c.req.valid("param");
const { userId } = c.req.valid("json");
@@ -544,6 +553,7 @@ const task = new Hono<{
validator("param", v.object({ id: v.string() })),
validator("json", v.object({ dueDate: v.optional(v.string()) })),
workspaceAccess.fromTask(),
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const { dueDate = null } = c.req.valid("json");
@@ -577,6 +587,7 @@ const task = new Hono<{
validator("param", v.object({ id: v.string() })),
validator("json", v.object({ title: v.string() })),
workspaceAccess.fromTask(),
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const { title } = c.req.valid("json");
@@ -615,6 +626,7 @@ const task = new Hono<{
}),
),
workspaceAccess.fromTask(),
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const { filename, contentType, size, surface } = c.req.valid("json");
@@ -698,6 +710,7 @@ const task = new Hono<{
}),
),
workspaceAccess.fromTask(),
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const { key, filename, contentType, size, surface } = c.req.valid("json");
@@ -813,6 +826,7 @@ const task = new Hono<{
validator("param", v.object({ id: v.string() })),
validator("json", v.object({ description: v.string() })),
workspaceAccess.fromTask(),
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const { description } = c.req.valid("json");
diff --git a/apps/api/src/telegram-integration/index.ts b/apps/api/src/telegram-integration/index.ts
index 4fdb86a9b..d65786273 100644
--- a/apps/api/src/telegram-integration/index.ts
+++ b/apps/api/src/telegram-integration/index.ts
@@ -12,6 +12,7 @@ import {
validateTelegramConfig,
} from "../plugins/telegram/config";
import { telegramIntegrationSchema } from "../schemas";
+import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { workspaceAccess } from "../utils/workspace-access-middleware";
import {
buildNextTelegramConfigFromPatch,
@@ -105,6 +106,7 @@ telegramIntegration
}),
),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const body = c.req.valid("json");
@@ -188,6 +190,7 @@ telegramIntegration
validator("param", v.object({ projectId: v.string() })),
validator("json", telegramIntegrationPatchBodySchema),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const body = c.req.valid("json");
@@ -276,6 +279,7 @@ telegramIntegration
}),
validator("param", v.object({ projectId: v.string() })),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ workspace: ["manage_settings"] }),
async (c) => {
const { projectId } = c.req.valid("param");
diff --git a/apps/api/src/time-entry/index.ts b/apps/api/src/time-entry/index.ts
index 4a6a11160..d614a4d6a 100644
--- a/apps/api/src/time-entry/index.ts
+++ b/apps/api/src/time-entry/index.ts
@@ -2,6 +2,7 @@ import { Hono } from "hono";
import { describeRoute, resolver, validator } from "hono-openapi";
import * as v from "valibot";
import { timeEntrySchema } from "../schemas";
+import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { workspaceAccess } from "../utils/workspace-access-middleware";
import createTimeEntry from "./controllers/create-time-entry";
import getTimeEntriesByTaskId from "./controllers/get-time-entries";
@@ -84,6 +85,7 @@ const timeEntry = new Hono<{
}),
),
workspaceAccess.fromTaskId(),
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const { taskId, startTime, endTime, description } = c.req.valid("json");
const userId = c.get("userId");
@@ -122,6 +124,7 @@ const timeEntry = new Hono<{
}),
),
workspaceAccess.fromTimeEntry(),
+ requireWorkspacePermission({ task: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const { startTime, endTime, description } = c.req.valid("json");
diff --git a/apps/api/src/utils/is-instance-admin.ts b/apps/api/src/utils/is-instance-admin.ts
new file mode 100644
index 000000000..7e39f7436
--- /dev/null
+++ b/apps/api/src/utils/is-instance-admin.ts
@@ -0,0 +1,22 @@
+import { eq } from "drizzle-orm";
+import type { Context } from "hono";
+import db from "../database";
+import { userTable } from "../database/schema";
+
+export async function isInstanceAdmin(c: Context): Promise<boolean> {
+ const user = c.get("user") as { role?: string | null } | null | undefined;
+ if (user?.role) {
+ return user.role === "admin";
+ }
+
+ const userId = c.get("userId");
+ if (!userId) return false;
+
+ const [row] = await db
+ .select({ role: userTable.role })
+ .from(userTable)
+ .where(eq(userTable.id, userId))
+ .limit(1);
+
+ return row?.role === "admin";
+}
diff --git a/apps/api/src/utils/require-workspace-permission.ts b/apps/api/src/utils/require-workspace-permission.ts
new file mode 100644
index 000000000..8adfb01ac
--- /dev/null
+++ b/apps/api/src/utils/require-workspace-permission.ts
@@ -0,0 +1,41 @@
+import type { Context, Next } from "hono";
+import { HTTPException } from "hono/http-exception";
+import { auth } from "../auth";
+import { isInstanceAdmin } from "./is-instance-admin";
+
+type PermissionMap = Record<string, string[]>;
+
+export function requireWorkspacePermission(permissions: PermissionMap) {
+ return async (c: Context, next: Next) => {
+ const workspaceId = c.get("workspaceId");
+ if (!workspaceId) {
+ throw new HTTPException(500, {
+ message: "workspaceId not set in context",
+ });
+ }
+
+ if (await isInstanceAdmin(c)) {
+ return next();
+ }
+
+ let allowed = false;
+ try {
+ const result = await auth.api.hasPermission({
+ headers: c.req.raw.headers,
+ body: {
+ organizationId: workspaceId,
+ permissions,
+ },
+ });
+ allowed = result?.success === true;
+ } catch {
+ allowed = false;
+ }
+
+ if (!allowed) {
+ throw new HTTPException(403, { message: "Insufficient permissions" });
+ }
+
+ return next();
+ };
+}
diff --git a/apps/api/src/utils/validate-workspace-access.ts b/apps/api/src/utils/validate-workspace-access.ts
index 17886d984..76d2a19c4 100644
--- a/apps/api/src/utils/validate-workspace-access.ts
+++ b/apps/api/src/utils/validate-workspace-access.ts
@@ -30,6 +30,16 @@ export async function validateWorkspaceAccess(
}
}
+ const [user] = await db
+ .select({ role: schema.userTable.role })
+ .from(schema.userTable)
+ .where(eq(schema.userTable.id, userId))
+ .limit(1);
+
+ if (user?.role === "admin") {
+ return;
+ }
+
const membership = await db
.select()
.from(schema.workspaceUserTable)
diff --git a/apps/api/src/workflow-rule/index.ts b/apps/api/src/workflow-rule/index.ts
index 6bd4b9c58..3fdccad4d 100644
--- a/apps/api/src/workflow-rule/index.ts
+++ b/apps/api/src/workflow-rule/index.ts
@@ -1,6 +1,7 @@
import { Hono } from "hono";
import { describeRoute, resolver, validator } from "hono-openapi";
import * as v from "valibot";
+import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { workspaceAccess } from "../utils/workspace-access-middleware";
import deleteWorkflowRule from "./controllers/delete-workflow-rule";
import getWorkflowRules from "./controllers/get-workflow-rules";
@@ -59,6 +60,7 @@ const workflowRule = new Hono<{
}),
),
workspaceAccess.fromProject("projectId"),
+ requireWorkspacePermission({ project: ["update"] }),
async (c) => {
const { projectId } = c.req.valid("param");
const { integrationType, eventType, columnId } = c.req.valid("json");
@@ -88,6 +90,7 @@ const workflowRule = new Hono<{
}),
validator("param", v.object({ id: v.string() })),
workspaceAccess.fromWorkflowRule("id"),
+ requireWorkspacePermission({ project: ["update"] }),
async (c) => {
const { id } = c.req.valid("param");
const result = await deleteWorkflowRule(id);
diff --git a/apps/web/package.json b/apps/web/package.json
index 96a2d311f..3d3cacaae 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -101,6 +101,7 @@
},
"devDependencies": {
"@kaneo/libs": "workspace:*",
+ "@kaneo/permissions": "workspace:*",
"@tailwindcss/postcss": "^4.2.1",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
diff --git a/apps/web/src/components/auth/sso-providers.tsx b/apps/web/src/components/auth/sso-providers.tsx
new file mode 100644
index 000000000..869e3f248
--- /dev/null
+++ b/apps/web/src/components/auth/sso-providers.tsx
@@ -0,0 +1,182 @@
+import { Github, KeyRound } from "lucide-react";
+import { useState } from "react";
+import { useTranslation } from "react-i18next";
+import { Button } from "@/components/ui/button";
+import type { GetConfigResponse } from "@/fetchers/config/get-config";
+import { authClient } from "@/lib/auth-client";
+import { cn } from "@/lib/cn";
+import { toast } from "@/lib/toast";
+
+type Props = {
+ config: GetConfigResponse | undefined;
+ callbackURL: string;
+ errorCallbackURL: string;
+ lastLoginMethod?: string | null;
+};
+
+export function SSOProviders({
+ config,
+ callbackURL,
+ errorCallbackURL,
+ lastLoginMethod,
+}: Props) {
+ const { t } = useTranslation();
+ const [loadingProvider, setLoadingProvider] = useState<string | null>(null);
+
+ const handleSocial = async (
+ provider: "google" | "github" | "discord",
+ errorKey: string,
+ ) => {
+ setLoadingProvider(provider);
+ try {
+ const result = await authClient.signIn.social({
+ provider,
+ callbackURL,
+ errorCallbackURL,
+ });
+ if (result.error) throw new Error(result.error.message);
+ } catch (error) {
+ toast.error(error instanceof Error ? error.message : t(errorKey));
+ } finally {
+ setLoadingProvider(null);
+ }
+ };
+
+ const handleCustomOAuth = async () => {
+ setLoadingProvider("custom");
+ try {
+ const result = await authClient.signIn.oauth2({
+ providerId: "custom",
+ callbackURL,
+ errorCallbackURL,
+ });
+ if (result.error) throw new Error(result.error.message);
+ } catch (error) {
+ toast.error(
+ error instanceof Error ? error.message : t("auth:signIn.oidcError"),
+ );
+ } finally {
+ setLoadingProvider(null);
+ }
+ };
+
+ const hasAny =
+ config?.hasGoogleSignIn ||
+ config?.hasGithubSignIn ||
+ config?.hasDiscordSignIn ||
+ config?.hasCustomOAuth;
+
+ if (!hasAny) return null;
+
+ return (
+ <div className="space-y-3">
+ {config?.hasGoogleSignIn && (
+ <ProviderButton
+ providerId="google"
+ isLoading={loadingProvider === "google"}
+ isLastUsed={lastLoginMethod === "google"}
+ onClick={() => handleSocial("google", "auth:signIn.googleError")}
+ label={t("auth:signIn.continueWithGoogle")}
+ loadingLabel={t("auth:signIn.signingIn")}
+ icon={
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 24 24"
+ className="w-5 h-5 mr-2"
+ aria-label={t("auth:providers.google")}
+ >
+ <title>Google</title>
+ <path
+ d="M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z"
+ fill="currentColor"
+ />
+ </svg>
+ }
+ />
+ )}
+ {config?.hasGithubSignIn && (
+ <ProviderButton
+ providerId="github"
+ isLoading={loadingProvider === "github"}
+ isLastUsed={lastLoginMethod === "github"}
+ onClick={() => handleSocial("github", "auth:signIn.githubError")}
+ label={t("auth:signIn.continueWithGithub")}
+ loadingLabel={t("auth:signIn.signingIn")}
+ icon={<Github className="w-5 h-5 mr-2" />}
+ />
+ )}
+ {config?.hasDiscordSignIn && (
+ <ProviderButton
+ providerId="discord"
+ isLoading={loadingProvider === "discord"}
+ isLastUsed={lastLoginMethod === "discord"}
+ onClick={() => handleSocial("discord", "auth:signIn.discordError")}
+ label={t("auth:signIn.continueWithDiscord")}
+ loadingLabel={t("auth:signIn.signingIn")}
+ icon={
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 24 24"
+ className="w-5 h-5 mr-2"
+ fill="currentColor"
+ aria-label={t("auth:providers.discord")}
+ >
+ <title>Discord</title>
+ <path d="M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515a.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0a12.64 12.64 0 0 0-.617-1.25a.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057a19.9 19.9 0 0 0 5.993 3.03a.078.078 0 0 0 .084-.028a14.09 14.09 0 0 0 1.226-1.994a.076.076 0 0 0-.041-.106a13.107 13.107 0 0 1-1.872-.892a.077.077 0 0 1-.008-.128a10.2 10.2 0 0 0 .372-.292a.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127a12.299 12.299 0 0 1-1.873.892a.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028a19.839 19.839 0 0 0 6.002-3.03a.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419c0-1.333.956-2.419 2.157-2.419c1.21 0 2.176 1.096 2.157 2.42c0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419c0-1.333.955-2.419 2.157-2.419c1.21 0 2.176 1.096 2.157 2.42c0 1.333-.946 2.418-2.157 2.418z" />
+ </svg>
+ }
+ />
+ )}
+ {config?.hasCustomOAuth && (
+ <ProviderButton
+ providerId="custom"
+ isLoading={loadingProvider === "custom"}
+ isLastUsed={lastLoginMethod === "custom"}
+ onClick={handleCustomOAuth}
+ label={t("auth:signIn.continueWithOidc")}
+ loadingLabel={t("auth:signIn.signingIn")}
+ icon={<KeyRound className="w-5 h-5 mr-2" />}
+ />
+ )}
+ </div>
+ );
+}
+
+function ProviderButton({
+ providerId,
+ icon,
+ label,
+ loadingLabel,
+ isLoading,
+ isLastUsed,
+ onClick,
+}: {
+ providerId: string;
+ icon: React.ReactNode;
+ label: string;
+ loadingLabel: string;
+ isLoading: boolean;
+ isLastUsed: boolean;
+ onClick: () => void;
+}) {
+ const { t } = useTranslation();
+ return (
+ <div className="relative">
+ <Button
+ variant="outline"
+ onClick={onClick}
+ disabled={isLoading}
+ className={cn("w-full", isLastUsed && "border-primary/50!")}
+ data-provider={providerId}
+ >
+ {icon}
+ {isLoading ? loadingLabel : label}
+ </Button>
+ {isLastUsed && (
+ <span className="absolute rounded-md -top-3 right-1 px-1.5 text-xs text-primary font-medium bg-sidebar border border-primary/50">
+ {t("auth:signIn.lastUsed")}
+ </span>
+ )}
+ </div>
+ );
+}
diff --git a/apps/web/src/components/command-palette/index.tsx b/apps/web/src/components/command-palette/index.tsx
index 135d4bca5..94e743c94 100644
--- a/apps/web/src/components/command-palette/index.tsx
+++ b/apps/web/src/components/command-palette/index.tsx
@@ -121,13 +121,11 @@ function CommandPalette() {
},
{
value: "members",
- label: t("navigation:commandPalette.members"),
+ label: t("navigation:commandPalette.members", {
+ defaultValue: "Members",
+ }),
onRun: () => {
- if (!workspace?.id) return;
- navigate({
- to: "/dashboard/workspace/$workspaceId/members",
- params: { workspaceId: workspace.id },
- });
+ navigate({ to: "/dashboard/settings/workspace/members" });
},
},
{
diff --git a/apps/web/src/components/nav-main.tsx b/apps/web/src/components/nav-main.tsx
index 6ca846590..df9dbe55e 100644
--- a/apps/web/src/components/nav-main.tsx
+++ b/apps/web/src/components/nav-main.tsx
@@ -35,14 +35,6 @@ export function NavMain() {
window.location.pathname === `/dashboard/workspace/${workspace.id}`,
badge: null,
},
- {
- title: t("navigation:sidebar.members"),
- url: `/dashboard/workspace/${workspace.id}/members`,
- isActive:
- window.location.pathname ===
- `/dashboard/workspace/${workspace.id}/members`,
- badge: null,
- },
{
title: t("navigation:sidebar.invitations"),
url: "/dashboard/invitations",
diff --git a/apps/web/src/components/nav-projects.tsx b/apps/web/src/components/nav-projects.tsx
index 30218aa39..0dee2623e 100644
--- a/apps/web/src/components/nav-projects.tsx
+++ b/apps/web/src/components/nav-projects.tsx
@@ -34,6 +34,7 @@ import {
import useDeleteProject from "@/hooks/mutations/project/use-delete-project";
import useGetProjects from "@/hooks/queries/project/use-get-projects";
import useActiveWorkspace from "@/hooks/queries/workspace/use-active-workspace";
+import { useWorkspacePermission } from "@/hooks/use-workspace-permission";
import { toast } from "@/lib/toast";
import type { ProjectWithTasks } from "@/types/project";
import CreateProjectModal from "./shared/modals/create-project-modal";
@@ -57,6 +58,9 @@ export function NavProjects() {
});
const queryClient = useQueryClient();
const { mutateAsync: deleteProject } = useDeleteProject();
+ const { canCreateProjects, checkRolePermission } = useWorkspacePermission();
+ const canCreate = canCreateProjects();
+ const canDeleteProject = checkRolePermission({ project: ["delete"] });
const navigate = useNavigate();
const { workspaceId: currentWorkspaceId, projectId: currentProjectId } =
useParams({
@@ -175,34 +179,40 @@ export function NavProjects() {
{t("navigation:projectList.projectSettings")}
</span>
</DropdownMenuItem>
- <DropdownMenuSeparator />
- <DropdownMenuItem
- className="h-7 items-start text-destructive cursor-pointer text-sm"
- onClick={() => {
- setProjectToDeleteID(project.id);
- setIsDeleteProjectModalOpen(true);
- }}
- >
- <Trash2 className="text-destructive" />
- <span>
- {t("navigation:projectList.deleteProject")}
- </span>
- </DropdownMenuItem>
+ {canDeleteProject && (
+ <>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ className="h-7 items-start text-destructive cursor-pointer text-sm"
+ onClick={() => {
+ setProjectToDeleteID(project.id);
+ setIsDeleteProjectModalOpen(true);
+ }}
+ >
+ <Trash2 className="text-destructive" />
+ <span>
+ {t("navigation:projectList.deleteProject")}
+ </span>
+ </DropdownMenuItem>
+ </>
+ )}
</DropdownMenuContent>
</DropdownMenu>
</SidebarMenuItem>
);
})}
- <SidebarMenuItem className="mt-1">
- <SidebarMenuButton
- size="default"
- className="h-8 ps-3.5 text-sm hover:bg-transparent hover:text-sidebar-accent-foreground active:bg-transparent"
- onClick={() => setIsCreateProjectModalOpen(true)}
- >
- <span>{t("navigation:projectList.addProject")}</span>
- </SidebarMenuButton>
- </SidebarMenuItem>
+ {canCreate && (
+ <SidebarMenuItem className="mt-1">
+ <SidebarMenuButton
+ size="default"
+ className="h-8 ps-3.5 text-sm hover:bg-transparent hover:text-sidebar-accent-foreground active:bg-transparent"
+ onClick={() => setIsCreateProjectModalOpen(true)}
+ >
+ <span>{t("navigation:projectList.addProject")}</span>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ )}
</SidebarMenu>
</SidebarGroupContent>
</CollapsiblePanel>
diff --git a/apps/web/src/components/team/delete-team-member-modal.tsx b/apps/web/src/components/team/delete-team-member-modal.tsx
index 09616a7a4..56818fbd5 100644
--- a/apps/web/src/components/team/delete-team-member-modal.tsx
+++ b/apps/web/src/components/team/delete-team-member-modal.tsx
@@ -1,7 +1,7 @@
import { useQueryClient } from "@tanstack/react-query";
import { Trash2, X } from "lucide-react";
import useDeleteWorkspaceUser from "@/hooks/mutations/workspace-user/use-delete-workspace-user";
-import { Route } from "@/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/members";
+import useActiveWorkspace from "@/hooks/queries/workspace/use-active-workspace";
import { Button } from "../ui/button";
import { Dialog, DialogClose, DialogPopup, DialogTitle } from "../ui/dialog";
@@ -14,7 +14,8 @@ function DeleteTeamMemberModal({
open: boolean;
onClose: () => void;
}) {
- const { workspaceId } = Route.useParams();
+ const { data: workspace } = useActiveWorkspace();
+ const workspaceId = workspace?.id ?? "";
const { mutateAsync: deleteWorkspaceUser } = useDeleteWorkspaceUser();
const queryClient = useQueryClient();
diff --git a/apps/web/src/components/team/invite-team-member-modal.tsx b/apps/web/src/components/team/invite-team-member-modal.tsx
index de2c13fa4..23ca5e0a6 100644
--- a/apps/web/src/components/team/invite-team-member-modal.tsx
+++ b/apps/web/src/components/team/invite-team-member-modal.tsx
@@ -5,8 +5,8 @@ import { useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { z } from "zod/v4";
import useInviteWorkspaceUser from "@/hooks/mutations/workspace-user/use-invite-workspace-user";
+import useActiveWorkspace from "@/hooks/queries/workspace/use-active-workspace";
import { toast } from "@/lib/toast";
-import { Route } from "@/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/members";
import { Button } from "../ui/button";
import { Dialog, DialogClose, DialogPopup, DialogTitle } from "../ui/dialog";
import {
@@ -34,7 +34,8 @@ function InviteTeamMemberModal({ open, onClose }: Props) {
const { t } = useTranslation();
const { mutateAsync } = useInviteWorkspaceUser();
const queryClient = useQueryClient();
- const { workspaceId } = Route.useParams();
+ const { data: workspace } = useActiveWorkspace();
+ const workspaceId = workspace?.id ?? "";
const form = useForm<TeamMemberFormValues>({
resolver: standardSchemaResolver(teamMemberSchema),
diff --git a/apps/web/src/components/team/members-table.tsx b/apps/web/src/components/team/members-table.tsx
index aa37b4f73..2ac901d39 100644
--- a/apps/web/src/components/team/members-table.tsx
+++ b/apps/web/src/components/team/members-table.tsx
@@ -1,11 +1,13 @@
-import { Trash2 } from "lucide-react";
+import { Mail, MoreHorizontal, Trash2, UserPlus } from "lucide-react";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import useCancelInvitation from "@/hooks/mutations/workspace-user/use-cancel-invitation";
import useDeleteWorkspaceUser from "@/hooks/mutations/workspace-user/use-delete-workspace-user";
+import useUpdateWorkspaceUserRole from "@/hooks/mutations/workspace-user/use-update-workspace-user-role";
+import useWorkspaceRoles from "@/hooks/queries/workspace/use-workspace-roles";
+import { useWorkspacePermission } from "@/hooks/use-workspace-permission";
import { formatDateMedium } from "@/lib/format";
import { toast } from "@/lib/toast";
-import { Route } from "@/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/members";
import type {
WorkspaceUser,
WorkspaceUserInvitation,
@@ -21,23 +23,47 @@ import {
AlertDialogTitle,
} from "../ui/alert-dialog";
import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar";
+import { Badge } from "../ui/badge";
import { Button } from "../ui/button";
import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from "../ui/table";
+ Empty,
+ EmptyDescription,
+ EmptyHeader,
+ EmptyMedia,
+ EmptyTitle,
+} from "../ui/empty";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "../ui/menu";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "../ui/select";
-function MembersTable({
- invitations,
- users,
-}: {
+type Props = {
+ workspaceId: string;
invitations: WorkspaceUserInvitation[];
users: WorkspaceUser[];
-}) {
+ onInvite: () => void;
+};
+
+function initials(value: string | null | undefined): string {
+ if (!value) return "?";
+ return value
+ .split(/\s+/)
+ .filter(Boolean)
+ .slice(0, 2)
+ .map((part) => part[0]?.toUpperCase() ?? "")
+ .join("");
+}
+
+function MembersTable({ workspaceId, invitations, users, onInvite }: Props) {
const [memberToDelete, setMemberToDelete] = useState<WorkspaceUser | null>(
null,
);
@@ -45,15 +71,35 @@ function MembersTable({
useState<WorkspaceUserInvitation | null>(null);
const { t } = useTranslation();
const { user: currentUser } = useAuth();
- const { workspaceId } = Route.useParams();
const { mutateAsync: deleteWorkspaceUser, isPending } =
useDeleteWorkspaceUser();
const { mutateAsync: cancelInvitation, isPending: isCancelling } =
useCancelInvitation();
+ const { mutateAsync: updateMemberRole } = useUpdateWorkspaceUserRole();
+ const { data: customRoles = [] } = useWorkspaceRoles(workspaceId);
+ const { isAdmin, isOwner } = useWorkspacePermission();
+ const canEditRoles = isAdmin || isOwner;
+
+ const pendingInvitations = invitations.filter(
+ (inv) => inv.status !== "accepted" && inv.status !== "canceled",
+ );
+
+ const handleChangeRole = async (member: WorkspaceUser, role: string) => {
+ if (role === member.role) return;
+ try {
+ await updateMemberRole({ workspaceId, memberId: member.id, role });
+ toast.success(t("team:membersTable.roleUpdateSuccess"));
+ } catch (error) {
+ toast.error(
+ error instanceof Error
+ ? error.message
+ : t("team:membersTable.roleUpdateError"),
+ );
+ }
+ };
const handleDeleteMember = async () => {
if (!memberToDelete) return;
-
try {
await deleteWorkspaceUser({
workspaceId,
@@ -73,7 +119,6 @@ function MembersTable({
const handleCancelInvitation = async () => {
if (!invitationToCancel) return;
-
try {
await cancelInvitation({
invitationId: invitationToCancel.id,
@@ -91,144 +136,206 @@ function MembersTable({
}
};
- if (users?.length === 0) {
- return (
- <div className="flex items-center justify-center min-h-[60vh]">
- <div className="text-center space-y-6">
- <div className="w-16 h-16 mx-auto rounded-xl bg-muted flex items-center justify-center">
- <span className="text-2xl">👥</span>
- </div>
- <div className="space-y-2">
- <h3 className="text-xl font-semibold">
- {t("team:membersTable.emptyTitle")}
- </h3>
- <p className="text-muted-foreground">
- {t("team:membersTable.emptyDescription")}
+ return (
+ <>
+ <div className="space-y-6">
+ <div className="flex items-start justify-between gap-4">
+ <div className="space-y-1">
+ <h2 className="text-md font-medium">
+ {t("team:members.sectionTitle", { defaultValue: "Members" })}
+ </h2>
+ <p className="text-xs text-muted-foreground">
+ {users.length === 0
+ ? t("team:members.emptyDescription", {
+ defaultValue: "No members yet.",
+ })
+ : t("team:members.countDescription", {
+ defaultValue:
+ "{{count}} {{label}} with access to this workspace.",
+ count: users.length,
+ label: users.length === 1 ? "person" : "people",
+ })}
</p>
</div>
+ <Button size="sm" onClick={onInvite} className="gap-1.5">
+ <UserPlus className="w-3.5 h-3.5" />
+ {t("team:members.inviteMember")}
+ </Button>
</div>
- </div>
- );
- }
- return (
- <>
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead className="text-muted-foreground text-xs w-2/3 pl-6">
- {t("team:membersTable.columns.name")}
- </TableHead>
- <TableHead className="text-muted-foreground text-xs">
- {t("team:membersTable.columns.role")}
- </TableHead>
- <TableHead className="text-muted-foreground text-xs">
- {t("team:membersTable.columns.joined")}
- </TableHead>
- <TableHead className="text-muted-foreground text-xs pr-6 text-right">
- {t("team:membersTable.columns.actions")}
- </TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- {invitations
- .filter(
- (invitation) =>
- invitation.status !== "accepted" &&
- invitation.status !== "canceled",
- )
- ?.map((invitation) => (
- <TableRow key={invitation.email} className="cursor-pointer">
- <TableCell className="py-3 pl-6">
- <div className="flex items-center gap-3">
- <Avatar className="h-5 w-5">
+ <div className="border border-border rounded-md bg-sidebar overflow-hidden">
+ {users.length === 0 ? (
+ <Empty>
+ <EmptyHeader>
+ <EmptyMedia variant="icon">
+ <UserPlus />
+ </EmptyMedia>
+ <EmptyTitle>{t("team:membersTable.emptyTitle")}</EmptyTitle>
+ <EmptyDescription>
+ {t("team:membersTable.emptyDescription")}
+ </EmptyDescription>
+ </EmptyHeader>
+ </Empty>
+ ) : (
+ <ul className="divide-y divide-border">
+ {users.map((member) => {
+ const isSelf = currentUser?.id === member.userId;
+ const showRoleSelect = canEditRoles && !isSelf;
+ return (
+ <li
+ key={member.user.email}
+ className="flex items-center gap-4 px-4 py-3"
+ >
+ <Avatar className="h-9 w-9">
+ <AvatarImage
+ src={member.user.image ?? ""}
+ alt={member.user.name || ""}
+ />
<AvatarFallback className="bg-muted text-muted-foreground text-xs">
- {invitation?.email?.charAt(0).toUpperCase()}
+ {initials(member.user.name)}
</AvatarFallback>
</Avatar>
- <span>{invitation.email}</span>
+ <div className="flex-1 min-w-0">
+ <p className="text-sm font-medium truncate">
+ {member.user.name}
+ {isSelf && (
+ <span className="ml-2 text-xs font-normal text-muted-foreground">
+ ({t("team:members.you", { defaultValue: "You" })})
+ </span>
+ )}
+ </p>
+ <p className="text-xs text-muted-foreground truncate">
+ {member.user.email}
+ </p>
+ </div>
+ {showRoleSelect ? (
+ <Select
+ value={member.role}
+ onValueChange={(value) => {
+ if (typeof value === "string" && value) {
+ handleChangeRole(member, value);
+ }
+ }}
+ >
+ <SelectTrigger size="sm" className="w-32">
+ <SelectValue className="capitalize">
+ {member.role}
+ </SelectValue>
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="viewer">Viewer</SelectItem>
+ <SelectItem value="member">Member</SelectItem>
+ <SelectItem value="admin">Admin</SelectItem>
+ {isOwner && (
+ <SelectItem value="owner">Owner</SelectItem>
+ )}
+ {customRoles.map((r) => (
+ <SelectItem key={r.id} value={r.role}>
+ {r.role.charAt(0).toUpperCase() + r.role.slice(1)}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ ) : (
+ <Badge variant="secondary" className="capitalize">
+ {member.role}
+ </Badge>
+ )}
+ {!isSelf && canEditRoles && (
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button
+ variant="ghost"
+ size="icon"
+ className="h-8 w-8 text-muted-foreground"
+ aria-label={t(
+ "team:membersTable.ariaRemoveMember",
+ )}
+ />
+ }
+ >
+ <MoreHorizontal className="w-4 h-4" />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-44">
+ <DropdownMenuItem
+ className="text-destructive"
+ onClick={() => setMemberToDelete(member)}
+ >
+ <Trash2 className="w-4 h-4" />
+ {t("team:membersTable.removeMember")}
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ </li>
+ );
+ })}
+ </ul>
+ )}
+ </div>
+ </div>
+
+ {pendingInvitations.length > 0 && (
+ <div className="space-y-6">
+ <div className="space-y-1">
+ <h2 className="text-md font-medium">
+ {t("team:invitations.sectionTitle", {
+ defaultValue: "Pending invitations",
+ })}
+ </h2>
+ <p className="text-xs text-muted-foreground">
+ {t("team:invitations.countDescription", {
+ defaultValue: "{{count}} {{label}} awaiting acceptance.",
+ count: pendingInvitations.length,
+ label:
+ pendingInvitations.length === 1
+ ? "invitation"
+ : "invitations",
+ })}
+ </p>
+ </div>
+ <div className="border border-border rounded-md bg-sidebar overflow-hidden">
+ <ul className="divide-y divide-border">
+ {pendingInvitations.map((invitation) => (
+ <li
+ key={invitation.email}
+ className="flex items-center gap-4 px-4 py-3"
+ >
+ <div className="flex h-9 w-9 items-center justify-center rounded-full bg-muted text-muted-foreground">
+ <Mail className="w-4 h-4" />
</div>
- </TableCell>
- <TableCell className="py-3">
- <span className="inline-flex items-center px-1.5 py-0.5 rounded text-xs bg-muted text-muted-foreground">
- {t("team:membersTable.memberRolePending", {
- role:
- invitation.role.charAt(0).toUpperCase() +
- invitation.role.slice(1).toLowerCase(),
- })}
- </span>
- </TableCell>
- <TableCell className="py-3">
- <span className="text-sm text-muted-foreground">
- {invitation.expiresAt &&
- formatDateMedium(invitation.expiresAt)}
- </span>
- </TableCell>
- <TableCell className="py-3 pr-6 text-right">
+ <div className="flex-1 min-w-0">
+ <p className="text-sm font-medium truncate">
+ {invitation.email}
+ </p>
+ <p className="text-xs text-muted-foreground">
+ {t("team:invitations.expires", {
+ defaultValue: "Expires {{date}}",
+ date: invitation.expiresAt
+ ? formatDateMedium(invitation.expiresAt)
+ : "—",
+ })}
+ </p>
+ </div>
+ <Badge variant="outline" className="capitalize">
+ {invitation.role}
+ </Badge>
<Button
variant="ghost"
size="icon"
- onClick={(e) => {
- e.stopPropagation();
- setInvitationToCancel(invitation);
- }}
- className="h-8 w-8 text-muted-foreground hover:text-destructive hover:bg-destructive/10"
+ onClick={() => setInvitationToCancel(invitation)}
+ className="h-8 w-8 text-muted-foreground hover:text-destructive"
aria-label={t("team:membersTable.ariaCancelInvitation")}
>
- <Trash2 className="h-4 w-4" />
- </Button>
- </TableCell>
- </TableRow>
- ))}
-
- {users?.map((member) => (
- <TableRow key={member.user.email} className="cursor-pointer">
- <TableCell className="py-3 pl-6">
- <div className="flex items-center gap-3">
- <Avatar className="h-5 w-5">
- <AvatarImage
- src={member.user.image ?? ""}
- alt={member.user.name || ""}
- />
- <AvatarFallback className="bg-muted text-muted-foreground text-xs">
- {member?.user?.name?.charAt(0).toUpperCase()}
- </AvatarFallback>
- </Avatar>
- <span>{member.user.name}</span>
- </div>
- </TableCell>
- <TableCell className="py-3">
- <span className="inline-flex items-center px-1.5 py-0.5 rounded text-xs bg-muted text-muted-foreground">
- {member.role.charAt(0).toUpperCase() +
- member.role.slice(1).toLowerCase()}
- </span>
- </TableCell>
-
- <TableCell className="py-3">
- <span className="text-sm text-muted-foreground">
- {member.createdAt && formatDateMedium(member.createdAt)}
- </span>
- </TableCell>
- <TableCell className="py-3 pr-6 text-right">
- {currentUser?.id !== member.userId && (
- <Button
- variant="ghost"
- size="icon"
- onClick={(e) => {
- e.stopPropagation();
- setMemberToDelete(member);
- }}
- className="h-8 w-8 text-muted-foreground hover:text-destructive hover:bg-destructive/10"
- aria-label={t("team:membersTable.ariaRemoveMember")}
- >
- <Trash2 className="h-4 w-4" />
+ <Trash2 className="w-4 h-4" />
</Button>
- )}
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
+ </li>
+ ))}
+ </ul>
+ </div>
+ </div>
+ )}
<AlertDialog
open={!!memberToDelete}
diff --git a/apps/web/src/fetchers/instance/get-instance-status.ts b/apps/web/src/fetchers/instance/get-instance-status.ts
new file mode 100644
index 000000000..d060b25fe
--- /dev/null
+++ b/apps/web/src/fetchers/instance/get-instance-status.ts
@@ -0,0 +1,17 @@
+import { resolveApiBaseUrl } from "@kaneo/libs";
+
+export type InstanceStatus = {
+ hasUsers: boolean;
+ hasAdmin: boolean;
+};
+
+export async function getInstanceStatus(): Promise<InstanceStatus> {
+ const baseUrl = resolveApiBaseUrl(import.meta.env.VITE_API_URL);
+ const response = await fetch(`${baseUrl}/instance/status`, {
+ credentials: "include",
+ });
+ if (!response.ok) {
+ throw new Error("Failed to fetch instance status");
+ }
+ return response.json();
+}
diff --git a/apps/web/src/hooks/mutations/workspace-user/use-update-workspace-user-role.ts b/apps/web/src/hooks/mutations/workspace-user/use-update-workspace-user-role.ts
index ad6a9ab15..f2c478ffb 100644
--- a/apps/web/src/hooks/mutations/workspace-user/use-update-workspace-user-role.ts
+++ b/apps/web/src/hooks/mutations/workspace-user/use-update-workspace-user-role.ts
@@ -1,13 +1,14 @@
-import { useMutation } from "@tanstack/react-query";
+import { useMutation, useQueryClient } from "@tanstack/react-query";
import { authClient } from "@/lib/auth-client";
type UpdateWorkspaceUserRoleRequest = {
workspaceId: string;
memberId: string;
- role: "admin" | "member" | "owner";
+ role: string;
};
function useUpdateWorkspaceUserRole() {
+ const queryClient = useQueryClient();
return useMutation({
mutationFn: async ({
workspaceId,
@@ -17,7 +18,7 @@ function useUpdateWorkspaceUserRole() {
const { data, error } = await authClient.organization.updateMemberRole({
memberId,
organizationId: workspaceId,
- role,
+ role: role as "admin" | "member" | "owner",
});
if (error) {
@@ -28,6 +29,13 @@ function useUpdateWorkspaceUserRole() {
return data;
},
+ onSuccess: (_data, variables) => {
+ queryClient.invalidateQueries({
+ queryKey: ["workspace", variables.workspaceId],
+ });
+ queryClient.invalidateQueries({ queryKey: ["full-workspace"] });
+ queryClient.invalidateQueries({ queryKey: ["active-workspace-user"] });
+ },
});
}
diff --git a/apps/web/src/hooks/mutations/workspace/use-create-workspace-role.ts b/apps/web/src/hooks/mutations/workspace/use-create-workspace-role.ts
new file mode 100644
index 000000000..3c7d62506
--- /dev/null
+++ b/apps/web/src/hooks/mutations/workspace/use-create-workspace-role.ts
@@ -0,0 +1,36 @@
+import { useMutation, useQueryClient } from "@tanstack/react-query";
+import { authClient } from "@/lib/auth-client";
+
+type CreateWorkspaceRoleRequest = {
+ workspaceId: string;
+ role: string;
+ permission: Record<string, string[]>;
+};
+
+function useCreateWorkspaceRole() {
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn: async ({
+ workspaceId,
+ role,
+ permission,
+ }: CreateWorkspaceRoleRequest) => {
+ const { data, error } = await authClient.organization.createRole({
+ organizationId: workspaceId,
+ role,
+ permission,
+ });
+ if (error) {
+ throw new Error(error.message || "Failed to create role");
+ }
+ return data;
+ },
+ onSuccess: (_data, variables) => {
+ queryClient.invalidateQueries({
+ queryKey: ["workspace-roles", variables.workspaceId],
+ });
+ },
+ });
+}
+
+export default useCreateWorkspaceRole;
diff --git a/apps/web/src/hooks/mutations/workspace/use-delete-workspace-role.ts b/apps/web/src/hooks/mutations/workspace/use-delete-workspace-role.ts
new file mode 100644
index 000000000..a3ae64df5
--- /dev/null
+++ b/apps/web/src/hooks/mutations/workspace/use-delete-workspace-role.ts
@@ -0,0 +1,33 @@
+import { useMutation, useQueryClient } from "@tanstack/react-query";
+import { authClient } from "@/lib/auth-client";
+
+type DeleteWorkspaceRoleRequest = {
+ workspaceId: string;
+ roleName: string;
+};
+
+function useDeleteWorkspaceRole() {
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn: async ({
+ workspaceId,
+ roleName,
+ }: DeleteWorkspaceRoleRequest) => {
+ const { data, error } = await authClient.organization.deleteRole({
+ organizationId: workspaceId,
+ roleName,
+ });
+ if (error) {
+ throw new Error(error.message || "Failed to delete role");
+ }
+ return data;
+ },
+ onSuccess: (_data, variables) => {
+ queryClient.invalidateQueries({
+ queryKey: ["workspace-roles", variables.workspaceId],
+ });
+ },
+ });
+}
+
+export default useDeleteWorkspaceRole;
diff --git a/apps/web/src/hooks/mutations/workspace/use-update-workspace-role.ts b/apps/web/src/hooks/mutations/workspace/use-update-workspace-role.ts
new file mode 100644
index 000000000..8b279a859
--- /dev/null
+++ b/apps/web/src/hooks/mutations/workspace/use-update-workspace-role.ts
@@ -0,0 +1,34 @@
+import { useMutation, useQueryClient } from "@tanstack/react-query";
+import { authClient } from "@/lib/auth-client";
+
+type UpdateWorkspaceRoleRequest = {
+ workspaceId: string;
+ roleName: string;
+ permission: Record<string, string[]>;
+};
+
+function useUpdateWorkspaceRole() {
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn: async ({
+ workspaceId,
+ roleName,
+ permission,
+ }: UpdateWorkspaceRoleRequest) => {
+ const { data, error } = await authClient.organization.updateRole({
+ organizationId: workspaceId,
+ roleName,
+ data: { permission },
+ });
+ if (error) throw new Error(error.message || "Failed to update role");
+ return data;
+ },
+ onSuccess: (_data, variables) => {
+ queryClient.invalidateQueries({
+ queryKey: ["workspace-roles", variables.workspaceId],
+ });
+ },
+ });
+}
+
+export default useUpdateWorkspaceRole;
diff --git a/apps/web/src/hooks/queries/instance/use-instance-status.ts b/apps/web/src/hooks/queries/instance/use-instance-status.ts
new file mode 100644
index 000000000..f629832aa
--- /dev/null
+++ b/apps/web/src/hooks/queries/instance/use-instance-status.ts
@@ -0,0 +1,12 @@
+import { useQuery } from "@tanstack/react-query";
+import { getInstanceStatus } from "@/fetchers/instance/get-instance-status";
+
+function useInstanceStatus() {
+ return useQuery({
+ queryKey: ["instance-status"],
+ queryFn: getInstanceStatus,
+ staleTime: 60_000,
+ });
+}
+
+export default useInstanceStatus;
diff --git a/apps/web/src/hooks/queries/workspace/use-workspace-roles.ts b/apps/web/src/hooks/queries/workspace/use-workspace-roles.ts
new file mode 100644
index 000000000..116f19a81
--- /dev/null
+++ b/apps/web/src/hooks/queries/workspace/use-workspace-roles.ts
@@ -0,0 +1,47 @@
+import { useQuery } from "@tanstack/react-query";
+import { authClient } from "@/lib/auth-client";
+
+export type WorkspaceRole = {
+ id: string;
+ workspaceId: string;
+ role: string;
+ permission: Record<string, string[]>;
+ createdAt: Date | string;
+ updatedAt?: Date | string | null;
+};
+
+function useWorkspaceRoles(workspaceId: string | undefined) {
+ return useQuery<WorkspaceRole[]>({
+ queryKey: ["workspace-roles", workspaceId],
+ enabled: !!workspaceId,
+ queryFn: async () => {
+ if (!workspaceId) return [];
+ const result = await authClient.organization.listRoles({
+ query: { organizationId: workspaceId },
+ });
+ if (result.error) throw new Error(result.error.message);
+ const roles = (result.data ?? []) as Array<{
+ id: string;
+ organizationId: string;
+ role: string;
+ permission: string;
+ createdAt: Date | string;
+ updatedAt?: Date | string | null;
+ }>;
+
+ return roles.map((r) => ({
+ id: r.id,
+ workspaceId: r.organizationId,
+ role: r.role,
+ permission:
+ typeof r.permission === "string"
+ ? (JSON.parse(r.permission) as Record<string, string[]>)
+ : (r.permission as unknown as Record<string, string[]>),
+ createdAt: r.createdAt,
+ updatedAt: r.updatedAt,
+ }));
+ },
+ });
+}
+
+export default useWorkspaceRoles;
diff --git a/apps/web/src/hooks/use-workspace-permission.ts b/apps/web/src/hooks/use-workspace-permission.ts
index 5a1205a69..2e1ee1d67 100644
--- a/apps/web/src/hooks/use-workspace-permission.ts
+++ b/apps/web/src/hooks/use-workspace-permission.ts
@@ -9,102 +9,67 @@ export function useWorkspacePermission() {
const { data: activeWorkspace } = useActiveWorkspace();
const { data: activeMember } = useGetActiveWorkspaceUser();
- const permissionCheckers = useMemo(
- () => ({
- // Server-side permission checking (most secure)
- async hasPermission(permissions: Record<string, string[]>) {
- try {
- const result = await authClient.organization.hasPermission({
- permissions,
- });
- return result.data || false;
- } catch (error) {
- console.error("Permission check failed:", error);
- return false;
- }
- },
+ const permissionCheckers = useMemo(() => {
+ const role = activeMember?.role as PermissionLevel | undefined;
- // Client-side role-based checking (faster for UI)
- checkRolePermission(permissions: Record<string, string[]>) {
- if (!activeMember?.role) return false;
- try {
- return authClient.organization.checkRolePermission({
- permissions,
- role: activeMember.role as PermissionLevel,
- });
- } catch (error) {
- console.error("Role permission check failed:", error);
- return false;
- }
- },
-
- // Convenience methods for common checks
- canManageProjects() {
- return this.checkRolePermission({
- project: ["create", "update", "delete"],
- });
- },
-
- canCreateProjects() {
- return this.checkRolePermission({ project: ["create"] });
- },
-
- canManageTasks() {
- return this.checkRolePermission({
- task: ["create", "update", "delete"],
+ const hasPermission = async (permissions: Record<string, string[]>) => {
+ try {
+ const result = await authClient.organization.hasPermission({
+ permissions,
});
- },
-
- canAssignTasks() {
- return this.checkRolePermission({ task: ["assign"] });
- },
-
- canManageWorkspace() {
- return this.checkRolePermission({
- workspace: ["update", "manage_settings"],
+ return result.data || false;
+ } catch (error) {
+ console.error("Permission check failed:", error);
+ return false;
+ }
+ };
+
+ const checkRolePermission = (permissions: Record<string, string[]>) => {
+ if (!role) return false;
+ try {
+ return authClient.organization.checkRolePermission({
+ permissions,
+ role,
});
- },
-
- canDeleteWorkspace() {
- return this.checkRolePermission({ workspace: ["delete"] });
- },
-
- canInviteUsers() {
- return this.checkRolePermission({ team: ["invite"] });
- },
-
- canManageTeam() {
- return this.checkRolePermission({ team: ["remove", "manage_roles"] });
- },
-
- canRemoveMembers() {
- return this.checkRolePermission({ team: ["remove"] });
- },
-
- // Legacy compatibility method
- checkPermission(requiredRole: PermissionLevel = "member"): boolean {
- if (!activeWorkspace || !activeMember) return false;
-
- const userRole = activeMember.role as PermissionLevel;
-
- if (requiredRole === "owner") {
- return userRole === "owner";
- }
-
- if (requiredRole === "admin") {
- return ["owner", "admin"].includes(userRole);
- }
-
- // For member level, all roles have access
- return ["owner", "admin", "member"].includes(userRole);
- },
-
- isOwner: activeMember?.role === "owner",
- isAdmin: ["owner", "admin"].includes(activeMember?.role || ""),
- role: activeMember?.role as PermissionLevel | undefined,
- }),
- [activeMember, activeWorkspace],
- );
+ } catch (error) {
+ console.error("Role permission check failed:", error);
+ return false;
+ }
+ };
+
+ const checkPermission = (
+ requiredRole: PermissionLevel = "member",
+ ): boolean => {
+ if (!activeWorkspace || !activeMember) return false;
+ const userRole = activeMember.role as PermissionLevel;
+ if (requiredRole === "owner") return userRole === "owner";
+ if (requiredRole === "admin")
+ return ["owner", "admin"].includes(userRole);
+ return ["owner", "admin", "member"].includes(userRole);
+ };
+
+ return {
+ hasPermission,
+ checkRolePermission,
+ canManageProjects: () =>
+ checkRolePermission({ project: ["create", "update", "delete"] }),
+ canCreateProjects: () => checkRolePermission({ project: ["create"] }),
+ canManageTasks: () =>
+ checkRolePermission({ task: ["create", "update", "delete"] }),
+ canAssignTasks: () => checkRolePermission({ task: ["assign"] }),
+ canManageWorkspace: () =>
+ checkRolePermission({ workspace: ["update", "manage_settings"] }),
+ canDeleteWorkspace: () => checkRolePermission({ workspace: ["delete"] }),
+ canInviteUsers: () => checkRolePermission({ team: ["invite"] }),
+ canManageTeam: () =>
+ checkRolePermission({ team: ["remove", "manage_roles"] }),
+ canRemoveMembers: () => checkRolePermission({ team: ["remove"] }),
+ checkPermission,
+ isOwner: role === "owner",
+ isAdmin: ["owner", "admin"].includes(role || ""),
+ role,
+ };
+ }, [activeMember, activeWorkspace]);
return {
...permissionCheckers,
diff --git a/apps/web/src/lib/auth-client.ts b/apps/web/src/lib/auth-client.ts
index 30c9928dc..4416f3f19 100644
--- a/apps/web/src/lib/auth-client.ts
+++ b/apps/web/src/lib/auth-client.ts
@@ -1,5 +1,6 @@
import { apiKeyClient } from "@better-auth/api-key/client";
import {
+ adminClient,
anonymousClient,
deviceAuthorizationClient,
emailOTPClient,
@@ -10,7 +11,7 @@ import {
organizationClient,
} from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";
-import { ac, admin, member, owner } from "./permissions";
+import { ac, admin, member, owner, viewer } from "./permissions";
const getBaseURL = () => {
const apiUrl = import.meta.env.VITE_API_URL || "http://localhost:1337";
@@ -33,14 +34,19 @@ export const authClient = createAuthClient({
organizationClient({
ac,
roles: {
+ viewer,
member,
admin,
owner,
},
+ dynamicAccessControl: {
+ enabled: true,
+ },
}),
genericOAuthClient(),
deviceAuthorizationClient(),
apiKeyClient(),
+ adminClient(),
inferAdditionalFields({
user: {
locale: {
diff --git a/apps/web/src/lib/permissions.ts b/apps/web/src/lib/permissions.ts
index 534495874..c4d7e0d37 100644
--- a/apps/web/src/lib/permissions.ts
+++ b/apps/web/src/lib/permissions.ts
@@ -1,45 +1,10 @@
-import { createAccessControl } from "better-auth/plugins/access";
-import {
- adminAc,
- defaultStatements,
- memberAc,
- ownerAc,
-} from "better-auth/plugins/organization/access";
-
-// Define custom permissions for workspace-specific resources
-const statement = {
- ...defaultStatements, // Include default org/member/invitation permissions
- project: ["create", "read", "update", "delete", "share"],
- task: ["create", "read", "update", "delete", "assign"],
- workspace: ["read", "update", "delete", "manage_settings"],
- // team: ["invite", "remove", "manage_roles"],
-} as const;
-
-const ac = createAccessControl(statement);
-
-// Custom role definitions that extend default permissions
-const member = ac.newRole({
- ...memberAc.statements, // Inherit default member permissions
- project: ["create", "read"],
- task: ["create", "read", "update"],
- workspace: ["read"],
- // team: ["invite"], // Members can invite others
-});
-
-const admin = ac.newRole({
- ...adminAc.statements, // Inherit default admin permissions
- project: ["create", "read", "update", "delete", "share"],
- task: ["create", "read", "update", "delete", "assign"],
- workspace: ["read", "update", "manage_settings"],
- // team: ["invite", "remove", "manage_roles"],
-});
-
-const owner = ac.newRole({
- ...ownerAc.statements, // Inherit default owner permissions
- project: ["create", "read", "update", "delete", "share"],
- task: ["create", "read", "update", "delete", "assign"],
- workspace: ["read", "update", "delete", "manage_settings"],
- // team: ["invite", "remove", "manage_roles"],
-});
-
-export { ac, admin, member, owner, statement };
+export {
+ ac,
+ admin,
+ type BuiltInRoleName,
+ builtInRoles,
+ member,
+ owner,
+ statement,
+ viewer,
+} from "@kaneo/permissions";
diff --git a/apps/web/src/routeTree.gen.ts b/apps/web/src/routeTree.gen.ts
index b67999dd7..63b6c0224 100644
--- a/apps/web/src/routeTree.gen.ts
+++ b/apps/web/src/routeTree.gen.ts
@@ -37,7 +37,8 @@ import { Route as LayoutAuthenticatedDashboardSettingsProjectsRouteImport } from
import { Route as LayoutAuthenticatedDashboardSettingsAccountRouteImport } from './routes/_layout/_authenticated/dashboard/settings/account'
import { Route as LayoutAuthenticatedDashboardWorkspaceWorkspaceIdIndexRouteImport } from './routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index'
import { Route as LayoutAuthenticatedDashboardWorkspaceWorkspaceIdSearchRouteImport } from './routes/_layout/_authenticated/dashboard/workspace/$workspaceId/search'
-import { Route as LayoutAuthenticatedDashboardWorkspaceWorkspaceIdMembersRouteImport } from './routes/_layout/_authenticated/dashboard/workspace/$workspaceId/members'
+import { Route as LayoutAuthenticatedDashboardSettingsWorkspaceRolesRouteImport } from './routes/_layout/_authenticated/dashboard/settings/workspace/roles'
+import { Route as LayoutAuthenticatedDashboardSettingsWorkspaceMembersRouteImport } from './routes/_layout/_authenticated/dashboard/settings/workspace/members'
import { Route as LayoutAuthenticatedDashboardSettingsWorkspaceGeneralRouteImport } from './routes/_layout/_authenticated/dashboard/settings/workspace/general'
import { Route as LayoutAuthenticatedDashboardSettingsAccountPreferencesRouteImport } from './routes/_layout/_authenticated/dashboard/settings/account/preferences'
import { Route as LayoutAuthenticatedDashboardSettingsAccountNotificationsRouteImport } from './routes/_layout/_authenticated/dashboard/settings/account/notifications'
@@ -206,11 +207,17 @@ const LayoutAuthenticatedDashboardWorkspaceWorkspaceIdSearchRoute =
path: '/search',
getParentRoute: () => LayoutAuthenticatedDashboardWorkspaceWorkspaceIdRoute,
} as any)
-const LayoutAuthenticatedDashboardWorkspaceWorkspaceIdMembersRoute =
- LayoutAuthenticatedDashboardWorkspaceWorkspaceIdMembersRouteImport.update({
+const LayoutAuthenticatedDashboardSettingsWorkspaceRolesRoute =
+ LayoutAuthenticatedDashboardSettingsWorkspaceRolesRouteImport.update({
+ id: '/roles',
+ path: '/roles',
+ getParentRoute: () => LayoutAuthenticatedDashboardSettingsWorkspaceRoute,
+ } as any)
+const LayoutAuthenticatedDashboardSettingsWorkspaceMembersRoute =
+ LayoutAuthenticatedDashboardSettingsWorkspaceMembersRouteImport.update({
id: '/members',
path: '/members',
- getParentRoute: () => LayoutAuthenticatedDashboardWorkspaceWorkspaceIdRoute,
+ getParentRoute: () => LayoutAuthenticatedDashboardSettingsWorkspaceRoute,
} as any)
const LayoutAuthenticatedDashboardSettingsWorkspaceGeneralRoute =
LayoutAuthenticatedDashboardSettingsWorkspaceGeneralRouteImport.update({
@@ -350,7 +357,8 @@ export interface FileRoutesByFullPath {
'/dashboard/settings/account/notifications': typeof LayoutAuthenticatedDashboardSettingsAccountNotificationsRoute
'/dashboard/settings/account/preferences': typeof LayoutAuthenticatedDashboardSettingsAccountPreferencesRoute
'/dashboard/settings/workspace/general': typeof LayoutAuthenticatedDashboardSettingsWorkspaceGeneralRoute
- '/dashboard/workspace/$workspaceId/members': typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdMembersRoute
+ '/dashboard/settings/workspace/members': typeof LayoutAuthenticatedDashboardSettingsWorkspaceMembersRoute
+ '/dashboard/settings/workspace/roles': typeof LayoutAuthenticatedDashboardSettingsWorkspaceRolesRoute
'/dashboard/workspace/$workspaceId/search': typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdSearchRoute
'/dashboard/workspace/$workspaceId/': typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdIndexRoute
'/dashboard/settings/projects/$projectId/general': typeof LayoutAuthenticatedDashboardSettingsProjectsProjectIdGeneralRoute
@@ -390,7 +398,8 @@ export interface FileRoutesByTo {
'/dashboard/settings/account/notifications': typeof LayoutAuthenticatedDashboardSettingsAccountNotificationsRoute
'/dashboard/settings/account/preferences': typeof LayoutAuthenticatedDashboardSettingsAccountPreferencesRoute
'/dashboard/settings/workspace/general': typeof LayoutAuthenticatedDashboardSettingsWorkspaceGeneralRoute
- '/dashboard/workspace/$workspaceId/members': typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdMembersRoute
+ '/dashboard/settings/workspace/members': typeof LayoutAuthenticatedDashboardSettingsWorkspaceMembersRoute
+ '/dashboard/settings/workspace/roles': typeof LayoutAuthenticatedDashboardSettingsWorkspaceRolesRoute
'/dashboard/workspace/$workspaceId/search': typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdSearchRoute
'/dashboard/workspace/$workspaceId': typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdIndexRoute
'/dashboard/settings/projects/$projectId/general': typeof LayoutAuthenticatedDashboardSettingsProjectsProjectIdGeneralRoute
@@ -436,7 +445,8 @@ export interface FileRoutesById {
'/_layout/_authenticated/dashboard/settings/account/notifications': typeof LayoutAuthenticatedDashboardSettingsAccountNotificationsRoute
'/_layout/_authenticated/dashboard/settings/account/preferences': typeof LayoutAuthenticatedDashboardSettingsAccountPreferencesRoute
'/_layout/_authenticated/dashboard/settings/workspace/general': typeof LayoutAuthenticatedDashboardSettingsWorkspaceGeneralRoute
- '/_layout/_authenticated/dashboard/workspace/$workspaceId/members': typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdMembersRoute
+ '/_layout/_authenticated/dashboard/settings/workspace/members': typeof LayoutAuthenticatedDashboardSettingsWorkspaceMembersRoute
+ '/_layout/_authenticated/dashboard/settings/workspace/roles': typeof LayoutAuthenticatedDashboardSettingsWorkspaceRolesRoute
'/_layout/_authenticated/dashboard/workspace/$workspaceId/search': typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdSearchRoute
'/_layout/_authenticated/dashboard/workspace/$workspaceId/': typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdIndexRoute
'/_layout/_authenticated/dashboard/settings/projects/$projectId/general': typeof LayoutAuthenticatedDashboardSettingsProjectsProjectIdGeneralRoute
@@ -481,7 +491,8 @@ export interface FileRouteTypes {
| '/dashboard/settings/account/notifications'
| '/dashboard/settings/account/preferences'
| '/dashboard/settings/workspace/general'
- | '/dashboard/workspace/$workspaceId/members'
+ | '/dashboard/settings/workspace/members'
+ | '/dashboard/settings/workspace/roles'
| '/dashboard/workspace/$workspaceId/search'
| '/dashboard/workspace/$workspaceId/'
| '/dashboard/settings/projects/$projectId/general'
@@ -521,7 +532,8 @@ export interface FileRouteTypes {
| '/dashboard/settings/account/notifications'
| '/dashboard/settings/account/preferences'
| '/dashboard/settings/workspace/general'
- | '/dashboard/workspace/$workspaceId/members'
+ | '/dashboard/settings/workspace/members'
+ | '/dashboard/settings/workspace/roles'
| '/dashboard/workspace/$workspaceId/search'
| '/dashboard/workspace/$workspaceId'
| '/dashboard/settings/projects/$projectId/general'
@@ -566,7 +578,8 @@ export interface FileRouteTypes {
| '/_layout/_authenticated/dashboard/settings/account/notifications'
| '/_layout/_authenticated/dashboard/settings/account/preferences'
| '/_layout/_authenticated/dashboard/settings/workspace/general'
- | '/_layout/_authenticated/dashboard/workspace/$workspaceId/members'
+ | '/_layout/_authenticated/dashboard/settings/workspace/members'
+ | '/_layout/_authenticated/dashboard/settings/workspace/roles'
| '/_layout/_authenticated/dashboard/workspace/$workspaceId/search'
| '/_layout/_authenticated/dashboard/workspace/$workspaceId/'
| '/_layout/_authenticated/dashboard/settings/projects/$projectId/general'
@@ -788,12 +801,19 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdSearchRouteImport
parentRoute: typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdRoute
}
- '/_layout/_authenticated/dashboard/workspace/$workspaceId/members': {
- id: '/_layout/_authenticated/dashboard/workspace/$workspaceId/members'
+ '/_layout/_authenticated/dashboard/settings/workspace/roles': {
+ id: '/_layout/_authenticated/dashboard/settings/workspace/roles'
+ path: '/roles'
+ fullPath: '/dashboard/settings/workspace/roles'
+ preLoaderRoute: typeof LayoutAuthenticatedDashboardSettingsWorkspaceRolesRouteImport
+ parentRoute: typeof LayoutAuthenticatedDashboardSettingsWorkspaceRoute
+ }
+ '/_layout/_authenticated/dashboard/settings/workspace/members': {
+ id: '/_layout/_authenticated/dashboard/settings/workspace/members'
path: '/members'
- fullPath: '/dashboard/workspace/$workspaceId/members'
- preLoaderRoute: typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdMembersRouteImport
- parentRoute: typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdRoute
+ fullPath: '/dashboard/settings/workspace/members'
+ preLoaderRoute: typeof LayoutAuthenticatedDashboardSettingsWorkspaceMembersRouteImport
+ parentRoute: typeof LayoutAuthenticatedDashboardSettingsWorkspaceRoute
}
'/_layout/_authenticated/dashboard/settings/workspace/general': {
id: '/_layout/_authenticated/dashboard/settings/workspace/general'
@@ -946,12 +966,18 @@ const LayoutAuthenticatedDashboardSettingsProjectsRouteWithChildren =
interface LayoutAuthenticatedDashboardSettingsWorkspaceRouteChildren {
LayoutAuthenticatedDashboardSettingsWorkspaceGeneralRoute: typeof LayoutAuthenticatedDashboardSettingsWorkspaceGeneralRoute
+ LayoutAuthenticatedDashboardSettingsWorkspaceMembersRoute: typeof LayoutAuthenticatedDashboardSettingsWorkspaceMembersRoute
+ LayoutAuthenticatedDashboardSettingsWorkspaceRolesRoute: typeof LayoutAuthenticatedDashboardSettingsWorkspaceRolesRoute
}
const LayoutAuthenticatedDashboardSettingsWorkspaceRouteChildren: LayoutAuthenticatedDashboardSettingsWorkspaceRouteChildren =
{
LayoutAuthenticatedDashboardSettingsWorkspaceGeneralRoute:
LayoutAuthenticatedDashboardSettingsWorkspaceGeneralRoute,
+ LayoutAuthenticatedDashboardSettingsWorkspaceMembersRoute:
+ LayoutAuthenticatedDashboardSettingsWorkspaceMembersRoute,
+ LayoutAuthenticatedDashboardSettingsWorkspaceRolesRoute:
+ LayoutAuthenticatedDashboardSettingsWorkspaceRolesRoute,
}
const LayoutAuthenticatedDashboardSettingsWorkspaceRouteWithChildren =
@@ -981,7 +1007,6 @@ const LayoutAuthenticatedDashboardSettingsRouteWithChildren =
)
interface LayoutAuthenticatedDashboardWorkspaceWorkspaceIdRouteChildren {
- LayoutAuthenticatedDashboardWorkspaceWorkspaceIdMembersRoute: typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdMembersRoute
LayoutAuthenticatedDashboardWorkspaceWorkspaceIdSearchRoute: typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdSearchRoute
LayoutAuthenticatedDashboardWorkspaceWorkspaceIdIndexRoute: typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdIndexRoute
LayoutAuthenticatedDashboardWorkspaceWorkspaceIdProjectProjectIdBacklogRoute: typeof LayoutAuthenticatedDashboardWorkspaceWorkspaceIdProjectProjectIdBacklogRoute
@@ -993,8 +1018,6 @@ interface LayoutAuthenticatedDashboardWorkspaceWorkspaceIdRouteChildren {
const LayoutAuthenticatedDashboardWorkspaceWorkspaceIdRouteChildren: LayoutAuthenticatedDashboardWorkspaceWorkspaceIdRouteChildren =
{
- LayoutAuthenticatedDashboardWorkspaceWorkspaceIdMembersRoute:
- LayoutAuthenticatedDashboardWorkspaceWorkspaceIdMembersRoute,
LayoutAuthenticatedDashboardWorkspaceWorkspaceIdSearchRoute:
LayoutAuthenticatedDashboardWorkspaceWorkspaceIdSearchRoute,
LayoutAuthenticatedDashboardWorkspaceWorkspaceIdIndexRoute:
diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace.tsx
index adfcd886c..ccbd7b033 100644
--- a/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace.tsx
+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace.tsx
@@ -4,7 +4,7 @@ import {
Outlet,
useLocation,
} from "@tanstack/react-router";
-import { Settings } from "lucide-react";
+import { Settings, Shield, Users } from "lucide-react";
import { useTranslation } from "react-i18next";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
@@ -34,6 +34,16 @@ function RouteComponent() {
url: "/dashboard/settings/workspace/general",
icon: Settings,
},
+ {
+ title: t("settings:workspaceMembers.title", { defaultValue: "Members" }),
+ url: "/dashboard/settings/workspace/members",
+ icon: Users,
+ },
+ {
+ title: t("settings:workspaceRoles.title", { defaultValue: "Roles" }),
+ url: "/dashboard/settings/workspace/roles",
+ icon: Shield,
+ },
];
const isActivePath = (path: string) => location.pathname === path;
const workspaceInitials =
diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace/members.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace/members.tsx
new file mode 100644
index 000000000..27273fe49
--- /dev/null
+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace/members.tsx
@@ -0,0 +1,61 @@
+import { createFileRoute } from "@tanstack/react-router";
+import { useState } from "react";
+import { useTranslation } from "react-i18next";
+import PageTitle from "@/components/page-title";
+import InviteTeamMemberModal from "@/components/team/invite-team-member-modal";
+import MembersTable from "@/components/team/members-table";
+import useGetFullWorkspace from "@/hooks/queries/workspace/use-get-full-workspace";
+import { useWorkspacePermission } from "@/hooks/use-workspace-permission";
+
+export const Route = createFileRoute(
+ "/_layout/_authenticated/dashboard/settings/workspace/members",
+)({
+ component: RouteComponent,
+});
+
+function RouteComponent() {
+ const { t } = useTranslation();
+ const { workspace } = useWorkspacePermission();
+ const workspaceId = workspace?.id ?? "";
+ const { data: fullWorkspace } = useGetFullWorkspace({ workspaceId });
+ const [isInviteOpen, setIsInviteOpen] = useState(false);
+
+ const users = fullWorkspace?.members ?? [];
+ const invitations = fullWorkspace?.invitations ?? [];
+
+ return (
+ <>
+ <PageTitle
+ title={t("settings:workspaceMembers.pageTitle", {
+ defaultValue: "Members",
+ })}
+ />
+ <div className="max-w-4xl mx-auto space-y-8">
+ <div className="space-y-2">
+ <h1 className="text-2xl font-semibold">
+ {t("settings:workspaceMembers.title", { defaultValue: "Members" })}
+ </h1>
+ <p className="text-muted-foreground">
+ {t("settings:workspaceMembers.subtitle", {
+ defaultValue:
+ "People with access to {{workspace}} and pending invitations.",
+ workspace: workspace?.name ?? "this workspace",
+ })}
+ </p>
+ </div>
+
+ <MembersTable
+ workspaceId={workspaceId}
+ users={users}
+ invitations={invitations}
+ onInvite={() => setIsInviteOpen(true)}
+ />
+
+ <InviteTeamMemberModal
+ open={isInviteOpen}
+ onClose={() => setIsInviteOpen(false)}
+ />
+ </div>
+ </>
+ );
+}
diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace/roles.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace/roles.tsx
new file mode 100644
index 000000000..32b780e4e
--- /dev/null
+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace/roles.tsx
@@ -0,0 +1,725 @@
+import { statement } from "@kaneo/permissions";
+import { createFileRoute } from "@tanstack/react-router";
+import { Lock, Plus, Shield, Trash2, X } from "lucide-react";
+import { useMemo, useState } from "react";
+import PageTitle from "@/components/page-title";
+import {
+ Accordion,
+ AccordionItem,
+ AccordionPanel,
+ AccordionTrigger,
+} from "@/components/ui/accordion";
+import {
+ AlertDialog,
+ AlertDialogClose,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+} from "@/components/ui/alert-dialog";
+import { Button } from "@/components/ui/button";
+import {
+ Empty,
+ EmptyDescription,
+ EmptyHeader,
+ EmptyMedia,
+ EmptyTitle,
+} from "@/components/ui/empty";
+import { Input } from "@/components/ui/input";
+import { Label } from "@/components/ui/label";
+import { Separator } from "@/components/ui/separator";
+import { Switch } from "@/components/ui/switch";
+import useCreateWorkspaceRole from "@/hooks/mutations/workspace/use-create-workspace-role";
+import useDeleteWorkspaceRole from "@/hooks/mutations/workspace/use-delete-workspace-role";
+import useUpdateWorkspaceRole from "@/hooks/mutations/workspace/use-update-workspace-role";
+import useWorkspaceRoles, {
+ type WorkspaceRole,
+} from "@/hooks/queries/workspace/use-workspace-roles";
+import { useWorkspacePermission } from "@/hooks/use-workspace-permission";
+import { toast } from "@/lib/toast";
+
+export const Route = createFileRoute(
+ "/_layout/_authenticated/dashboard/settings/workspace/roles",
+)({
+ component: RouteComponent,
+});
+
+type CustomResource = "project" | "task" | "workspace";
+const CUSTOM_RESOURCES: CustomResource[] = ["project", "task", "workspace"];
+
+const RESOURCE_LABELS: Record<CustomResource, string> = {
+ project: "Projects",
+ task: "Tasks",
+ workspace: "Workspace",
+};
+
+const PERMISSION_LABELS: Record<
+ string,
+ { label: string; description: string }
+> = {
+ "project:create": {
+ label: "Create projects",
+ description: "Create new projects in this workspace.",
+ },
+ "project:read": {
+ label: "View projects",
+ description: "View projects and their details.",
+ },
+ "project:update": {
+ label: "Edit projects",
+ description: "Update project name, icon, description, and settings.",
+ },
+ "project:delete": {
+ label: "Delete projects",
+ description: "Permanently delete projects in this workspace.",
+ },
+ "project:share": {
+ label: "Share projects",
+ description: "Make projects publicly accessible via share links.",
+ },
+ "task:create": {
+ label: "Create tasks",
+ description: "Create new tasks in any project.",
+ },
+ "task:read": {
+ label: "View tasks",
+ description: "View tasks across projects.",
+ },
+ "task:update": {
+ label: "Edit tasks",
+ description: "Edit task content, status, priority, due date, and labels.",
+ },
+ "task:delete": {
+ label: "Delete tasks",
+ description: "Permanently delete tasks.",
+ },
+ "task:assign": {
+ label: "Assign tasks",
+ description: "Assign tasks to other workspace members.",
+ },
+ "workspace:read": {
+ label: "Access workspace",
+ description: "Read workspace metadata and members.",
+ },
+ "workspace:update": {
+ label: "Edit workspace",
+ description: "Edit workspace name and description.",
+ },
+ "workspace:delete": {
+ label: "Delete workspace",
+ description: "Permanently delete this workspace.",
+ },
+ "workspace:manage_settings": {
+ label: "Manage settings",
+ description:
+ "Configure integrations, notification rules, and workspace preferences.",
+ },
+};
+
+const BUILT_IN_ROLES: Array<{
+ name: string;
+ description: string;
+ permissions: Partial<Record<CustomResource, string[]>>;
+}> = [
+ {
+ name: "viewer",
+ description: "Read-only access to projects, tasks, and workspace.",
+ permissions: { project: ["read"], task: ["read"], workspace: ["read"] },
+ },
+ {
+ name: "member",
+ description: "Can create and update projects and tasks.",
+ permissions: {
+ project: ["create", "read"],
+ task: ["create", "read", "update"],
+ workspace: ["read"],
+ },
+ },
+ {
+ name: "admin",
+ description: "Full project and task management plus workspace settings.",
+ permissions: {
+ project: ["create", "read", "update", "delete", "share"],
+ task: ["create", "read", "update", "delete", "assign"],
+ workspace: ["read", "update", "manage_settings"],
+ },
+ },
+ {
+ name: "owner",
+ description: "Full access including workspace deletion.",
+ permissions: {
+ project: ["create", "read", "update", "delete", "share"],
+ task: ["create", "read", "update", "delete", "assign"],
+ workspace: ["read", "update", "delete", "manage_settings"],
+ },
+ },
+];
+
+function permissionsEqual(
+ a: Record<string, string[]>,
+ b: Record<string, string[]>,
+): boolean {
+ const keys = new Set([...Object.keys(a), ...Object.keys(b)]);
+ for (const key of keys) {
+ const arrA = [...(a[key] ?? [])].sort();
+ const arrB = [...(b[key] ?? [])].sort();
+ if (arrA.length !== arrB.length) return false;
+ for (let i = 0; i < arrA.length; i++) {
+ if (arrA[i] !== arrB[i]) return false;
+ }
+ }
+ return true;
+}
+
+function permissionCount(permissions: Record<string, string[] | undefined>) {
+ return Object.values(permissions).reduce(
+ (sum, actions) => sum + (actions?.length ?? 0),
+ 0,
+ );
+}
+
+function RouteComponent() {
+ const { workspace, isAdmin } = useWorkspacePermission();
+ const workspaceId = workspace?.id ?? "";
+ const { data: customRoles = [], isLoading } = useWorkspaceRoles(workspaceId);
+ const [draftActive, setDraftActive] = useState(false);
+ const [roleToDelete, setRoleToDelete] = useState<WorkspaceRole | null>(null);
+ const [openCustom, setOpenCustom] = useState<string[]>([]);
+
+ if (!isAdmin) {
+ return (
+ <>
+ <PageTitle title="Roles" />
+ <div className="max-w-4xl mx-auto space-y-8">
+ <div className="space-y-2">
+ <h1 className="text-2xl font-semibold">Roles</h1>
+ <p className="text-muted-foreground">
+ You need admin or owner permissions to manage workspace roles.
+ </p>
+ </div>
+ </div>
+ </>
+ );
+ }
+
+ return (
+ <>
+ <PageTitle title="Roles" />
+ <div className="max-w-4xl mx-auto space-y-8">
+ <div className="space-y-2">
+ <h1 className="text-2xl font-semibold">Roles</h1>
+ <p className="text-muted-foreground">
+ Define which actions members can perform in{" "}
+ {workspace?.name ?? "this workspace"}.
+ </p>
+ </div>
+
+ <div className="space-y-6">
+ <div className="space-y-1">
+ <h2 className="text-md font-medium">Built-in roles</h2>
+ <p className="text-xs text-muted-foreground">
+ Default roles available in every workspace. Click to inspect the
+ permissions they grant.
+ </p>
+ </div>
+ <div className="border border-border rounded-md bg-sidebar">
+ <Accordion>
+ {BUILT_IN_ROLES.map((role) => (
+ <AccordionItem
+ key={role.name}
+ value={role.name}
+ className="border-b border-border last:border-b-0"
+ >
+ <AccordionTrigger className="px-4">
+ <div className="flex items-center gap-3 min-w-0">
+ <Lock className="w-3.5 h-3.5 text-muted-foreground shrink-0" />
+ <div className="min-w-0">
+ <p className="text-sm font-medium capitalize">
+ {role.name}
+ </p>
+ <p className="text-xs font-normal text-muted-foreground truncate">
+ {role.description}
+ </p>
+ </div>
+ </div>
+ </AccordionTrigger>
+ <AccordionPanel className="px-0 pt-0 pb-0">
+ <PermissionList permissions={role.permissions} readOnly />
+ </AccordionPanel>
+ </AccordionItem>
+ ))}
+ </Accordion>
+ </div>
+ </div>
+
+ <div className="space-y-6">
+ <div className="flex items-start justify-between gap-4">
+ <div className="space-y-1">
+ <h2 className="text-md font-medium">Custom roles</h2>
+ <p className="text-xs text-muted-foreground">
+ Roles you've defined for this workspace.
+ </p>
+ </div>
+ <Button
+ size="sm"
+ className="gap-1.5"
+ onClick={() => {
+ setDraftActive(true);
+ setOpenCustom((prev) =>
+ prev.includes("__draft__") ? prev : [...prev, "__draft__"],
+ );
+ }}
+ disabled={draftActive}
+ >
+ <Plus className="w-3.5 h-3.5" />
+ New role
+ </Button>
+ </div>
+ <div className="border border-border rounded-md bg-sidebar">
+ {isLoading && !draftActive ? (
+ <p className="text-xs text-muted-foreground px-4 py-6">
+ Loading…
+ </p>
+ ) : customRoles.length === 0 && !draftActive ? (
+ <Empty>
+ <EmptyHeader>
+ <EmptyMedia variant="icon">
+ <Shield />
+ </EmptyMedia>
+ <EmptyTitle>No custom roles yet</EmptyTitle>
+ <EmptyDescription>
+ Create one to grant a tailored permission set.
+ </EmptyDescription>
+ </EmptyHeader>
+ </Empty>
+ ) : (
+ <Accordion
+ openMultiple
+ value={openCustom}
+ onValueChange={(value) =>
+ setOpenCustom(Array.isArray(value) ? value : [value])
+ }
+ >
+ {draftActive && (
+ <AccordionItem
+ value="__draft__"
+ className="border-b border-border last:border-b-0"
+ >
+ <AccordionTrigger className="px-4">
+ <div className="flex items-center gap-3 min-w-0">
+ <Shield className="w-3.5 h-3.5 text-muted-foreground shrink-0" />
+ <p className="text-sm font-medium italic">New role</p>
+ </div>
+ </AccordionTrigger>
+ <AccordionPanel className="px-0 pt-0 pb-0">
+ <DraftEditor
+ workspaceId={workspaceId}
+ existingNames={[
+ ...BUILT_IN_ROLES.map((r) => r.name),
+ ...customRoles.map((r) => r.role),
+ ]}
+ onCreated={(roleName) => {
+ setDraftActive(false);
+ setOpenCustom((prev) => [
+ ...prev.filter((v) => v !== "__draft__"),
+ roleName,
+ ]);
+ }}
+ onDiscard={() => {
+ setDraftActive(false);
+ setOpenCustom((prev) =>
+ prev.filter((v) => v !== "__draft__"),
+ );
+ }}
+ />
+ </AccordionPanel>
+ </AccordionItem>
+ )}
+ {customRoles.map((role) => (
+ <AccordionItem
+ key={role.id}
+ value={role.role}
+ className="border-b border-border last:border-b-0"
+ >
+ <AccordionTrigger className="px-4">
+ <div className="flex items-center justify-between gap-4 flex-1 min-w-0">
+ <div className="flex items-center gap-3 min-w-0">
+ <Shield className="w-3.5 h-3.5 text-muted-foreground shrink-0" />
+ <p className="text-sm font-medium capitalize truncate">
+ {role.role}
+ </p>
+ </div>
+ <p className="text-xs font-normal text-muted-foreground shrink-0">
+ {permissionCount(role.permission)} permissions
+ </p>
+ </div>
+ </AccordionTrigger>
+ <AccordionPanel className="px-0 pt-0 pb-0">
+ <CustomRoleEditor
+ key={role.id}
+ workspaceId={workspaceId}
+ role={role}
+ onDelete={() => setRoleToDelete(role)}
+ />
+ </AccordionPanel>
+ </AccordionItem>
+ ))}
+ </Accordion>
+ )}
+ </div>
+ </div>
+ </div>
+
+ <AlertDialog
+ open={!!roleToDelete}
+ onOpenChange={(open) => !open && setRoleToDelete(null)}
+ >
+ <DeleteRoleConfirm
+ role={roleToDelete}
+ workspaceId={workspaceId}
+ onDeleted={() => {
+ setOpenCustom((prev) =>
+ prev.filter((v) => v !== roleToDelete?.role),
+ );
+ setRoleToDelete(null);
+ }}
+ onCancel={() => setRoleToDelete(null)}
+ />
+ </AlertDialog>
+ </>
+ );
+}
+
+function PermissionList({
+ permissions,
+ selected,
+ onToggle,
+ readOnly,
+ disabled,
+}: {
+ permissions: Partial<Record<string, string[]>>;
+ selected?: Record<string, Set<string>>;
+ onToggle?: (resource: string, action: string) => void;
+ readOnly?: boolean;
+ disabled?: boolean;
+}) {
+ const groups = useMemo(
+ () =>
+ CUSTOM_RESOURCES.map((resource) => ({
+ resource,
+ actions: [...(statement[resource] ?? [])] as string[],
+ })),
+ [],
+ );
+
+ const isChecked = (resource: string, action: string) => {
+ if (selected) return selected[resource]?.has(action) ?? false;
+ return permissions[resource]?.includes(action) ?? false;
+ };
+
+ return (
+ <div className="border-t border-border">
+ {groups.map(({ resource, actions }, groupIndex) => (
+ <div key={resource}>
+ {groupIndex > 0 && <Separator />}
+ <div className="space-y-4 p-4">
+ <p className="text-sm font-medium capitalize">
+ {RESOURCE_LABELS[resource as CustomResource]}
+ </p>
+ <div className="space-y-4">
+ {actions.map((action, idx) => {
+ const meta = PERMISSION_LABELS[`${resource}:${action}`] ?? {
+ label: `${action} ${resource}`,
+ description: "",
+ };
+ return (
+ <div key={`${resource}:${action}`}>
+ {idx > 0 && <Separator className="mb-4" />}
+ <div className="flex items-center justify-between gap-6">
+ <div className="space-y-0.5 flex-1 min-w-0">
+ <Label className="text-sm font-medium">
+ {meta.label}
+ </Label>
+ {meta.description && (
+ <p className="text-xs text-muted-foreground">
+ {meta.description}
+ </p>
+ )}
+ </div>
+ <Switch
+ checked={isChecked(resource, action)}
+ onCheckedChange={
+ readOnly || !onToggle
+ ? undefined
+ : () => onToggle(resource, action)
+ }
+ disabled={readOnly || disabled}
+ />
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ </div>
+ ))}
+ </div>
+ );
+}
+
+function DraftEditor({
+ workspaceId,
+ existingNames,
+ onCreated,
+ onDiscard,
+}: {
+ workspaceId: string;
+ existingNames: string[];
+ onCreated: (roleName: string) => void;
+ onDiscard: () => void;
+}) {
+ const [name, setName] = useState("");
+ const [permissions, setPermissions] = useState<Record<string, Set<string>>>(
+ {},
+ );
+ const { mutateAsync: createRole, isPending } = useCreateWorkspaceRole();
+
+ const togglePermission = (resource: string, action: string) => {
+ setPermissions((prev) => {
+ const next = { ...prev };
+ const set = new Set(next[resource] ?? []);
+ if (set.has(action)) set.delete(action);
+ else set.add(action);
+ next[resource] = set;
+ return next;
+ });
+ };
+
+ const handleCreate = async () => {
+ const trimmed = name.trim().toLowerCase();
+ if (!trimmed) {
+ toast.error("Name is required");
+ return;
+ }
+ if (existingNames.map((n) => n.toLowerCase()).includes(trimmed)) {
+ toast.error("A role with that name already exists");
+ return;
+ }
+ const permission: Record<string, string[]> = {};
+ for (const [r, set] of Object.entries(permissions)) {
+ if (set.size > 0) permission[r] = Array.from(set);
+ }
+ if (Object.keys(permission).length === 0) {
+ toast.error("Select at least one permission");
+ return;
+ }
+ try {
+ await createRole({ workspaceId, role: trimmed, permission });
+ toast.success("Role created");
+ onCreated(trimmed);
+ } catch (error) {
+ toast.error(
+ error instanceof Error ? error.message : "Failed to create role",
+ );
+ }
+ };
+
+ return (
+ <div>
+ <div className="border-t border-border">
+ <div className="flex items-center justify-between gap-4 px-4 py-3">
+ <div className="space-y-0.5">
+ <Label className="text-sm font-medium">Name</Label>
+ <p className="text-xs text-muted-foreground">
+ Lowercase. Cannot be changed later.
+ </p>
+ </div>
+ <Input
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ placeholder="e.g. reviewer"
+ className="w-64"
+ autoFocus
+ disabled={isPending}
+ />
+ </div>
+ </div>
+ <PermissionList
+ permissions={{}}
+ selected={permissions}
+ onToggle={togglePermission}
+ disabled={isPending}
+ />
+ <Separator />
+ <div className="flex justify-end gap-2 px-4 py-3">
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={onDiscard}
+ disabled={isPending}
+ >
+ <X className="w-4 h-4" />
+ Discard
+ </Button>
+ <Button size="sm" onClick={handleCreate} disabled={isPending}>
+ Create role
+ </Button>
+ </div>
+ </div>
+ );
+}
+
+function CustomRoleEditor({
+ workspaceId,
+ role,
+ onDelete,
+}: {
+ workspaceId: string;
+ role: WorkspaceRole;
+ onDelete: () => void;
+}) {
+ const [permissions, setPermissions] = useState<Record<string, Set<string>>>(
+ () => {
+ const out: Record<string, Set<string>> = {};
+ for (const [r, actions] of Object.entries(role.permission)) {
+ out[r] = new Set(actions);
+ }
+ return out;
+ },
+ );
+ const { mutateAsync: updateRole, isPending } = useUpdateWorkspaceRole();
+
+ const currentPermissions = useMemo(() => {
+ const out: Record<string, string[]> = {};
+ for (const [r, set] of Object.entries(permissions)) {
+ if (set.size > 0) out[r] = Array.from(set);
+ }
+ return out;
+ }, [permissions]);
+
+ const dirty = !permissionsEqual(currentPermissions, role.permission);
+
+ const togglePermission = (resource: string, action: string) => {
+ setPermissions((prev) => {
+ const next = { ...prev };
+ const set = new Set(next[resource] ?? []);
+ if (set.has(action)) set.delete(action);
+ else set.add(action);
+ next[resource] = set;
+ return next;
+ });
+ };
+
+ const handleSave = async () => {
+ if (Object.keys(currentPermissions).length === 0) {
+ toast.error("Select at least one permission");
+ return;
+ }
+ try {
+ await updateRole({
+ workspaceId,
+ roleName: role.role,
+ permission: currentPermissions,
+ });
+ toast.success("Role updated");
+ } catch (error) {
+ toast.error(
+ error instanceof Error ? error.message : "Failed to update role",
+ );
+ }
+ };
+
+ return (
+ <div>
+ <PermissionList
+ permissions={role.permission}
+ selected={permissions}
+ onToggle={togglePermission}
+ disabled={isPending}
+ />
+ <Separator />
+ <div className="flex items-center justify-between gap-2 px-4 py-3">
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={onDelete}
+ className="text-destructive hover:text-destructive"
+ disabled={isPending}
+ >
+ <Trash2 className="w-4 h-4" />
+ Delete role
+ </Button>
+ <div className="flex items-center gap-3">
+ <p className="text-xs text-muted-foreground">
+ {dirty ? "You have unsaved changes" : "All changes saved"}
+ </p>
+ <Button size="sm" onClick={handleSave} disabled={isPending || !dirty}>
+ Save changes
+ </Button>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+function DeleteRoleConfirm({
+ role,
+ workspaceId,
+ onDeleted,
+ onCancel,
+}: {
+ role: WorkspaceRole | null;
+ workspaceId: string;
+ onDeleted: () => void;
+ onCancel: () => void;
+}) {
+ const { mutateAsync: deleteRole, isPending } = useDeleteWorkspaceRole();
+
+ return (
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>Delete role</AlertDialogTitle>
+ <AlertDialogDescription>
+ {role
+ ? `This will permanently delete the role "${role.role}". Members assigned to this role will lose its permissions.`
+ : ""}
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogClose disabled={isPending}>
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={isPending}
+ onClick={onCancel}
+ >
+ Cancel
+ </Button>
+ </AlertDialogClose>
+ <AlertDialogClose
+ onClick={async () => {
+ if (!role) return;
+ try {
+ await deleteRole({ workspaceId, roleName: role.role });
+ toast.success("Role deleted");
+ onDeleted();
+ } catch (error) {
+ toast.error(
+ error instanceof Error
+ ? error.message
+ : "Failed to delete role",
+ );
+ }
+ }}
+ disabled={isPending}
+ >
+ <Button variant="destructive" size="sm" disabled={isPending}>
+ <Trash2 className="w-4 h-4 mr-2" />
+ Delete
+ </Button>
+ </AlertDialogClose>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ );
+}
diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index.tsx
index b10f6dfad..78c602555 100644
--- a/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index.tsx
+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index.tsx
@@ -29,6 +29,7 @@ import icons from "@/constants/project-icons";
import { shortcuts } from "@/constants/shortcuts";
import useGetProjects from "@/hooks/queries/project/use-get-projects";
import { useRegisterShortcuts } from "@/hooks/use-keyboard-shortcuts";
+import { useWorkspacePermission } from "@/hooks/use-workspace-permission";
import { formatDateMedium } from "@/lib/format";
export const Route = createFileRoute(
@@ -45,8 +46,11 @@ function RouteComponent() {
const { data: projects, isLoading } = useGetProjects({
workspaceId,
});
+ const { canCreateProjects } = useWorkspacePermission();
+ const canCreate = canCreateProjects();
const handleCreateProject = () => {
+ if (!canCreate) return;
setIsCreateProjectOpen(true);
};
@@ -72,15 +76,17 @@ function RouteComponent() {
<WorkspaceLayout
title={t("workspace:projects.pageTitle")}
headerActions={
- <Button
- variant="outline"
- size="xs"
- onClick={handleCreateProject}
- className="gap-1"
- >
- <Plus className="w-3 h-3" />
- {t("workspace:projects.createProject")}
- </Button>
+ canCreate ? (
+ <Button
+ variant="outline"
+ size="xs"
+ onClick={handleCreateProject}
+ className="gap-1"
+ >
+ <Plus className="w-3 h-3" />
+ {t("workspace:projects.createProject")}
+ </Button>
+ ) : null
}
>
<Table>
@@ -134,15 +140,17 @@ function RouteComponent() {
<WorkspaceLayout
title={t("workspace:projects.pageTitle")}
headerActions={
- <Button
- variant="outline"
- size="xs"
- onClick={handleCreateProject}
- className="gap-1"
- >
- <Plus className="w-3 h-3" />
- {t("workspace:projects.createProject")}
- </Button>
+ canCreate ? (
+ <Button
+ variant="outline"
+ size="xs"
+ onClick={handleCreateProject}
+ className="gap-1"
+ >
+ <Plus className="w-3 h-3" />
+ {t("workspace:projects.createProject")}
+ </Button>
+ ) : null
}
>
<Empty className="min-h-[60vh]">
@@ -156,10 +164,12 @@ function RouteComponent() {
</EmptyDescription>
</EmptyHeader>
<EmptyContent>
- <Button onClick={handleCreateProject}>
- <Plus />
- {t("workspace:projects.createProject")}
- </Button>
+ {canCreate && (
+ <Button onClick={handleCreateProject}>
+ <Plus />
+ {t("workspace:projects.createProject")}
+ </Button>
+ )}
</EmptyContent>
</Empty>
</WorkspaceLayout>
diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/members.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/members.tsx
deleted file mode 100644
index d738aaaf7..000000000
--- a/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/members.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import { createFileRoute } from "@tanstack/react-router";
-import { UserPlus } from "lucide-react";
-import { useState } from "react";
-import { useTranslation } from "react-i18next";
-import WorkspaceLayout from "@/components/common/workspace-layout";
-import PageTitle from "@/components/page-title";
-import InviteTeamMemberModal from "@/components/team/invite-team-member-modal";
-import MembersTable from "@/components/team/members-table";
-import { Button } from "@/components/ui/button";
-import useGetFullWorkspace from "@/hooks/queries/workspace/use-get-full-workspace";
-
-export const Route = createFileRoute(
- "/_layout/_authenticated/dashboard/workspace/$workspaceId/members",
-)({
- component: RouteComponent,
-});
-
-function RouteComponent() {
- const { t } = useTranslation();
- const { workspaceId } = Route.useParams();
- const { data: workspace } = useGetFullWorkspace({ workspaceId });
-
- const [isInviteTeamMemberModalOpen, setIsInviteTeamMemberModalOpen] =
- useState(false);
-
- const users = workspace?.members;
- const userInvitations = workspace?.invitations;
-
- return (
- <>
- <PageTitle title={t("team:members.pageTitle")} />
- <WorkspaceLayout
- title={t("team:members.pageTitle")}
- headerActions={
- <Button
- onClick={() => setIsInviteTeamMemberModalOpen(true)}
- variant="outline"
- size="xs"
- className="gap-1 w-full md:w-auto"
- >
- <UserPlus className="w-3 h-3" />
- {t("team:members.inviteMember")}
- </Button>
- }
- >
- <MembersTable users={users ?? []} invitations={userInvitations ?? []} />
-
- <InviteTeamMemberModal
- open={isInviteTeamMemberModalOpen}
- onClose={() => setIsInviteTeamMemberModalOpen(false)}
- />
- </WorkspaceLayout>
- </>
- );
-}
diff --git a/apps/web/src/routes/auth/sign-in.tsx b/apps/web/src/routes/auth/sign-in.tsx
index b47c2fe89..70405cf71 100644
--- a/apps/web/src/routes/auth/sign-in.tsx
+++ b/apps/web/src/routes/auth/sign-in.tsx
@@ -4,13 +4,14 @@ import {
useSearch,
} from "@tanstack/react-router";
import { Github, KeyRound, UserCheck } from "lucide-react";
-import { useState } from "react";
+import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { z } from "zod/v4";
import PageTitle from "@/components/page-title";
import { Alert, AlertDescription } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
import useGetConfig from "@/hooks/queries/config/use-get-config";
+import useInstanceStatus from "@/hooks/queries/instance/use-instance-status";
import { authClient } from "@/lib/auth-client";
import { cn } from "@/lib/cn";
import { toast } from "@/lib/toast";
@@ -42,6 +43,13 @@ function SignIn() {
const [isGuestLoading, setIsGuestLoading] = useState(false);
const lastLoginMethod = authClient.getLastUsedLoginMethod();
const { data: config, isLoading: isConfigLoading } = useGetConfig();
+ const { data: instanceStatus } = useInstanceStatus();
+
+ useEffect(() => {
+ if (instanceStatus && instanceStatus.hasUsers === false) {
+ navigate({ to: "/auth/sign-up", replace: true });
+ }
+ }, [instanceStatus, navigate]);
const invitationId = search.invitationId;
const defaultEmail = search.email;
diff --git a/apps/web/src/routes/auth/sign-up.tsx b/apps/web/src/routes/auth/sign-up.tsx
index 22fc6ab08..ca5048695 100644
--- a/apps/web/src/routes/auth/sign-up.tsx
+++ b/apps/web/src/routes/auth/sign-up.tsx
@@ -9,11 +9,13 @@ import { useTranslation } from "react-i18next";
import { z } from "zod/v4";
import { AuthLayout } from "@/components/auth/layout";
import { SignUpForm } from "@/components/auth/sign-up-form";
+import { SSOProviders } from "@/components/auth/sso-providers";
import { AuthToggle } from "@/components/auth/toggle";
import PageTitle from "@/components/page-title";
import { Alert, AlertDescription } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
import useGetConfig from "@/hooks/queries/config/use-get-config";
+import useInstanceStatus from "@/hooks/queries/instance/use-instance-status";
import { authClient } from "@/lib/auth-client";
import { toast } from "@/lib/toast";
@@ -33,9 +35,17 @@ function SignUp() {
const search = useSearch({ from: "/auth/sign-up" });
const [isGuestLoading, setIsGuestLoading] = useState(false);
const { data: config } = useGetConfig();
+ const { data: instanceStatus } = useInstanceStatus();
const invitationId = search.invitationId;
const prefillEmail = search.email;
+ const isInstanceAdminSetup = instanceStatus?.hasUsers === false;
+
+ const baseUrl = import.meta.env.VITE_CLIENT_URL ?? window.location.origin;
+ const callbackURL = invitationId
+ ? `${baseUrl}/invitation/accept/${invitationId}`
+ : `${baseUrl}/dashboard`;
+ const errorCallbackURL = `${baseUrl}/auth/sign-up`;
const handleGuestAccess = async () => {
setIsGuestLoading(true);
@@ -59,15 +69,26 @@ function SignUp() {
<>
<PageTitle title={t("auth:signUp.pageTitle")} />
<AuthLayout
- title={t("auth:signUp.title")}
+ title={
+ isInstanceAdminSetup
+ ? t("auth:signUp.instanceAdminTitle", {
+ defaultValue: "Set up your Kaneo instance",
+ })
+ : t("auth:signUp.title")
+ }
subtitle={
- invitationId
- ? t("auth:signUp.subtitleInvitation")
- : config?.disableRegistration
- ? t("auth:signUp.subtitleRegistrationDisabled")
- : config?.disablePasswordRegistration
- ? t("auth:signUp.subtitlePasswordDisabled")
- : t("auth:signUp.subtitleDefault")
+ isInstanceAdminSetup
+ ? t("auth:signUp.instanceAdminSubtitle", {
+ defaultValue:
+ "This account becomes the instance administrator with full access.",
+ })
+ : invitationId
+ ? t("auth:signUp.subtitleInvitation")
+ : config?.disableRegistration
+ ? t("auth:signUp.subtitleRegistrationDisabled")
+ : config?.disablePasswordRegistration
+ ? t("auth:signUp.subtitlePasswordDisabled")
+ : t("auth:signUp.subtitleDefault")
}
>
<div className="space-y-4 mt-6">
@@ -78,14 +99,16 @@ function SignUp() {
</AlertDescription>
</Alert>
)}
- {config?.disableRegistration && !invitationId && (
- <Alert>
- <AlertDescription>
- {t("auth:signUp.registrationDisabledAlert")}
- </AlertDescription>
- </Alert>
- )}
- {config?.disablePasswordRegistration && (
+ {config?.disableRegistration &&
+ !invitationId &&
+ !isInstanceAdminSetup && (
+ <Alert>
+ <AlertDescription>
+ {t("auth:signUp.registrationDisabledAlert")}
+ </AlertDescription>
+ </Alert>
+ )}
+ {config?.disablePasswordRegistration && !isInstanceAdminSetup && (
<Alert>
<AlertDescription>
{t("auth:signUp.passwordDisabledAlert")}
@@ -93,22 +116,44 @@ function SignUp() {
</Alert>
)}
- {config?.hasGuestAccess &&
- !invitationId &&
- !config?.disablePasswordRegistration && (
+ {(() => {
+ const ssoNode = (
+ <SSOProviders
+ config={config}
+ callbackURL={callbackURL}
+ errorCallbackURL={errorCallbackURL}
+ />
+ );
+ const hasGuest =
+ config?.hasGuestAccess &&
+ !invitationId &&
+ !isInstanceAdminSetup &&
+ !config?.disablePasswordRegistration;
+ const hasAnySso =
+ config?.hasGoogleSignIn ||
+ config?.hasGithubSignIn ||
+ config?.hasDiscordSignIn ||
+ config?.hasCustomOAuth;
+ const showAlternatives = hasGuest || hasAnySso;
+ if (!showAlternatives) return null;
+ return (
<>
- <Button
- variant="outline"
- onClick={handleGuestAccess}
- disabled={isGuestLoading}
- className="w-full mb-0"
- size="sm"
- >
- <UserCheck className="w-4 h-4 mr-2" />
- {isGuestLoading
- ? t("auth:signUp.signingIn")
- : t("auth:signUp.continueAsGuest")}
- </Button>
+ <div className="space-y-3">
+ {ssoNode}
+ {hasGuest && (
+ <Button
+ variant="outline"
+ onClick={handleGuestAccess}
+ disabled={isGuestLoading}
+ className="w-full"
+ >
+ <UserCheck className="w-4 h-4 mr-2" />
+ {isGuestLoading
+ ? t("auth:signUp.signingIn")
+ : t("auth:signUp.continueAsGuest")}
+ </Button>
+ )}
+ </div>
<div className="flex items-center gap-4 my-4">
<div className="flex-1 h-px bg-border" />
<span className="text-sm text-muted-foreground">
@@ -117,18 +162,21 @@ function SignUp() {
<div className="flex-1 h-px bg-border" />
</div>
</>
- )}
- {!config?.disablePasswordRegistration && (
+ );
+ })()}
+ {(!config?.disablePasswordRegistration || isInstanceAdminSetup) && (
<SignUpForm
invitationId={invitationId}
defaultEmail={prefillEmail}
/>
)}
- <AuthToggle
- message={t("auth:signUp.toggleMessage")}
- linkText={t("auth:signUp.toggleLink")}
- linkTo="/auth/sign-in"
- />
+ {!isInstanceAdminSetup && (
+ <AuthToggle
+ message={t("auth:signUp.toggleMessage")}
+ linkText={t("auth:signUp.toggleLink")}
+ linkTo="/auth/sign-in"
+ />
+ )}
</div>
</AuthLayout>
</>
diff --git a/packages/permissions/package.json b/packages/permissions/package.json
new file mode 100644
index 000000000..2f9e8d36f
--- /dev/null
+++ b/packages/permissions/package.json
@@ -0,0 +1,25 @@
+{
+ "name": "@kaneo/permissions",
+ "version": "0.0.0",
+ "private": true,
+ "type": "module",
+ "main": "./src/index.ts",
+ "types": "./src/index.ts",
+ "exports": {
+ ".": {
+ "types": "./src/index.ts",
+ "default": "./src/index.ts"
+ }
+ },
+ "license": "MIT",
+ "scripts": {
+ "lint": "biome check --write ."
+ },
+ "dependencies": {
+ "better-auth": "^1.6.9"
+ },
+ "devDependencies": {
+ "@kaneo/typescript-config": "workspace:*",
+ "typescript": "^5.9.2"
+ }
+}
diff --git a/packages/permissions/src/index.ts b/packages/permissions/src/index.ts
new file mode 100644
index 000000000..3fe90e3d5
--- /dev/null
+++ b/packages/permissions/src/index.ts
@@ -0,0 +1,48 @@
+import { createAccessControl } from "better-auth/plugins/access";
+import {
+ adminAc,
+ defaultStatements,
+ memberAc,
+ ownerAc,
+} from "better-auth/plugins/organization/access";
+
+export const statement = {
+ ...defaultStatements,
+ project: ["create", "read", "update", "delete", "share"],
+ task: ["create", "read", "update", "delete", "assign"],
+ workspace: ["read", "update", "delete", "manage_settings"],
+} as const;
+
+export const ac = createAccessControl(statement);
+
+export const viewer = ac.newRole({
+ ...memberAc.statements,
+ project: ["read"],
+ task: ["read"],
+ workspace: ["read"],
+});
+
+export const member = ac.newRole({
+ ...memberAc.statements,
+ project: ["create", "read"],
+ task: ["create", "read", "update"],
+ workspace: ["read"],
+});
+
+export const admin = ac.newRole({
+ ...adminAc.statements,
+ project: ["create", "read", "update", "delete", "share"],
+ task: ["create", "read", "update", "delete", "assign"],
+ workspace: ["read", "update", "manage_settings"],
+});
+
+export const owner = ac.newRole({
+ ...ownerAc.statements,
+ project: ["create", "read", "update", "delete", "share"],
+ task: ["create", "read", "update", "delete", "assign"],
+ workspace: ["read", "update", "delete", "manage_settings"],
+});
+
+export const builtInRoles = { viewer, member, admin, owner } as const;
+
+export type BuiltInRoleName = keyof typeof builtInRoles;
diff --git a/packages/permissions/tsconfig.json b/packages/permissions/tsconfig.json
new file mode 100644
index 000000000..3529e95d8
--- /dev/null
+++ b/packages/permissions/tsconfig.json
@@ -0,0 +1,22 @@
+{
+ "compilerOptions": {
+ "outDir": "./dist",
+ "rootDir": "./src",
+ "module": "ESNext",
+ "target": "ESNext",
+ "moduleResolution": "node",
+ "declaration": true,
+ "sourceMap": true,
+ "strict": true,
+ "esModuleInterop": true,
+ "skipLibCheck": true,
+ "forceConsistentCasingInFileNames": true
+ },
+ "include": [
+ "src/**/*"
+ ],
+ "exclude": [
+ "node_modules",
+ "dist"
+ ]
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ebbfa0271..9d0e358ff 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -87,6 +87,9 @@ importers:
'@kaneo/email':
specifier: workspace:*
version: link:../../packages/email
+ '@kaneo/permissions':
+ specifier: workspace:*
+ version: link:../../packages/permissions
'@modelcontextprotocol/sdk':
specifier: ^1.26.0
version: 1.26.0([email protected])
@@ -492,6 +495,9 @@ importers:
'@kaneo/libs':
specifier: workspace:*
version: link:../../packages/libs
+ '@kaneo/permissions':
+ specifier: workspace:*
+ version: link:../../packages/permissions
'@tailwindcss/postcss':
specifier: ^4.2.1
version: 4.2.1
@@ -639,6 +645,19 @@ importers:
specifier: ^4.1.2
+ packages/permissions:
+ dependencies:
+ better-auth:
+ specifier: ^1.6.9
+ devDependencies:
+ '@kaneo/typescript-config':
+ specifier: workspace:*
+ version: link:../typescript-config
+ typescript:
+ specifier: ^5.9.2
+ version: 5.9.3
+
packages/typescript-config: {}
packages: