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: restrict members to selected projects

Andrejb41c290403cb
diff --git a/apps/api/drizzle/0060_flaky_ezekiel.sql b/apps/api/drizzle/0060_flaky_ezekiel.sql
new file mode 100644
index 000000000..18a8fa02f
--- /dev/null
+++ b/apps/api/drizzle/0060_flaky_ezekiel.sql
@@ -0,0 +1,27 @@
+CREATE TABLE "workspace_member_access" (
+ "id" text PRIMARY KEY NOT NULL,
+ "workspace_id" text NOT NULL,
+ "user_id" text NOT NULL,
+ "project_access" text DEFAULT 'all' NOT NULL,
+ "created_at" timestamp DEFAULT now() NOT NULL,
+ "updated_at" timestamp DEFAULT now() NOT NULL,
+ CONSTRAINT "workspace_member_access_workspace_user_unique" UNIQUE("workspace_id","user_id")
+);
+--> statement-breakpoint
+CREATE TABLE "workspace_member_project" (
+ "id" text PRIMARY KEY NOT NULL,
+ "workspace_id" text NOT NULL,
+ "user_id" text NOT NULL,
+ "project_id" text NOT NULL,
+ "created_at" timestamp DEFAULT now() NOT NULL,
+ CONSTRAINT "workspace_member_project_workspace_user_project_unique" UNIQUE("workspace_id","user_id","project_id")
+);
+--> statement-breakpoint
+ALTER TABLE "invitation" ADD COLUMN "project_access" text DEFAULT 'all' NOT NULL;--> statement-breakpoint
+ALTER TABLE "invitation" ADD COLUMN "project_ids" text[] DEFAULT '{}'::text[] NOT NULL;--> statement-breakpoint
+ALTER TABLE "workspace_member_access" ADD CONSTRAINT "workspace_member_access_workspace_id_workspace_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspace"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "workspace_member_access" ADD CONSTRAINT "workspace_member_access_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "workspace_member_project" ADD CONSTRAINT "workspace_member_project_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "workspace_member_project" ADD CONSTRAINT "workspace_member_project_workspace_id_project_id_project_workspace_id_id_fk" FOREIGN KEY ("workspace_id","project_id") REFERENCES "public"."project"("workspace_id","id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
+CREATE INDEX "workspace_member_access_userId_idx" ON "workspace_member_access" USING btree ("user_id");--> statement-breakpoint
+CREATE INDEX "workspace_member_project_projectId_idx" ON "workspace_member_project" USING btree ("project_id");
\ No newline at end of file
diff --git a/apps/api/drizzle/meta/0060_snapshot.json b/apps/api/drizzle/meta/0060_snapshot.json
new file mode 100644
index 000000000..081a57943
--- /dev/null
+++ b/apps/api/drizzle/meta/0060_snapshot.json
@@ -0,0 +1,5231 @@
+{
+ "id": "dc330bce-1038-4b1e-b083-0d39004554e4",
+ "prevId": "c5e655f6-a02b-4400-97ba-0116328bd6b0",
+ "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": {}
+ },
+ "activity_userId_idx": {
+ "name": "activity_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "activity_createdAt_idx": {
+ "name": "activity_createdAt_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "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": "set null",
+ "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": {}
+ },
+ "asset_createdBy_idx": {
+ "name": "asset_createdBy_idx",
+ "columns": [
+ {
+ "expression": "created_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "asset_draft_expiry_idx": {
+ "name": "asset_draft_expiry_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"asset\".\"task_id\" is null and \"asset\".\"surface\" in ('draft', 'draft-pending')",
+ "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.billing_event": {
+ "name": "billing_event",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "processed_at": {
+ "name": "processed_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.billing_reminder_sent": {
+ "name": "billing_reminder_sent",
+ "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
+ },
+ "reminder_type": {
+ "name": "reminder_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "trial_ends_at": {
+ "name": "trial_ends_at",
+ "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": {
+ "billing_reminder_sent_workspaceId_idx": {
+ "name": "billing_reminder_sent_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "billing_reminder_sent_userId_idx": {
+ "name": "billing_reminder_sent_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "billing_reminder_sent_user_id_user_id_fk": {
+ "name": "billing_reminder_sent_user_id_user_id_fk",
+ "tableFrom": "billing_reminder_sent",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "billing_reminder_sent_workspace_id_workspace_id_fk": {
+ "name": "billing_reminder_sent_workspace_id_workspace_id_fk",
+ "tableFrom": "billing_reminder_sent",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "billing_reminder_sent_user_type_unique": {
+ "name": "billing_reminder_sent_user_type_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "reminder_type"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.calendar_feed": {
+ "name": "calendar_feed",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label_ids": {
+ "name": "label_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "time_zone": {
+ "name": "time_zone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'UTC'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "calendar_feed_project_id_idx": {
+ "name": "calendar_feed_project_id_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "calendar_feed_project_id_project_id_fk": {
+ "name": "calendar_feed_project_id_project_id_fk",
+ "tableFrom": "calendar_feed",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "calendar_feed_token_unique": {
+ "name": "calendar_feed_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "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.custom_field_definition": {
+ "name": "custom_field_definition",
+ "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
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "required": {
+ "name": "required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "default_value": {
+ "name": "default_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "options": {
+ "name": "options",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "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": {
+ "custom_field_def_projectId_idx": {
+ "name": "custom_field_def_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "custom_field_definition_project_id_project_id_fk": {
+ "name": "custom_field_definition_project_id_project_id_fk",
+ "tableFrom": "custom_field_definition",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.custom_field_value": {
+ "name": "custom_field_value",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "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": {
+ "custom_field_value_taskId_idx": {
+ "name": "custom_field_value_taskId_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "custom_field_value_fieldId_idx": {
+ "name": "custom_field_value_fieldId_idx",
+ "columns": [
+ {
+ "expression": "field_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "custom_field_value_task_id_task_id_fk": {
+ "name": "custom_field_value_task_id_task_id_fk",
+ "tableFrom": "custom_field_value",
+ "tableTo": "task",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "custom_field_value_field_id_custom_field_definition_id_fk": {
+ "name": "custom_field_value_field_id_custom_field_definition_id_fk",
+ "tableFrom": "custom_field_value",
+ "tableTo": "custom_field_definition",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "custom_field_value_task_field_unique": {
+ "name": "custom_field_value_task_field_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "task_id",
+ "field_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.data_migration": {
+ "name": "data_migration",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "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": false
+ },
+ "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": {}
+ },
+ "external_link_deferred_issue_idx": {
+ "name": "external_link_deferred_issue_idx",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"external_link\".\"resource_type\" = 'issue' AND \"external_link\".\"metadata\" LIKE '%\"deferredIssueEdit\":%'",
+ "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_import": {
+ "name": "github_import",
+ "schema": "",
+ "columns": {
+ "integration_id": {
+ "name": "integration_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "github_import_integration_id_integration_id_fk": {
+ "name": "github_import_integration_id_integration_id_fk",
+ "tableFrom": "github_import",
+ "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
+ },
+ "project_access": {
+ "name": "project_access",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'all'"
+ },
+ "project_ids": {
+ "name": "project_ids",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::text[]"
+ }
+ },
+ "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": {}
+ },
+ "invitation_inviterId_idx": {
+ "name": "invitation_inviterId_idx",
+ "columns": [
+ {
+ "expression": "inviter_id",
+ "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.job_lease": {
+ "name": "job_lease",
+ "schema": "",
+ "columns": {
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner": {
+ "name": "owner",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "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()"
+ },
+ "deletion_started_at": {
+ "name": "deletion_started_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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_cascade_idx": {
+ "name": "label_workspace_cascade_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"label\".\"task_id\" is not null",
+ "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.mcp_oauth_state": {
+ "name": "mcp_oauth_state",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "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": {
+ "mcp_oauth_state_kind_key_uidx": {
+ "name": "mcp_oauth_state_kind_key_uidx",
+ "columns": [
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "mcp_oauth_state_expiresAt_idx": {
+ "name": "mcp_oauth_state_expiresAt_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "notification_userId_idx": {
+ "name": "notification_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "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": true,
+ "default": "now()"
+ }
+ },
+ "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": "cascade"
+ }
+ },
+ "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
+ },
+ "last_task_number": {
+ "name": "last_task_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "background_object_key": {
+ "name": "background_object_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "background_mime_type": {
+ "name": "background_mime_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "background_version": {
+ "name": "background_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "project_background_object_key_idx": {
+ "name": "project_background_object_key_idx",
+ "columns": [
+ {
+ "expression": "background_object_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"project\".\"background_object_key\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_workspaceId_position_idx": {
+ "name": "project_workspaceId_position_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "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.storage_cleanup": {
+ "name": "storage_cleanup",
+ "schema": "",
+ "columns": {
+ "object_key": {
+ "name": "object_key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "last_attempt_at": {
+ "name": "last_attempt_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "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": true,
+ "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": {}
+ },
+ "task_assigneeId_idx": {
+ "name": "task_assigneeId_idx",
+ "columns": [
+ {
+ "expression": "assignee_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_columnId_idx": {
+ "name": "task_columnId_idx",
+ "columns": [
+ {
+ "expression": "column_id",
+ "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": "set null",
+ "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()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "time_entry_taskId_idx": {
+ "name": "time_entry_taskId_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "time_entry_userId_idx": {
+ "name": "time_entry_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "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": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.trial_grant": {
+ "name": "trial_grant",
+ "schema": "",
+ "columns": {
+ "email_hash": {
+ "name": "email_hash",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "trial_ends_at": {
+ "name": "trial_ends_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "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_avatar": {
+ "name": "user_avatar",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "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
+ },
+ "data": {
+ "name": "data",
+ "type": "bytea",
+ "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_avatar_userId_idx": {
+ "name": "user_avatar_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_avatar_user_id_user_id_fk": {
+ "name": "user_avatar_user_id_user_id_fk",
+ "tableFrom": "user_avatar",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_avatar_user_id_unique": {
+ "name": "user_avatar_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ }
+ },
+ "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
+ },
+ "task_assignment_enabled": {
+ "name": "task_assignment_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "task_comment_enabled": {
+ "name": "task_comment_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "task_status_change_enabled": {
+ "name": "task_status_change_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "due_date_reminder_enabled": {
+ "name": "due_date_reminder_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "due_date_reminder_lead_time_minutes": {
+ "name": "due_date_reminder_lead_time_minutes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1440
+ },
+ "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": {}
+ },
+ "user_notification_workspace_project_workspaceId_projectId_idx": {
+ "name": "user_notification_workspace_project_workspaceId_projectId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "unwp_workspaceId_workspaceRuleId_idx": {
+ "name": "unwp_workspaceId_workspaceRuleId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "workspace_rule_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": {}
+ },
+ "workflow_rule_columnId_idx": {
+ "name": "workflow_rule_columnId_idx",
+ "columns": [
+ {
+ "expression": "column_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_billing": {
+ "name": "workspace_billing",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "founding_free": {
+ "name": "founding_free",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "trial_ends_at": {
+ "name": "trial_ends_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "creem_customer_id": {
+ "name": "creem_customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "creem_subscription_id": {
+ "name": "creem_subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "creem_product_id": {
+ "name": "creem_product_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plan": {
+ "name": "plan",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "billing_interval": {
+ "name": "billing_interval",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "seats": {
+ "name": "seats",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canceled_at": {
+ "name": "canceled_at",
+ "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": {
+ "workspace_billing_workspaceId_idx": {
+ "name": "workspace_billing_workspaceId_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_billing_workspace_id_workspace_id_fk": {
+ "name": "workspace_billing_workspace_id_workspace_id_fk",
+ "tableFrom": "workspace_billing",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_billing_workspace_id_unique": {
+ "name": "workspace_billing_workspace_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "workspace_id"
+ ]
+ },
+ "workspace_billing_creem_subscription_id_unique": {
+ "name": "workspace_billing_creem_subscription_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "creem_subscription_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_member_access": {
+ "name": "workspace_member_access",
+ "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
+ },
+ "project_access": {
+ "name": "project_access",
+ "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": {
+ "workspace_member_access_userId_idx": {
+ "name": "workspace_member_access_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_member_access_workspace_id_workspace_id_fk": {
+ "name": "workspace_member_access_workspace_id_workspace_id_fk",
+ "tableFrom": "workspace_member_access",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_member_access_user_id_user_id_fk": {
+ "name": "workspace_member_access_user_id_user_id_fk",
+ "tableFrom": "workspace_member_access",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_member_access_workspace_user_unique": {
+ "name": "workspace_member_access_workspace_user_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_member_project": {
+ "name": "workspace_member_project",
+ "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
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_member_project_projectId_idx": {
+ "name": "workspace_member_project_projectId_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_member_project_user_id_user_id_fk": {
+ "name": "workspace_member_project_user_id_user_id_fk",
+ "tableFrom": "workspace_member_project",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_member_project_workspace_id_project_id_project_workspace_id_id_fk": {
+ "name": "workspace_member_project_workspace_id_project_id_project_workspace_id_id_fk",
+ "tableFrom": "workspace_member_project",
+ "tableTo": "project",
+ "columnsFrom": [
+ "workspace_id",
+ "project_id"
+ ],
+ "columnsTo": [
+ "workspace_id",
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_member_project_workspace_user_project_unique": {
+ "name": "workspace_member_project_workspace_user_project_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "workspace_id",
+ "user_id",
+ "project_id"
+ ]
+ }
+ },
+ "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": {}
+ }
+}
\ No newline at end of file
diff --git a/apps/api/drizzle/meta/_journal.json b/apps/api/drizzle/meta/_journal.json
index 796db82d8..501019bd2 100644
--- a/apps/api/drizzle/meta/_journal.json
+++ b/apps/api/drizzle/meta/_journal.json
@@ -421,6 +421,13 @@
"when": 1790975740959,
"tag": "0059_odd_medusa",
"breakpoints": true
+ },
+ {
+ "idx": 60,
+ "version": "7",
+ "when": 1791234516735,
+ "tag": "0060_flaky_ezekiel",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/apps/api/src/activity/controllers/get-workspace-activities.ts b/apps/api/src/activity/controllers/get-workspace-activities.ts
index 87ca6a9a1..1a45a3b7e 100644
--- a/apps/api/src/activity/controllers/get-workspace-activities.ts
+++ b/apps/api/src/activity/controllers/get-workspace-activities.ts
@@ -7,6 +7,7 @@ import {
taskTable,
userTable,
} from "../../database/schema";
+import { projectAccessCondition } from "../../project-access/project-access-condition";
import { commentExcerpt } from "../comment-excerpt";
export const WORKSPACE_ACTIVITY_LIMIT = 20;
@@ -15,7 +16,7 @@ export const WORKSPACE_ACTIVITY_LIMIT = 20;
// in workspaces with years of history.
const WINDOW_DAYS = 30;
-async function getWorkspaceActivities(workspaceId: string) {
+async function getWorkspaceActivities(workspaceId: string, userId: string) {
const since = new Date(Date.now() - WINDOW_DAYS * 24 * 60 * 60 * 1000);
// Concrete project IDs let PostgreSQL estimate task selectivity before it
@@ -28,6 +29,7 @@ async function getWorkspaceActivities(workspaceId: string) {
and(
eq(projectTable.workspaceId, workspaceId),
isNull(projectTable.archivedAt),
+ projectAccessCondition(userId, projectTable.id),
),
);
if (!projects.length) return [];
diff --git a/apps/api/src/activity/index.ts b/apps/api/src/activity/index.ts
index 98cdfe119..1b122f2f9 100644
--- a/apps/api/src/activity/index.ts
+++ b/apps/api/src/activity/index.ts
@@ -181,7 +181,13 @@ const deleteCommentRoute = createRoute({
const activity = apiRouter()
.openapi(getWorkspaceActivitiesRoute, async (c) =>
- c.json(await getWorkspaceActivities(c.req.valid("param").workspaceId), 200),
+ c.json(
+ await getWorkspaceActivities(
+ c.req.valid("param").workspaceId,
+ c.get("userId"),
+ ),
+ 200,
+ ),
)
.openapi(getActivitiesRoute, async (c) =>
c.json(
diff --git a/apps/api/src/auth-openapi.ts b/apps/api/src/auth-openapi.ts
index ac98c909a..be421d570 100644
--- a/apps/api/src/auth-openapi.ts
+++ b/apps/api/src/auth-openapi.ts
@@ -519,6 +519,14 @@ export function organizationRoutes(registry: OpenAPIHono["openAPIRegistry"]) {
"Resend the invitation email, if the user is already invited. Eg: true",
}),
teamId: z.union([z.string(), z.array(z.string())]).optional(),
+ projectAccess: z.enum(["all", "selected"]).optional().openapi({
+ description:
+ '"all" (the default) gives access to every project. "selected" limits the new member to projectIds once they accept.',
+ }),
+ projectIds: z.array(z.string()).optional().openapi({
+ description:
+ 'Projects the new member can access when projectAccess is "selected". They must belong to the workspace, and an inviter whose own access is limited can only choose projects they can access.',
+ }),
}),
},
},
diff --git a/apps/api/src/auth.ts b/apps/api/src/auth.ts
index 8c1a9b2a8..d1f07b9ec 100644
--- a/apps/api/src/auth.ts
+++ b/apps/api/src/auth.ts
@@ -45,6 +45,11 @@ import { syncWorkspaceSeats } from "./billing/controllers/sync-seats";
import db, { schema } from "./database";
import { authDatabaseAdapter } from "./database/auth-adapter";
import { publishEvent } from "./events";
+import {
+ applyInvitationProjectAccess,
+ resolveInvitationProjectAccess,
+} from "./project-access/invitation-project-access";
+import { clearMemberProjectAccess } from "./project-access/member-project-access";
import clearEmailVerificationOnAdminChange from "./user/controllers/clear-email-verification-on-admin-change";
import deleteAccountData from "./user/controllers/delete-account-data";
import prepareAdminUserRemoval from "./user/controllers/prepare-admin-user-removal";
@@ -409,6 +414,20 @@ export const auth = betterAuth({
fields: {
organizationId: "workspaceId",
},
+ additionalFields: {
+ projectAccess: {
+ type: "string",
+ input: true,
+ required: false,
+ defaultValue: "all",
+ },
+ projectIds: {
+ type: "string[]",
+ input: true,
+ required: false,
+ defaultValue: [],
+ },
+ },
},
organizationRole: {
modelName: "workspace_role",
@@ -539,6 +558,13 @@ export const auth = betterAuth({
),
);
},
+ beforeCreateInvitation: async ({ invitation }) => {
+ const access = await resolveInvitationProjectAccess(invitation);
+ return { data: access };
+ },
+ beforeAcceptInvitation: async ({ invitation, user }) => {
+ await applyInvitationProjectAccess(invitation, user.id);
+ },
afterAddMember: async ({ member }) => {
if (member?.organizationId) {
void syncWorkspaceSeats(member.organizationId).catch((error) => {
@@ -548,6 +574,12 @@ export const auth = betterAuth({
},
afterRemoveMember: async ({ member, user }) => {
if (member?.organizationId) {
+ await clearMemberProjectAccess(
+ member.organizationId,
+ member.userId,
+ ).catch((error) => {
+ console.error("Project access cleanup failed:", error);
+ });
if (!hasInstanceAdminRole(user.role)) {
await revokeWorkspaceConnections(
member.userId,
@@ -856,6 +888,12 @@ export const auth = betterAuth({
typeof removed.organizationId === "string" &&
removed.organizationId === ctx.body?.organizationId
) {
+ await clearMemberProjectAccess(
+ removed.organizationId,
+ removed.userId,
+ ).catch((error) => {
+ console.error("Project access cleanup failed:", error);
+ });
await revokeWorkspaceConnections(
removed.userId,
removed.organizationId,
diff --git a/apps/api/src/database/index.ts b/apps/api/src/database/index.ts
index 0d4e0db5e..43bb94b51 100644
--- a/apps/api/src/database/index.ts
+++ b/apps/api/src/database/index.ts
@@ -77,6 +77,8 @@ import {
workflowRuleTable,
workspaceBillingTable,
workspaceRoleTable,
+ workspaceMemberAccessTable,
+ workspaceMemberProjectTable,
workspaceTable,
workspaceUserTable,
} from "./schema";
@@ -123,6 +125,8 @@ export const schema = {
verificationTable,
workflowRuleTable,
workspaceRoleTable,
+ workspaceMemberAccessTable,
+ workspaceMemberProjectTable,
workspaceTable,
workspaceUserTable,
accountTableRelations,
diff --git a/apps/api/src/database/schema.ts b/apps/api/src/database/schema.ts
index 679154df3..124c85da8 100644
--- a/apps/api/src/database/schema.ts
+++ b/apps/api/src/database/schema.ts
@@ -275,6 +275,11 @@ export const invitationTable = pgTable(
inviterId: text("inviter_id")
.notNull()
.references(() => userTable.id, { onDelete: "cascade" }),
+ projectAccess: text("project_access").default("all").notNull(),
+ projectIds: text("project_ids")
+ .array()
+ .default(sql`'{}'::text[]`)
+ .notNull(),
},
(table) => [
index("invitation_workspaceId_idx").on(table.workspaceId),
@@ -346,6 +351,63 @@ export const projectTable = pgTable(
],
);
+export const workspaceMemberAccessTable = pgTable(
+ "workspace_member_access",
+ {
+ id: text("id")
+ .$defaultFn(() => createId())
+ .primaryKey(),
+ workspaceId: text("workspace_id")
+ .notNull()
+ .references(() => workspaceTable.id, { onDelete: "cascade" }),
+ userId: text("user_id")
+ .notNull()
+ .references(() => userTable.id, { onDelete: "cascade" }),
+ projectAccess: text("project_access").default("all").notNull(),
+ createdAt: timestamp("created_at", { mode: "date" }).defaultNow().notNull(),
+ updatedAt: timestamp("updated_at", { mode: "date" })
+ .defaultNow()
+ .$onUpdate(() => new Date())
+ .notNull(),
+ },
+ (table) => [
+ unique("workspace_member_access_workspace_user_unique").on(
+ table.workspaceId,
+ table.userId,
+ ),
+ index("workspace_member_access_userId_idx").on(table.userId),
+ ],
+);
+
+export const workspaceMemberProjectTable = pgTable(
+ "workspace_member_project",
+ {
+ id: text("id")
+ .$defaultFn(() => createId())
+ .primaryKey(),
+ workspaceId: text("workspace_id").notNull(),
+ userId: text("user_id")
+ .notNull()
+ .references(() => userTable.id, { onDelete: "cascade" }),
+ projectId: text("project_id").notNull(),
+ createdAt: timestamp("created_at", { mode: "date" }).defaultNow().notNull(),
+ },
+ (table) => [
+ foreignKey({
+ columns: [table.workspaceId, table.projectId],
+ foreignColumns: [projectTable.workspaceId, projectTable.id],
+ })
+ .onDelete("cascade")
+ .onUpdate("cascade"),
+ unique("workspace_member_project_workspace_user_project_unique").on(
+ table.workspaceId,
+ table.userId,
+ table.projectId,
+ ),
+ index("workspace_member_project_projectId_idx").on(table.projectId),
+ ],
+);
+
export const columnTable = pgTable(
"column",
{
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index da70740a4..f9d94f44f 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -53,6 +53,7 @@ import { createRoute, errorResponse, jsonResponse, z } from "./openapi";
import { initializePlugins } from "./plugins";
import { migrateGitHubIntegration } from "./plugins/github/migration";
import project from "./project";
+import { assertProjectAccess } from "./project-access/assert-project-access";
import { getPublicProject } from "./project/controllers/get-public-project";
import { initializeScheduler, shutdownScheduler } from "./scheduler";
import search from "./search";
@@ -457,6 +458,7 @@ export function createApp() {
surface: schema.assetTable.surface,
createdBy: schema.assetTable.createdBy,
workspaceId: schema.assetTable.workspaceId,
+ projectId: schema.assetTable.projectId,
isPublic: schema.projectTable.isPublic,
})
.from(schema.assetTable)
@@ -843,6 +845,7 @@ export function createApp() {
}
await validateWorkspaceAccess(userId, project.workspaceId);
+ await assertProjectAccess(userId, projectId);
workspaceId = project.workspaceId;
}
diff --git a/apps/api/src/integrations/middleware.ts b/apps/api/src/integrations/middleware.ts
index 389fa368f..5cc51ff5e 100644
--- a/apps/api/src/integrations/middleware.ts
+++ b/apps/api/src/integrations/middleware.ts
@@ -3,6 +3,7 @@ import type { Context, Next } from "hono";
import { HTTPException } from "hono/http-exception";
import db from "../database";
import { projectTable } from "../database/schema";
+import { assertProjectAccess } from "../project-access/assert-project-access";
import { validateWorkspaceAccess } from "../utils/validate-workspace-access";
// Route middleware runs before the validators, so c.req.valid() is unavailable.
@@ -35,6 +36,7 @@ export async function scopeToProjectFromBody(c: Context, next: Next) {
project.workspaceId,
c.get("apiKey")?.id,
);
+ await assertProjectAccess(userId, projectId);
c.set("workspaceId", project.workspaceId);
return next();
diff --git a/apps/api/src/label/controllers/assign-label-to-task.ts b/apps/api/src/label/controllers/assign-label-to-task.ts
index 80eb7e947..684bb8455 100644
--- a/apps/api/src/label/controllers/assign-label-to-task.ts
+++ b/apps/api/src/label/controllers/assign-label-to-task.ts
@@ -20,6 +20,7 @@ import {
removeLabelFromGitlab,
syncLabelToGitlab,
} from "../../plugins/gitlab/utils/sync-label-to-gitlab";
+import { assertProjectAccess } from "../../project-access/assert-project-access";
type LabelRow = typeof labelTableType.$inferSelect;
@@ -60,6 +61,8 @@ async function assignLabelToTask(id: string, taskId: string, userId: string) {
});
}
+ await assertProjectAccess(userId, task.projectId);
+
if (label.taskId === taskId) {
return label;
}
diff --git a/apps/api/src/label/controllers/create-label.ts b/apps/api/src/label/controllers/create-label.ts
index 61078e607..8c7ccc7d3 100644
--- a/apps/api/src/label/controllers/create-label.ts
+++ b/apps/api/src/label/controllers/create-label.ts
@@ -6,6 +6,7 @@ import { publishEvent } from "../../events";
import { syncLabelToGitea } from "../../plugins/gitea/utils/sync-label-to-gitea";
import { syncLabelToGitHub } from "../../plugins/github/utils/sync-label-to-github";
import { syncLabelToGitlab } from "../../plugins/gitlab/utils/sync-label-to-gitlab";
+import { assertProjectAccess } from "../../project-access/assert-project-access";
async function createLabel(
name: string,
@@ -48,6 +49,8 @@ async function createLabel(
});
}
+ await assertProjectAccess(userId, task.projectId);
+
const [inserted] = await db
.insert(labelTable)
.values({ name, color, taskId, workspaceId: task.workspaceId })
diff --git a/apps/api/src/label/controllers/get-labels-by-workspace-id.ts b/apps/api/src/label/controllers/get-labels-by-workspace-id.ts
index e008840b8..101b0b744 100644
--- a/apps/api/src/label/controllers/get-labels-by-workspace-id.ts
+++ b/apps/api/src/label/controllers/get-labels-by-workspace-id.ts
@@ -1,12 +1,31 @@
-import { eq } from "drizzle-orm";
+import { and, eq, exists, isNull, or } from "drizzle-orm";
import db from "../../database";
-import { labelTable } from "../../database/schema";
+import { labelTable, taskTable } from "../../database/schema";
+import { projectAccessCondition } from "../../project-access/project-access-condition";
-function getLabelsByWorkspaceId(workspaceId: string) {
+function getLabelsByWorkspaceId(workspaceId: string, userId: string) {
return db
.select()
.from(labelTable)
- .where(eq(labelTable.workspaceId, workspaceId));
+ .where(
+ and(
+ eq(labelTable.workspaceId, workspaceId),
+ or(
+ isNull(labelTable.taskId),
+ exists(
+ db
+ .select({ id: taskTable.id })
+ .from(taskTable)
+ .where(
+ and(
+ eq(taskTable.id, labelTable.taskId),
+ projectAccessCondition(userId, taskTable.projectId),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
}
export default getLabelsByWorkspaceId;
diff --git a/apps/api/src/label/index.ts b/apps/api/src/label/index.ts
index 5db6b629b..fc1c7cc92 100644
--- a/apps/api/src/label/index.ts
+++ b/apps/api/src/label/index.ts
@@ -226,7 +226,10 @@ const label = apiRouter()
})
.openapi(getWorkspaceLabelsRoute, async (c) => {
const { workspaceId } = c.req.valid("param");
- return c.json(await getLabelsByWorkspaceId(workspaceId), 200);
+ return c.json(
+ await getLabelsByWorkspaceId(workspaceId, c.get("userId")),
+ 200,
+ );
})
.openapi(createLabelRoute, async (c) => {
const { name, color, workspaceId, taskId } = c.req.valid("json");
diff --git a/apps/api/src/notification-preferences/service.ts b/apps/api/src/notification-preferences/service.ts
index 767be8695..46a7f5f21 100644
--- a/apps/api/src/notification-preferences/service.ts
+++ b/apps/api/src/notification-preferences/service.ts
@@ -9,6 +9,7 @@ import {
workspaceUserTable,
} from "../database/schema";
import { assertPublicWebhookDestination } from "../plugins/generic-webhook/config";
+import { projectAccessCondition } from "../project-access/project-access-condition";
import { decryptSecret, encryptSecret } from "./secrets";
export type NotificationPreferenceProjectMode = "all" | "selected";
@@ -136,6 +137,7 @@ async function assertWorkspaceMembership(userId: string, workspaceId: string) {
}
export async function validateProjectSelection(
+ userId: string,
workspaceId: string,
selectedProjectIds: string[],
) {
@@ -152,6 +154,7 @@ export async function validateProjectSelection(
and(
eq(projectTable.workspaceId, workspaceId),
inArray(projectTable.id, selectedProjectIds),
+ projectAccessCondition(userId, projectTable.id),
),
);
@@ -513,7 +516,11 @@ export async function upsertWorkspaceRule(
await assertWorkspaceMembership(userId, workspaceId);
if (input.projectMode === "selected") {
- await validateProjectSelection(workspaceId, input.selectedProjectIds ?? []);
+ await validateProjectSelection(
+ userId,
+ workspaceId,
+ input.selectedProjectIds ?? [],
+ );
}
const preference = await db.query.userNotificationPreferenceTable.findFirst({
diff --git a/apps/api/src/notification/resource-access.ts b/apps/api/src/notification/resource-access.ts
index a3b05f2fa..7f06d2d81 100644
--- a/apps/api/src/notification/resource-access.ts
+++ b/apps/api/src/notification/resource-access.ts
@@ -1,6 +1,7 @@
import { and, eq, type SQLWrapper, sql } from "drizzle-orm";
import db from "../database";
import { userTable } from "../database/schema";
+import { projectAccessCondition } from "../project-access/project-access-condition";
// Membership, rather than public visibility or global admin privileges, defines
// who may be subscribed to private task activity. Use the same predicate when
@@ -17,6 +18,7 @@ export function notificationResourceAccess(
JOIN project AS notification_project ON notification_project.id = notification_task.project_id
JOIN workspace_member AS notification_member ON notification_member.workspace_id = notification_project.workspace_id
WHERE notification_task.id = ${resourceId} AND notification_member.user_id = ${userId}
+ AND ${projectAccessCondition(userId, sql`notification_project.id`)}
))
OR (${resourceType}::text = 'workspace' AND EXISTS (
SELECT 1 FROM workspace_member AS notification_member
diff --git a/apps/api/src/project-access/assert-project-access.ts b/apps/api/src/project-access/assert-project-access.ts
new file mode 100644
index 000000000..72125af8f
--- /dev/null
+++ b/apps/api/src/project-access/assert-project-access.ts
@@ -0,0 +1,42 @@
+import { and, inArray, not } from "drizzle-orm";
+import { HTTPException } from "hono/http-exception";
+import db, { schema } from "../database";
+import { projectAccessCondition } from "./project-access-condition";
+
+export async function findInaccessibleProjectIds(
+ userId: string,
+ projectIds: readonly string[],
+ database: Pick<typeof db, "select"> = db,
+): Promise<string[]> {
+ const ids = [...new Set(projectIds)];
+ if (ids.length === 0) return [];
+
+ const rows = await database
+ .select({ id: schema.projectTable.id })
+ .from(schema.projectTable)
+ .where(
+ and(
+ inArray(schema.projectTable.id, ids),
+ not(projectAccessCondition(userId, schema.projectTable.id)),
+ ),
+ );
+
+ return rows.map((row) => row.id);
+}
+
+export async function canAccessProject(userId: string, projectId: string) {
+ return (await findInaccessibleProjectIds(userId, [projectId])).length === 0;
+}
+
+export async function assertProjectAccess(
+ userId: string,
+ projectIds: string | readonly string[],
+): Promise<void> {
+ const ids = typeof projectIds === "string" ? [projectIds] : projectIds;
+ const denied = await findInaccessibleProjectIds(userId, ids);
+ if (denied.length > 0) {
+ throw new HTTPException(403, {
+ message: "You don't have access to this project",
+ });
+ }
+}
diff --git a/apps/api/src/project-access/filter-users-with-project-access.ts b/apps/api/src/project-access/filter-users-with-project-access.ts
new file mode 100644
index 000000000..fc826c7c0
--- /dev/null
+++ b/apps/api/src/project-access/filter-users-with-project-access.ts
@@ -0,0 +1,24 @@
+import { and, inArray } from "drizzle-orm";
+import db, { schema } from "../database";
+import { projectAccessCondition } from "./project-access-condition";
+
+export async function filterUsersWithProjectAccess(
+ userIds: Iterable<string>,
+ projectId: string,
+ database: Pick<typeof db, "select"> = db,
+): Promise<Set<string>> {
+ const ids = [...new Set(userIds)];
+ if (ids.length === 0) return new Set();
+
+ const rows = await database
+ .select({ id: schema.userTable.id })
+ .from(schema.userTable)
+ .where(
+ and(
+ inArray(schema.userTable.id, ids),
+ projectAccessCondition(schema.userTable.id, projectId),
+ ),
+ );
+
+ return new Set(rows.map((row) => row.id));
+}
diff --git a/apps/api/src/project-access/invitation-project-access.ts b/apps/api/src/project-access/invitation-project-access.ts
new file mode 100644
index 000000000..444bb0de8
--- /dev/null
+++ b/apps/api/src/project-access/invitation-project-access.ts
@@ -0,0 +1,55 @@
+import { APIError } from "better-auth/api";
+import db from "../database";
+import { replaceMemberProjectAccess } from "./member-project-access";
+import { isOwnerRole } from "./project-access-mode";
+import { resolveProjectAccessRequest } from "./resolve-project-access-request";
+
+type InvitationProjectAccess = {
+ organizationId: string;
+ role?: string | null;
+ projectAccess?: unknown;
+ projectIds?: unknown;
+};
+
+export async function resolveInvitationProjectAccess(
+ invitation: InvitationProjectAccess & { inviterId: string },
+) {
+ const resolution = await resolveProjectAccessRequest({
+ workspaceId: invitation.organizationId,
+ actorId: invitation.inviterId,
+ targetRole: invitation.role,
+ projectAccess: invitation.projectAccess,
+ projectIds: invitation.projectIds,
+ });
+
+ if (!resolution.ok) {
+ throw new APIError(
+ resolution.status === 400 ? "BAD_REQUEST" : "FORBIDDEN",
+ {
+ message: resolution.message,
+ },
+ );
+ }
+
+ return resolution.access;
+}
+
+export async function applyInvitationProjectAccess(
+ invitation: InvitationProjectAccess,
+ userId: string,
+) {
+ const restricted =
+ invitation.projectAccess === "selected" && !isOwnerRole(invitation.role);
+ const projectIds = Array.isArray(invitation.projectIds)
+ ? invitation.projectIds.filter((id): id is string => typeof id === "string")
+ : [];
+
+ await db.transaction((tx) =>
+ replaceMemberProjectAccess(tx, {
+ workspaceId: invitation.organizationId,
+ userId,
+ projectAccess: restricted ? "selected" : "all",
+ projectIds,
+ }),
+ );
+}
diff --git a/apps/api/src/project-access/is-project-access-restricted.ts b/apps/api/src/project-access/is-project-access-restricted.ts
new file mode 100644
index 000000000..9b31dbf4d
--- /dev/null
+++ b/apps/api/src/project-access/is-project-access-restricted.ts
@@ -0,0 +1,31 @@
+import { and, eq } from "drizzle-orm";
+import db, { schema } from "../database";
+import { hasInstanceAdminRole } from "../utils/instance-admin-role";
+import { getMemberProjectAccess } from "./member-project-access";
+import { isOwnerRole } from "./project-access-mode";
+
+export async function isProjectAccessRestricted(
+ workspaceId: string,
+ userId: string,
+): Promise<boolean> {
+ const access = await getMemberProjectAccess(workspaceId, userId);
+ if (access.projectAccess === "all") return false;
+
+ const [row] = await db
+ .select({
+ memberRole: schema.workspaceUserTable.role,
+ userRole: schema.userTable.role,
+ })
+ .from(schema.userTable)
+ .leftJoin(
+ schema.workspaceUserTable,
+ and(
+ eq(schema.workspaceUserTable.userId, schema.userTable.id),
+ eq(schema.workspaceUserTable.workspaceId, workspaceId),
+ ),
+ )
+ .where(eq(schema.userTable.id, userId))
+ .limit(1);
+
+ return !isOwnerRole(row?.memberRole) && !hasInstanceAdminRole(row?.userRole);
+}
diff --git a/apps/api/src/project-access/keep-hidden-grants.ts b/apps/api/src/project-access/keep-hidden-grants.ts
new file mode 100644
index 000000000..b5abea4f1
--- /dev/null
+++ b/apps/api/src/project-access/keep-hidden-grants.ts
@@ -0,0 +1,39 @@
+import { findInaccessibleProjectIds } from "./assert-project-access";
+import { isProjectAccessRestricted } from "./is-project-access-restricted";
+import { getMemberProjectAccess } from "./member-project-access";
+import type { ResolvedProjectAccess } from "./resolve-project-access-request";
+
+type Outcome =
+ | { ok: true; access: ResolvedProjectAccess }
+ | { ok: false; message: string };
+
+export async function keepHiddenGrants(request: {
+ workspaceId: string;
+ actorId: string;
+ userId: string;
+ access: ResolvedProjectAccess;
+}): Promise<Outcome> {
+ const { workspaceId, actorId, userId, access } = request;
+
+ if (!(await isProjectAccessRestricted(workspaceId, actorId))) {
+ return { ok: true, access };
+ }
+
+ const current = await getMemberProjectAccess(workspaceId, userId);
+ if (current.projectAccess === "all") {
+ return {
+ ok: false,
+ message:
+ "You can't limit a member who can access every project while your own access is limited",
+ };
+ }
+
+ const hidden = await findInaccessibleProjectIds(actorId, current.projectIds);
+ return {
+ ok: true,
+ access: {
+ projectAccess: access.projectAccess,
+ projectIds: [...new Set([...access.projectIds, ...hidden])],
+ },
+ };
+}
diff --git a/apps/api/src/project-access/member-project-access.ts b/apps/api/src/project-access/member-project-access.ts
new file mode 100644
index 000000000..1ec75a8a6
--- /dev/null
+++ b/apps/api/src/project-access/member-project-access.ts
@@ -0,0 +1,189 @@
+import { and, eq, inArray } from "drizzle-orm";
+import db, { schema } from "../database";
+import type { ProjectAccessMode } from "./project-access-mode";
+
+type DbOrTx = typeof db | Parameters<Parameters<typeof db.transaction>[0]>[0];
+
+export type MemberProjectAccess = {
+ userId: string;
+ projectAccess: ProjectAccessMode;
+ projectIds: string[];
+};
+
+export async function listWorkspaceProjectAccess(
+ workspaceId: string,
+): Promise<MemberProjectAccess[]> {
+ const [rules, grants] = await Promise.all([
+ db
+ .select({
+ userId: schema.workspaceMemberAccessTable.userId,
+ projectAccess: schema.workspaceMemberAccessTable.projectAccess,
+ })
+ .from(schema.workspaceMemberAccessTable)
+ .where(eq(schema.workspaceMemberAccessTable.workspaceId, workspaceId)),
+ db
+ .select({
+ userId: schema.workspaceMemberProjectTable.userId,
+ projectId: schema.workspaceMemberProjectTable.projectId,
+ })
+ .from(schema.workspaceMemberProjectTable)
+ .where(eq(schema.workspaceMemberProjectTable.workspaceId, workspaceId)),
+ ]);
+
+ return rules
+ .filter((rule) => rule.projectAccess !== "all")
+ .map((rule) => ({
+ userId: rule.userId,
+ projectAccess: "selected" as const,
+ projectIds: grants
+ .filter((grant) => grant.userId === rule.userId)
+ .map((grant) => grant.projectId),
+ }));
+}
+
+export async function getMemberProjectAccess(
+ workspaceId: string,
+ userId: string,
+ database: DbOrTx = db,
+): Promise<MemberProjectAccess> {
+ const [rule] = await database
+ .select({ projectAccess: schema.workspaceMemberAccessTable.projectAccess })
+ .from(schema.workspaceMemberAccessTable)
+ .where(
+ and(
+ eq(schema.workspaceMemberAccessTable.workspaceId, workspaceId),
+ eq(schema.workspaceMemberAccessTable.userId, userId),
+ ),
+ )
+ .limit(1);
+
+ if (!rule || rule.projectAccess === "all") {
+ return { userId, projectAccess: "all", projectIds: [] };
+ }
+
+ const grants = await database
+ .select({ projectId: schema.workspaceMemberProjectTable.projectId })
+ .from(schema.workspaceMemberProjectTable)
+ .where(
+ and(
+ eq(schema.workspaceMemberProjectTable.workspaceId, workspaceId),
+ eq(schema.workspaceMemberProjectTable.userId, userId),
+ ),
+ );
+
+ return {
+ userId,
+ projectAccess: "selected",
+ projectIds: grants.map((grant) => grant.projectId),
+ };
+}
+
+export async function findWorkspaceProjectIds(
+ workspaceId: string,
+ projectIds: readonly string[],
+ database: DbOrTx = db,
+): Promise<string[]> {
+ const ids = [...new Set(projectIds)];
+ if (ids.length === 0) return [];
+
+ const rows = await database
+ .select({ id: schema.projectTable.id })
+ .from(schema.projectTable)
+ .where(
+ and(
+ eq(schema.projectTable.workspaceId, workspaceId),
+ inArray(schema.projectTable.id, ids),
+ ),
+ );
+
+ return rows.map((row) => row.id);
+}
+
+export async function replaceMemberProjectAccess(
+ database: DbOrTx,
+ access: {
+ workspaceId: string;
+ userId: string;
+ projectAccess: ProjectAccessMode;
+ projectIds: readonly string[];
+ },
+): Promise<void> {
+ const { workspaceId, userId, projectAccess } = access;
+
+ if (projectAccess === "all") {
+ await clearMemberProjectAccess(workspaceId, userId, database);
+ return;
+ }
+
+ await database
+ .insert(schema.workspaceMemberAccessTable)
+ .values({ workspaceId, userId, projectAccess })
+ .onConflictDoUpdate({
+ target: [
+ schema.workspaceMemberAccessTable.workspaceId,
+ schema.workspaceMemberAccessTable.userId,
+ ],
+ set: { projectAccess, updatedAt: new Date() },
+ });
+
+ await database
+ .delete(schema.workspaceMemberProjectTable)
+ .where(
+ and(
+ eq(schema.workspaceMemberProjectTable.workspaceId, workspaceId),
+ eq(schema.workspaceMemberProjectTable.userId, userId),
+ ),
+ );
+
+ const projectIds = await findWorkspaceProjectIds(
+ workspaceId,
+ access.projectIds,
+ database,
+ );
+ if (projectIds.length === 0) return;
+
+ await database
+ .insert(schema.workspaceMemberProjectTable)
+ .values(projectIds.map((projectId) => ({ workspaceId, userId, projectId })))
+ .onConflictDoNothing();
+}
+
+export async function clearMemberProjectAccess(
+ workspaceId: string,
+ userId: string,
+ database: DbOrTx = db,
+): Promise<void> {
+ await database
+ .delete(schema.workspaceMemberProjectTable)
+ .where(
+ and(
+ eq(schema.workspaceMemberProjectTable.workspaceId, workspaceId),
+ eq(schema.workspaceMemberProjectTable.userId, userId),
+ ),
+ );
+ await database
+ .delete(schema.workspaceMemberAccessTable)
+ .where(
+ and(
+ eq(schema.workspaceMemberAccessTable.workspaceId, workspaceId),
+ eq(schema.workspaceMemberAccessTable.userId, userId),
+ ),
+ );
+}
+
+export async function grantProjectToRestrictedMember(
+ database: DbOrTx,
+ grant: { workspaceId: string; userId: string; projectId: string },
+): Promise<void> {
+ const access = await getMemberProjectAccess(
+ grant.workspaceId,
+ grant.userId,
+ database,
+ );
+ if (access.projectAccess === "all") return;
+
+ await database
+ .insert(schema.workspaceMemberProjectTable)
+ .values(grant)
+ .onConflictDoNothing();
+}
diff --git a/apps/api/src/project-access/project-access-condition.ts b/apps/api/src/project-access/project-access-condition.ts
new file mode 100644
index 000000000..d66eeb655
--- /dev/null
+++ b/apps/api/src/project-access/project-access-condition.ts
@@ -0,0 +1,34 @@
+import { type SQLWrapper, sql } from "drizzle-orm";
+
+export function projectAccessCondition(
+ userId: string | SQLWrapper,
+ projectId: string | SQLWrapper,
+) {
+ return sql<boolean>`(
+ EXISTS (
+ SELECT 1 FROM "user" AS access_user
+ WHERE access_user.id = ${userId}
+ AND 'admin' = ANY(string_to_array(access_user.role, ','))
+ )
+ OR NOT EXISTS (
+ SELECT 1 FROM project AS access_project
+ JOIN workspace_member_access AS access_rule
+ ON access_rule.workspace_id = access_project.workspace_id
+ AND access_rule.user_id = ${userId}
+ WHERE access_project.id = ${projectId}
+ AND access_rule.project_access <> 'all'
+ AND NOT EXISTS (
+ SELECT 1 FROM workspace_member AS access_member
+ WHERE access_member.workspace_id = access_project.workspace_id
+ AND access_member.user_id = ${userId}
+ AND 'owner' = ANY(string_to_array(access_member.role, ','))
+ )
+ AND NOT EXISTS (
+ SELECT 1 FROM workspace_member_project AS access_grant
+ WHERE access_grant.workspace_id = access_project.workspace_id
+ AND access_grant.user_id = ${userId}
+ AND access_grant.project_id = access_project.id
+ )
+ )
+ )`;
+}
diff --git a/apps/api/src/project-access/project-access-mode.ts b/apps/api/src/project-access/project-access-mode.ts
new file mode 100644
index 000000000..a748483e7
--- /dev/null
+++ b/apps/api/src/project-access/project-access-mode.ts
@@ -0,0 +1,13 @@
+export const PROJECT_ACCESS_MODES = ["all", "selected"] as const;
+
+export type ProjectAccessMode = (typeof PROJECT_ACCESS_MODES)[number];
+
+export function isProjectAccessMode(
+ value: unknown,
+): value is ProjectAccessMode {
+ return PROJECT_ACCESS_MODES.includes(value as ProjectAccessMode);
+}
+
+export function isOwnerRole(role: string | null | undefined) {
+ return typeof role === "string" && role.split(",").includes("owner");
+}
diff --git a/apps/api/src/project-access/resolve-project-access-request.ts b/apps/api/src/project-access/resolve-project-access-request.ts
new file mode 100644
index 000000000..4e7675f83
--- /dev/null
+++ b/apps/api/src/project-access/resolve-project-access-request.ts
@@ -0,0 +1,78 @@
+import { findInaccessibleProjectIds } from "./assert-project-access";
+import { isProjectAccessRestricted } from "./is-project-access-restricted";
+import { findWorkspaceProjectIds } from "./member-project-access";
+import {
+ isOwnerRole,
+ isProjectAccessMode,
+ type ProjectAccessMode,
+} from "./project-access-mode";
+
+export type ResolvedProjectAccess = {
+ projectAccess: ProjectAccessMode;
+ projectIds: string[];
+};
+
+type Resolution =
+ | { ok: true; access: ResolvedProjectAccess }
+ | { ok: false; status: 400 | 403; message: string };
+
+const GRANT_DENIED =
+ "You can only give access to projects you can access yourself";
+
+export async function resolveProjectAccessRequest(request: {
+ workspaceId: string;
+ actorId: string;
+ targetRole: string | null | undefined;
+ projectAccess: unknown;
+ projectIds: unknown;
+}): Promise<Resolution> {
+ const projectAccess = request.projectAccess ?? "all";
+ if (!isProjectAccessMode(projectAccess)) {
+ return {
+ ok: false,
+ status: 400,
+ message: 'Project access must be "all" or "selected"',
+ };
+ }
+
+ const rawIds = request.projectIds ?? [];
+ if (!Array.isArray(rawIds) || rawIds.some((id) => typeof id !== "string")) {
+ return {
+ ok: false,
+ status: 400,
+ message: "Project IDs must be a list of strings",
+ };
+ }
+
+ if (projectAccess === "selected" && isOwnerRole(request.targetRole)) {
+ return {
+ ok: false,
+ status: 400,
+ message: "Owners always have access to every project",
+ };
+ }
+
+ if (projectAccess === "all") {
+ if (await isProjectAccessRestricted(request.workspaceId, request.actorId)) {
+ return { ok: false, status: 403, message: GRANT_DENIED };
+ }
+ return { ok: true, access: { projectAccess, projectIds: [] } };
+ }
+
+ const projectIds = [...new Set(rawIds as string[])];
+ const known = await findWorkspaceProjectIds(request.workspaceId, projectIds);
+ if (known.length !== projectIds.length) {
+ return {
+ ok: false,
+ status: 400,
+ message: "Some selected projects don't belong to this workspace",
+ };
+ }
+
+ const denied = await findInaccessibleProjectIds(request.actorId, projectIds);
+ if (denied.length > 0) {
+ return { ok: false, status: 403, message: GRANT_DENIED };
+ }
+
+ return { ok: true, access: { projectAccess, projectIds } };
+}
diff --git a/apps/api/src/project/controllers/create-project.ts b/apps/api/src/project/controllers/create-project.ts
index a37b652aa..aa64e5563 100644
--- a/apps/api/src/project/controllers/create-project.ts
+++ b/apps/api/src/project/controllers/create-project.ts
@@ -2,6 +2,7 @@ import { eq, max, sql } from "drizzle-orm";
import { HTTPException } from "hono/http-exception";
import db from "../../database";
import { columnTable, projectTable } from "../../database/schema";
+import { grantProjectToRestrictedMember } from "../../project-access/member-project-access";
import { findProjectKeyConflict, projectKeyTakenMessage } from "../project-key";
export const DEFAULT_PROJECT_COLUMNS = [
@@ -16,6 +17,7 @@ async function createProject(
name: string,
icon: string,
slug: string,
+ userId: string,
) {
return db.transaction(async (tx) => {
// Serialize ordering writes per workspace: without this, two concurrent
@@ -60,6 +62,12 @@ async function createProject(
isFinal: col.isFinal,
});
}
+
+ await grantProjectToRestrictedMember(tx, {
+ workspaceId,
+ userId,
+ projectId: createdProject.id,
+ });
}
return createdProject;
diff --git a/apps/api/src/project/controllers/get-projects.ts b/apps/api/src/project/controllers/get-projects.ts
index d4b709005..e48b393cf 100644
--- a/apps/api/src/project/controllers/get-projects.ts
+++ b/apps/api/src/project/controllers/get-projects.ts
@@ -1,6 +1,7 @@
import { and, count, eq, isNull, min, sql } from "drizzle-orm";
import db from "../../database";
import { projectTable, taskTable } from "../../database/schema";
+import { projectAccessCondition } from "../../project-access/project-access-condition";
type ProjectStatistics = {
completionPercentage: number;
@@ -16,6 +17,7 @@ const EMPTY_STATISTICS: ProjectStatistics = {
async function getProjectStatistics(
workspaceId: string,
+ userId: string,
includeArchived: boolean,
) {
const statisticsByProject = new Map<string, ProjectStatistics>();
@@ -45,7 +47,8 @@ async function getProjectStatistics(
isNull(projectTable.archivedAt),
),
)
- .groupBy(taskTable.projectId);
+ .groupBy(taskTable.projectId)
+ .having(projectAccessCondition(userId, taskTable.projectId));
for (const row of rows) {
const totalTasks = Number(row.totalTasks);
@@ -62,14 +65,17 @@ async function getProjectStatistics(
return statisticsByProject;
}
-async function getProjects(workspaceId: string, includeArchived = false) {
+async function getProjects(
+ workspaceId: string,
+ userId: string,
+ includeArchived = false,
+) {
const projects = await db.query.projectTable.findMany({
- where: includeArchived
- ? eq(projectTable.workspaceId, workspaceId)
- : and(
- eq(projectTable.workspaceId, workspaceId),
- isNull(projectTable.archivedAt),
- ),
+ where: and(
+ eq(projectTable.workspaceId, workspaceId),
+ includeArchived ? undefined : isNull(projectTable.archivedAt),
+ projectAccessCondition(userId, projectTable.id),
+ ),
// `id` is the deterministic tie-breaker: without it, rows sharing both a
// position and a createdAt come back in an unspecified order.
orderBy: (project, { asc }) => [
@@ -81,6 +87,7 @@ async function getProjects(workspaceId: string, includeArchived = false) {
const statisticsByProject = await getProjectStatistics(
workspaceId,
+ userId,
includeArchived,
);
diff --git a/apps/api/src/project/controllers/move-project.ts b/apps/api/src/project/controllers/move-project.ts
index 31d2ab2b6..414fba9cf 100644
--- a/apps/api/src/project/controllers/move-project.ts
+++ b/apps/api/src/project/controllers/move-project.ts
@@ -11,9 +11,12 @@ import {
taskRelationTable,
taskTable,
userNotificationWorkspaceProjectTable,
+ workspaceMemberProjectTable,
workspaceUserTable,
} from "../../database/schema";
import { publishEvent } from "../../events";
+import { grantProjectToRestrictedMember } from "../../project-access/member-project-access";
+import { filterUsersWithProjectAccess } from "../../project-access/filter-users-with-project-access";
import { closeProjectConnections } from "../../ws";
import { findProjectKeyConflict } from "../project-key";
@@ -107,6 +110,44 @@ async function moveProject(
),
);
+ await tx
+ .delete(workspaceMemberProjectTable)
+ .where(eq(workspaceMemberProjectTable.projectId, id));
+
+ // The source position means nothing in the target's ordering, and keeping
+ // it would collide with whichever project already holds that slot. Append
+ // instead, matching where `createProject` puts a new project.
+ const [{ maxPosition } = { maxPosition: null }] = await tx
+ .select({ maxPosition: max(projectTable.position) })
+ .from(projectTable)
+ .where(eq(projectTable.workspaceId, targetWorkspaceId));
+
+ const [movedProject] = await tx
+ .update(projectTable)
+ .set({
+ workspaceId: targetWorkspaceId,
+ position: maxPosition === null ? 0 : maxPosition + 1,
+ })
+ .where(
+ and(
+ eq(projectTable.id, id),
+ eq(projectTable.workspaceId, sourceWorkspaceId),
+ ),
+ )
+ .returning();
+
+ if (!movedProject) {
+ throw new HTTPException(409, {
+ message: "Project was moved to another workspace, please try again",
+ });
+ }
+
+ await grantProjectToRestrictedMember(tx, {
+ workspaceId: targetWorkspaceId,
+ userId: currentUserId,
+ projectId: id,
+ });
+
const tasks = await tx
.select({
id: taskTable.id,
@@ -135,7 +176,11 @@ async function moveProject(
),
);
- const memberIds = new Set(targetMembers.map((member) => member.userId));
+ const memberIds = await filterUsersWithProjectAccess(
+ targetMembers.map((member) => member.userId),
+ id,
+ tx,
+ );
// Kept as rows rather than a count: each one needs an activity row
// afterwards, keyed by task id.
unassigned = tasks.filter(
@@ -161,34 +206,6 @@ async function moveProject(
}
}
- // The source position means nothing in the target's ordering, and keeping
- // it would collide with whichever project already holds that slot. Append
- // instead, matching where `createProject` puts a new project.
- const [{ maxPosition } = { maxPosition: null }] = await tx
- .select({ maxPosition: max(projectTable.position) })
- .from(projectTable)
- .where(eq(projectTable.workspaceId, targetWorkspaceId));
-
- const [movedProject] = await tx
- .update(projectTable)
- .set({
- workspaceId: targetWorkspaceId,
- position: maxPosition === null ? 0 : maxPosition + 1,
- })
- .where(
- and(
- eq(projectTable.id, id),
- eq(projectTable.workspaceId, sourceWorkspaceId),
- ),
- )
- .returning();
-
- if (!movedProject) {
- throw new HTTPException(409, {
- message: "Project was moved to another workspace, please try again",
- });
- }
-
// Older task moves could leave links owned by a different project.
await tx
.delete(externalLinkTable)
diff --git a/apps/api/src/project/controllers/reorder-projects.ts b/apps/api/src/project/controllers/reorder-projects.ts
index f1ab5e8d1..41917698d 100644
--- a/apps/api/src/project/controllers/reorder-projects.ts
+++ b/apps/api/src/project/controllers/reorder-projects.ts
@@ -1,10 +1,13 @@
-import { asc, eq, sql } from "drizzle-orm";
+import { and, asc, eq, sql } from "drizzle-orm";
import { HTTPException } from "hono/http-exception";
import db from "../../database";
import { projectTable } from "../../database/schema";
+import { assertProjectAccess } from "../../project-access/assert-project-access";
+import { projectAccessCondition } from "../../project-access/project-access-condition";
async function reorderProjects(
workspaceId: string,
+ userId: string,
projects: Array<{ id: string; position: number }>,
) {
const ids = projects.map((project) => project.id);
@@ -16,6 +19,8 @@ async function reorderProjects(
});
}
+ await assertProjectAccess(userId, ids);
+
return db.transaction(async (tx) => {
// Serialize ordering writes per workspace so a concurrent create (which
// appends at max(position) + 1) cannot interleave with a renumber.
@@ -85,7 +90,10 @@ async function reorderProjects(
}
return tx.query.projectTable.findMany({
- where: eq(projectTable.workspaceId, workspaceId),
+ where: and(
+ eq(projectTable.workspaceId, workspaceId),
+ projectAccessCondition(userId, projectTable.id),
+ ),
orderBy: [
asc(projectTable.position),
asc(projectTable.createdAt),
diff --git a/apps/api/src/project/index.ts b/apps/api/src/project/index.ts
index b9d5f3ea8..bc215a290 100644
--- a/apps/api/src/project/index.ts
+++ b/apps/api/src/project/index.ts
@@ -178,7 +178,7 @@ const reorderProjectsRoute = createRoute({
200: jsonResponse("The reordered projects", z.array(projectSchema)),
400: errorResponse("Invalid body, or workspace ID could not be determined"),
403: errorResponse(
- "No workspace access, or missing project:update permission",
+ "No workspace access, missing project:update permission, or no access to a listed project",
),
},
});
@@ -436,6 +436,7 @@ const project = apiRouter<BaseVariables & { workspaceId: string }>()
const { includeArchived } = c.req.valid("query");
const projects = await getProjectsCtrl(
workspaceId,
+ c.get("userId"),
includeArchived === "true",
);
return c.json(projects.map(toPublicProject), 200);
@@ -443,7 +444,13 @@ const project = apiRouter<BaseVariables & { workspaceId: string }>()
.openapi(createProjectRoute, async (c) => {
const { name, icon, slug } = c.req.valid("json");
const workspaceId = c.get("workspaceId");
- const newProject = await createProjectCtrl(workspaceId, name, icon, slug);
+ const newProject = await createProjectCtrl(
+ workspaceId,
+ name,
+ icon,
+ slug,
+ c.get("userId"),
+ );
return c.json(toPublicProject(newProject), 200);
})
.openapi(getProjectRoute, async (c) => {
@@ -520,7 +527,11 @@ const project = apiRouter<BaseVariables & { workspaceId: string }>()
.openapi(reorderProjectsRoute, async (c) => {
const workspaceId = c.get("workspaceId");
const { projects } = c.req.valid("json");
- const reordered = await reorderProjectsCtrl(workspaceId, projects);
+ const reordered = await reorderProjectsCtrl(
+ workspaceId,
+ c.get("userId"),
+ projects,
+ );
return c.json(reordered.map(toPublicProject), 200);
})
.openapi(updateProjectRoute, async (c) => {
diff --git a/apps/api/src/search/controllers/global-search.ts b/apps/api/src/search/controllers/global-search.ts
index a6ce0e2a3..105fe14aa 100644
--- a/apps/api/src/search/controllers/global-search.ts
+++ b/apps/api/src/search/controllers/global-search.ts
@@ -8,6 +8,8 @@ import {
workspaceTable,
workspaceUserTable,
} from "../../database/schema";
+import { canAccessProject } from "../../project-access/assert-project-access";
+import { projectAccessCondition } from "../../project-access/project-access-condition";
import { escapeLikePattern } from "../like-pattern";
import { TASK_SHORT_ID_PATTERN } from "../task-short-id";
@@ -137,16 +139,22 @@ async function globalSearch(params: SearchParams): Promise<{
.map((w) => w.workspaceId)
.filter(Boolean);
- if (accessibleWorkspaceIds.length === 0) {
+ if (
+ accessibleWorkspaceIds.length === 0 ||
+ (projectId && !(await canAccessProject(resolvedUserId, projectId)))
+ ) {
return { results: [], totalCount: 0, searchQuery: query };
}
const results: SearchResult[] = [];
const searchPattern = `%${query.toLowerCase()}%`;
- const workspaceFilter = workspaceId
- ? eq(projectTable.workspaceId, workspaceId)
- : inArray(projectTable.workspaceId, accessibleWorkspaceIds);
+ const workspaceFilter = and(
+ workspaceId
+ ? eq(projectTable.workspaceId, workspaceId)
+ : inArray(projectTable.workspaceId, accessibleWorkspaceIds),
+ projectAccessCondition(resolvedUserId, projectTable.id),
+ );
// Check if query matches short-id pattern (e.g. "DEP-23"). `generateProjectSlug`
// normalizes to NFKC before it stores a key, so the query is normalized too,
diff --git a/apps/api/src/task-relation/controllers/create-task-relation.ts b/apps/api/src/task-relation/controllers/create-task-relation.ts
index fec1a15a7..411b56f8f 100644
--- a/apps/api/src/task-relation/controllers/create-task-relation.ts
+++ b/apps/api/src/task-relation/controllers/create-task-relation.ts
@@ -7,6 +7,7 @@ import {
taskTable,
} from "../../database/schema";
import { publishEvent } from "../../events";
+import { assertProjectAccess } from "../../project-access/assert-project-access";
async function createTaskRelation({
sourceTaskId,
@@ -84,6 +85,8 @@ async function createTaskRelation({
throw new HTTPException(404, { message: "Target task not found" });
}
+ await assertProjectAccess(userId, targetTask.projectId);
+
const existing = await tx
.select({ id: taskRelationTable.id })
.from(taskRelationTable)
diff --git a/apps/api/src/task-relation/controllers/delete-task-relation.ts b/apps/api/src/task-relation/controllers/delete-task-relation.ts
index cfe93ecca..744ea34f4 100644
--- a/apps/api/src/task-relation/controllers/delete-task-relation.ts
+++ b/apps/api/src/task-relation/controllers/delete-task-relation.ts
@@ -7,6 +7,7 @@ import {
taskTable,
} from "../../database/schema";
import { publishEvent } from "../../events";
+import { projectAccessCondition } from "../../project-access/project-access-condition";
async function deleteTaskRelation(
id: string,
@@ -17,7 +18,12 @@ async function deleteTaskRelation(
.select({ id: taskTable.id })
.from(taskTable)
.innerJoin(projectTable, eq(taskTable.projectId, projectTable.id))
- .where(eq(projectTable.workspaceId, workspaceId));
+ .where(
+ and(
+ eq(projectTable.workspaceId, workspaceId),
+ projectAccessCondition(userId, taskTable.projectId),
+ ),
+ );
// Check both endpoints in the delete statement itself. Legacy cross-tenant
// rows must not bypass the same boundary enforced on creation and reads.
diff --git a/apps/api/src/task-relation/controllers/get-task-relations.ts b/apps/api/src/task-relation/controllers/get-task-relations.ts
index 9b1712196..53495458b 100644
--- a/apps/api/src/task-relation/controllers/get-task-relations.ts
+++ b/apps/api/src/task-relation/controllers/get-task-relations.ts
@@ -6,9 +6,14 @@ import {
taskTable,
userTable,
} from "../../database/schema";
+import { projectAccessCondition } from "../../project-access/project-access-condition";
import { taskIsCompleted } from "../../task/task-is-completed";
-async function getTaskRelations(taskId: string, workspaceId: string) {
+async function getTaskRelations(
+ taskId: string,
+ workspaceId: string,
+ userId: string,
+) {
const relations = await db
.select({
id: taskRelationTable.id,
@@ -66,6 +71,7 @@ async function getTaskRelations(taskId: string, workspaceId: string) {
and(
inArray(taskTable.id, [...taskIds]),
eq(projectTable.workspaceId, workspaceId),
+ projectAccessCondition(userId, projectTable.id),
),
);
diff --git a/apps/api/src/task-relation/index.ts b/apps/api/src/task-relation/index.ts
index 9700498ed..9b665e84f 100644
--- a/apps/api/src/task-relation/index.ts
+++ b/apps/api/src/task-relation/index.ts
@@ -10,6 +10,7 @@ import {
errorResponse,
jsonResponse,
} from "../openapi";
+import { assertProjectAccess } from "../project-access/assert-project-access";
import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { validateWorkspaceAccess } from "../utils/validate-workspace-access";
import { workspaceAccess } from "../utils/workspace-access-middleware";
@@ -26,14 +27,17 @@ import {
taskRelationParam,
} from "./schema";
-async function workspaceIdOfTask(taskId: string) {
+async function scopeOfTask(taskId: string) {
const [task] = await db
- .select({ workspaceId: projectTable.workspaceId })
+ .select({
+ workspaceId: projectTable.workspaceId,
+ projectId: projectTable.id,
+ })
.from(taskTable)
.innerJoin(projectTable, eq(taskTable.projectId, projectTable.id))
.where(eq(taskTable.id, taskId))
.limit(1);
- return task?.workspaceId ?? null;
+ return task ?? null;
}
function requireUserId(c: Context) {
@@ -58,13 +62,14 @@ async function scopeToSourceTask(c: Context, next: Next) {
throw new HTTPException(400, { message: "sourceTaskId is required" });
}
- const workspaceId = await workspaceIdOfTask(sourceTaskId);
- if (!workspaceId) {
+ const scope = await scopeOfTask(sourceTaskId);
+ if (!scope) {
throw new HTTPException(404, { message: "Source task not found" });
}
- await validateWorkspaceAccess(userId, workspaceId);
- c.set("workspaceId", workspaceId);
+ await validateWorkspaceAccess(userId, scope.workspaceId);
+ await assertProjectAccess(userId, scope.projectId);
+ c.set("workspaceId", scope.workspaceId);
return next();
}
@@ -81,13 +86,14 @@ async function scopeToRelation(c: Context, next: Next) {
throw new HTTPException(404, { message: "Task relation not found" });
}
- const workspaceId = await workspaceIdOfTask(rel.sourceTaskId);
- if (!workspaceId) {
+ const scope = await scopeOfTask(rel.sourceTaskId);
+ if (!scope) {
throw new HTTPException(404, { message: "Task not found" });
}
- await validateWorkspaceAccess(userId, workspaceId);
- c.set("workspaceId", workspaceId);
+ await validateWorkspaceAccess(userId, scope.workspaceId);
+ await assertProjectAccess(userId, scope.projectId);
+ c.set("workspaceId", scope.workspaceId);
return next();
}
@@ -166,7 +172,11 @@ const deleteTaskRelationRoute = createRoute({
const taskRelation = apiRouter<BaseVariables & { workspaceId: string }>()
.openapi(getTaskRelationsRoute, async (c) =>
c.json(
- await getTaskRelations(c.req.valid("param").taskId, c.get("workspaceId")),
+ await getTaskRelations(
+ c.req.valid("param").taskId,
+ c.get("workspaceId"),
+ c.get("userId"),
+ ),
200,
),
)
diff --git a/apps/api/src/task/controllers/bulk-update-tasks.ts b/apps/api/src/task/controllers/bulk-update-tasks.ts
index 71b119f62..e9c7cc064 100644
--- a/apps/api/src/task/controllers/bulk-update-tasks.ts
+++ b/apps/api/src/task/controllers/bulk-update-tasks.ts
@@ -246,7 +246,11 @@ async function bulkUpdateTasks({
const assigneeId = value?.trim() || null;
if (assigneeId) {
- await assertAssignableUser(assigneeId, workspaceId);
+ await assertAssignableUser(
+ assigneeId,
+ workspaceId,
+ tasks.map((task) => task.projectId),
+ );
}
const assignee = assigneeId
diff --git a/apps/api/src/task/controllers/create-task.ts b/apps/api/src/task/controllers/create-task.ts
index e833e3ad1..e382cf3f9 100644
--- a/apps/api/src/task/controllers/create-task.ts
+++ b/apps/api/src/task/controllers/create-task.ts
@@ -116,6 +116,7 @@ async function createTask({
await assertAssignableUser(
normalizedUserId,
await getProjectWorkspaceId(projectId),
+ projectId,
);
[assignee] = await db
diff --git a/apps/api/src/task/controllers/duplicate-task.ts b/apps/api/src/task/controllers/duplicate-task.ts
index d9c770695..bd5fa2f2d 100644
--- a/apps/api/src/task/controllers/duplicate-task.ts
+++ b/apps/api/src/task/controllers/duplicate-task.ts
@@ -14,9 +14,14 @@ import {
userTable,
} from "../../database/schema";
import { publishEvent } from "../../events";
+import { projectAccessCondition } from "../../project-access/project-access-condition";
import { contentReferencesAsset } from "../../storage/cleanup-assets";
import { copyTaskAssetObject, deleteS3Object } from "../../storage/s3";
-import { assertAssignableUser } from "../../utils/assert-assignable-user";
+import { filterUsersWithProjectAccess } from "../../project-access/filter-users-with-project-access";
+import {
+ filterAssignableUsers,
+ NOT_ASSIGNABLE,
+} from "../../utils/assert-assignable-user";
import {
assertRequiredCustomFields,
assertValidTaskStatus,
@@ -150,8 +155,21 @@ async function duplicateTask({
}
await assertValidTaskStatus(sourceTask.status, sourceTask.projectId);
- if (sourceTask.userId)
- await assertAssignableUser(sourceTask.userId, project.workspaceId);
+ let assigneeId = sourceTask.userId;
+ if (assigneeId) {
+ const members = await filterAssignableUsers(
+ [assigneeId],
+ project.workspaceId,
+ );
+ if (!members.has(assigneeId)) {
+ throw new HTTPException(403, { message: NOT_ASSIGNABLE });
+ }
+ const permitted = await filterUsersWithProjectAccess(
+ [assigneeId],
+ sourceTask.projectId,
+ );
+ if (!permitted.has(assigneeId)) assigneeId = null;
+ }
const column = await db.query.columnTable.findFirst({
where: and(
eq(columnTable.projectId, sourceTask.projectId),
@@ -230,6 +248,7 @@ async function duplicateTask({
eq(taskRelationTable.targetTaskId, sourceTask.id),
eq(projectTable.workspaceId, project.workspaceId),
eq(taskRelationTable.relationType, "subtask"),
+ projectAccessCondition(currentUserId, taskTable.projectId),
),
);
@@ -269,7 +288,7 @@ async function duplicateTask({
.values({
id: duplicatedTaskId,
projectId: sourceTask.projectId,
- userId: sourceTask.userId,
+ userId: assigneeId,
title: title?.trim() || sourceTask.title,
status: sourceTask.status,
columnId: column?.id ?? null,
diff --git a/apps/api/src/task/controllers/get-assigned-tasks.ts b/apps/api/src/task/controllers/get-assigned-tasks.ts
index 930003a7f..3b5fcd0f2 100644
--- a/apps/api/src/task/controllers/get-assigned-tasks.ts
+++ b/apps/api/src/task/controllers/get-assigned-tasks.ts
@@ -16,6 +16,7 @@ import {
projectTable,
taskTable,
} from "../../database/schema";
+import { projectAccessCondition } from "../../project-access/project-access-condition";
import { taskIsCompleted } from "../task-is-completed";
// Home and My tasks render this list whole, so it stays one bounded page.
@@ -44,6 +45,7 @@ async function getAssignedTasks(
where ${columnTable.id} = ${taskTable.columnId}
and ${columnTable.projectId} = ${taskTable.projectId}
), ${taskIsCompleted})`,
+ projectAccessCondition(userId, projectTable.id),
);
const totalsQuery = db
diff --git a/apps/api/src/task/controllers/get-task-by-ticket-id.ts b/apps/api/src/task/controllers/get-task-by-ticket-id.ts
index 28402dfdb..6d257baa7 100644
--- a/apps/api/src/task/controllers/get-task-by-ticket-id.ts
+++ b/apps/api/src/task/controllers/get-task-by-ticket-id.ts
@@ -12,6 +12,7 @@ import {
isSameProjectKey,
mayMatchProjectKey,
} from "../../project/project-key";
+import { projectAccessCondition } from "../../project-access/project-access-condition";
import { TICKET_ID_PATTERN } from "../ticket-id";
import { hasInstanceAdminRole } from "../../utils/instance-admin-role";
import getTask from "./get-task";
@@ -86,6 +87,7 @@ export default async function getTaskByTicketId(
hasInstanceAdminRole(user?.role)
? undefined
: inArray(projectTable.workspaceId, memberWorkspaces),
+ projectAccessCondition(userId, projectTable.id),
),
);
diff --git a/apps/api/src/task/controllers/get-task.ts b/apps/api/src/task/controllers/get-task.ts
index 001523fb0..fa142a3b6 100644
--- a/apps/api/src/task/controllers/get-task.ts
+++ b/apps/api/src/task/controllers/get-task.ts
@@ -12,7 +12,7 @@ import {
taskRelationTable,
} from "../../database/schema";
-async function getTask(taskId: string, board = false) {
+async function getTask(taskId: string, board = false, userId?: string) {
const task = await db
.select({
id: taskTable.id,
@@ -69,6 +69,7 @@ async function getTask(taskId: string, board = false) {
[taskId, ...parents.map((task) => task.id)],
workspaceId,
false,
+ userId,
),
);
return {
diff --git a/apps/api/src/task/controllers/get-tasks.ts b/apps/api/src/task/controllers/get-tasks.ts
index f606f3952..4f111b55b 100644
--- a/apps/api/src/task/controllers/get-tasks.ts
+++ b/apps/api/src/task/controllers/get-tasks.ts
@@ -96,6 +96,7 @@ async function getTasksPage(
db: TaskReadDatabase,
projectId: string,
options: GetTasksOptions,
+ userId?: string,
) {
const [project] = await db
.select({
@@ -211,6 +212,7 @@ async function getTasksPage(
taskIds,
project.workspaceId,
options.publicOnly ?? false,
+ userId,
);
const labelsData =
@@ -504,9 +506,10 @@ function parseMetadata(raw: string | null): Record<string, unknown> | null {
export default function getTasks(
projectId: string,
options: GetTasksOptions = {},
+ userId?: string,
) {
return boundedTaskRead(
- (db) => getTasksPage(db, projectId, options),
+ (db) => getTasksPage(db, projectId, options, userId),
"Task list request took too long; retry later",
);
}
diff --git a/apps/api/src/task/controllers/import-tasks.ts b/apps/api/src/task/controllers/import-tasks.ts
index 37129d843..915f1c6f7 100644
--- a/apps/api/src/task/controllers/import-tasks.ts
+++ b/apps/api/src/task/controllers/import-tasks.ts
@@ -3,7 +3,12 @@ import { HTTPException } from "hono/http-exception";
import db from "../../database";
import { columnTable, projectTable, taskTable } from "../../database/schema";
import { publishEvent } from "../../events";
-import { filterAssignableUsers } from "../../utils/assert-assignable-user";
+import { filterUsersWithProjectAccess } from "../../project-access/filter-users-with-project-access";
+import {
+ filterAssignableUsers,
+ NO_PROJECT_ACCESS,
+ NOT_ASSIGNABLE,
+} from "../../utils/assert-assignable-user";
import {
coercePriority,
coerceStatus,
@@ -44,10 +49,14 @@ async function importTasks(
),
];
- const assignableIds = await filterAssignableUsers(
+ const memberIds = await filterAssignableUsers(
assigneeIds,
project.workspaceId,
);
+ const assignableIds = await filterUsersWithProjectAccess(
+ memberIds,
+ projectId,
+ );
const validStatuses = await getValidTaskStatuses(projectId);
@@ -59,7 +68,7 @@ async function importTasks(
if (assigneeId && !assignableIds.has(assigneeId)) {
results.push({
success: false,
- error: "Assignee is not a member of this workspace",
+ error: memberIds.has(assigneeId) ? NO_PROJECT_ACCESS : NOT_ASSIGNABLE,
task: taskData,
});
continue;
diff --git a/apps/api/src/task/controllers/move-task.ts b/apps/api/src/task/controllers/move-task.ts
index 039c58d66..56b805c4e 100644
--- a/apps/api/src/task/controllers/move-task.ts
+++ b/apps/api/src/task/controllers/move-task.ts
@@ -1,5 +1,6 @@
import { and, asc, eq, isNotNull, notInArray } from "drizzle-orm";
import { HTTPException } from "hono/http-exception";
+import createActivities from "../../activity/controllers/create-activities";
import db from "../../database";
import {
assetTable,
@@ -10,6 +11,8 @@ import {
taskTable,
} from "../../database/schema";
import { publishEvent } from "../../events";
+import { assertProjectAccess } from "../../project-access/assert-project-access";
+import { filterUsersWithProjectAccess } from "../../project-access/filter-users-with-project-access";
import { claimTaskNumber } from "./claim-task-numbers";
import { nextTaskPosition } from "./next-task-position";
@@ -108,6 +111,8 @@ async function moveTask({
});
}
+ await assertProjectAccess(currentUserId, destinationProjectId);
+
const resolvedColumn = await resolveDestinationStatus(
destinationProjectId,
existingTask.status,
@@ -162,6 +167,38 @@ async function moveTask({
});
}
+ let movedTask = updatedTask;
+ const assigneeId = updatedTask.userId;
+ if (
+ assigneeId &&
+ !(
+ await filterUsersWithProjectAccess(
+ [assigneeId],
+ destinationProjectId,
+ tx,
+ )
+ ).has(assigneeId)
+ ) {
+ const [unassignedTask] = await tx
+ .update(taskTable)
+ .set({ userId: null })
+ .where(eq(taskTable.id, taskId))
+ .returning();
+ movedTask = unassignedTask ?? { ...updatedTask, userId: null };
+ await createActivities(
+ [
+ {
+ taskId,
+ type: "unassigned",
+ userId: currentUserId,
+ content: null,
+ eventData: {},
+ },
+ ],
+ tx,
+ );
+ }
+
await tx
.delete(externalLinkTable)
.where(
@@ -183,7 +220,7 @@ async function moveTask({
.set({ projectId: destinationProjectId })
.where(eq(assetTable.taskId, taskId));
- return updatedTask;
+ return movedTask;
});
await publishEvent("task.moved", {
diff --git a/apps/api/src/task/controllers/update-task-assignee.ts b/apps/api/src/task/controllers/update-task-assignee.ts
index a796ef975..ec02249db 100644
--- a/apps/api/src/task/controllers/update-task-assignee.ts
+++ b/apps/api/src/task/controllers/update-task-assignee.ts
@@ -29,6 +29,7 @@ async function updateTaskAssignee({
await assertAssignableUser(
nextAssigneeId,
await getProjectWorkspaceId(existingTask.projectId, tx),
+ existingTask.projectId,
tx,
);
}
diff --git a/apps/api/src/task/controllers/update-task.ts b/apps/api/src/task/controllers/update-task.ts
index ca5d57adc..d50960949 100644
--- a/apps/api/src/task/controllers/update-task.ts
+++ b/apps/api/src/task/controllers/update-task.ts
@@ -63,10 +63,11 @@ async function updateTask(
const normalizedUserId = userId?.trim() || undefined;
- if (normalizedUserId) {
+ if (normalizedUserId && normalizedUserId !== existingTask.userId) {
await assertAssignableUser(
normalizedUserId,
await getProjectWorkspaceId(projectId),
+ projectId,
);
}
diff --git a/apps/api/src/task/get-subtask-counts.ts b/apps/api/src/task/get-subtask-counts.ts
index ba06eaabe..c7c8cab7b 100644
--- a/apps/api/src/task/get-subtask-counts.ts
+++ b/apps/api/src/task/get-subtask-counts.ts
@@ -1,5 +1,6 @@
import { and, eq, inArray, sql } from "drizzle-orm";
import { projectTable, taskRelationTable, taskTable } from "../database/schema";
+import { projectAccessCondition } from "../project-access/project-access-condition";
import type { TaskReadDatabase } from "./bounded-read";
import { taskIsCompleted } from "./task-is-completed";
@@ -9,6 +10,7 @@ export async function getSubtaskCounts(
taskIds: string[],
workspaceId: string,
publicOnly: boolean,
+ userId?: string,
) {
if (taskIds.length === 0) {
return new Map<string, { completed: number; total: number }>();
@@ -32,6 +34,7 @@ export async function getSubtaskCounts(
eq(taskRelationTable.relationType, "subtask"),
eq(projectTable.workspaceId, workspaceId),
publicOnly ? eq(projectTable.isPublic, true) : undefined,
+ userId ? projectAccessCondition(userId, projectTable.id) : undefined,
),
)
.groupBy(taskRelationTable.sourceTaskId);
diff --git a/apps/api/src/task/index.ts b/apps/api/src/task/index.ts
index d2cd30d7c..1835b2034 100644
--- a/apps/api/src/task/index.ts
+++ b/apps/api/src/task/index.ts
@@ -814,7 +814,7 @@ const task = apiRouter<BaseVariables & { workspaceId: string }>()
const { projectId } = c.req.valid("param");
const filters = c.req.valid("query") || {};
- const tasks = await getTasks(projectId, filters);
+ const tasks = await getTasks(projectId, filters, c.get("userId"));
return c.json(tasks, 200);
})
@@ -937,7 +937,11 @@ const task = apiRouter<BaseVariables & { workspaceId: string }>()
.openapi(getTaskRoute, async (c) => {
const { id } = c.req.valid("param");
- const task = await getTask(id, c.req.valid("query").view === "board");
+ const task = await getTask(
+ id,
+ c.req.valid("query").view === "board",
+ c.get("userId"),
+ );
return c.json(task, 200);
})
diff --git a/apps/api/src/utils/assert-assignable-user.ts b/apps/api/src/utils/assert-assignable-user.ts
index eef238c49..01458fbd5 100644
--- a/apps/api/src/utils/assert-assignable-user.ts
+++ b/apps/api/src/utils/assert-assignable-user.ts
@@ -1,9 +1,12 @@
import { and, eq, inArray } from "drizzle-orm";
import { HTTPException } from "hono/http-exception";
import db, { schema } from "../database";
+import { findInaccessibleProjectIds } from "../project-access/assert-project-access";
import { instanceAdminRoleSql } from "./instance-admin-role";
-const NOT_ASSIGNABLE = "Assignee is not a member of this workspace";
+export const NOT_ASSIGNABLE = "Assignee is not a member of this workspace";
+export const NO_PROJECT_ACCESS =
+ "Assignee does not have access to this project";
export async function filterAssignableUsers(
userIds: string[],
@@ -51,6 +54,7 @@ export async function filterAssignableUsers(
export async function assertAssignableUser(
userId: string,
workspaceId: string,
+ projectIds: string | readonly string[],
database: Pick<typeof db, "select"> = db,
): Promise<void> {
const assignable = await filterAssignableUsers(
@@ -62,6 +66,11 @@ export async function assertAssignableUser(
if (!assignable.has(userId)) {
throw new HTTPException(403, { message: NOT_ASSIGNABLE });
}
+
+ const ids = typeof projectIds === "string" ? [projectIds] : projectIds;
+ if ((await findInaccessibleProjectIds(userId, ids, database)).length > 0) {
+ throw new HTTPException(403, { message: NO_PROJECT_ACCESS });
+ }
}
export async function getProjectWorkspaceId(
diff --git a/apps/api/src/utils/authorize-asset-access.ts b/apps/api/src/utils/authorize-asset-access.ts
index ae9a5ad2b..7fcbc79f8 100644
--- a/apps/api/src/utils/authorize-asset-access.ts
+++ b/apps/api/src/utils/authorize-asset-access.ts
@@ -1,10 +1,12 @@
import type { Context } from "hono";
import { HTTPException } from "hono/http-exception";
+import { assertProjectAccess } from "../project-access/assert-project-access";
import { resolveAssetBearerOrCookie } from "./authenticate-api-request";
import { validateWorkspaceAccess } from "./validate-workspace-access";
type AssetAccessTarget = {
workspaceId: string;
+ projectId: string;
isPublic: boolean | null;
surface: string;
createdBy?: string | null;
@@ -29,4 +31,5 @@ export async function authorizeAssetAccess(
message: "Staged uploads are private to their owner",
});
await validateWorkspaceAccess(userId, asset.workspaceId, apiKeyId);
+ await assertProjectAccess(userId, asset.projectId);
}
diff --git a/apps/api/src/utils/workspace-access-middleware.ts b/apps/api/src/utils/workspace-access-middleware.ts
index 9babe25ea..2406e0041 100644
--- a/apps/api/src/utils/workspace-access-middleware.ts
+++ b/apps/api/src/utils/workspace-access-middleware.ts
@@ -2,6 +2,7 @@ import { and, eq, inArray } from "drizzle-orm";
import type { Context, Next } from "hono";
import { HTTPException } from "hono/http-exception";
import db, { schema } from "../database";
+import { assertProjectAccess } from "../project-access/assert-project-access";
import { validateWorkspaceAccess } from "./validate-workspace-access";
type WorkspaceIdSource =
@@ -32,6 +33,8 @@ type WorkspaceAccessMiddlewareConfig = {
sources: WorkspaceIdSource[];
};
+type ResourceScope = { workspaceId: string; projectId: string | null };
+
async function readJsonObjectBody(
c: Context,
): Promise<Record<string, unknown>> {
@@ -53,6 +56,7 @@ export function workspaceAccessMiddleware(
}
let workspaceId: string | null = null;
+ let projectIds: string[] = [];
for (const source of config.sources) {
if (source.type === "query") {
@@ -73,7 +77,9 @@ export function workspaceAccessMiddleware(
// handler acted on another (`{"taskId": "<someone else's>"}`).
const id = c.req.param(source.idKey) || idFromBody;
if (id) {
- workspaceId = await lookupWorkspaceId(source.resource, id);
+ const scope = await lookupScope(source.resource, id);
+ workspaceId = scope?.workspaceId ?? null;
+ projectIds = scope?.projectId ? [scope.projectId] : [];
}
} else if (source.type === "lookupMany") {
const body = await readJsonObjectBody(c);
@@ -84,7 +90,10 @@ export function workspaceAccessMiddleware(
);
if (taskIds.length > 0) {
const tasks = await db
- .select({ workspaceId: schema.projectTable.workspaceId })
+ .select({
+ workspaceId: schema.projectTable.workspaceId,
+ projectId: schema.projectTable.id,
+ })
.from(schema.taskTable)
.innerJoin(
schema.projectTable,
@@ -103,6 +112,7 @@ export function workspaceAccessMiddleware(
});
}
workspaceId = workspaceIds[0] ?? null;
+ projectIds = [...new Set(tasks.map((task) => task.projectId))];
}
}
}
@@ -122,6 +132,7 @@ export function workspaceAccessMiddleware(
const apiKeyId = apiKey?.id;
await validateWorkspaceAccess(userId, workspaceId, apiKeyId);
+ await assertProjectAccess(userId, projectIds);
c.set("workspaceId", workspaceId);
@@ -129,7 +140,7 @@ export function workspaceAccessMiddleware(
};
}
-async function lookupWorkspaceId(
+async function lookupScope(
resource:
| "project"
| "task"
@@ -141,175 +152,185 @@ async function lookupWorkspaceId(
| "workflowRule"
| "customField",
id: string,
-): Promise<string | null> {
- try {
- switch (resource) {
- case "project": {
- const [project] = await db
- .select({ workspaceId: schema.projectTable.workspaceId })
- .from(schema.projectTable)
- .where(eq(schema.projectTable.id, id))
- .limit(1);
- return project?.workspaceId || null;
- }
-
- case "task": {
- const [task] = await db
- .select({
- workspaceId: schema.projectTable.workspaceId,
- })
- .from(schema.taskTable)
- .innerJoin(
- schema.projectTable,
- eq(schema.taskTable.projectId, schema.projectTable.id),
- )
- .where(eq(schema.taskTable.id, id))
- .limit(1);
- return task?.workspaceId || null;
- }
+): Promise<ResourceScope | null> {
+ switch (resource) {
+ case "project": {
+ const [project] = await db
+ .select({
+ workspaceId: schema.projectTable.workspaceId,
+ projectId: schema.projectTable.id,
+ })
+ .from(schema.projectTable)
+ .where(eq(schema.projectTable.id, id))
+ .limit(1);
+ return project ?? null;
+ }
- case "label": {
- const [label] = await db
- .select({
- workspaceId: schema.labelTable.workspaceId,
- taskId: schema.labelTable.taskId,
- taskWorkspaceId: schema.projectTable.workspaceId,
- })
- .from(schema.labelTable)
- .leftJoin(
- schema.taskTable,
- eq(schema.labelTable.taskId, schema.taskTable.id),
- )
- .leftJoin(
- schema.projectTable,
- eq(schema.taskTable.projectId, schema.projectTable.id),
- )
- .where(eq(schema.labelTable.id, id))
- .limit(1);
- // Older releases allowed inconsistent label/task references. Never use
- // such a row to authorize reads, mutations or external provider sync.
- if (label?.taskId && label.taskWorkspaceId !== label.workspaceId) {
- return null;
- }
- return label?.workspaceId || null;
- }
+ case "task": {
+ const [task] = await db
+ .select({
+ workspaceId: schema.projectTable.workspaceId,
+ projectId: schema.projectTable.id,
+ })
+ .from(schema.taskTable)
+ .innerJoin(
+ schema.projectTable,
+ eq(schema.taskTable.projectId, schema.projectTable.id),
+ )
+ .where(eq(schema.taskTable.id, id))
+ .limit(1);
+ return task ?? null;
+ }
- case "timeEntry": {
- const [timeEntry] = await db
- .select({
- workspaceId: schema.projectTable.workspaceId,
- })
- .from(schema.timeEntryTable)
- .innerJoin(
- schema.taskTable,
- eq(schema.timeEntryTable.taskId, schema.taskTable.id),
- )
- .innerJoin(
- schema.projectTable,
- eq(schema.taskTable.projectId, schema.projectTable.id),
- )
- .where(eq(schema.timeEntryTable.id, id))
- .limit(1);
- return timeEntry?.workspaceId || null;
+ case "label": {
+ const [label] = await db
+ .select({
+ workspaceId: schema.labelTable.workspaceId,
+ taskId: schema.labelTable.taskId,
+ taskWorkspaceId: schema.projectTable.workspaceId,
+ taskProjectId: schema.projectTable.id,
+ })
+ .from(schema.labelTable)
+ .leftJoin(
+ schema.taskTable,
+ eq(schema.labelTable.taskId, schema.taskTable.id),
+ )
+ .leftJoin(
+ schema.projectTable,
+ eq(schema.taskTable.projectId, schema.projectTable.id),
+ )
+ .where(eq(schema.labelTable.id, id))
+ .limit(1);
+ // Older releases allowed inconsistent label/task references. Never use
+ // such a row to authorize reads, mutations or external provider sync.
+ if (label?.taskId && label.taskWorkspaceId !== label.workspaceId) {
+ return null;
}
+ if (!label?.workspaceId) return null;
+ return {
+ workspaceId: label.workspaceId,
+ projectId: label.taskProjectId ?? null,
+ };
+ }
- case "activity": {
- const [activity] = await db
- .select({
- workspaceId: schema.projectTable.workspaceId,
- })
- .from(schema.activityTable)
- .innerJoin(
- schema.taskTable,
- eq(schema.activityTable.taskId, schema.taskTable.id),
- )
- .innerJoin(
- schema.projectTable,
- eq(schema.taskTable.projectId, schema.projectTable.id),
- )
- .where(eq(schema.activityTable.id, id))
- .limit(1);
- return activity?.workspaceId || null;
- }
+ case "timeEntry": {
+ const [timeEntry] = await db
+ .select({
+ workspaceId: schema.projectTable.workspaceId,
+ projectId: schema.projectTable.id,
+ })
+ .from(schema.timeEntryTable)
+ .innerJoin(
+ schema.taskTable,
+ eq(schema.timeEntryTable.taskId, schema.taskTable.id),
+ )
+ .innerJoin(
+ schema.projectTable,
+ eq(schema.taskTable.projectId, schema.projectTable.id),
+ )
+ .where(eq(schema.timeEntryTable.id, id))
+ .limit(1);
+ return timeEntry ?? null;
+ }
- case "comment": {
- const [comment] = await db
- .select({
- workspaceId: schema.projectTable.workspaceId,
- })
- .from(schema.activityTable)
- .innerJoin(
- schema.taskTable,
- eq(schema.activityTable.taskId, schema.taskTable.id),
- )
- .innerJoin(
- schema.projectTable,
- eq(schema.taskTable.projectId, schema.projectTable.id),
- )
- .where(
- and(
- eq(schema.activityTable.id, id),
- eq(schema.activityTable.type, "comment"),
- ),
- )
- .limit(1);
- return comment?.workspaceId || null;
- }
+ case "activity": {
+ const [activity] = await db
+ .select({
+ workspaceId: schema.projectTable.workspaceId,
+ projectId: schema.projectTable.id,
+ })
+ .from(schema.activityTable)
+ .innerJoin(
+ schema.taskTable,
+ eq(schema.activityTable.taskId, schema.taskTable.id),
+ )
+ .innerJoin(
+ schema.projectTable,
+ eq(schema.taskTable.projectId, schema.projectTable.id),
+ )
+ .where(eq(schema.activityTable.id, id))
+ .limit(1);
+ return activity ?? null;
+ }
- case "column": {
- const [column] = await db
- .select({
- workspaceId: schema.projectTable.workspaceId,
- })
- .from(schema.columnTable)
- .innerJoin(
- schema.projectTable,
- eq(schema.columnTable.projectId, schema.projectTable.id),
- )
- .where(eq(schema.columnTable.id, id))
- .limit(1);
- return column?.workspaceId || null;
- }
+ case "comment": {
+ const [comment] = await db
+ .select({
+ workspaceId: schema.projectTable.workspaceId,
+ projectId: schema.projectTable.id,
+ })
+ .from(schema.activityTable)
+ .innerJoin(
+ schema.taskTable,
+ eq(schema.activityTable.taskId, schema.taskTable.id),
+ )
+ .innerJoin(
+ schema.projectTable,
+ eq(schema.taskTable.projectId, schema.projectTable.id),
+ )
+ .where(
+ and(
+ eq(schema.activityTable.id, id),
+ eq(schema.activityTable.type, "comment"),
+ ),
+ )
+ .limit(1);
+ return comment ?? null;
+ }
- case "workflowRule": {
- const [workflowRule] = await db
- .select({
- workspaceId: schema.projectTable.workspaceId,
- })
- .from(schema.workflowRuleTable)
- .innerJoin(
- schema.projectTable,
- eq(schema.workflowRuleTable.projectId, schema.projectTable.id),
- )
- .where(eq(schema.workflowRuleTable.id, id))
- .limit(1);
- return workflowRule?.workspaceId || null;
- }
+ case "column": {
+ const [column] = await db
+ .select({
+ workspaceId: schema.projectTable.workspaceId,
+ projectId: schema.projectTable.id,
+ })
+ .from(schema.columnTable)
+ .innerJoin(
+ schema.projectTable,
+ eq(schema.columnTable.projectId, schema.projectTable.id),
+ )
+ .where(eq(schema.columnTable.id, id))
+ .limit(1);
+ return column ?? null;
+ }
- case "customField": {
- const [field] = await db
- .select({
- workspaceId: schema.projectTable.workspaceId,
- })
- .from(schema.customFieldDefinitionTable)
- .innerJoin(
- schema.projectTable,
- eq(
- schema.customFieldDefinitionTable.projectId,
- schema.projectTable.id,
- ),
- )
- .where(eq(schema.customFieldDefinitionTable.id, id))
- .limit(1);
- return field?.workspaceId || null;
- }
+ case "workflowRule": {
+ const [workflowRule] = await db
+ .select({
+ workspaceId: schema.projectTable.workspaceId,
+ projectId: schema.projectTable.id,
+ })
+ .from(schema.workflowRuleTable)
+ .innerJoin(
+ schema.projectTable,
+ eq(schema.workflowRuleTable.projectId, schema.projectTable.id),
+ )
+ .where(eq(schema.workflowRuleTable.id, id))
+ .limit(1);
+ return workflowRule ?? null;
+ }
- default:
- return null;
+ case "customField": {
+ const [field] = await db
+ .select({
+ workspaceId: schema.projectTable.workspaceId,
+ projectId: schema.projectTable.id,
+ })
+ .from(schema.customFieldDefinitionTable)
+ .innerJoin(
+ schema.projectTable,
+ eq(
+ schema.customFieldDefinitionTable.projectId,
+ schema.projectTable.id,
+ ),
+ )
+ .where(eq(schema.customFieldDefinitionTable.id, id))
+ .limit(1);
+ return field ?? null;
}
- } catch (error) {
- console.error(`Error looking up workspaceId for ${resource}:`, error);
- return null;
+
+ default:
+ return null;
}
}
diff --git a/apps/api/src/workspace/controllers/get-workspace-members.ts b/apps/api/src/workspace/controllers/get-workspace-members.ts
index 59b71bc78..4c272d2cd 100644
--- a/apps/api/src/workspace/controllers/get-workspace-members.ts
+++ b/apps/api/src/workspace/controllers/get-workspace-members.ts
@@ -1,8 +1,26 @@
-import { eq } from "drizzle-orm";
+import { and, eq } from "drizzle-orm";
+import { HTTPException } from "hono/http-exception";
import db from "../../database";
import { userTable, workspaceUserTable } from "../../database/schema";
+import { assertProjectAccess } from "../../project-access/assert-project-access";
+import { findWorkspaceProjectIds } from "../../project-access/member-project-access";
+import { projectAccessCondition } from "../../project-access/project-access-condition";
+
+async function getWorkspaceMembers(request: {
+ workspaceId: string;
+ userId: string;
+ projectId?: string;
+}) {
+ const { workspaceId, projectId } = request;
+
+ if (projectId) {
+ const [known] = await findWorkspaceProjectIds(workspaceId, [projectId]);
+ if (!known) {
+ throw new HTTPException(404, { message: "Project not found" });
+ }
+ await assertProjectAccess(request.userId, projectId);
+ }
-async function getWorkspaceMembers(workspaceId: string) {
const members = await db
.select({
id: userTable.id,
@@ -13,7 +31,14 @@ async function getWorkspaceMembers(workspaceId: string) {
})
.from(workspaceUserTable)
.innerJoin(userTable, eq(workspaceUserTable.userId, userTable.id))
- .where(eq(workspaceUserTable.workspaceId, workspaceId));
+ .where(
+ and(
+ eq(workspaceUserTable.workspaceId, workspaceId),
+ projectId
+ ? projectAccessCondition(workspaceUserTable.userId, projectId)
+ : undefined,
+ ),
+ );
return members;
}
diff --git a/apps/api/src/workspace/controllers/update-member-project-access.ts b/apps/api/src/workspace/controllers/update-member-project-access.ts
new file mode 100644
index 000000000..8b689e525
--- /dev/null
+++ b/apps/api/src/workspace/controllers/update-member-project-access.ts
@@ -0,0 +1,78 @@
+import { and, eq } from "drizzle-orm";
+import { HTTPException } from "hono/http-exception";
+import db, { schema } from "../../database";
+import { publishEvent } from "../../events";
+import { keepHiddenGrants } from "../../project-access/keep-hidden-grants";
+import { replaceMemberProjectAccess } from "../../project-access/member-project-access";
+import type { ProjectAccessMode } from "../../project-access/project-access-mode";
+import { resolveProjectAccessRequest } from "../../project-access/resolve-project-access-request";
+
+async function updateMemberProjectAccess(request: {
+ workspaceId: string;
+ actorId: string;
+ userId: string;
+ projectAccess: ProjectAccessMode;
+ projectIds: string[];
+}) {
+ const { workspaceId, actorId, userId } = request;
+
+ if (actorId === userId) {
+ throw new HTTPException(403, {
+ message: "You can't change your own project access",
+ });
+ }
+
+ const [member] = await db
+ .select({ role: schema.workspaceUserTable.role })
+ .from(schema.workspaceUserTable)
+ .where(
+ and(
+ eq(schema.workspaceUserTable.workspaceId, workspaceId),
+ eq(schema.workspaceUserTable.userId, userId),
+ ),
+ )
+ .limit(1);
+
+ if (!member) {
+ throw new HTTPException(404, { message: "Member not found" });
+ }
+
+ const resolution = await resolveProjectAccessRequest({
+ workspaceId,
+ actorId,
+ targetRole: member.role,
+ projectAccess: request.projectAccess,
+ projectIds: request.projectIds,
+ });
+
+ if (!resolution.ok) {
+ throw new HTTPException(resolution.status, {
+ message: resolution.message,
+ });
+ }
+
+ const outcome = await keepHiddenGrants({
+ workspaceId,
+ actorId,
+ userId,
+ access: resolution.access,
+ });
+
+ if (!outcome.ok) {
+ throw new HTTPException(403, { message: outcome.message });
+ }
+
+ await db.transaction((tx) =>
+ replaceMemberProjectAccess(tx, {
+ workspaceId,
+ userId,
+ ...outcome.access,
+ }),
+ );
+
+ await publishEvent("project_access.updated", { workspaceId, userId });
+
+ return { userId, ...outcome.access };
+}
+
+export default updateMemberProjectAccess;
diff --git a/apps/api/src/workspace/index.ts b/apps/api/src/workspace/index.ts
index d35fce80b..a583123d5 100644
--- a/apps/api/src/workspace/index.ts
+++ b/apps/api/src/workspace/index.ts
@@ -5,10 +5,22 @@ import {
errorResponse,
jsonResponse,
} from "../openapi";
+import { listWorkspaceProjectAccess } from "../project-access/member-project-access";
+import { requireWorkspacePermission } from "../utils/require-workspace-permission";
import { workspaceAccess } from "../utils/workspace-access-middleware";
import getWorkspaceMembersCtrl from "./controllers/get-workspace-members";
-import { workspaceMemberListSchema } from "./response";
-import { workspaceIdParam } from "./schema";
+import updateMemberProjectAccessCtrl from "./controllers/update-member-project-access";
+import {
+ memberProjectAccessListSchema,
+ memberProjectAccessSchema,
+ workspaceMemberListSchema,
+} from "./response";
+import {
+ updateMemberProjectAccessBody,
+ workspaceIdParam,
+ workspaceMemberParam,
+ workspaceMembersQuery,
+} from "./schema";
const getWorkspaceMembersRoute = createRoute({
method: "get",
@@ -16,19 +28,103 @@ const getWorkspaceMembersRoute = createRoute({
path: "/{workspaceId}/members",
tags: ["Workspaces"],
summary: "Get workspace members",
- description: "Get all members of a workspace, with their role.",
+ description:
+ "Get all members of a workspace, with their role. Pass projectId to get only the members who can access that project.",
middleware: [workspaceAccess.fromParam("workspaceId")] as const,
- request: { params: workspaceIdParam },
+ request: { params: workspaceIdParam, query: workspaceMembersQuery },
responses: {
200: jsonResponse("List of workspace members", workspaceMemberListSchema),
400: errorResponse("Workspace ID could not be determined"),
- 403: errorResponse("No access to the workspace"),
+ 403: errorResponse("No access to the workspace or to the project"),
+ 404: errorResponse("Project not found in this workspace"),
+ },
+});
+
+const getWorkspaceProjectAccessRoute = createRoute({
+ method: "get",
+ operationId: "getWorkspaceProjectAccess",
+ path: "/{workspaceId}/project-access",
+ tags: ["Workspaces"],
+ summary: "Get member project access",
+ description:
+ "List the members who are limited to selected projects, with the projects each one can access. Everyone else in the workspace can access every project.",
+ middleware: [
+ workspaceAccess.fromParam("workspaceId"),
+ requireWorkspacePermission({ member: ["update"] }),
+ ] as const,
+ request: { params: workspaceIdParam },
+ responses: {
+ 200: jsonResponse(
+ "Members limited to selected projects",
+ memberProjectAccessListSchema,
+ ),
+ 400: errorResponse("Workspace ID could not be determined"),
+ 403: errorResponse(
+ "No workspace access, or missing member:update permission",
+ ),
+ },
+});
+
+const updateMemberProjectAccessRoute = createRoute({
+ method: "put",
+ operationId: "updateMemberProjectAccess",
+ path: "/{workspaceId}/members/{userId}/project-access",
+ tags: ["Workspaces"],
+ summary: "Update member project access",
+ description:
+ "Give a member access to every project, or limit them to selected projects. Owners always access every project, and you can't change your own access or give access to projects you can't access yourself.",
+ middleware: [
+ workspaceAccess.fromParam("workspaceId"),
+ requireWorkspacePermission({ member: ["update"] }),
+ ] as const,
+ request: {
+ params: workspaceMemberParam,
+ body: {
+ required: true,
+ content: {
+ "application/json": { schema: updateMemberProjectAccessBody },
+ },
+ },
+ },
+ responses: {
+ 200: jsonResponse("The member's project access", memberProjectAccessSchema),
+ 400: errorResponse(
+ "Invalid body, the member is an owner, or a project is not in this workspace",
+ ),
+ 403: errorResponse(
+ "Missing member:update permission, changing your own access, or granting a project you can't access",
+ ),
+ 404: errorResponse("Member not found"),
},
});
-const workspace = apiRouter<BaseVariables & { workspaceId: string }>().openapi(
- getWorkspaceMembersRoute,
- async (c) => c.json(await getWorkspaceMembersCtrl(c.get("workspaceId")), 200),
-);
+const workspace = apiRouter<BaseVariables & { workspaceId: string }>()
+ .openapi(getWorkspaceMembersRoute, async (c) =>
+ c.json(
+ await getWorkspaceMembersCtrl({
+ workspaceId: c.get("workspaceId"),
+ userId: c.get("userId"),
+ projectId: c.req.valid("query").projectId,
+ }),
+ 200,
+ ),
+ )
+ .openapi(getWorkspaceProjectAccessRoute, async (c) =>
+ c.json(await listWorkspaceProjectAccess(c.get("workspaceId")), 200),
+ )
+ .openapi(updateMemberProjectAccessRoute, async (c) => {
+ const { userId } = c.req.valid("param");
+ const body = c.req.valid("json");
+ return c.json(
+ await updateMemberProjectAccessCtrl({
+ workspaceId: c.get("workspaceId"),
+ actorId: c.get("userId"),
+ userId,
+ projectAccess: body.projectAccess,
+ projectIds: body.projectIds,
+ }),
+ 200,
+ );
+ });
export default workspace;
diff --git a/apps/api/src/workspace/response.ts b/apps/api/src/workspace/response.ts
index dca2965b2..7410a4e97 100644
--- a/apps/api/src/workspace/response.ts
+++ b/apps/api/src/workspace/response.ts
@@ -1,3 +1,4 @@
+import { PROJECT_ACCESS_MODES } from "../project-access/project-access-mode";
import { z } from "../openapi";
export const workspaceMemberSchema = z
@@ -14,3 +15,18 @@ export const workspaceMemberSchema = z
.openapi("WorkspaceMember");
export const workspaceMemberListSchema = z.array(workspaceMemberSchema);
+
+export const memberProjectAccessSchema = z
+ .object({
+ userId: z.string(),
+ projectAccess: z.enum(PROJECT_ACCESS_MODES),
+ projectIds: z.array(z.string()),
+ })
+ .openapi("MemberProjectAccess");
+
+export const memberProjectAccessListSchema = z
+ .array(memberProjectAccessSchema)
+ .openapi({
+ description:
+ "Members limited to selected projects. Members not listed can access every project.",
+ });
diff --git a/apps/api/src/workspace/schema.ts b/apps/api/src/workspace/schema.ts
index fd911d4b6..de1d84c2f 100644
--- a/apps/api/src/workspace/schema.ts
+++ b/apps/api/src/workspace/schema.ts
@@ -1,3 +1,27 @@
+import { PROJECT_ACCESS_MODES } from "../project-access/project-access-mode";
import { z } from "../openapi";
export const workspaceIdParam = z.object({ workspaceId: z.string() });
+
+export const workspaceMemberParam = z.object({
+ workspaceId: z.string(),
+ userId: z.string(),
+});
+
+export const workspaceMembersQuery = z.object({
+ projectId: z.string().optional().openapi({
+ description:
+ "Only return members who can access this project, for example to fill an assignee picker.",
+ }),
+});
+
+export const updateMemberProjectAccessBody = z.object({
+ projectAccess: z.enum(PROJECT_ACCESS_MODES).openapi({
+ description:
+ '"all" gives access to every project in the workspace, including future ones. "selected" limits the member to projectIds.',
+ }),
+ projectIds: z.array(z.string()).default([]).openapi({
+ description:
+ 'Projects the member can access when projectAccess is "selected".',
+ }),
+});
diff --git a/apps/api/src/ws/index.ts b/apps/api/src/ws/index.ts
index 1db77f972..2c19f215e 100644
--- a/apps/api/src/ws/index.ts
+++ b/apps/api/src/ws/index.ts
@@ -10,6 +10,8 @@ import {
workspaceUserTable,
} from "../database/schema";
import { subscribeToEvent } from "../events";
+import { findInaccessibleProjectIds } from "../project-access/assert-project-access";
+import { filterUsersWithProjectAccess } from "../project-access/filter-users-with-project-access";
import {
hasInstanceAdminRole,
instanceAdminRoleSql,
@@ -95,6 +97,12 @@ function deliverToLocalUserConnections(
) {
revokeLocalWorkspaceConnections(userId, message.workspaceId);
}
+ if (
+ message.type === "PROJECT_ACCESS_CHANGED" &&
+ typeof message.workspaceId === "string"
+ ) {
+ void revokeLocalProjectConnections(userId, message.workspaceId);
+ }
const allAccessRevoked = message.type === "USER_ACCESS_REVOKED";
if (allAccessRevoked) {
for (const [projectId, connections] of projectConnections)
@@ -303,6 +311,40 @@ function revokeLocalWorkspaceConnections(userId: string, workspaceId: string) {
}
}
+async function revokeLocalProjectConnections(
+ userId: string,
+ workspaceId: string,
+) {
+ const owned = [...projectConnections].flatMap(([projectId, connections]) =>
+ [...connections]
+ .filter(
+ (conn) => conn.userId === userId && conn.workspaceId === workspaceId,
+ )
+ .map((conn) => ({ projectId, conn })),
+ );
+ if (owned.length === 0) return;
+ let denied: Set<string>;
+ try {
+ denied = new Set(
+ await findInaccessibleProjectIds(
+ userId,
+ owned.map(({ projectId }) => projectId),
+ ),
+ );
+ } catch (error) {
+ console.error("Failed to verify project access:", error);
+ return;
+ }
+ for (const { projectId, conn } of owned) {
+ if (!denied.has(projectId)) continue;
+ if (!projectConnections.get(projectId)?.has(conn)) continue;
+ removeConnection(projectId, conn);
+ try {
+ conn.ws.close(1008, "Project access revoked");
+ } catch {}
+ }
+}
+
export async function revokeUserConnections(userId: string) {
const message = { type: "USER_ACCESS_REVOKED" };
deliverToLocalUserConnections(userId, message);
@@ -383,18 +425,19 @@ function currentProjectWorkspace(projectId: string) {
const authorizationLookups = new Map<
string,
- Promise<{ workspaceId: string | null; members: Set<string> } | null>
+ Promise<{
+ workspaceId: string | null;
+ members: Set<string>;
+ restricted: Set<string>;
+ } | null>
>();
function currentBroadcastAccess(
projectId: string,
recipients: Array<{ userId: string }>,
authorizationBatch: string,
) {
- const key = JSON.stringify([
- projectId,
- authorizationBatch,
- [...new Set(recipients.map((conn) => conn.userId))].sort(),
- ]);
+ const userIds = [...new Set(recipients.map((conn) => conn.userId))].sort();
+ const key = JSON.stringify([projectId, authorizationBatch, userIds]);
let pending = authorizationLookups.get(key);
if (!pending) {
pending = (async () => {
@@ -406,23 +449,26 @@ function currentBroadcastAccess(
return null;
}
let members = new Set<string>();
+ let restricted = new Set<string>();
if (workspaceId) {
try {
- const rows = await db
- .select({ userId: workspaceUserTable.userId })
- .from(workspaceUserTable)
- .where(
- and(
- eq(workspaceUserTable.workspaceId, workspaceId),
- inArray(workspaceUserTable.userId, [
- ...new Set(recipients.map((conn) => conn.userId)),
- ]),
+ const [rows, permitted] = await Promise.all([
+ db
+ .select({ userId: workspaceUserTable.userId })
+ .from(workspaceUserTable)
+ .where(
+ and(
+ eq(workspaceUserTable.workspaceId, workspaceId),
+ inArray(workspaceUserTable.userId, userIds),
+ ),
),
- );
+ filterUsersWithProjectAccess(userIds, projectId),
+ ]);
members = new Set(rows.map((row) => row.userId));
- const nonmembers = [
- ...new Set(recipients.map((conn) => conn.userId)),
- ].filter((userId) => !members.has(userId));
+ restricted = new Set(
+ userIds.filter((userId) => !permitted.has(userId)),
+ );
+ const nonmembers = userIds.filter((userId) => !members.has(userId));
if (nonmembers.length > 0) {
const admins = await db
.select({ userId: userTable.id, role: userTable.role })
@@ -440,7 +486,7 @@ function currentBroadcastAccess(
return null;
}
}
- return { workspaceId, members };
+ return { workspaceId, members, restricted };
})().finally(() => authorizationLookups.delete(key));
authorizationLookups.set(key, pending);
}
@@ -466,20 +512,23 @@ async function deliverToLocalConnections(
authorizationBatch,
);
if (!access) return;
- const { workspaceId, members } = access;
+ const { workspaceId, members, restricted } = access;
const payload = JSON.stringify(message);
for (const conn of recipients) {
// A move may have closed these connections while the lookup was in flight.
if (!projectConnections.get(projectId)?.has(conn)) continue;
- if (conn.workspaceId !== workspaceId || !members.has(conn.userId)) {
+ const revoked =
+ conn.workspaceId !== workspaceId
+ ? "Project workspace changed"
+ : !members.has(conn.userId)
+ ? "Workspace access revoked"
+ : restricted.has(conn.userId)
+ ? "Project access revoked"
+ : null;
+ if (revoked) {
removeConnection(projectId, conn);
try {
- conn.ws.close(
- 1008,
- conn.workspaceId !== workspaceId
- ? "Project workspace changed"
- : "Workspace access revoked",
- );
+ conn.ws.close(1008, revoked);
} catch {
/* Already closed. */
}
@@ -712,6 +761,16 @@ subscribeToEvent<{ notificationId: string; userId: string }>(
},
);
+subscribeToEvent<{ workspaceId: string; userId: string }>(
+ "project_access.updated",
+ async ({ workspaceId, userId }) => {
+ if (!workspaceId || !userId) return;
+ const message = { type: "PROJECT_ACCESS_CHANGED", workspaceId };
+ deliverToLocalUserConnections(userId, message);
+ await revocationDelivery?.send({ userId, message, origin: INSTANCE_ID });
+ },
+);
+
subscribeToEvent<{
projectId: string;
initiatorId?: string;
diff --git a/apps/api/src/ws/revocation-delivery.ts b/apps/api/src/ws/revocation-delivery.ts
index b03ab1f02..987c65b70 100644
--- a/apps/api/src/ws/revocation-delivery.ts
+++ b/apps/api/src/ws/revocation-delivery.ts
@@ -43,7 +43,11 @@ export function createRevocationDelivery(
return {
async send(message: UserBroadcast, shouldRetry?: () => Promise<boolean>) {
if (stopped) return;
- const key = JSON.stringify([message.userId, message.message.workspaceId]);
+ const key = JSON.stringify([
+ message.userId,
+ message.message.workspaceId,
+ message.message.type,
+ ]);
const entry = { message, shouldRetry };
pending.set(key, entry);
// Redis can queue PUBLISH through a long outage. Local revocation has
diff --git a/apps/docs/core/functional/collaborate-with-team.mdx b/apps/docs/core/functional/collaborate-with-team.mdx
index e46c3f5ef..e18bc44b8 100644
--- a/apps/docs/core/functional/collaborate-with-team.mdx
+++ b/apps/docs/core/functional/collaborate-with-team.mdx
@@ -9,8 +9,9 @@ Membership belongs to a workspace. Make sure the workspace name at the top of th
1. Open **Members** in the workspace sidebar.
2. Choose **Invite member** and enter their email address.
-3. Create the invitation, then copy the link shown in the dialog.
-4. Share the link with that person. With SMTP configured, the instance can also send an invitation email.
+3. Under **Project access**, keep **All projects** or choose **Selected projects** and pick the projects they need. See [Limit a member to selected projects](#limit-a-member-to-selected-projects).
+4. Create the invitation, then copy the link shown in the dialog.
+5. Share the link with that person. With SMTP configured, the instance can also send an invitation email.
The person must sign in or sign up with the invited email address and accept the invitation. New invitations created from this dialog use the **Member** role. You can change the role after the person joins.
@@ -42,6 +43,29 @@ These are the starting permissions. An administrator can edit the **Viewer**, **
Task assignment and deletion are separate permissions. A member who can edit a task may still be unable to assign or delete it.
+## Limit a member to selected projects
+
+By default, members can open every project in the workspace, including projects created later. To invite a client or contractor without showing them unrelated work, limit them to selected projects:
+
+1. Open **Members** in the workspace sidebar.
+2. In the **Projects** column, choose the member's current access, for example **All projects**.
+3. Choose **Selected projects**, tick the projects they should see, and choose **Save**.
+
+If a limited member opens a link to another project, they see **You don't have access to this project** and can ask a workspace admin for access.
+
+A limited member only sees those projects: their boards, tasks, comments, activity, search results, notifications, and **My tasks**. The same limit applies to their API keys and MCP clients, and a board they have open closes as soon as you remove the project.
+
+Project access works alongside roles. The role decides what someone can do; project access decides where. A limited member who can create projects keeps access to the projects they create.
+
+Some rules keep this predictable:
+
+- Owners always have access to every project.
+- You need permission to change roles, and you can't change your own project access.
+- If your own access is limited, you can only give others access to projects you can open, and you can't give anyone **All projects** or limit someone who has it. Projects you can't open stay as they are on the member you edit.
+- Tasks can only be assigned to people who can see the project.
+
+Project access set on an invitation applies when the person accepts it. To change it before then, cancel the invitation and invite them again.
+
## Edit roles or create a custom role
Open **Settings → Workspace → Roles** to inspect the permissions behind a role. If you have role-management permission, you can change the editable roles or create a custom one.
diff --git a/apps/docs/openapi.json b/apps/docs/openapi.json
index 6ca25821d..5c451309d 100644
--- a/apps/docs/openapi.json
+++ b/apps/docs/openapi.json
@@ -4325,6 +4325,32 @@
"role"
]
},
+ "MemberProjectAccess": {
+ "type": "object",
+ "properties": {
+ "userId": {
+ "type": "string"
+ },
+ "projectAccess": {
+ "type": "string",
+ "enum": [
+ "all",
+ "selected"
+ ]
+ },
+ "projectIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": [
+ "userId",
+ "projectAccess",
+ "projectIds"
+ ]
+ },
"CustomFieldDefinition": {
"type": "object",
"properties": {
@@ -5999,6 +6025,21 @@
}
}
]
+ },
+ "projectAccess": {
+ "type": "string",
+ "enum": [
+ "all",
+ "selected"
+ ],
+ "description": "\"all\" (the default) gives access to every project. \"selected\" limits the new member to projectIds once they accept."
+ },
+ "projectIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "Projects the new member can access when projectAccess is \"selected\". They must belong to the workspace, and an inviter whose own access is limited can only choose projects they can access."
}
},
"required": [
@@ -8159,7 +8200,7 @@
"description": "Missing or invalid credentials"
},
"403": {
- "description": "No workspace access, or missing project:update permission",
+ "description": "No workspace access, missing project:update permission, or no access to a listed project",
"content": {
"text/plain": {
"schema": {
@@ -18719,7 +18760,7 @@
"Workspaces"
],
"summary": "Get workspace members",
- "description": "Get all members of a workspace, with their role.",
+ "description": "Get all members of a workspace, with their role. Pass projectId to get only the members who can access that project.",
"parameters": [
{
"schema": {
@@ -18728,6 +18769,16 @@
"required": true,
"name": "workspaceId",
"in": "path"
+ },
+ {
+ "schema": {
+ "type": "string",
+ "description": "Only return members who can access this project, for example to fill an assignee picker."
+ },
+ "required": false,
+ "description": "Only return members who can access this project, for example to fill an assignee picker.",
+ "name": "projectId",
+ "in": "query"
}
],
"responses": {
@@ -18758,7 +18809,180 @@
"description": "Missing or invalid credentials"
},
"403": {
- "description": "No access to the workspace",
+ "description": "No access to the workspace or to the project",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "Project not found in this workspace",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/workspace/{workspaceId}/project-access": {
+ "get": {
+ "operationId": "getWorkspaceProjectAccess",
+ "tags": [
+ "Workspaces"
+ ],
+ "summary": "Get member project access",
+ "description": "List the members who are limited to selected projects, with the projects each one can access. Everyone else in the workspace can access every project.",
+ "parameters": [
+ {
+ "schema": {
+ "type": "string"
+ },
+ "required": true,
+ "name": "workspaceId",
+ "in": "path"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Members limited to selected projects",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/MemberProjectAccess"
+ },
+ "description": "Members limited to selected projects. Members not listed can access every project."
+ }
+ }
+ }
+ },
+ "400": {
+ "description": "Workspace ID could not be determined",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ },
+ "403": {
+ "description": "No workspace access, or missing member:update permission",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/workspace/{workspaceId}/members/{userId}/project-access": {
+ "put": {
+ "operationId": "updateMemberProjectAccess",
+ "tags": [
+ "Workspaces"
+ ],
+ "summary": "Update member project access",
+ "description": "Give a member access to every project, or limit them to selected projects. Owners always access every project, and you can't change your own access or give access to projects you can't access yourself.",
+ "parameters": [
+ {
+ "schema": {
+ "type": "string"
+ },
+ "required": true,
+ "name": "workspaceId",
+ "in": "path"
+ },
+ {
+ "schema": {
+ "type": "string"
+ },
+ "required": true,
+ "name": "userId",
+ "in": "path"
+ }
+ ],
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "projectAccess": {
+ "type": "string",
+ "enum": [
+ "all",
+ "selected"
+ ],
+ "description": "\"all\" gives access to every project in the workspace, including future ones. \"selected\" limits the member to projectIds."
+ },
+ "projectIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": [],
+ "description": "Projects the member can access when projectAccess is \"selected\"."
+ }
+ },
+ "required": [
+ "projectAccess"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "The member's project access",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/MemberProjectAccess"
+ }
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid body, the member is an owner, or a project is not in this workspace",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid credentials"
+ },
+ "403": {
+ "description": "Missing member:update permission, changing your own access, or granting a project you can't access",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "Member not found",
"content": {
"text/plain": {
"schema": {
diff --git a/apps/web/src/components/activity/comment-editor-image-upload.test.tsx b/apps/web/src/components/activity/comment-editor-image-upload.test.tsx
index b1c56460b..0ca89394c 100644
--- a/apps/web/src/components/activity/comment-editor-image-upload.test.tsx
+++ b/apps/web/src/components/activity/comment-editor-image-upload.test.tsx
@@ -74,6 +74,9 @@ vi.mock(
useGetActiveWorkspaceUsers: () => ({ data: undefined }),
}),
);
+vi.mock("@/hooks/queries/workspace-users/use-get-project-members", () => ({
+ default: () => ({ data: undefined }),
+}));
vi.mock("@/lib/toast", () => ({
toast: {
error: vi.fn(),
diff --git a/apps/web/src/components/activity/comment-editor.tsx b/apps/web/src/components/activity/comment-editor.tsx
index bded5cf77..718a658dd 100644
--- a/apps/web/src/components/activity/comment-editor.tsx
+++ b/apps/web/src/components/activity/comment-editor.tsx
@@ -45,6 +45,7 @@ import {
} from "@/components/ui/menu";
import useActiveWorkspace from "@/hooks/queries/workspace/use-active-workspace";
import { useGetActiveWorkspaceUsers } from "@/hooks/queries/workspace-users/use-get-active-workspace-users";
+import useGetProjectMembers from "@/hooks/queries/workspace-users/use-get-project-members";
import { cn } from "@/lib/cn";
import {
extractIssueKeyFromUrl,
@@ -73,6 +74,7 @@ type CommentEditorProps = {
onSubmitShortcut?: () => void;
onCancelShortcut?: () => void;
taskId?: string;
+ projectId?: string;
uploadSurface?: "description" | "comment";
ensureTaskId?: () => Promise<string | null>;
uploadAsset?: (
@@ -150,6 +152,7 @@ export default function CommentEditor({
onSubmitShortcut,
onCancelShortcut,
taskId,
+ projectId,
uploadSurface = "comment",
ensureTaskId,
uploadAsset,
@@ -160,18 +163,29 @@ export default function CommentEditor({
const resolvedPlaceholder =
placeholder ?? t("activity:comment.leavePlaceholder");
const { data: activeWorkspace } = useActiveWorkspace();
+ const mentionWorkspaceId = activeWorkspace?.id ?? "";
const { data: workspaceUsers } = useGetActiveWorkspaceUsers(
- activeWorkspace?.id ?? "",
+ projectId ? "" : mentionWorkspaceId,
);
+ const { data: projectMembers } = useGetProjectMembers({
+ workspaceId: mentionWorkspaceId,
+ projectId: projectId ?? "",
+ });
const mentionMembersRef = useRef<MentionMember[]>([]);
mentionMembersRef.current = useMemo(
() =>
- (workspaceUsers?.members ?? []).map((member) => ({
- id: member.userId,
- label: member.user?.name ?? member.user?.email ?? "",
- image: member.user?.image ?? null,
- })),
- [workspaceUsers],
+ projectId
+ ? (projectMembers ?? []).map((member) => ({
+ id: member.id,
+ label: member.name || member.email,
+ image: member.image,
+ }))
+ : (workspaceUsers?.members ?? []).map((member) => ({
+ id: member.userId,
+ label: member.user?.name ?? member.user?.email ?? "",
+ image: member.user?.image ?? null,
+ })),
+ [projectId, projectMembers, workspaceUsers],
);
const editorShellRef = useRef<HTMLDivElement | null>(null);
const imageInputRef = useRef<HTMLInputElement | null>(null);
diff --git a/apps/web/src/components/activity/comment-input.tsx b/apps/web/src/components/activity/comment-input.tsx
index 576d30f6c..14aa86d3d 100644
--- a/apps/web/src/components/activity/comment-input.tsx
+++ b/apps/web/src/components/activity/comment-input.tsx
@@ -18,9 +18,10 @@ import { toast } from "@/lib/toast";
type CommentInputProps = {
taskId: string;
+ projectId?: string;
};
-export default function CommentInput({ taskId }: CommentInputProps) {
+export default function CommentInput({ taskId, projectId }: CommentInputProps) {
const { t } = useTranslation();
const [content, setContent] = useState("");
const [attachAction, setAttachAction] = useState<(() => void) | null>(null);
@@ -64,6 +65,7 @@ export default function CommentInput({ taskId }: CommentInputProps) {
onChange={setContent}
placeholder={t("activity:comment.leavePlaceholder")}
taskId={taskId}
+ projectId={projectId}
uploadSurface="comment"
showQuickAttachButton={false}
onAttachActionChange={handleAttachActionChange}
diff --git a/apps/web/src/components/bulk-selection/backlog-bulk-toolbar.tsx b/apps/web/src/components/bulk-selection/backlog-bulk-toolbar.tsx
index 63ade37d7..9b369737c 100644
--- a/apps/web/src/components/bulk-selection/backlog-bulk-toolbar.tsx
+++ b/apps/web/src/components/bulk-selection/backlog-bulk-toolbar.tsx
@@ -46,7 +46,7 @@ import {
import { useBulkOperations } from "@/hooks/mutations/task/use-bulk-operations";
import useGetLabelsByWorkspace from "@/hooks/queries/label/use-get-labels-by-workspace";
import useActiveWorkspace from "@/hooks/queries/workspace/use-active-workspace";
-import { useGetActiveWorkspaceUsers } from "@/hooks/queries/workspace-users/use-get-active-workspace-users";
+import useGetProjectMembers from "@/hooks/queries/workspace-users/use-get-project-members";
import { useWorkspacePermission } from "@/hooks/use-workspace-permission";
import { getColumnIcon } from "@/lib/column";
import { getInitials } from "@/lib/get-initials";
@@ -98,9 +98,10 @@ function BacklogBulkToolbar() {
bulkDueDate,
} = useBulkOperations();
const { data: workspace } = useActiveWorkspace();
- const { data: workspaceUsers } = useGetActiveWorkspaceUsers(
- workspace?.id ?? "",
- );
+ const { data: projectMembers } = useGetProjectMembers({
+ workspaceId: workspace?.id ?? "",
+ projectId: project?.id ?? "",
+ });
const { data: workspaceLabels = [] } = useGetLabelsByWorkspace(
workspace?.id ?? "",
);
@@ -300,22 +301,19 @@ function BacklogBulkToolbar() {
groups.push({
value: "assign",
label: t("tasks:bulk.assignTo"),
- items: (workspaceUsers?.members ?? []).map((member) => ({
- value: `assign-${member.userId}`,
- label: member.user?.name || t("common:people.someone"),
+ items: (projectMembers ?? []).map((member) => ({
+ value: `assign-${member.id}`,
+ label: member.name || t("common:people.someone"),
icon: (
<Avatar className="h-5 w-5">
- <AvatarImage
- src={member.user?.image ?? ""}
- alt={member.user?.name || ""}
- />
+ <AvatarImage src={member.image ?? ""} alt={member.name || ""} />
<AvatarFallback className="text-xs font-medium border border-border/30">
- {getInitials(member.user?.name)}
+ {getInitials(member.name)}
</AvatarFallback>
</Avatar>
),
onRun: () => {
- void handleBulkAssign(member.userId);
+ void handleBulkAssign(member.id);
},
})),
});
@@ -361,7 +359,7 @@ function BacklogBulkToolbar() {
canDelete,
canAssign,
canEditLabels,
- workspaceUsers?.members,
+ projectMembers,
uniqueLabels,
handleBulkDelete,
handleBulkArchive,
diff --git a/apps/web/src/components/bulk-selection/bulk-toolbar.tsx b/apps/web/src/components/bulk-selection/bulk-toolbar.tsx
index ce2107698..0d716975b 100644
--- a/apps/web/src/components/bulk-selection/bulk-toolbar.tsx
+++ b/apps/web/src/components/bulk-selection/bulk-toolbar.tsx
@@ -39,7 +39,7 @@ import {
import { useBulkOperations } from "@/hooks/mutations/task/use-bulk-operations";
import useGetLabelsByWorkspace from "@/hooks/queries/label/use-get-labels-by-workspace";
import useActiveWorkspace from "@/hooks/queries/workspace/use-active-workspace";
-import { useGetActiveWorkspaceUsers } from "@/hooks/queries/workspace-users/use-get-active-workspace-users";
+import useGetProjectMembers from "@/hooks/queries/workspace-users/use-get-project-members";
import { useWorkspacePermission } from "@/hooks/use-workspace-permission";
import { getColumnIcon } from "@/lib/column";
import { getInitials } from "@/lib/get-initials";
@@ -92,9 +92,10 @@ function BulkToolbar() {
bulkDueDate,
} = useBulkOperations();
const { data: workspace } = useActiveWorkspace();
- const { data: workspaceUsers } = useGetActiveWorkspaceUsers(
- workspace?.id ?? "",
- );
+ const { data: projectMembers } = useGetProjectMembers({
+ workspaceId: workspace?.id ?? "",
+ projectId: project?.id ?? "",
+ });
const { data: workspaceLabels = [] } = useGetLabelsByWorkspace(
workspace?.id ?? "",
);
@@ -319,22 +320,19 @@ function BulkToolbar() {
groups.push({
value: "assign",
label: t("tasks:bulk.assignTo"),
- items: (workspaceUsers?.members ?? []).map((member) => ({
- value: `assign-${member.userId}`,
- label: member.user?.name || t("common:people.someone"),
+ items: (projectMembers ?? []).map((member) => ({
+ value: `assign-${member.id}`,
+ label: member.name || t("common:people.someone"),
icon: (
<Avatar className="h-5 w-5">
- <AvatarImage
- src={member.user?.image ?? ""}
- alt={member.user?.name || ""}
- />
+ <AvatarImage src={member.image ?? ""} alt={member.name || ""} />
<AvatarFallback className="text-xs font-medium border border-border/30">
- {getInitials(member.user?.name)}
+ {getInitials(member.name)}
</AvatarFallback>
</Avatar>
),
onRun: () => {
- void handleBulkAssign(member.userId);
+ void handleBulkAssign(member.id);
},
})),
});
@@ -381,7 +379,7 @@ function BulkToolbar() {
canAssign,
canEditLabels,
project?.columns,
- workspaceUsers?.members,
+ projectMembers,
uniqueLabels,
handleBulkDelete,
handleBulkArchive,
diff --git a/apps/web/src/components/common/project-layout.test.tsx b/apps/web/src/components/common/project-layout.test.tsx
new file mode 100644
index 000000000..49c2b915b
--- /dev/null
+++ b/apps/web/src/components/common/project-layout.test.tsx
@@ -0,0 +1,98 @@
+import { cleanup, render, screen } from "@testing-library/react";
+import type { ReactNode } from "react";
+import { afterEach, describe, expect, it, vi } from "vite-plus/test";
+import { HttpError } from "@/lib/http-error";
+import ProjectLayout from "./project-layout";
+
+const project = vi.hoisted(() => ({
+ current: { data: undefined, error: null } as {
+ data: { name: string } | undefined;
+ error: unknown;
+ },
+}));
+
+vi.mock("@tanstack/react-router", () => ({
+ useNavigate: () => vi.fn(),
+ useLocation: () => ({ pathname: "/board" }),
+ Link: ({ children, to }: { children: ReactNode; to: string }) => (
+ <a href={to}>{children}</a>
+ ),
+}));
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+vi.mock("@/hooks/queries/project/use-get-project", () => ({
+ default: () => project.current,
+}));
+vi.mock("@/hooks/use-project-websocket", () => ({
+ useProjectWebSocket: () => undefined,
+}));
+vi.mock("@/components/common/layout", () => {
+ const Layout = ({ children }: { children: ReactNode }) => <>{children}</>;
+ Layout.Header = ({ children }: { children: ReactNode }) => <>{children}</>;
+ Layout.Content = ({ children }: { children: ReactNode }) => (
+ <main>{children}</main>
+ );
+ return { default: Layout };
+});
+vi.mock("@/components/ui/sidebar", () => ({ SidebarTrigger: () => null }));
+vi.mock("@/components/common/header/mobile-project-nav", () => ({
+ default: () => null,
+}));
+vi.mock("@/components/common/header/project-crumb-select", () => ({
+ default: () => null,
+}));
+vi.mock("@/components/common/header/workspace-crumb-select", () => ({
+ default: () => null,
+}));
+vi.mock("@/components/shared/modals/create-project-modal", () => ({
+ default: () => null,
+}));
+vi.mock("@/components/page-title", () => ({ default: () => null }));
+
+afterEach(cleanup);
+
+function renderLayout() {
+ render(
+ <ProjectLayout projectId="project-1" workspaceId="workspace-1">
+ <p>Board content</p>
+ </ProjectLayout>,
+ );
+}
+
+describe("ProjectLayout access states", () => {
+ it("replaces the board with a no-access state on 403", () => {
+ project.current = { data: undefined, error: new HttpError(403, "denied") };
+ renderLayout();
+
+ expect(
+ screen.getByRole("heading", {
+ name: "workspace:projects.unavailable.noAccessTitle",
+ }),
+ ).toBeVisible();
+ expect(
+ screen.getByRole("link", {
+ name: "workspace:projects.unavailable.backToWorkspace",
+ }),
+ ).toBeVisible();
+ expect(screen.queryByText("Board content")).toBeNull();
+ });
+
+ it("shows a not-found state on 404", () => {
+ project.current = { data: undefined, error: new HttpError(404, "gone") };
+ renderLayout();
+
+ expect(
+ screen.getByRole("heading", {
+ name: "workspace:projects.unavailable.notFoundTitle",
+ }),
+ ).toBeVisible();
+ });
+
+ it("renders the project when it loads", () => {
+ project.current = { data: { name: "Alpha" }, error: null };
+ renderLayout();
+
+ expect(screen.getByText("Board content")).toBeVisible();
+ });
+});
diff --git a/apps/web/src/components/common/project-layout.tsx b/apps/web/src/components/common/project-layout.tsx
index 0d9a410df..6a61456f5 100644
--- a/apps/web/src/components/common/project-layout.tsx
+++ b/apps/web/src/components/common/project-layout.tsx
@@ -25,7 +25,9 @@ import { shortcuts } from "@/constants/shortcuts";
import useGetProject from "@/hooks/queries/project/use-get-project";
import { useProjectWebSocket } from "@/hooks/use-project-websocket";
import { cn } from "@/lib/cn";
+import { getProjectUnavailableReason } from "@/lib/project-unavailable-reason";
import { useBackgroundStore } from "@/store/background";
+import ProjectUnavailable from "./project-unavailable";
type ProjectLayoutProps = {
projectId: string;
@@ -47,12 +49,16 @@ export default function ProjectLayout({
const { t } = useTranslation();
const navigate = useNavigate();
const location = useLocation();
- const { data: project } = useGetProject({ id: projectId, workspaceId });
+ const { data: project, error: projectError } = useGetProject({
+ id: projectId,
+ workspaceId,
+ });
+ const unavailableReason = getProjectUnavailableReason(projectError);
const [isCreateProjectModalOpen, setIsCreateProjectModalOpen] =
useState(false);
const { background } = useBackgroundStore();
- useProjectWebSocket(projectId);
+ useProjectWebSocket(unavailableReason ? "" : projectId);
const resolvedView =
activeView ??
@@ -165,7 +171,7 @@ export default function ProjectLayout({
/>
</div>
- {showViewSwitcher && (
+ {showViewSwitcher && !unavailableReason && (
<div className="hidden h-8 items-center gap-0.5 rounded-lg border border-border/80 bg-background p-0.5 sm:inline-flex">
<Button
variant={resolvedView === "backlog" ? "secondary" : "ghost"}
@@ -220,12 +226,21 @@ export default function ProjectLayout({
</div>
<div className="flex shrink-0 items-center gap-1.5">
- {headerActions}
+ {unavailableReason ? null : headerActions}
</div>
</div>
</Layout.Header>
- <Layout.Content>{children}</Layout.Content>
+ <Layout.Content>
+ {unavailableReason ? (
+ <ProjectUnavailable
+ reason={unavailableReason}
+ workspaceId={workspaceId}
+ />
+ ) : (
+ children
+ )}
+ </Layout.Content>
<CreateProjectModal
open={isCreateProjectModalOpen}
diff --git a/apps/web/src/components/common/project-unavailable.tsx b/apps/web/src/components/common/project-unavailable.tsx
new file mode 100644
index 000000000..813648c1e
--- /dev/null
+++ b/apps/web/src/components/common/project-unavailable.tsx
@@ -0,0 +1,59 @@
+import { Link } from "@tanstack/react-router";
+import { FolderXIcon, LockIcon } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import PageTitle from "@/components/page-title";
+import { Button } from "@/components/ui/button";
+import {
+ Empty,
+ EmptyContent,
+ EmptyDescription,
+ EmptyHeader,
+ EmptyMedia,
+ EmptyTitle,
+} from "@/components/ui/empty";
+import type { ProjectUnavailableReason } from "@/lib/project-unavailable-reason";
+
+type Props = {
+ reason: ProjectUnavailableReason;
+ workspaceId: string;
+};
+
+export default function ProjectUnavailable({ reason, workspaceId }: Props) {
+ const { t } = useTranslation();
+ const isForbidden = reason === "forbidden";
+ const title = isForbidden
+ ? t("workspace:projects.unavailable.noAccessTitle")
+ : t("workspace:projects.unavailable.notFoundTitle");
+
+ return (
+ <Empty className="h-full">
+ <PageTitle title={title} />
+ <EmptyHeader>
+ <EmptyMedia variant="icon">
+ {isForbidden ? <LockIcon /> : <FolderXIcon />}
+ </EmptyMedia>
+ <EmptyTitle role="heading" aria-level={1}>
+ {title}
+ </EmptyTitle>
+ <EmptyDescription>
+ {isForbidden
+ ? t("workspace:projects.unavailable.noAccessDescription")
+ : t("workspace:projects.unavailable.notFoundDescription")}
+ </EmptyDescription>
+ </EmptyHeader>
+ <EmptyContent>
+ <Button
+ variant="outline"
+ render={
+ <Link
+ to="/dashboard/workspace/$workspaceId"
+ params={{ workspaceId }}
+ />
+ }
+ >
+ {t("workspace:projects.unavailable.backToWorkspace")}
+ </Button>
+ </EmptyContent>
+ </Empty>
+ );
+}
diff --git a/apps/web/src/components/common/task-layout.tsx b/apps/web/src/components/common/task-layout.tsx
index c4414fb1e..a3b1b584d 100644
--- a/apps/web/src/components/common/task-layout.tsx
+++ b/apps/web/src/components/common/task-layout.tsx
@@ -15,6 +15,8 @@ import { shortcuts } from "@/constants/shortcuts";
import useGetProject from "@/hooks/queries/project/use-get-project";
import useGetTask from "@/hooks/queries/task/use-get-task";
import { useProjectWebSocket } from "@/hooks/use-project-websocket";
+import { getProjectUnavailableReason } from "@/lib/project-unavailable-reason";
+import ProjectUnavailable from "./project-unavailable";
type TaskLayoutProps = {
taskId: string;
@@ -35,10 +37,14 @@ export default function TaskLayout({
}: TaskLayoutProps) {
const { t } = useTranslation();
const navigate = useNavigate();
- const { data: project } = useGetProject({ id: projectId, workspaceId });
+ const { data: project, error: projectError } = useGetProject({
+ id: projectId,
+ workspaceId,
+ });
const { data: task } = useGetTask(taskId);
+ const unavailableReason = getProjectUnavailableReason(projectError);
- useProjectWebSocket(projectId);
+ useProjectWebSocket(unavailableReason ? "" : projectId);
const taskLabel =
project?.slug && task?.number != null
@@ -103,25 +109,34 @@ export default function TaskLayout({
</div>
<div className="flex shrink-0 items-center gap-1.5">
- {headerActions}
+ {unavailableReason ? null : headerActions}
</div>
</div>
</Layout.Header>
<Layout.Content>
- <div className="flex h-full min-h-0 flex-col overflow-hidden lg:flex-row">
- <div className="order-2 min-h-0 flex-1 overflow-y-auto overscroll-contain lg:order-1">
- {children}
- </div>
- <div className="order-1 border-b border-border/80 lg:order-2 lg:hidden">
- {rightSidebar}
+ {unavailableReason ? (
+ <ProjectUnavailable
+ reason={unavailableReason}
+ workspaceId={workspaceId}
+ />
+ ) : (
+ <div className="flex h-full min-h-0 flex-col overflow-hidden lg:flex-row">
+ <div className="order-2 min-h-0 flex-1 overflow-y-auto overscroll-contain lg:order-1">
+ {children}
+ </div>
+ <div className="order-1 border-b border-border/80 lg:order-2 lg:hidden">
+ {rightSidebar}
+ </div>
</div>
- </div>
+ )}
</Layout.Content>
</div>
- <div className="hidden border-l border-border/80 bg-card lg:flex lg:h-full lg:overflow-y-auto">
- {rightSidebar}
- </div>
+ {unavailableReason ? null : (
+ <div className="hidden border-l border-border/80 bg-card lg:flex lg:h-full lg:overflow-y-auto">
+ {rightSidebar}
+ </div>
+ )}
</Layout>
);
}
diff --git a/apps/web/src/components/inbox/inbox-task.tsx b/apps/web/src/components/inbox/inbox-task.tsx
index 510a4e714..745edae5e 100644
--- a/apps/web/src/components/inbox/inbox-task.tsx
+++ b/apps/web/src/components/inbox/inbox-task.tsx
@@ -186,7 +186,9 @@ export function InboxTask({ taskId, workspaceId }: InboxTaskProps) {
</Timeline>
)
)}
- {canUpdateTasks() && <CommentInput taskId={taskId} />}
+ {canUpdateTasks() && (
+ <CommentInput taskId={taskId} projectId={task?.projectId} />
+ )}
</div>
</div>
);
diff --git a/apps/web/src/components/kanban-board/task-card-context-menu/task-card-context-menu-content.test.tsx b/apps/web/src/components/kanban-board/task-card-context-menu/task-card-context-menu-content.test.tsx
index e7117a154..111e7dbd6 100644
--- a/apps/web/src/components/kanban-board/task-card-context-menu/task-card-context-menu-content.test.tsx
+++ b/apps/web/src/components/kanban-board/task-card-context-menu/task-card-context-menu-content.test.tsx
@@ -70,6 +70,10 @@ vi.mock(
}),
);
+vi.mock("@/hooks/queries/workspace-users/use-get-project-members", () => ({
+ default: () => ({ data: [] }),
+}));
+
vi.mock("@tanstack/react-query", async (importOriginal) => ({
...(await importOriginal<typeof import("@tanstack/react-query")>()),
useQueryClient: () => ({ getQueryData: () => [] }),
diff --git a/apps/web/src/components/kanban-board/task-card-context-menu/task-card-context-menu-content.tsx b/apps/web/src/components/kanban-board/task-card-context-menu/task-card-context-menu-content.tsx
index 3e750f1fd..fa8f9373d 100644
--- a/apps/web/src/components/kanban-board/task-card-context-menu/task-card-context-menu-content.tsx
+++ b/apps/web/src/components/kanban-board/task-card-context-menu/task-card-context-menu-content.tsx
@@ -23,7 +23,7 @@ import { useUpdateTaskPriority } from "@/hooks/mutations/task/use-update-task-st
import { useUpdateTaskTitle } from "@/hooks/mutations/task/use-update-task-title";
import type getProjects from "@/fetchers/project/get-projects";
import { useGetColumns } from "@/hooks/queries/column/use-get-columns";
-import { useGetActiveWorkspaceUsers } from "@/hooks/queries/workspace-users/use-get-active-workspace-users";
+import useGetProjectMembers from "@/hooks/queries/workspace-users/use-get-project-members";
import { useWorkspacePermission } from "@/hooks/use-workspace-permission";
import { getColumnIcon } from "@/lib/column";
import { generateLink } from "@/lib/generate-link";
@@ -70,9 +70,10 @@ export default function TaskCardContextMenuContent({
icon: col.icon,
isFinal: col.isFinal,
}));
- const { data: workspaceUsers } = useGetActiveWorkspaceUsers(
- taskCardContext.worskpaceId,
- );
+ const { data: projectMembers } = useGetProjectMembers({
+ workspaceId: taskCardContext.worskpaceId,
+ projectId: taskCardContext.projectId,
+ });
const { mutateAsync: updateTask } = useUpdateTask();
const { mutateAsync: updateTaskPriority } = useUpdateTaskPriority();
const { mutateAsync: updateTaskStatus } = useUpdateTaskStatus();
@@ -89,13 +90,13 @@ export default function TaskCardContextMenuContent({
const canAssign = canAssignTasks();
const usersOptions = useMemo(() => {
- return workspaceUsers?.members?.map((member) => ({
- label: member?.user?.name ?? member.userId,
- value: member.userId,
- image: member?.user?.image ?? "",
- name: member?.user?.name ?? "",
+ return projectMembers?.map((member) => ({
+ label: member.name || member.email,
+ value: member.id,
+ image: member.image ?? "",
+ name: member.name,
}));
- }, [workspaceUsers]);
+ }, [projectMembers]);
const handleCopyTaskLink = () => {
const path = getTaskPath({
diff --git a/apps/web/src/components/shared/modals/create-task-modal.test.tsx b/apps/web/src/components/shared/modals/create-task-modal.test.tsx
index fea9ebf16..77f82bf81 100644
--- a/apps/web/src/components/shared/modals/create-task-modal.test.tsx
+++ b/apps/web/src/components/shared/modals/create-task-modal.test.tsx
@@ -149,6 +149,10 @@ vi.mock(
}),
);
+vi.mock("@/hooks/queries/workspace-users/use-get-project-members", () => ({
+ default: () => ({ data: undefined }),
+}));
+
vi.mock("@/hooks/use-workspace-permission", () => ({
useWorkspacePermission: () => ({
canCreateTasks: () => true,
diff --git a/apps/web/src/components/shared/modals/create-task-modal.tsx b/apps/web/src/components/shared/modals/create-task-modal.tsx
index c6984a21f..79005bfb8 100644
--- a/apps/web/src/components/shared/modals/create-task-modal.tsx
+++ b/apps/web/src/components/shared/modals/create-task-modal.tsx
@@ -85,6 +85,7 @@ import useGetLabelsByWorkspace from "@/hooks/queries/label/use-get-labels-by-wor
import useGetProjects from "@/hooks/queries/project/use-get-projects";
import useActiveWorkspace from "@/hooks/queries/workspace/use-active-workspace";
import { useGetActiveWorkspaceUsers } from "@/hooks/queries/workspace-users/use-get-active-workspace-users";
+import useGetProjectMembers from "@/hooks/queries/workspace-users/use-get-project-members";
import { useWorkspacePermission } from "@/hooks/use-workspace-permission";
import { cn } from "@/lib/cn";
import { uploadDraftAsset } from "@/lib/upload-draft-asset";
@@ -275,6 +276,28 @@ function CreateTaskModalContent({
(candidate) => candidate.id === (explicitProjectId || selectedProjectId),
);
const resolvedProjectId = resolvedProject?.id ?? "";
+ const { data: projectMembers } = useGetProjectMembers({
+ workspaceId: workspace?.id || "",
+ projectId: resolvedProjectId,
+ });
+ const assigneeOptions = useMemo(
+ () =>
+ resolvedProjectId && projectMembers
+ ? projectMembers.map((member) => ({
+ id: member.id,
+ name: member.name,
+ image: member.image,
+ }))
+ : (workspaceUsers?.members ?? []).map((member) => ({
+ id: member.userId,
+ name: member.user?.name ?? "",
+ image: member.user?.image ?? null,
+ })),
+ [resolvedProjectId, projectMembers, workspaceUsers?.members],
+ );
+ const selectedUser = assigneeOptions.find(
+ (option) => option.id === assigneeId,
+ );
const {
data: projectColumns,
isError: columnsError,
@@ -514,7 +537,7 @@ function CreateTaskModalContent({
await createTask({
title: title.trim(),
description: description.trim() || "",
- userId: assigneeId,
+ userId: selectedUser?.id ?? "",
priority,
projectId: resolvedProjectId,
startDate: startDate ? startDate.toISOString() : undefined,
@@ -600,10 +623,6 @@ function CreateTaskModalContent({
const selectedPriority = priorityOptions.find((p) => p.value === priority);
const statusLabel = getStatusDisplayLabel(taskStatus, initialColumn?.name);
- const selectedUser = workspaceUsers?.members?.find(
- (u) => u.userId === assigneeId,
- );
-
useEffect(() => {
if (labelsOpen && labelsStep === "select" && searchInputRef.current) {
setTimeout(() => searchInputRef.current?.focus(), 100);
@@ -1000,6 +1019,7 @@ function CreateTaskModalContent({
placeholder={t(
"common:modals.createTask.descriptionPlaceholder",
)}
+ projectId={resolvedProjectId || undefined}
uploadAsset={stageAsset}
/>
</div>
@@ -1243,14 +1263,14 @@ function CreateTaskModalContent({
<>
<Avatar className="h-4 w-4">
<AvatarImage
- src={selectedUser?.user?.image ?? ""}
- alt={selectedUser?.user?.name || ""}
+ src={selectedUser.image ?? ""}
+ alt={selectedUser.name}
/>
<AvatarFallback className="text-[10px] font-medium border border-border/30">
- {getInitials(selectedUser?.user?.name)}
+ {getInitials(selectedUser.name)}
</AvatarFallback>
</Avatar>
- <span>{selectedUser.user?.name}</span>
+ <span>{selectedUser.name}</span>
</>
) : (
<>
@@ -1280,26 +1300,26 @@ function CreateTaskModalContent({
<span className="text-sm">
{t("common:modals.createTask.assignUnassigned")}
</span>
- {!assigneeId && <Check className="ml-auto h-4 w-4" />}
+ {!selectedUser && <Check className="ml-auto h-4 w-4" />}
</button>
- {workspaceUsers?.members?.map((member) => (
+ {assigneeOptions.map((member) => (
<button
- key={member.userId}
+ key={member.id}
type="button"
className="w-full flex items-center gap-2 px-2 py-1.5 text-sm hover:bg-accent/50 text-left transition-colors h-8"
- onClick={() => setAssigneeId(member.userId || "")}
+ onClick={() => setAssigneeId(member.id)}
>
<Avatar className="h-6 w-6">
<AvatarImage
- src={member?.user?.image ?? ""}
- alt={member?.user?.name || ""}
+ src={member.image ?? ""}
+ alt={member.name}
/>
<AvatarFallback className="text-xs font-medium border border-border/30">
- {getInitials(member?.user?.name)}
+ {getInitials(member.name)}
</AvatarFallback>
</Avatar>
- <span className="text-sm">{member?.user?.name}</span>
- {assigneeId === member.userId && (
+ <span className="text-sm">{member.name}</span>
+ {selectedUser?.id === member.id && (
<Check className="ml-auto h-4 w-4" />
)}
</button>
diff --git a/apps/web/src/components/task/subtask-assignee-popover.tsx b/apps/web/src/components/task/subtask-assignee-popover.tsx
index c9c22eef5..c1cedf9b8 100644
--- a/apps/web/src/components/task/subtask-assignee-popover.tsx
+++ b/apps/web/src/components/task/subtask-assignee-popover.tsx
@@ -10,7 +10,7 @@ import {
} from "@/components/ui/popover";
import { ShortcutNumber } from "@/components/ui/shortcut-number";
import { useUpdateTaskAssignee } from "@/hooks/mutations/task/use-update-task-assignee";
-import { useGetActiveWorkspaceUsers } from "@/hooks/queries/workspace-users/use-get-active-workspace-users";
+import useGetProjectMembers from "@/hooks/queries/workspace-users/use-get-project-members";
import { useNumberedShortcuts } from "@/hooks/use-numbered-shortcuts";
import { useWorkspacePermission } from "@/hooks/use-workspace-permission";
import { getInitials } from "@/lib/get-initials";
@@ -37,18 +37,21 @@ export default function SubtaskAssigneePopover({
INITIAL_VISIBLE_USERS,
);
const { mutateAsync: updateTaskAssignee } = useUpdateTaskAssignee();
- const { data: workspaceUsers } = useGetActiveWorkspaceUsers(workspaceId);
+ const { data: projectMembers } = useGetProjectMembers({
+ workspaceId,
+ projectId: tasks[0]?.projectId ?? "",
+ });
const { canAssignTasks } = useWorkspacePermission();
const canAssign = canAssignTasks();
const usersOptions = useMemo(() => {
- return workspaceUsers?.members?.map((member) => ({
- label: member?.user?.name ?? member.userId,
- value: member.userId,
- image: member?.user?.image ?? "",
- name: member?.user?.name ?? "",
+ return projectMembers?.map((member) => ({
+ label: member.name || member.email,
+ value: member.id,
+ image: member.image ?? "",
+ name: member.name,
}));
- }, [workspaceUsers]);
+ }, [projectMembers]);
const allSameAssignee =
tasks.length > 0 && tasks.every((t) => t.userId === tasks[0].userId);
diff --git a/apps/web/src/components/task/task-assignee-popover.tsx b/apps/web/src/components/task/task-assignee-popover.tsx
index fdcbe7bdf..aa204ae7d 100644
--- a/apps/web/src/components/task/task-assignee-popover.tsx
+++ b/apps/web/src/components/task/task-assignee-popover.tsx
@@ -10,7 +10,7 @@ import {
} from "@/components/ui/popover";
import { ShortcutNumber } from "@/components/ui/shortcut-number";
import { useUpdateTaskAssignee } from "@/hooks/mutations/task/use-update-task-assignee";
-import { useGetActiveWorkspaceUsers } from "@/hooks/queries/workspace-users/use-get-active-workspace-users";
+import useGetProjectMembers from "@/hooks/queries/workspace-users/use-get-project-members";
import { useNumberedShortcuts } from "@/hooks/use-numbered-shortcuts";
import { useWorkspacePermission } from "@/hooks/use-workspace-permission";
import { getInitials } from "@/lib/get-initials";
@@ -37,18 +37,21 @@ export default function TaskAssigneePopover({
INITIAL_VISIBLE_USERS,
);
const { mutateAsync: updateTaskAssignee } = useUpdateTaskAssignee();
- const { data: workspaceUsers } = useGetActiveWorkspaceUsers(workspaceId);
+ const { data: projectMembers } = useGetProjectMembers({
+ workspaceId,
+ projectId: task.projectId,
+ });
const { canAssignTasks } = useWorkspacePermission();
const canAssign = canAssignTasks();
const usersOptions = useMemo(() => {
- return workspaceUsers?.members?.map((member) => ({
- label: member?.user?.name ?? member.userId,
- value: member.userId,
- image: member?.user?.image ?? "",
- name: member?.user?.name ?? "",
+ return projectMembers?.map((member) => ({
+ label: member.name || member.email,
+ value: member.id,
+ image: member.image ?? "",
+ name: member.name,
}));
- }, [workspaceUsers]);
+ }, [projectMembers]);
const handleAssigneeChange = useCallback(
async (newUserId: string) => {
diff --git a/apps/web/src/components/task/task-description-editor.tsx b/apps/web/src/components/task/task-description-editor.tsx
index 9d5977511..f95fc0dd9 100644
--- a/apps/web/src/components/task/task-description-editor.tsx
+++ b/apps/web/src/components/task/task-description-editor.tsx
@@ -7,6 +7,7 @@ type TaskDescriptionEditorProps = {
onChange: (value: string) => void;
placeholder?: string;
taskId?: string;
+ projectId?: string;
ensureTaskId?: () => Promise<string | null>;
uploadAsset?: (
file: File,
@@ -18,6 +19,7 @@ export default function TaskDescriptionEditor({
onChange,
placeholder,
taskId,
+ projectId,
ensureTaskId,
uploadAsset,
}: TaskDescriptionEditorProps) {
@@ -29,6 +31,7 @@ export default function TaskDescriptionEditor({
onChange={onChange}
placeholder={placeholder ?? t("tasks:detail.addDescription")}
taskId={taskId}
+ projectId={projectId}
ensureTaskId={ensureTaskId}
uploadAsset={uploadAsset}
uploadSurface="description"
diff --git a/apps/web/src/components/task/task-details-content.tsx b/apps/web/src/components/task/task-details-content.tsx
index 34c3c630d..a74cc78ec 100644
--- a/apps/web/src/components/task/task-details-content.tsx
+++ b/apps/web/src/components/task/task-details-content.tsx
@@ -679,7 +679,9 @@ export default function TaskDetailsContent({
<div className="flex flex-col gap-4">
<h1 className="text-md font-semibold">{t("tasks:detail.activity")}</h1>
- {user?.id && taskId && <CommentInput taskId={taskId} />}
+ {user?.id && taskId && (
+ <CommentInput taskId={taskId} projectId={projectId} />
+ )}
{activities.length > 0 ? (
<Timeline>
diff --git a/apps/web/src/components/team/invite-team-member-modal.test.tsx b/apps/web/src/components/team/invite-team-member-modal.test.tsx
index 4758509fa..fd93af91c 100644
--- a/apps/web/src/components/team/invite-team-member-modal.test.tsx
+++ b/apps/web/src/components/team/invite-team-member-modal.test.tsx
@@ -41,6 +41,15 @@ vi.mock("@/hooks/queries/workspace/use-active-workspace", () => ({
vi.mock("@/hooks/use-workspace-permission", () => ({
useWorkspacePermission: () => ({ canInviteUsers: () => true }),
}));
+vi.mock("@/hooks/queries/project/use-get-projects", () => ({
+ default: () => ({
+ data: [
+ { id: "project-a", name: "Alpha" },
+ { id: "project-b", name: "Beta" },
+ ],
+ isLoading: false,
+ }),
+}));
vi.mock("@/lib/toast", () => ({ toast: { success: vi.fn(), error: vi.fn() } }));
vi.mock("./invitation-link-field", () => ({ default: () => null }));
function wrapper({ children }: PropsWithChildren) {
@@ -107,3 +116,59 @@ describe("invitation email delivery errors", () => {
expect(onClose).not.toHaveBeenCalled();
});
});
+
+describe("invitation project access", () => {
+ beforeEach(() => {
+ inviteMember.mockResolvedValue({ data: { id: "invite-1" }, error: null });
+ });
+
+ async function fillEmail() {
+ fireEvent.change(
+ await screen.findByPlaceholderText("team:inviteModal.emailPlaceholder"),
+ { target: { value: "[email protected]" } },
+ );
+ }
+
+ function submit() {
+ fireEvent.click(
+ screen.getByRole("button", { name: "team:inviteModal.sendInvitation" }),
+ );
+ }
+
+ it("invites with access to every project by default", async () => {
+ render(<InviteTeamMemberModal open onClose={vi.fn()} />, { wrapper });
+ await fillEmail();
+ submit();
+ await waitFor(() =>
+ expect(inviteMember).toHaveBeenCalledWith(
+ expect.objectContaining({ projectAccess: "all", projectIds: [] }),
+ ),
+ );
+ });
+
+ it("requires a project before inviting with selected access", async () => {
+ render(<InviteTeamMemberModal open onClose={vi.fn()} />, { wrapper });
+ await fillEmail();
+ fireEvent.click(
+ screen.getByRole("radio", {
+ name: /team:projectAccess.selectedProjects/,
+ }),
+ );
+ submit();
+ expect(
+ await screen.findByText("team:projectAccess.selectAtLeastOne"),
+ ).toBeVisible();
+ expect(inviteMember).not.toHaveBeenCalled();
+
+ fireEvent.click(screen.getByRole("checkbox", { name: "Beta" }));
+ submit();
+ await waitFor(() =>
+ expect(inviteMember).toHaveBeenCalledWith(
+ expect.objectContaining({
+ projectAccess: "selected",
+ projectIds: ["project-b"],
+ }),
+ ),
+ );
+ });
+});
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 18d975792..71bd1e2d1 100644
--- a/apps/web/src/components/team/invite-team-member-modal.tsx
+++ b/apps/web/src/components/team/invite-team-member-modal.tsx
@@ -5,6 +5,7 @@ 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 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";
@@ -28,6 +29,13 @@ import {
} from "../ui/form";
import { Input } from "../ui/input";
import InvitationLinkField from "./invitation-link-field";
+import {
+ ALL_PROJECTS_ACCESS,
+ isProjectAccessComplete,
+ type ProjectAccessValue,
+ toProjectAccessRequest,
+} from "./project-access";
+import ProjectAccessFields from "./project-access-fields";
type Props = {
open: boolean;
@@ -52,6 +60,12 @@ function InviteTeamMemberModal({ open, onClose }: Props) {
id: string;
email: string;
} | null>(null);
+ const [projectAccess, setProjectAccess] =
+ useState<ProjectAccessValue>(ALL_PROJECTS_ACCESS);
+ const [showProjectAccessError, setShowProjectAccessError] = useState(false);
+ const { data: projects, isLoading: isLoadingProjects } = useGetProjects({
+ workspaceId: open ? (workspaceId ?? "") : "",
+ });
const form = useForm<TeamMemberFormValues>({
resolver: standardSchemaResolver(teamMemberSchema),
@@ -72,11 +86,20 @@ function InviteTeamMemberModal({ open, onClose }: Props) {
toast.error(t("team:inviteModal.error"));
return;
}
+ const access = toProjectAccessRequest(
+ projectAccess,
+ (projects ?? []).map((project) => project.id),
+ );
+ if (!isProjectAccessComplete(access)) {
+ setShowProjectAccessError(true);
+ return;
+ }
try {
const invitation = await mutateAsync({
email,
workspaceId,
role: "member",
+ ...access,
}); // TODO: role and email
await queryClient.refetchQueries({
queryKey: ["workspace-users", workspaceId],
@@ -90,6 +113,7 @@ function InviteTeamMemberModal({ open, onClose }: Props) {
if (invitation?.id) {
setCreatedInvitation({ id: invitation.id, email });
form.reset();
+ setProjectAccess(ALL_PROJECTS_ACCESS);
return;
}
@@ -109,6 +133,8 @@ function InviteTeamMemberModal({ open, onClose }: Props) {
});
}
form.reset();
+ setProjectAccess(ALL_PROJECTS_ACCESS);
+ setShowProjectAccessError(false);
};
const resetAndCloseModal = () => {
@@ -147,7 +173,7 @@ function InviteTeamMemberModal({ open, onClose }: Props) {
) : (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="contents">
- <DialogPanel>
+ <DialogPanel className="space-y-5">
<FormField
control={form.control}
name="email"
@@ -165,6 +191,21 @@ function InviteTeamMemberModal({ open, onClose }: Props) {
</FormItem>
)}
/>
+ <ProjectAccessFields
+ value={projectAccess}
+ onChange={(next) => {
+ setProjectAccess(next);
+ setShowProjectAccessError(false);
+ }}
+ projects={projects}
+ isLoadingProjects={isLoadingProjects}
+ disabled={form.formState.isSubmitting}
+ error={
+ showProjectAccessError
+ ? t("team:projectAccess.selectAtLeastOne")
+ : undefined
+ }
+ />
</DialogPanel>
<DialogFooter>
diff --git a/apps/web/src/components/team/member-project-access-dialog.tsx b/apps/web/src/components/team/member-project-access-dialog.tsx
new file mode 100644
index 000000000..e5705053b
--- /dev/null
+++ b/apps/web/src/components/team/member-project-access-dialog.tsx
@@ -0,0 +1,126 @@
+import { useState } from "react";
+import { useTranslation } from "react-i18next";
+import useUpdateMemberProjectAccess from "@/hooks/mutations/workspace-user/use-update-member-project-access";
+import useGetProjects from "@/hooks/queries/project/use-get-projects";
+import { toast } from "@/lib/toast";
+import { Button } from "../ui/button";
+import {
+ Dialog,
+ DialogClose,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogPanel,
+ DialogPopup,
+ DialogTitle,
+} from "../ui/dialog";
+import {
+ isProjectAccessComplete,
+ type ProjectAccessValue,
+ toProjectAccessRequest,
+} from "./project-access";
+import ProjectAccessFields from "./project-access-fields";
+
+type Props = {
+ workspaceId: string;
+ open: boolean;
+ member: { userId: string; name: string } | null;
+ access: ProjectAccessValue;
+ onOpenChange: (open: boolean) => void;
+};
+
+function MemberProjectAccessDialog({
+ workspaceId,
+ open,
+ member,
+ access,
+ onOpenChange,
+}: Props) {
+ const { t } = useTranslation();
+ const [value, setValue] = useState(access);
+ const [showError, setShowError] = useState(false);
+ const [wasOpen, setWasOpen] = useState(open);
+ const { data: projects, isLoading: isLoadingProjects } = useGetProjects({
+ workspaceId,
+ includeArchived: true,
+ });
+ const { mutateAsync, isPending } = useUpdateMemberProjectAccess();
+
+ if (open !== wasOpen) {
+ setWasOpen(open);
+ if (open) {
+ setValue(access);
+ setShowError(false);
+ }
+ }
+
+ const handleSave = async () => {
+ if (!member) return;
+ const request = toProjectAccessRequest(
+ value,
+ (projects ?? []).map((project) => project.id),
+ );
+ if (!isProjectAccessComplete(request)) {
+ setShowError(true);
+ return;
+ }
+ try {
+ await mutateAsync({ workspaceId, userId: member.userId, ...request });
+ toast.success(t("team:projectAccess.updateSuccess"));
+ onOpenChange(false);
+ } catch (error) {
+ toast.error(
+ error instanceof Error && error.message
+ ? error.message
+ : t("team:projectAccess.updateError"),
+ );
+ }
+ };
+
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogPopup className="w-full max-w-md">
+ <DialogHeader>
+ <DialogTitle>{t("team:projectAccess.dialogTitle")}</DialogTitle>
+ <DialogDescription>
+ {t("team:projectAccess.dialogDescription", {
+ name: member?.name ?? "",
+ })}
+ </DialogDescription>
+ </DialogHeader>
+ <DialogPanel>
+ <ProjectAccessFields
+ value={value}
+ onChange={(next) => {
+ setValue(next);
+ setShowError(false);
+ }}
+ projects={projects}
+ isLoadingProjects={isLoadingProjects}
+ disabled={isPending}
+ error={
+ showError ? t("team:projectAccess.selectAtLeastOne") : undefined
+ }
+ />
+ </DialogPanel>
+ <DialogFooter>
+ <DialogClose
+ render={<Button variant="outline" size="sm" type="button" />}
+ >
+ {t("common:actions.cancel")}
+ </DialogClose>
+ <Button
+ size="sm"
+ type="button"
+ disabled={isPending || isLoadingProjects}
+ onClick={handleSave}
+ >
+ {t("team:projectAccess.save")}
+ </Button>
+ </DialogFooter>
+ </DialogPopup>
+ </Dialog>
+ );
+}
+
+export default MemberProjectAccessDialog;
diff --git a/apps/web/src/components/team/members-table.test.tsx b/apps/web/src/components/team/members-table.test.tsx
index afc7d55d1..342fc68c2 100644
--- a/apps/web/src/components/team/members-table.test.tsx
+++ b/apps/web/src/components/team/members-table.test.tsx
@@ -34,7 +34,8 @@ vi.mock("@/lib/toast", () => ({
},
}));
-vi.mock("react-i18next", () => ({
+vi.mock("react-i18next", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("react-i18next")>()),
useTranslation: () => ({ t: (key: string) => key }),
}));
@@ -61,6 +62,40 @@ vi.mock("@/hooks/queries/workspace/use-workspace-roles", () => ({
default: () => ({ data: [] }),
}));
+const updateProjectAccess = vi.fn();
+
+vi.mock(
+ "@/hooks/mutations/workspace-user/use-update-member-project-access",
+ () => ({
+ default: () => ({ mutateAsync: updateProjectAccess, isPending: false }),
+ }),
+);
+
+vi.mock(
+ "@/hooks/queries/workspace-users/use-get-workspace-project-access",
+ () => ({
+ default: () => ({
+ data: [
+ {
+ userId: "restricted-user",
+ projectAccess: "selected",
+ projectIds: ["project-a"],
+ },
+ ],
+ }),
+ }),
+);
+
+vi.mock("@/hooks/queries/project/use-get-projects", () => ({
+ default: () => ({
+ data: [
+ { id: "project-a", name: "Alpha" },
+ { id: "project-b", name: "Beta" },
+ ],
+ isLoading: false,
+ }),
+}));
+
const canInviteUsers = vi.fn(() => true);
vi.mock("@/hooks/use-workspace-permission", () => ({
@@ -169,3 +204,101 @@ describe("MembersTable pending invitation row menu", () => {
).toBeNull();
});
});
+
+function makeMember(userId: string, role: string, name: string) {
+ return {
+ id: `member-${userId}`,
+ userId,
+ role,
+ createdAt: "2026-09-01T00:00:00.000Z",
+ user: { id: userId, name, email: `${userId}@example.com`, image: null },
+ } as unknown as WorkspaceUser;
+}
+
+describe("MembersTable project access", () => {
+ const members = [
+ makeMember("owner-user", "owner", "Olive Owner"),
+ makeMember("current-user", "admin", "Casey Current"),
+ makeMember("restricted-user", "member", "Riley Restricted"),
+ makeMember("open-user", "member", "Avery All"),
+ ];
+
+ it("lets managers edit other members' access but not owners or themselves", () => {
+ render(
+ <MembersTable
+ workspaceId="workspace-1"
+ invitations={[]}
+ users={members}
+ />,
+ );
+
+ const editButtons = screen.getAllByRole("button", {
+ name: "team:projectAccess.editAria",
+ });
+ expect(editButtons).toHaveLength(2);
+ expect(
+ screen.getAllByText("team:projectAccess.projectCount").length,
+ ).toBeGreaterThan(0);
+ });
+
+ it("saves selected projects for a member from the dialog", async () => {
+ updateProjectAccess.mockResolvedValue({});
+
+ render(
+ <MembersTable
+ workspaceId="workspace-1"
+ invitations={[]}
+ users={[members[2]]}
+ />,
+ );
+
+ fireEvent.click(
+ screen.getByRole("button", { name: "team:projectAccess.editAria" }),
+ );
+
+ expect(
+ await screen.findByText("team:projectAccess.dialogTitle"),
+ ).toBeVisible();
+ expect(screen.getByRole("checkbox", { name: "Alpha" })).toBeChecked();
+
+ fireEvent.click(screen.getByRole("checkbox", { name: "Beta" }));
+ fireEvent.click(
+ screen.getByRole("button", { name: "team:projectAccess.save" }),
+ );
+
+ await waitFor(() =>
+ expect(updateProjectAccess).toHaveBeenCalledWith({
+ workspaceId: "workspace-1",
+ userId: "restricted-user",
+ projectAccess: "selected",
+ projectIds: ["project-a", "project-b"],
+ }),
+ );
+ await waitFor(() =>
+ expect(success).toHaveBeenCalledWith("team:projectAccess.updateSuccess"),
+ );
+ });
+
+ it("asks for a project instead of saving an empty selection", async () => {
+ render(
+ <MembersTable
+ workspaceId="workspace-1"
+ invitations={[]}
+ users={[members[2]]}
+ />,
+ );
+
+ fireEvent.click(
+ screen.getByRole("button", { name: "team:projectAccess.editAria" }),
+ );
+ fireEvent.click(await screen.findByRole("checkbox", { name: "Alpha" }));
+ fireEvent.click(
+ screen.getByRole("button", { name: "team:projectAccess.save" }),
+ );
+
+ expect(
+ await screen.findByText("team:projectAccess.selectAtLeastOne"),
+ ).toBeVisible();
+ expect(updateProjectAccess).not.toHaveBeenCalled();
+ });
+});
diff --git a/apps/web/src/components/team/members-table.tsx b/apps/web/src/components/team/members-table.tsx
index 202b41f6a..dd78d8c0c 100644
--- a/apps/web/src/components/team/members-table.tsx
+++ b/apps/web/src/components/team/members-table.tsx
@@ -3,6 +3,7 @@ import {
CopyIcon,
EllipsisIcon,
MailIcon,
+ PencilIcon,
ShieldIcon,
TrashIcon,
} from "lucide-react";
@@ -12,6 +13,7 @@ import useCancelInvitation from "@/hooks/mutations/workspace-user/use-cancel-inv
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 useGetWorkspaceProjectAccess from "@/hooks/queries/workspace-users/use-get-workspace-project-access";
import { useCopyInvitationLink } from "@/hooks/use-copy-invitation-link";
import { useWorkspacePermission } from "@/hooks/use-workspace-permission";
import { cn } from "@/lib/cn";
@@ -51,6 +53,13 @@ import {
TableHeader,
TableRow,
} from "../ui/table";
+import MemberProjectAccessDialog from "./member-project-access-dialog";
+import {
+ ALL_PROJECTS_ACCESS,
+ findMemberProjectAccess,
+ getInvitationProjectAccess,
+ type ProjectAccessValue,
+} from "./project-access";
type Props = {
workspaceId: string;
@@ -97,6 +106,12 @@ function MembersTable({ workspaceId, invitations, users }: Props) {
);
const [invitationToCancel, setInvitationToCancel] =
useState<WorkspaceUserInvitation | null>(null);
+ const [accessTarget, setAccessTarget] = useState<{
+ userId: string;
+ name: string;
+ access: ProjectAccessValue;
+ } | null>(null);
+ const [isAccessDialogOpen, setIsAccessDialogOpen] = useState(false);
const { user: currentUser } = useAuth();
const { mutateAsync: deleteWorkspaceUser, isPending: isDeleting } =
@@ -111,6 +126,18 @@ function MembersTable({ workspaceId, invitations, users }: Props) {
const canChangeRoles = Boolean(canManageTeam());
const canRemove = Boolean(canRemoveMembers());
const canInvite = Boolean(canInviteUsers());
+ const { data: projectAccessEntries } = useGetWorkspaceProjectAccess(
+ workspaceId,
+ canChangeRoles,
+ );
+ const columnCount = canChangeRoles ? 5 : 4;
+
+ const describeAccess = (access: ProjectAccessValue) =>
+ access.projectAccess === "all"
+ ? t("team:projectAccess.allProjects")
+ : t("team:projectAccess.projectCount", {
+ count: access.projectIds.length,
+ });
const customRoles = allWorkspaceRoles.filter(
(role) => !RESERVED_ROLE_NAMES.has(role.role),
@@ -194,6 +221,11 @@ function MembersTable({ workspaceId, invitations, users }: Props) {
<TableHead className="text-foreground font-medium">
{t("team:membersTable.columns.role", { defaultValue: "Role" })}
</TableHead>
+ {canChangeRoles ? (
+ <TableHead className="text-foreground font-medium">
+ {t("team:membersTable.columns.projects")}
+ </TableHead>
+ ) : null}
<TableHead className="text-foreground font-medium">
{t("team:membersTable.columns.joined", {
defaultValue: "Joined",
@@ -207,6 +239,12 @@ function MembersTable({ workspaceId, invitations, users }: Props) {
const isSelf = currentUser?.id === member.userId;
const showRoleSelect =
canChangeRoles && !isSelf && member.role !== "owner";
+ const access =
+ member.role === "owner"
+ ? ALL_PROJECTS_ACCESS
+ : findMemberProjectAccess(projectAccessEntries, member.userId);
+ const accessLabel = describeAccess(access);
+ const memberName = member.user.name || member.user.email;
const tone = toneFor(member.user.email);
return (
<TableRow key={member.user.email}>
@@ -289,6 +327,36 @@ function MembersTable({ workspaceId, invitations, users }: Props) {
</Badge>
)}
</TableCell>
+ {canChangeRoles ? (
+ <TableCell className="py-3 text-sm text-muted-foreground">
+ {!projectAccessEntries ? (
+ "–"
+ ) : showRoleSelect ? (
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-8 gap-1.5 px-2 text-muted-foreground"
+ aria-label={t("team:projectAccess.editAria", {
+ name: memberName,
+ access: accessLabel,
+ })}
+ onClick={() => {
+ setAccessTarget({
+ userId: member.userId,
+ name: memberName,
+ access,
+ });
+ setIsAccessDialogOpen(true);
+ }}
+ >
+ {accessLabel}
+ <PencilIcon className="size-3" />
+ </Button>
+ ) : (
+ accessLabel
+ )}
+ </TableCell>
+ ) : null}
<TableCell className="py-3 text-sm text-muted-foreground tabular-nums">
{member.createdAt ? formatDateMedium(member.createdAt) : "–"}
</TableCell>
@@ -360,6 +428,11 @@ function MembersTable({ workspaceId, invitations, users }: Props) {
})}
</Badge>
</TableCell>
+ {canChangeRoles ? (
+ <TableCell className="py-3 text-sm text-muted-foreground">
+ {describeAccess(getInvitationProjectAccess(invitation))}
+ </TableCell>
+ ) : null}
<TableCell className="py-3 text-sm text-muted-foreground">
–
</TableCell>
@@ -402,7 +475,7 @@ function MembersTable({ workspaceId, invitations, users }: Props) {
{users.length === 0 && pendingInvitations.length === 0 ? (
<TableRow>
- <TableCell colSpan={4} className="py-16 text-center">
+ <TableCell colSpan={columnCount} className="py-16 text-center">
<div className="flex flex-col items-center gap-2 text-muted-foreground">
<p className="text-sm font-medium text-foreground">
{t("team:membersTable.emptyTitle")}
@@ -417,6 +490,14 @@ function MembersTable({ workspaceId, invitations, users }: Props) {
</TableBody>
</Table>
+ <MemberProjectAccessDialog
+ workspaceId={workspaceId}
+ open={isAccessDialogOpen}
+ member={accessTarget}
+ access={accessTarget?.access ?? ALL_PROJECTS_ACCESS}
+ onOpenChange={setIsAccessDialogOpen}
+ />
+
<AlertDialog
open={!!memberToDelete}
onOpenChange={(open) => !open && setMemberToDelete(null)}
diff --git a/apps/web/src/components/team/project-access-fields.tsx b/apps/web/src/components/team/project-access-fields.tsx
new file mode 100644
index 000000000..d41c7e2e7
--- /dev/null
+++ b/apps/web/src/components/team/project-access-fields.tsx
@@ -0,0 +1,145 @@
+import { useId } from "react";
+import { useTranslation } from "react-i18next";
+import { Badge } from "@/components/ui/badge";
+import { Checkbox } from "@/components/ui/checkbox";
+import { Radio, RadioGroup } from "@/components/ui/radio-group";
+import { Skeleton } from "@/components/ui/skeleton";
+import { type ProjectAccessValue, toggleProjectId } from "./project-access";
+
+type Props = {
+ value: ProjectAccessValue;
+ onChange: (value: ProjectAccessValue) => void;
+ projects:
+ | readonly { id: string; name: string; archivedAt?: string | null }[]
+ | undefined;
+ isLoadingProjects?: boolean;
+ disabled?: boolean;
+ error?: string;
+};
+
+function ProjectAccessFields({
+ value,
+ onChange,
+ projects,
+ isLoadingProjects = false,
+ disabled = false,
+ error,
+}: Props) {
+ const { t } = useTranslation();
+ const id = useId();
+ const headingId = `${id}-heading`;
+ const errorId = `${id}-error`;
+
+ return (
+ <div className="space-y-3">
+ <div className="space-y-0.5">
+ <p id={headingId} className="text-sm font-medium">
+ {t("team:projectAccess.label")}
+ </p>
+ <p className="text-xs text-muted-foreground">
+ {t("team:projectAccess.description")}
+ </p>
+ </div>
+
+ <RadioGroup
+ aria-labelledby={headingId}
+ className="gap-2"
+ disabled={disabled}
+ value={value.projectAccess}
+ onValueChange={(mode) =>
+ onChange({
+ ...value,
+ projectAccess: mode === "selected" ? "selected" : "all",
+ })
+ }
+ >
+ <label className="flex items-start gap-3" htmlFor={`${id}-all`}>
+ <Radio className="mt-0.5" id={`${id}-all`} value="all" />
+ <div className="min-w-0 space-y-0.5">
+ <p className="text-sm font-medium">
+ {t("team:projectAccess.allProjects")}
+ </p>
+ <p className="text-xs text-muted-foreground">
+ {t("team:projectAccess.allProjectsDescription")}
+ </p>
+ </div>
+ </label>
+
+ <label className="flex items-start gap-3" htmlFor={`${id}-selected`}>
+ <Radio className="mt-0.5" id={`${id}-selected`} value="selected" />
+ <div className="min-w-0 space-y-0.5">
+ <p className="text-sm font-medium">
+ {t("team:projectAccess.selectedProjects")}
+ </p>
+ <p className="text-xs text-muted-foreground">
+ {t("team:projectAccess.selectedProjectsDescription")}
+ </p>
+ </div>
+ </label>
+ </RadioGroup>
+
+ {value.projectAccess === "selected" ? (
+ <div
+ role="group"
+ aria-label={t("team:projectAccess.projectsLabel")}
+ aria-describedby={error ? errorId : undefined}
+ className="max-h-56 space-y-2 overflow-y-auto rounded-md border border-dashed border-border/80 px-3 py-3"
+ >
+ {isLoadingProjects ? (
+ <>
+ <Skeleton className="h-4 w-2/3" />
+ <Skeleton className="h-4 w-1/2" />
+ </>
+ ) : !projects?.length ? (
+ <p className="text-sm text-muted-foreground">
+ {t("team:projectAccess.noProjects")}
+ </p>
+ ) : (
+ projects.map((project) => {
+ const checkboxId = `${id}-project-${project.id}`;
+ return (
+ <label
+ key={project.id}
+ className="flex items-center gap-3"
+ htmlFor={checkboxId}
+ >
+ <Checkbox
+ checked={value.projectIds.includes(project.id)}
+ disabled={disabled}
+ id={checkboxId}
+ onCheckedChange={(checked) =>
+ onChange({
+ ...value,
+ projectIds: toggleProjectId(
+ value.projectIds,
+ project.id,
+ Boolean(checked),
+ ),
+ })
+ }
+ />
+ <span className="truncate text-sm font-medium">
+ {project.name}
+ </span>
+ {project.archivedAt ? (
+ <Badge variant="outline" className="shrink-0">
+ {t("team:projectAccess.archived")}
+ </Badge>
+ ) : null}
+ </label>
+ );
+ })
+ )}
+ </div>
+ ) : null}
+
+ {error ? (
+ <p id={errorId} className="text-sm font-medium text-destructive">
+ {error}
+ </p>
+ ) : null}
+ </div>
+ );
+}
+
+export default ProjectAccessFields;
diff --git a/apps/web/src/components/team/project-access.test.ts b/apps/web/src/components/team/project-access.test.ts
new file mode 100644
index 000000000..dba8fe61d
--- /dev/null
+++ b/apps/web/src/components/team/project-access.test.ts
@@ -0,0 +1,85 @@
+import { describe, expect, it } from "vite-plus/test";
+import {
+ findMemberProjectAccess,
+ getInvitationProjectAccess,
+ isProjectAccessComplete,
+ toggleProjectId,
+ toProjectAccessRequest,
+} from "./project-access";
+
+describe("toggleProjectId", () => {
+ it("adds a checked project once and removes an unchecked one", () => {
+ expect(toggleProjectId(["a"], "b", true)).toEqual(["a", "b"]);
+ expect(toggleProjectId(["a", "b"], "b", true)).toEqual(["a", "b"]);
+ expect(toggleProjectId(["a", "b"], "a", false)).toEqual(["b"]);
+ });
+});
+
+describe("findMemberProjectAccess", () => {
+ it("treats members missing from the restricted list as having every project", () => {
+ expect(findMemberProjectAccess([], "user-1")).toEqual({
+ projectAccess: "all",
+ projectIds: [],
+ });
+ expect(findMemberProjectAccess(undefined, "user-1").projectAccess).toBe(
+ "all",
+ );
+ });
+
+ it("returns the selected projects of a restricted member", () => {
+ expect(
+ findMemberProjectAccess(
+ [{ userId: "user-1", projectIds: ["p1", "p2"] }],
+ "user-1",
+ ),
+ ).toEqual({ projectAccess: "selected", projectIds: ["p1", "p2"] });
+ });
+});
+
+describe("getInvitationProjectAccess", () => {
+ it("reads limited access from an invitation and defaults to every project", () => {
+ expect(
+ getInvitationProjectAccess({
+ projectAccess: "selected",
+ projectIds: ["p1"],
+ }),
+ ).toEqual({ projectAccess: "selected", projectIds: ["p1"] });
+ expect(getInvitationProjectAccess({}).projectAccess).toBe("all");
+ expect(
+ getInvitationProjectAccess({ projectAccess: "all", projectIds: ["p1"] }),
+ ).toEqual({ projectAccess: "all", projectIds: [] });
+ });
+});
+
+describe("toProjectAccessRequest", () => {
+ it("clears project IDs when every project is allowed", () => {
+ expect(
+ toProjectAccessRequest({ projectAccess: "all", projectIds: ["p1"] }, [
+ "p1",
+ ]),
+ ).toEqual({ projectAccess: "all", projectIds: [] });
+ });
+
+ it("keeps only unique projects the editor can see", () => {
+ expect(
+ toProjectAccessRequest(
+ { projectAccess: "selected", projectIds: ["p1", "gone", "p1", "p2"] },
+ ["p1", "p2"],
+ ),
+ ).toEqual({ projectAccess: "selected", projectIds: ["p1", "p2"] });
+ });
+});
+
+describe("isProjectAccessComplete", () => {
+ it("requires at least one project when access is limited", () => {
+ expect(
+ isProjectAccessComplete({ projectAccess: "all", projectIds: [] }),
+ ).toBe(true);
+ expect(
+ isProjectAccessComplete({ projectAccess: "selected", projectIds: [] }),
+ ).toBe(false);
+ expect(
+ isProjectAccessComplete({ projectAccess: "selected", projectIds: ["p"] }),
+ ).toBe(true);
+ });
+});
diff --git a/apps/web/src/components/team/project-access.ts b/apps/web/src/components/team/project-access.ts
new file mode 100644
index 000000000..4e5139f85
--- /dev/null
+++ b/apps/web/src/components/team/project-access.ts
@@ -0,0 +1,57 @@
+export type ProjectAccessMode = "all" | "selected";
+
+export type ProjectAccessValue = {
+ projectAccess: ProjectAccessMode;
+ projectIds: string[];
+};
+
+export const ALL_PROJECTS_ACCESS: ProjectAccessValue = {
+ projectAccess: "all",
+ projectIds: [],
+};
+
+export function toggleProjectId(
+ projectIds: string[],
+ projectId: string,
+ checked: boolean,
+): string[] {
+ const rest = projectIds.filter((id) => id !== projectId);
+ return checked ? [...rest, projectId] : rest;
+}
+
+export function findMemberProjectAccess(
+ entries: readonly { userId: string; projectIds: string[] }[] | undefined,
+ userId: string,
+): ProjectAccessValue {
+ const entry = entries?.find((candidate) => candidate.userId === userId);
+ return entry
+ ? { projectAccess: "selected", projectIds: entry.projectIds }
+ : ALL_PROJECTS_ACCESS;
+}
+
+export function getInvitationProjectAccess(invitation: {
+ projectAccess?: string | null;
+ projectIds?: string[] | null;
+}): ProjectAccessValue {
+ return invitation.projectAccess === "selected"
+ ? { projectAccess: "selected", projectIds: invitation.projectIds ?? [] }
+ : ALL_PROJECTS_ACCESS;
+}
+
+export function toProjectAccessRequest(
+ value: ProjectAccessValue,
+ availableProjectIds: readonly string[],
+): ProjectAccessValue {
+ if (value.projectAccess === "all") return ALL_PROJECTS_ACCESS;
+ const available = new Set(availableProjectIds);
+ return {
+ projectAccess: "selected",
+ projectIds: [...new Set(value.projectIds)].filter((id) =>
+ available.has(id),
+ ),
+ };
+}
+
+export function isProjectAccessComplete(value: ProjectAccessValue): boolean {
+ return value.projectAccess === "all" || value.projectIds.length > 0;
+}
diff --git a/apps/web/src/fetchers/project/get-projects.ts b/apps/web/src/fetchers/project/get-projects.ts
index cdca4b974..3864aca65 100644
--- a/apps/web/src/fetchers/project/get-projects.ts
+++ b/apps/web/src/fetchers/project/get-projects.ts
@@ -6,10 +6,15 @@ export type GetProjectsRequest = InferRequestType<
(typeof client)["project"]["$get"]
>["query"];
-async function getProjects({ workspaceId }: GetProjectsRequest) {
+async function getProjects({
+ workspaceId,
+ includeArchived,
+}: GetProjectsRequest) {
if (!workspaceId) return;
- const response = await client.project.$get({ query: { workspaceId } });
+ const response = await client.project.$get({
+ query: includeArchived ? { workspaceId, includeArchived } : { workspaceId },
+ });
if (!response.ok) {
throw new HttpError(response.status, await response.text());
diff --git a/apps/web/src/fetchers/workspace-user/get-project-members.ts b/apps/web/src/fetchers/workspace-user/get-project-members.ts
new file mode 100644
index 000000000..8db7d8172
--- /dev/null
+++ b/apps/web/src/fetchers/workspace-user/get-project-members.ts
@@ -0,0 +1,25 @@
+import { client } from "@kaneo/libs";
+import { HttpError } from "@/lib/http-error";
+
+export type GetProjectMembersRequest = {
+ workspaceId: string;
+ projectId: string;
+};
+
+async function getProjectMembers({
+ workspaceId,
+ projectId,
+}: GetProjectMembersRequest) {
+ const response = await client.workspace[":workspaceId"].members.$get({
+ param: { workspaceId },
+ query: { projectId },
+ });
+
+ if (!response.ok) {
+ throw new HttpError(response.status, await response.text());
+ }
+
+ return response.json();
+}
+
+export default getProjectMembers;
diff --git a/apps/web/src/fetchers/workspace-user/get-workspace-project-access.ts b/apps/web/src/fetchers/workspace-user/get-workspace-project-access.ts
new file mode 100644
index 000000000..98ed1942f
--- /dev/null
+++ b/apps/web/src/fetchers/workspace-user/get-workspace-project-access.ts
@@ -0,0 +1,16 @@
+import { client } from "@kaneo/libs";
+import { HttpError } from "@/lib/http-error";
+
+async function getWorkspaceProjectAccess(workspaceId: string) {
+ const response = await client.workspace[":workspaceId"][
+ "project-access"
+ ].$get({ param: { workspaceId } });
+
+ if (!response.ok) {
+ throw new HttpError(response.status, await response.text());
+ }
+
+ return response.json();
+}
+
+export default getWorkspaceProjectAccess;
diff --git a/apps/web/src/fetchers/workspace-user/update-member-project-access.ts b/apps/web/src/fetchers/workspace-user/update-member-project-access.ts
new file mode 100644
index 000000000..af839a0ad
--- /dev/null
+++ b/apps/web/src/fetchers/workspace-user/update-member-project-access.ts
@@ -0,0 +1,32 @@
+import { client } from "@kaneo/libs";
+import type { InferRequestType } from "hono/client";
+import { HttpError } from "@/lib/http-error";
+
+type UpdateMemberProjectAccessEndpoint =
+ (typeof client)["workspace"][":workspaceId"]["members"][":userId"]["project-access"]["$put"];
+
+export type UpdateMemberProjectAccessRequest =
+ InferRequestType<UpdateMemberProjectAccessEndpoint>["param"] &
+ InferRequestType<UpdateMemberProjectAccessEndpoint>["json"];
+
+async function updateMemberProjectAccess({
+ workspaceId,
+ userId,
+ projectAccess,
+ projectIds,
+}: UpdateMemberProjectAccessRequest) {
+ const response = await client.workspace[":workspaceId"].members[":userId"][
+ "project-access"
+ ].$put({
+ param: { workspaceId, userId },
+ json: { projectAccess, projectIds },
+ });
+
+ if (!response.ok) {
+ throw new HttpError(response.status, await response.text());
+ }
+
+ return response.json();
+}
+
+export default updateMemberProjectAccess;
diff --git a/apps/web/src/hooks/mutations/workspace-user/use-invite-workspace-user.ts b/apps/web/src/hooks/mutations/workspace-user/use-invite-workspace-user.ts
index bd035d944..4237355ca 100644
--- a/apps/web/src/hooks/mutations/workspace-user/use-invite-workspace-user.ts
+++ b/apps/web/src/hooks/mutations/workspace-user/use-invite-workspace-user.ts
@@ -9,6 +9,8 @@ type InviteWorkspaceUserRequest = {
email: string;
role: "admin" | "member" | "owner";
resend?: boolean;
+ projectAccess?: "all" | "selected";
+ projectIds?: string[];
};
function useInviteWorkspaceUser() {
@@ -19,12 +21,15 @@ function useInviteWorkspaceUser() {
email,
role,
resend,
+ projectAccess,
+ projectIds,
}: InviteWorkspaceUserRequest) => {
const { data, error } = await authClient.organization.inviteMember({
email,
role,
organizationId: workspaceId,
resend,
+ ...(projectAccess ? { projectAccess, projectIds } : {}),
});
if (error?.code === "INVITATION_EMAIL_FAILED") {
diff --git a/apps/web/src/hooks/mutations/workspace-user/use-update-member-project-access.ts b/apps/web/src/hooks/mutations/workspace-user/use-update-member-project-access.ts
new file mode 100644
index 000000000..1c6c9c699
--- /dev/null
+++ b/apps/web/src/hooks/mutations/workspace-user/use-update-member-project-access.ts
@@ -0,0 +1,20 @@
+import { useMutation, useQueryClient } from "@tanstack/react-query";
+import updateMemberProjectAccess from "@/fetchers/workspace-user/update-member-project-access";
+
+function useUpdateMemberProjectAccess() {
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn: updateMemberProjectAccess,
+ onSuccess: (_data, { workspaceId }) => {
+ queryClient.invalidateQueries({
+ queryKey: ["workspace-users", workspaceId],
+ });
+ queryClient.invalidateQueries({
+ queryKey: ["active-workspace-users", workspaceId],
+ });
+ queryClient.invalidateQueries({ queryKey: ["projects", workspaceId] });
+ },
+ });
+}
+
+export default useUpdateMemberProjectAccess;
diff --git a/apps/web/src/hooks/queries/project/use-get-project.ts b/apps/web/src/hooks/queries/project/use-get-project.ts
index d6004f68c..830ad2f62 100644
--- a/apps/web/src/hooks/queries/project/use-get-project.ts
+++ b/apps/web/src/hooks/queries/project/use-get-project.ts
@@ -1,5 +1,7 @@
import { useQuery } from "@tanstack/react-query";
import getProject from "@/fetchers/project/get-project";
+import { isUnauthorizedError } from "@/lib/http-error";
+import { getProjectUnavailableReason } from "@/lib/project-unavailable-reason";
function useGetProject({
id,
@@ -12,6 +14,10 @@ function useGetProject({
queryFn: () => getProject({ id, workspaceId }),
queryKey: ["projects", workspaceId, id],
enabled: !!id,
+ retry: (failureCount, error) =>
+ !isUnauthorizedError(error) &&
+ !getProjectUnavailableReason(error) &&
+ failureCount < 2,
});
}
diff --git a/apps/web/src/hooks/queries/project/use-get-projects.ts b/apps/web/src/hooks/queries/project/use-get-projects.ts
index 6ca0191ad..06d19f534 100644
--- a/apps/web/src/hooks/queries/project/use-get-projects.ts
+++ b/apps/web/src/hooks/queries/project/use-get-projects.ts
@@ -2,12 +2,22 @@ import { useQuery } from "@tanstack/react-query";
import getProjects from "@/fetchers/project/get-projects";
function useGetProjects(
- { workspaceId }: { workspaceId: string },
+ {
+ workspaceId,
+ includeArchived = false,
+ }: { workspaceId: string; includeArchived?: boolean },
refreshWhileVisible = false,
) {
return useQuery({
- queryFn: () => getProjects({ workspaceId }),
- queryKey: ["projects", workspaceId],
+ queryFn: () =>
+ getProjects(
+ includeArchived
+ ? { workspaceId, includeArchived: "true" }
+ : { workspaceId },
+ ),
+ queryKey: includeArchived
+ ? ["projects", workspaceId, "including-archived"]
+ : ["projects", workspaceId],
enabled: !!workspaceId,
// Home and the sidebar show statistics without a project socket.
...(refreshWhileVisible
diff --git a/apps/web/src/hooks/queries/workspace-users/use-get-project-members.ts b/apps/web/src/hooks/queries/workspace-users/use-get-project-members.ts
new file mode 100644
index 000000000..473041b89
--- /dev/null
+++ b/apps/web/src/hooks/queries/workspace-users/use-get-project-members.ts
@@ -0,0 +1,18 @@
+import { useQuery } from "@tanstack/react-query";
+import getProjectMembers from "@/fetchers/workspace-user/get-project-members";
+
+function useGetProjectMembers({
+ workspaceId,
+ projectId,
+}: {
+ workspaceId: string;
+ projectId: string;
+}) {
+ return useQuery({
+ queryKey: ["workspace-users", workspaceId, "project", projectId],
+ queryFn: () => getProjectMembers({ workspaceId, projectId }),
+ enabled: !!workspaceId && !!projectId,
+ });
+}
+
+export default useGetProjectMembers;
diff --git a/apps/web/src/hooks/queries/workspace-users/use-get-workspace-project-access.ts b/apps/web/src/hooks/queries/workspace-users/use-get-workspace-project-access.ts
new file mode 100644
index 000000000..4835ecb27
--- /dev/null
+++ b/apps/web/src/hooks/queries/workspace-users/use-get-workspace-project-access.ts
@@ -0,0 +1,12 @@
+import { useQuery } from "@tanstack/react-query";
+import getWorkspaceProjectAccess from "@/fetchers/workspace-user/get-workspace-project-access";
+
+function useGetWorkspaceProjectAccess(workspaceId: string, enabled = true) {
+ return useQuery({
+ queryKey: ["workspace-users", workspaceId, "project-access"],
+ queryFn: () => getWorkspaceProjectAccess(workspaceId),
+ enabled: enabled && !!workspaceId,
+ });
+}
+
+export default useGetWorkspaceProjectAccess;
diff --git a/apps/web/src/hooks/use-project-websocket-access.test.tsx b/apps/web/src/hooks/use-project-websocket-access.test.tsx
index d0fa1b55e..bf182c1d1 100644
--- a/apps/web/src/hooks/use-project-websocket-access.test.tsx
+++ b/apps/web/src/hooks/use-project-websocket-access.test.tsx
@@ -9,21 +9,28 @@ import {
} from "vite-plus/test";
import { useProjectWebSocket } from "./use-project-websocket";
-const { client, auth, navigate } = vi.hoisted(() => ({
- client: {
- getQueryCache: () => ({ subscribe: () => () => {}, findAll: () => [] }),
- getQueryState: vi.fn(),
- getQueryData: vi.fn(),
- setQueryData: vi.fn(),
- setQueriesData: vi.fn(),
- getQueriesData: vi.fn().mockReturnValue([]),
- invalidateQueries: vi.fn(),
- cancelQueries: vi.fn(),
- clear: vi.fn(),
- },
- navigate: vi.fn(),
- auth: { userId: "user-a" as string | null },
-}));
+const { client, auth, navigate, cached, evictProjectCache } = vi.hoisted(
+ () => ({
+ cached: { queries: [] as { queryKey: unknown[] }[] },
+ evictProjectCache: vi.fn(),
+ client: {
+ getQueryCache: () => ({
+ subscribe: () => () => {},
+ findAll: () => cached.queries,
+ }),
+ getQueryState: vi.fn(),
+ getQueryData: vi.fn(),
+ setQueryData: vi.fn(),
+ setQueriesData: vi.fn(),
+ getQueriesData: vi.fn().mockReturnValue([]),
+ invalidateQueries: vi.fn(),
+ cancelQueries: vi.fn(),
+ clear: vi.fn(),
+ },
+ navigate: vi.fn(),
+ auth: { userId: "user-a" as string | null },
+ }),
+);
vi.mock("@tanstack/react-router", () => ({ useNavigate: () => navigate }));
vi.mock("@tanstack/react-query", () => ({ useQueryClient: () => client }));
vi.mock("@/lib/auth-client", () => ({
@@ -34,6 +41,7 @@ vi.mock("@/lib/auth-client", () => ({
},
}));
vi.mock("@kaneo/libs", () => ({ windowId: "local-test" }));
+vi.mock("@/lib/evict-project-cache", () => ({ evictProjectCache }));
class TestSocket {
static OPEN = 1;
@@ -63,6 +71,7 @@ describe("project WebSocket access", () => {
vi.stubEnv("VITE_API_URL", "http://localhost:1337");
TestSocket.instances = [];
auth.userId = "user-a";
+ cached.queries = [];
vi.clearAllMocks();
});
afterEach(() => {
@@ -89,6 +98,47 @@ describe("project WebSocket access", () => {
expect(vi.getTimerCount()).toBe(0);
});
+ it("evicts only the revoked project and returns to its workspace dashboard", async () => {
+ cached.queries = [
+ { queryKey: ["projects", "workspace-a"] },
+ { queryKey: ["projects", "workspace-a", "project-a"] },
+ ];
+ renderHook(() => useProjectWebSocket("project-a"));
+ act(() => {
+ TestSocket.instances[0].open();
+ TestSocket.instances[0].onclose?.({
+ code: 1008,
+ reason: "Project access revoked",
+ });
+ vi.advanceTimersByTime(60_000);
+ });
+ expect(navigate).toHaveBeenCalledWith({
+ to: "/dashboard/workspace/$workspaceId",
+ params: { workspaceId: "workspace-a" },
+ });
+ await act(async () => {
+ await Promise.resolve();
+ });
+ expect(evictProjectCache).toHaveBeenCalledWith(client, "project-a");
+ expect(client.invalidateQueries).toHaveBeenCalledWith({
+ queryKey: ["projects"],
+ });
+ expect(client.clear).not.toHaveBeenCalled();
+ expect(TestSocket.instances).toHaveLength(1);
+ expect(vi.getTimerCount()).toBe(0);
+ });
+
+ it("falls back to the dashboard when the project's workspace is unknown", () => {
+ renderHook(() => useProjectWebSocket("project-a"));
+ act(() => {
+ TestSocket.instances[0].onclose?.({
+ code: 1008,
+ reason: "Project access revoked",
+ });
+ });
+ expect(navigate).toHaveBeenCalledWith({ to: "/dashboard" });
+ });
+
it("reconnects after a project move without clearing authorized data", () => {
renderHook(() => useProjectWebSocket("project-a"));
act(() => {
diff --git a/apps/web/src/hooks/use-project-websocket.ts b/apps/web/src/hooks/use-project-websocket.ts
index 088b4d24b..277cad678 100644
--- a/apps/web/src/hooks/use-project-websocket.ts
+++ b/apps/web/src/hooks/use-project-websocket.ts
@@ -9,6 +9,7 @@ import { useNavigate } from "@tanstack/react-router";
import { useEffect } from "react";
import { getApiUrl } from "@/fetchers/get-api-url";
import { authClient } from "@/lib/auth-client";
+import { evictProjectCache } from "@/lib/evict-project-cache";
import getTask from "@/fetchers/task/get-task";
import getLabelsByTask from "@/fetchers/label/get-labels-by-task";
import getExternalLinks from "@/fetchers/external-link/get-external-links";
@@ -529,6 +530,26 @@ export function useProjectWebSocket(projectId: string) {
return;
}
+ if (event?.code === 1008 && event.reason === "Project access revoked") {
+ disposed = true;
+ const workspaceId = queryClient
+ .getQueryCache()
+ .findAll({ queryKey: ["projects"] })
+ .find((query) => query.queryKey[2] === projectId)?.queryKey[1];
+ void Promise.resolve(
+ typeof workspaceId === "string"
+ ? navigate({
+ to: "/dashboard/workspace/$workspaceId",
+ params: { workspaceId },
+ })
+ : navigate({ to: "/dashboard" }),
+ ).finally(() => {
+ evictProjectCache(queryClient, projectId);
+ void queryClient.invalidateQueries({ queryKey: ["projects"] });
+ });
+ return;
+ }
+
if (retries < MAX_RETRIES) {
const delay = BASE_DELAY * 2 ** retries; // 1s, 2s, 4s, 8s, 16s
retries += 1;
diff --git a/apps/web/src/hooks/use-user-websocket-lifecycle.test.tsx b/apps/web/src/hooks/use-user-websocket-lifecycle.test.tsx
index d6e8f3e55..f124251ad 100644
--- a/apps/web/src/hooks/use-user-websocket-lifecycle.test.tsx
+++ b/apps/web/src/hooks/use-user-websocket-lifecycle.test.tsx
@@ -220,6 +220,27 @@ describe("user WebSocket lifecycle", () => {
expect(auth.notify).toHaveBeenCalledWith("$sessionSignal");
});
+ it("refreshes project lists in every tab after a project access change", () => {
+ renderHook(useUserWebSocket);
+ act(() =>
+ TestSocket.instances[0].onmessage?.({
+ data: JSON.stringify({
+ type: "PROJECT_ACCESS_CHANGED",
+ workspaceId: "workspace",
+ }),
+ }),
+ );
+ for (const queryKey of [
+ ["projects", "workspace"],
+ ["assigned-tasks", "workspace"],
+ ["search", { workspaceId: "workspace" }],
+ ["workspace-activity", "workspace"],
+ ])
+ expect(client.invalidateQueries).toHaveBeenCalledWith({ queryKey });
+ expect(client.removeQueries).not.toHaveBeenCalled();
+ expect(navigate).not.toHaveBeenCalled();
+ });
+
it("redirects after a reconnect snapshot reveals a missed workspace revocation", () => {
renderHook(useUserWebSocket);
act(() =>
diff --git a/apps/web/src/hooks/use-user-websocket.ts b/apps/web/src/hooks/use-user-websocket.ts
index da4d0ad32..f23344f4a 100644
--- a/apps/web/src/hooks/use-user-websocket.ts
+++ b/apps/web/src/hooks/use-user-websocket.ts
@@ -132,6 +132,19 @@ export function useUserWebSocket() {
if (current === message.workspaceId)
void navigate({ to: "/dashboard" });
}
+ if (
+ message.type === "PROJECT_ACCESS_CHANGED" &&
+ message.workspaceId
+ ) {
+ const { workspaceId } = message;
+ for (const queryKey of [
+ ["projects", workspaceId],
+ ["assigned-tasks", workspaceId],
+ ["search", { workspaceId }],
+ ["workspace-activity", workspaceId],
+ ])
+ void queryClient.invalidateQueries({ queryKey });
+ }
if (message.type === "NOTIFICATION_CREATED") {
queryClient.invalidateQueries({ queryKey: ["notifications"] });
}
diff --git a/apps/web/src/lib/auth-client.ts b/apps/web/src/lib/auth-client.ts
index e090dee11..1a52215f5 100644
--- a/apps/web/src/lib/auth-client.ts
+++ b/apps/web/src/lib/auth-client.ts
@@ -6,6 +6,7 @@ import {
emailOTPClient,
genericOAuthClient,
inferAdditionalFields,
+ inferOrgAdditionalFields,
lastLoginMethodClient,
magicLinkClient,
organizationClient,
@@ -46,6 +47,22 @@ export const authClient = createAuthClient({
dynamicAccessControl: {
enabled: true,
},
+ schema: inferOrgAdditionalFields({
+ invitation: {
+ additionalFields: {
+ projectAccess: {
+ type: "string",
+ input: true,
+ required: false,
+ },
+ projectIds: {
+ type: "string[]",
+ input: true,
+ required: false,
+ },
+ },
+ },
+ }),
}),
genericOAuthClient(),
deviceAuthorizationClient(),
diff --git a/apps/web/src/lib/evict-project-cache.test.ts b/apps/web/src/lib/evict-project-cache.test.ts
new file mode 100644
index 000000000..c960e3cac
--- /dev/null
+++ b/apps/web/src/lib/evict-project-cache.test.ts
@@ -0,0 +1,68 @@
+import { QueryClient, QueryObserver } from "@tanstack/react-query";
+import { expect, it, vi } from "vite-plus/test";
+import { evictProjectCache } from "./evict-project-cache";
+
+it("evicts the revoked project's data while keeping other projects", () => {
+ const client = new QueryClient();
+ const revoked = {
+ id: "revoked-project",
+ workspaceId: "workspace",
+ columns: [
+ { tasks: [{ id: "revoked-task", projectId: "revoked-project" }] },
+ ],
+ };
+ const kept = {
+ id: "kept-project",
+ workspaceId: "workspace",
+ columns: [{ tasks: [{ id: "kept-task", projectId: "kept-project" }] }],
+ };
+ client.setQueryData(["tasks", "revoked-project"], revoked);
+ client.setQueryData(["tasks", "kept-project"], kept);
+ client.setQueryData(["projects", "workspace", "revoked-project"], revoked);
+ client.setQueryData(["task", "revoked-task"], {
+ id: "revoked-task",
+ projectId: "revoked-project",
+ });
+ client.setQueryData(["comments", "revoked-task"], [{ id: "comment" }]);
+ client.setQueryData(["task", "kept-task"], {
+ id: "kept-task",
+ projectId: "kept-project",
+ });
+ client.setQueryData(["labels", "workspace"], [{ id: "label" }]);
+ evictProjectCache(client, "revoked-project");
+ for (const key of [
+ ["tasks", "revoked-project"],
+ ["projects", "workspace", "revoked-project"],
+ ["task", "revoked-task"],
+ ["comments", "revoked-task"],
+ ])
+ expect(client.getQueryData(key)).toBeUndefined();
+ expect(client.getQueryData(["tasks", "kept-project"])).toEqual(kept);
+ expect(client.getQueryData(["task", "kept-task"])).toBeDefined();
+ expect(client.getQueryData(["labels", "workspace"])).toBeDefined();
+ client.clear();
+});
+
+it("refetches an active project list that still lists the revoked project", async () => {
+ const client = new QueryClient();
+ const queryFn = vi.fn().mockResolvedValue([{ id: "kept-project" }]);
+ client.setQueryData(
+ ["projects", "workspace"],
+ [{ id: "revoked-project" }, { id: "kept-project" }],
+ );
+ const observer = new QueryObserver(client, {
+ queryKey: ["projects", "workspace"],
+ queryFn,
+ staleTime: Infinity,
+ });
+ const unsubscribe = observer.subscribe(() => {});
+ evictProjectCache(client, "revoked-project");
+ await vi.waitFor(() =>
+ expect(client.getQueryData(["projects", "workspace"])).toEqual([
+ { id: "kept-project" },
+ ]),
+ );
+ expect(queryFn).toHaveBeenCalledOnce();
+ unsubscribe();
+ client.clear();
+});
diff --git a/apps/web/src/lib/evict-project-cache.ts b/apps/web/src/lib/evict-project-cache.ts
new file mode 100644
index 000000000..57a784478
--- /dev/null
+++ b/apps/web/src/lib/evict-project-cache.ts
@@ -0,0 +1,41 @@
+import type { QueryClient } from "@tanstack/react-query";
+
+function visit(
+ value: unknown,
+ callback: (record: Record<string, unknown>) => void,
+) {
+ if (!value || typeof value !== "object") return;
+ if (Array.isArray(value)) {
+ for (const item of value) visit(item, callback);
+ return;
+ }
+ const record = value as Record<string, unknown>;
+ callback(record);
+ for (const item of Object.values(record)) visit(item, callback);
+}
+
+export function evictProjectCache(client: QueryClient, projectId: string) {
+ const queries = client.getQueryCache().getAll();
+ const ids = new Set([projectId]);
+ for (const query of queries)
+ visit(query.state.data, (record) => {
+ if (typeof record.id === "string" && record.projectId === projectId)
+ ids.add(record.id);
+ });
+ const references = (value: unknown) =>
+ typeof value === "string" && ids.has(value);
+ const predicate = (query: (typeof queries)[number]) => {
+ let affected = query.queryKey.some(references);
+ visit([query.queryKey, query.state.data], (record) => {
+ if (Object.values(record).some(references)) affected = true;
+ });
+ return affected;
+ };
+ void client.cancelQueries({ predicate });
+ client.removeQueries({
+ predicate: (query) => predicate(query) && !query.isActive(),
+ });
+ void client.resetQueries({
+ predicate: (query) => predicate(query) && query.isActive(),
+ });
+}
diff --git a/apps/web/src/lib/project-unavailable-reason.test.ts b/apps/web/src/lib/project-unavailable-reason.test.ts
new file mode 100644
index 000000000..681ff2319
--- /dev/null
+++ b/apps/web/src/lib/project-unavailable-reason.test.ts
@@ -0,0 +1,20 @@
+import { describe, expect, it } from "vite-plus/test";
+import { HttpError } from "./http-error";
+import { getProjectUnavailableReason } from "./project-unavailable-reason";
+
+describe("getProjectUnavailableReason", () => {
+ it("maps 403 to no access and 404 to not found", () => {
+ expect(getProjectUnavailableReason(new HttpError(403, "denied"))).toBe(
+ "forbidden",
+ );
+ expect(getProjectUnavailableReason(new HttpError(404, "missing"))).toBe(
+ "notFound",
+ );
+ });
+
+ it("ignores other failures so they keep their own handling", () => {
+ expect(getProjectUnavailableReason(new HttpError(500, "boom"))).toBeNull();
+ expect(getProjectUnavailableReason(new Error("offline"))).toBeNull();
+ expect(getProjectUnavailableReason(null)).toBeNull();
+ });
+});
diff --git a/apps/web/src/lib/project-unavailable-reason.ts b/apps/web/src/lib/project-unavailable-reason.ts
new file mode 100644
index 000000000..79e8a2126
--- /dev/null
+++ b/apps/web/src/lib/project-unavailable-reason.ts
@@ -0,0 +1,12 @@
+import { HttpError } from "./http-error";
+
+export type ProjectUnavailableReason = "forbidden" | "notFound";
+
+export function getProjectUnavailableReason(
+ error: unknown,
+): ProjectUnavailableReason | null {
+ if (!(error instanceof HttpError)) return null;
+ if (error.status === 403) return "forbidden";
+ if (error.status === 404) return "notFound";
+ return null;
+}
diff --git a/i18n/az-AZ.json b/i18n/az-AZ.json
index 0c68ba180..9d528b55d 100644
--- a/i18n/az-AZ.json
+++ b/i18n/az-AZ.json
@@ -2760,7 +2760,14 @@
},
"noDueDate": "Son tarix yoxdur",
"reorderHandle": "Layihənin sırasını dəyiş",
- "reorderError": "Layihələrin sırasını dəyişmək alınmadı"
+ "reorderError": "Layihələrin sırasını dəyişmək alınmadı",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "Axtarış",
@@ -2890,7 +2897,8 @@
"name": "Ad",
"role": "Rol",
"joined": "Qoşulub",
- "actions": "Əməliyyatlar"
+ "actions": "Əməliyyatlar",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (gözləyir)",
"ariaCancelInvitation": "Dəvəti ləğv et",
@@ -2908,6 +2916,26 @@
"cancelInviteError": "Dəvəti ləğv etmək alınmadı",
"roleUpdateSuccess": "Rol yeniləndi",
"roleUpdateError": "Rolu yeniləmək alınmadı"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_one": "{{count}} project",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/de-DE.json b/i18n/de-DE.json
index 0c1f110e7..663e748a4 100644
--- a/i18n/de-DE.json
+++ b/i18n/de-DE.json
@@ -2760,7 +2760,14 @@
"noDueDate": "Kein Fälligkeitsdatum",
"reorderHandle": "Projekt neu anordnen",
"reorderError": "Projekte konnten nicht neu angeordnet werden",
- "emptyDescriptionReadOnly": "In diesem Workspace gibt es noch keine Projekte. Bitte einen Admin, eines zu erstellen."
+ "emptyDescriptionReadOnly": "In diesem Workspace gibt es noch keine Projekte. Bitte einen Admin, eines zu erstellen.",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "Suche",
@@ -2890,7 +2897,8 @@
"name": "Name",
"role": "Rolle",
"joined": "Beigetreten",
- "actions": "Aktionen"
+ "actions": "Aktionen",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (Ausstehend)",
"ariaCancelInvitation": "Einladung abbrechen",
@@ -2908,6 +2916,26 @@
"ariaInvitationActions": "Einladungsaktionen",
"roleUpdateSuccess": "Rolle aktualisiert",
"roleUpdateError": "Rolle konnte nicht aktualisiert werden"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_one": "{{count}} project",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/el-GR.json b/i18n/el-GR.json
index a5e364d09..d6bd5e3af 100644
--- a/i18n/el-GR.json
+++ b/i18n/el-GR.json
@@ -2760,7 +2760,14 @@
"noDueDate": "Χωρίς ημερομηνία λήξης",
"reorderHandle": "Αναδιάταξη έργου",
"reorderError": "Η αναδιάταξη των έργων απέτυχε",
- "emptyDescriptionReadOnly": "Δεν υπάρχουν ακόμα έργα σε αυτόν τον χώρο εργασίας. Ζητήστε από έναν διαχειριστή να δημιουργήσει ένα."
+ "emptyDescriptionReadOnly": "Δεν υπάρχουν ακόμα έργα σε αυτόν τον χώρο εργασίας. Ζητήστε από έναν διαχειριστή να δημιουργήσει ένα.",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "Αναζήτηση",
@@ -2890,7 +2897,8 @@
"name": "Όνομα",
"role": "Ρόλος",
"joined": "Εντάχθηκε",
- "actions": "Ενέργειες"
+ "actions": "Ενέργειες",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (Σε εκκρεμότητα)",
"ariaCancelInvitation": "Ακύρωση πρόσκλησης",
@@ -2908,6 +2916,26 @@
"ariaInvitationActions": "Ενέργειες πρόσκλησης",
"roleUpdateSuccess": "Ο ρόλος ενημερώθηκε",
"roleUpdateError": "Αποτυχία ενημέρωσης ρόλου"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_one": "{{count}} project",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/en-US.json b/i18n/en-US.json
index 279af3ab0..6a8f6be66 100644
--- a/i18n/en-US.json
+++ b/i18n/en-US.json
@@ -2760,7 +2760,14 @@
},
"noDueDate": "No due date",
"reorderHandle": "Reorder project",
- "reorderError": "Failed to reorder projects"
+ "reorderError": "Failed to reorder projects",
+ "unavailable": {
+ "noAccessTitle": "You don't have access to this project",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "notFoundTitle": "Project not found",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "backToWorkspace": "Back to workspace"
+ }
},
"search": {
"pageTitle": "Search",
@@ -2890,7 +2897,8 @@
"name": "Name",
"role": "Role",
"joined": "Joined",
- "actions": "Actions"
+ "actions": "Actions",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (Pending)",
"ariaCancelInvitation": "Cancel invitation",
@@ -2908,6 +2916,26 @@
"cancelInviteError": "Failed to cancel invitation",
"roleUpdateSuccess": "Role updated",
"roleUpdateError": "Failed to update role"
+ },
+ "projectAccess": {
+ "label": "Project access",
+ "description": "Choose which projects this person can see.",
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "projectsLabel": "Projects",
+ "noProjects": "No projects in this workspace yet.",
+ "archived": "Archived",
+ "selectAtLeastOne": "Choose at least one project.",
+ "projectCount_one": "{{count}} project",
+ "projectCount_other": "{{count}} projects",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "dialogTitle": "Project access",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "save": "Save",
+ "updateSuccess": "Project access updated",
+ "updateError": "Failed to update project access"
}
},
"publicProject": {
diff --git a/i18n/es-ES.json b/i18n/es-ES.json
index cf38a5d17..e83f6baec 100644
--- a/i18n/es-ES.json
+++ b/i18n/es-ES.json
@@ -2773,7 +2773,14 @@
"noDueDate": "Sin fecha de vencimiento",
"reorderHandle": "Reordenar proyecto",
"reorderError": "No se pudieron reordenar los proyectos",
- "emptyDescriptionReadOnly": "Todavía no hay proyectos en este espacio de trabajo. Pide a un admin que cree uno."
+ "emptyDescriptionReadOnly": "Todavía no hay proyectos en este espacio de trabajo. Pide a un admin que cree uno.",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "Buscar",
@@ -2907,7 +2914,8 @@
"name": "Nombre",
"role": "Rol",
"joined": "Unido",
- "actions": "Acciones"
+ "actions": "Acciones",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (Pendiente)",
"ariaCancelInvitation": "Cancelar invitacion",
@@ -2925,6 +2933,27 @@
"cancelInviteError": "Error al cancelar invitación",
"roleUpdateSuccess": "Rol actualizado",
"roleUpdateError": "Error al actualizar el rol"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_many": "{{count}} projects",
+ "projectCount_one": "{{count}} project",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/fr-FR.json b/i18n/fr-FR.json
index 0b68beb09..4347b9883 100644
--- a/i18n/fr-FR.json
+++ b/i18n/fr-FR.json
@@ -2773,7 +2773,14 @@
},
"noDueDate": "Pas de date d'échéance",
"reorderHandle": "Réorganiser le projet",
- "reorderError": "Échec de la réorganisation des projets"
+ "reorderError": "Échec de la réorganisation des projets",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "Rechercher",
@@ -2907,7 +2914,8 @@
"name": "Nom",
"role": "Rôle",
"joined": "Rejoint",
- "actions": "Actions"
+ "actions": "Actions",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (En attente)",
"ariaCancelInvitation": "Annuler l'invitation",
@@ -2925,6 +2933,27 @@
"roleUpdateSuccess": "Rôle mis à jour",
"roleUpdateError": "Échec de la mise à jour du rôle",
"ariaInvitationActions": "Actions de l'invitation"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_many": "{{count}} projects",
+ "projectCount_one": "{{count}} project",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/hi-IN.json b/i18n/hi-IN.json
index 97da78c89..b181dcccc 100644
--- a/i18n/hi-IN.json
+++ b/i18n/hi-IN.json
@@ -2760,7 +2760,14 @@
},
"noDueDate": "कोई नियत तारीख नहीं",
"reorderHandle": "प्रोजेक्ट का क्रम बदलें",
- "reorderError": "प्रोजेक्ट का क्रम बदलने में विफल"
+ "reorderError": "प्रोजेक्ट का क्रम बदलने में विफल",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "खोजें",
@@ -2890,7 +2897,8 @@
"name": "नाम",
"role": "भूमिका",
"joined": "शामिल हुए",
- "actions": "कार्रवाइयाँ"
+ "actions": "कार्रवाइयाँ",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (लंबित)",
"ariaCancelInvitation": "निमंत्रण रद्द करें",
@@ -2908,6 +2916,26 @@
"cancelInviteError": "निमंत्रण रद्द करने में विफल",
"roleUpdateSuccess": "भूमिका अपडेट की गई",
"roleUpdateError": "भूमिका अपडेट करने में विफल"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_one": "{{count}} project",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/id-ID.json b/i18n/id-ID.json
index 198f442b9..9d7f8d7c1 100644
--- a/i18n/id-ID.json
+++ b/i18n/id-ID.json
@@ -2747,7 +2747,14 @@
},
"noDueDate": "Tanpa tenggat",
"reorderHandle": "Ubah urutan proyek",
- "reorderError": "Gagal mengubah urutan proyek"
+ "reorderError": "Gagal mengubah urutan proyek",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "Cari",
@@ -2873,7 +2880,8 @@
"name": "Nama",
"role": "Peran",
"joined": "Bergabung",
- "actions": "Aksi"
+ "actions": "Aksi",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (Tertunda)",
"ariaCancelInvitation": "Batalkan undangan",
@@ -2891,6 +2899,25 @@
"roleUpdateSuccess": "Peran diperbarui",
"roleUpdateError": "Gagal memperbarui peran",
"ariaInvitationActions": "Tindakan undangan"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/it-IT.json b/i18n/it-IT.json
index 4e420335d..ed9785091 100644
--- a/i18n/it-IT.json
+++ b/i18n/it-IT.json
@@ -2773,7 +2773,14 @@
},
"noDueDate": "Nessuna scadenza",
"reorderHandle": "Riordina progetto",
- "reorderError": "Impossibile riordinare i progetti"
+ "reorderError": "Impossibile riordinare i progetti",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "Cerca",
@@ -2907,7 +2914,8 @@
"name": "Nome",
"role": "Ruolo",
"joined": "Iscritto",
- "actions": "Azioni"
+ "actions": "Azioni",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (In sospeso)",
"ariaCancelInvitation": "Annulla invito",
@@ -2925,6 +2933,27 @@
"cancelInviteError": "Annullamento invito fallito",
"roleUpdateSuccess": "Ruolo aggiornato",
"roleUpdateError": "Aggiornamento ruolo fallito"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_many": "{{count}} projects",
+ "projectCount_one": "{{count}} project",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/ja-JP.json b/i18n/ja-JP.json
index 054a02e46..512934fae 100644
--- a/i18n/ja-JP.json
+++ b/i18n/ja-JP.json
@@ -2747,7 +2747,14 @@
},
"noDueDate": "期限なし",
"reorderHandle": "プロジェクトの並び替え",
- "reorderError": "プロジェクトの並び替えに失敗しました"
+ "reorderError": "プロジェクトの並び替えに失敗しました",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "検索",
@@ -2873,7 +2880,8 @@
"name": "名前",
"role": "ロール",
"joined": "参加日",
- "actions": "操作"
+ "actions": "操作",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (保留中)",
"ariaCancelInvitation": "招待をキャンセル",
@@ -2891,6 +2899,25 @@
"cancelInviteError": "招待のキャンセルに失敗しました",
"roleUpdateSuccess": "ロールを更新しました",
"roleUpdateError": "ロールの更新に失敗しました"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/ko-KR.json b/i18n/ko-KR.json
index d34c86822..44a54d70e 100644
--- a/i18n/ko-KR.json
+++ b/i18n/ko-KR.json
@@ -2747,7 +2747,14 @@
"noDueDate": "마감일 없음",
"reorderHandle": "프로젝트 순서 변경",
"reorderError": "프로젝트 순서를 변경하지 못했습니다",
- "emptyDescriptionReadOnly": "이 워크스페이스에 아직 프로젝트가 없습니다. 관리자에게 프로젝트 생성을 요청하세요."
+ "emptyDescriptionReadOnly": "이 워크스페이스에 아직 프로젝트가 없습니다. 관리자에게 프로젝트 생성을 요청하세요.",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "검색",
@@ -2873,7 +2880,8 @@
"name": "이름",
"role": "역할",
"joined": "참여",
- "actions": "작업"
+ "actions": "작업",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (대기 중)",
"ariaCancelInvitation": "초대 취소",
@@ -2891,6 +2899,25 @@
"ariaInvitationActions": "초대 작업",
"roleUpdateSuccess": "역할이 업데이트되었습니다",
"roleUpdateError": "역할 업데이트에 실패했습니다"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/mk-MK.json b/i18n/mk-MK.json
index 0a36c83fd..52c71acaf 100644
--- a/i18n/mk-MK.json
+++ b/i18n/mk-MK.json
@@ -2760,7 +2760,14 @@
"noDueDate": "Без краен рок",
"reorderHandle": "Прередување на проектот",
"reorderError": "Прередувањето на проектите не успеа",
- "emptyDescriptionReadOnly": "Сè уште нема проекти во овој работен простор. Замоли администратор да креира еден."
+ "emptyDescriptionReadOnly": "Сè уште нема проекти во овој работен простор. Замоли администратор да креира еден.",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "Пребарување",
@@ -2890,7 +2897,8 @@
"name": "Име",
"role": "Улога",
"joined": "Приклучен",
- "actions": "Акции"
+ "actions": "Акции",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (На чекање)",
"ariaCancelInvitation": "Откажи покана",
@@ -2908,6 +2916,26 @@
"ariaInvitationActions": "Акции за поканата",
"roleUpdateSuccess": "Улогата е ажурирана",
"roleUpdateError": "Неуспешно ажурирање на улогата"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_one": "{{count}} project",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/nl-NL.json b/i18n/nl-NL.json
index 0d6a23fa5..4c2b70f5c 100644
--- a/i18n/nl-NL.json
+++ b/i18n/nl-NL.json
@@ -2760,7 +2760,14 @@
"noDueDate": "Geen einddatum",
"reorderHandle": "Project opnieuw ordenen",
"reorderError": "Projecten opnieuw ordenen mislukt",
- "emptyDescriptionReadOnly": "Er zijn nog geen projecten in deze werkruimte. Vraag een beheerder om er een aan te maken."
+ "emptyDescriptionReadOnly": "Er zijn nog geen projecten in deze werkruimte. Vraag een beheerder om er een aan te maken.",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "Zoeken",
@@ -2890,7 +2897,8 @@
"name": "Naam",
"role": "Rol",
"joined": "Lid sinds",
- "actions": "Acties"
+ "actions": "Acties",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (In afwachting)",
"ariaCancelInvitation": "Uitnodiging annuleren",
@@ -2908,6 +2916,26 @@
"ariaInvitationActions": "Uitnodigingsacties",
"roleUpdateSuccess": "Rol bijgewerkt",
"roleUpdateError": "Bijwerken rol mislukt"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_one": "{{count}} project",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/pl-PL.json b/i18n/pl-PL.json
index ae4a17ed5..7a9555a25 100644
--- a/i18n/pl-PL.json
+++ b/i18n/pl-PL.json
@@ -642,7 +642,14 @@
},
"noDueDate": "Brak terminu",
"reorderHandle": "Przestaw projekt",
- "reorderError": "Nie udało się zmienić kolejności projektów"
+ "reorderError": "Nie udało się zmienić kolejności projektów",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "Szukaj",
@@ -780,7 +787,8 @@
"name": "Nazwa",
"role": "Rola",
"joined": "Dołączył",
- "actions": "Działania"
+ "actions": "Działania",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (oczekuje)",
"ariaCancelInvitation": "Anuluj zaproszenie",
@@ -798,6 +806,28 @@
"cancelInviteError": "Nie udało się anulować zaproszenia",
"roleUpdateSuccess": "Rola zaktualizowana",
"roleUpdateError": "Nie udało się zaktualizować roli"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_few": "{{count}} projects",
+ "projectCount_many": "{{count}} projects",
+ "projectCount_one": "{{count}} project",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/pt-BR.json b/i18n/pt-BR.json
index f0b73cfd6..6929a25bd 100644
--- a/i18n/pt-BR.json
+++ b/i18n/pt-BR.json
@@ -2773,7 +2773,14 @@
},
"noDueDate": "Sem data de vencimento",
"reorderHandle": "Reordenar projeto",
- "reorderError": "Falha ao reordenar os projetos"
+ "reorderError": "Falha ao reordenar os projetos",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "Buscar",
@@ -2907,7 +2914,8 @@
"name": "Nome",
"role": "Função",
"joined": "Entrou em",
- "actions": "Ações"
+ "actions": "Ações",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (Pendente)",
"ariaCancelInvitation": "Cancelar convite",
@@ -2925,6 +2933,27 @@
"cancelInviteError": "Falha ao cancelar convite",
"roleUpdateSuccess": "Função atualizada",
"roleUpdateError": "Falha ao atualizar função"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_many": "{{count}} projects",
+ "projectCount_one": "{{count}} project",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/ru-RU.json b/i18n/ru-RU.json
index b447f650d..91c19f0bd 100644
--- a/i18n/ru-RU.json
+++ b/i18n/ru-RU.json
@@ -2842,7 +2842,14 @@
"noDueDate": "Без срока",
"reorderHandle": "Изменить порядок проекта",
"reorderError": "Не удалось изменить порядок проектов",
- "emptyDescriptionReadOnly": "В этой рабочей области пока нет проектов. Попросите администратора создать проект."
+ "emptyDescriptionReadOnly": "В этой рабочей области пока нет проектов. Попросите администратора создать проект.",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "Поиск",
@@ -2980,7 +2987,8 @@
"name": "Имя",
"role": "Роль",
"joined": "Присоединился",
- "actions": "Действия"
+ "actions": "Действия",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (Ожидает)",
"ariaCancelInvitation": "Отменить приглашение",
@@ -2998,6 +3006,28 @@
"ariaInvitationActions": "Действия с приглашением",
"roleUpdateSuccess": "Роль обновлена",
"roleUpdateError": "Не удалось обновить роль"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_few": "{{count}} projects",
+ "projectCount_many": "{{count}} projects",
+ "projectCount_one": "{{count}} project",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/schema.json b/i18n/schema.json
index c41a6d4a3..22178d2da 100644
--- a/i18n/schema.json
+++ b/i18n/schema.json
@@ -10618,9 +10618,12 @@
"properties": {
"addTask": {
"type": "string"
+ },
+ "automaticallySortedHint": {
+ "type": "string"
}
},
- "required": ["addTask"]
+ "required": ["addTask", "automaticallySortedHint"]
},
"pr": {
"type": "object",
@@ -11346,6 +11349,34 @@
},
"reorderError": {
"type": "string"
+ },
+ "unavailable": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "noAccessTitle": {
+ "type": "string"
+ },
+ "noAccessDescription": {
+ "type": "string"
+ },
+ "notFoundTitle": {
+ "type": "string"
+ },
+ "notFoundDescription": {
+ "type": "string"
+ },
+ "backToWorkspace": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "noAccessTitle",
+ "noAccessDescription",
+ "notFoundTitle",
+ "notFoundDescription",
+ "backToWorkspace"
+ ]
}
},
"required": [
@@ -11362,7 +11393,8 @@
"projectStatus",
"noDueDate",
"reorderHandle",
- "reorderError"
+ "reorderError",
+ "unavailable"
]
},
"search": {
@@ -11885,9 +11917,12 @@
},
"actions": {
"type": "string"
+ },
+ "projects": {
+ "type": "string"
}
},
- "required": ["name", "role", "joined", "actions"]
+ "required": ["name", "role", "joined", "actions", "projects"]
},
"memberRolePending": {
"type": "string"
@@ -11959,6 +11994,92 @@
"roleUpdateSuccess",
"roleUpdateError"
]
+ },
+ "projectAccess": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "label": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "allProjects": {
+ "type": "string"
+ },
+ "allProjectsDescription": {
+ "type": "string"
+ },
+ "selectedProjects": {
+ "type": "string"
+ },
+ "selectedProjectsDescription": {
+ "type": "string"
+ },
+ "projectsLabel": {
+ "type": "string"
+ },
+ "noProjects": {
+ "type": "string"
+ },
+ "selectAtLeastOne": {
+ "type": "string"
+ },
+ "projectCount_one": {
+ "type": "string"
+ },
+ "projectCount_zero": {
+ "type": "string"
+ },
+ "projectCount_two": {
+ "type": "string"
+ },
+ "projectCount_few": {
+ "type": "string"
+ },
+ "projectCount_many": {
+ "type": "string"
+ },
+ "projectCount_other": {
+ "type": "string"
+ },
+ "editAria": {
+ "type": "string"
+ },
+ "dialogTitle": {
+ "type": "string"
+ },
+ "dialogDescription": {
+ "type": "string"
+ },
+ "save": {
+ "type": "string"
+ },
+ "updateSuccess": {
+ "type": "string"
+ },
+ "updateError": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "label",
+ "description",
+ "allProjects",
+ "allProjectsDescription",
+ "selectedProjects",
+ "selectedProjectsDescription",
+ "projectsLabel",
+ "noProjects",
+ "selectAtLeastOne",
+ "editAria",
+ "dialogTitle",
+ "dialogDescription",
+ "save",
+ "updateSuccess",
+ "updateError"
+ ]
}
},
"required": [
@@ -11966,7 +12087,8 @@
"members",
"invitations",
"inviteModal",
- "membersTable"
+ "membersTable",
+ "projectAccess"
]
},
"publicProject": {
diff --git a/i18n/tr-TR.json b/i18n/tr-TR.json
index 0e13dac00..a0007774c 100644
--- a/i18n/tr-TR.json
+++ b/i18n/tr-TR.json
@@ -2760,7 +2760,14 @@
},
"noDueDate": "Bitiş tarihi yok",
"reorderHandle": "Projeyi yeniden sırala",
- "reorderError": "Projeler yeniden sıralanamadı"
+ "reorderError": "Projeler yeniden sıralanamadı",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "Ara",
@@ -2890,7 +2897,8 @@
"name": "Ad",
"role": "Rol",
"joined": "Katılım",
- "actions": "İşlemler"
+ "actions": "İşlemler",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (Beklemede)",
"ariaCancelInvitation": "Daveti iptal et",
@@ -2908,6 +2916,26 @@
"roleUpdateSuccess": "Rol güncellendi",
"roleUpdateError": "Rol güncellenemedi",
"ariaInvitationActions": "Davet işlemleri"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_one": "{{count}} project",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/uk-UA.json b/i18n/uk-UA.json
index 539f03b77..cf57e6e07 100644
--- a/i18n/uk-UA.json
+++ b/i18n/uk-UA.json
@@ -2786,7 +2786,14 @@
"noDueDate": "Без дати завершення",
"reorderHandle": "Змінити порядок проєкту",
"reorderError": "Не вдалося змінити порядок проєктів",
- "emptyDescriptionReadOnly": "У цьому робочому просторі ще немає проєктів. Попросіть адміністратора створити проєкт."
+ "emptyDescriptionReadOnly": "У цьому робочому просторі ще немає проєктів. Попросіть адміністратора створити проєкт.",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "Пошук",
@@ -2924,7 +2931,8 @@
"name": "Ім'я",
"role": "Роль",
"joined": "Приєднався",
- "actions": "Дії"
+ "actions": "Дії",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (Очікує)",
"ariaCancelInvitation": "Скасувати запрошення",
@@ -2942,6 +2950,28 @@
"ariaInvitationActions": "Дії із запрошенням",
"roleUpdateSuccess": "Роль оновлено",
"roleUpdateError": "Не вдалося оновити роль"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_few": "{{count}} projects",
+ "projectCount_many": "{{count}} projects",
+ "projectCount_one": "{{count}} project",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/vi-VN.json b/i18n/vi-VN.json
index 13f6e4c95..a5723f680 100644
--- a/i18n/vi-VN.json
+++ b/i18n/vi-VN.json
@@ -2747,7 +2747,14 @@
},
"noDueDate": "Không có ngày đến hạn",
"reorderHandle": "Sắp xếp lại dự án",
- "reorderError": "Không thể sắp xếp lại dự án"
+ "reorderError": "Không thể sắp xếp lại dự án",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "Tìm kiếm",
@@ -2873,7 +2880,8 @@
"name": "Tên",
"role": "Vai trò",
"joined": "Ngày tham gia",
- "actions": "Hành động"
+ "actions": "Hành động",
+ "projects": "Projects"
},
"memberRolePending": "{{role}} (Đang chờ)",
"ariaCancelInvitation": "Hủy lời mời",
@@ -2891,6 +2899,25 @@
"cancelInviteError": "Không thể hủy lời mời",
"roleUpdateSuccess": "Đã cập nhật vai trò",
"roleUpdateError": "Không thể cập nhật vai trò"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/zh-CN.json b/i18n/zh-CN.json
index b1a068db2..4cb82d527 100644
--- a/i18n/zh-CN.json
+++ b/i18n/zh-CN.json
@@ -2747,7 +2747,14 @@
},
"noDueDate": "无截止日期",
"reorderHandle": "重新排序项目",
- "reorderError": "重新排序项目失败"
+ "reorderError": "重新排序项目失败",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "搜索",
@@ -2873,7 +2880,8 @@
"name": "姓名",
"role": "角色",
"joined": "加入于",
- "actions": "操作"
+ "actions": "操作",
+ "projects": "Projects"
},
"memberRolePending": "{{role}}(待处理)",
"ariaCancelInvitation": "取消邀请",
@@ -2891,6 +2899,25 @@
"cancelInviteError": "取消邀请失败",
"roleUpdateSuccess": "角色已更新",
"roleUpdateError": "更新角色失败"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/i18n/zh-TW.json b/i18n/zh-TW.json
index dc3c8748c..7485858b0 100644
--- a/i18n/zh-TW.json
+++ b/i18n/zh-TW.json
@@ -2747,7 +2747,14 @@
},
"noDueDate": "無截止日期",
"reorderHandle": "重新排序專案",
- "reorderError": "無法重新排序專案"
+ "reorderError": "無法重新排序專案",
+ "unavailable": {
+ "backToWorkspace": "Back to workspace",
+ "noAccessDescription": "Ask a workspace admin to give you access.",
+ "noAccessTitle": "You don't have access to this project",
+ "notFoundDescription": "This project doesn't exist or has been deleted.",
+ "notFoundTitle": "Project not found"
+ }
},
"search": {
"pageTitle": "搜尋",
@@ -2873,7 +2880,8 @@
"name": "姓名",
"role": "角色",
"joined": "加入時間",
- "actions": "操作"
+ "actions": "操作",
+ "projects": "Projects"
},
"memberRolePending": "{{role}}(待處理)",
"ariaCancelInvitation": "取消邀請",
@@ -2891,6 +2899,25 @@
"cancelInviteError": "無法取消邀請",
"roleUpdateSuccess": "角色已更新",
"roleUpdateError": "無法更新角色"
+ },
+ "projectAccess": {
+ "allProjects": "All projects",
+ "allProjectsDescription": "Access every project in this workspace, including new ones.",
+ "description": "Choose which projects this person can see.",
+ "dialogDescription": "Choose which projects {{name}} can access.",
+ "dialogTitle": "Project access",
+ "editAria": "Change project access for {{name}} ({{access}})",
+ "label": "Project access",
+ "noProjects": "No projects in this workspace yet.",
+ "projectCount_other": "{{count}} projects",
+ "projectsLabel": "Projects",
+ "save": "Save",
+ "selectAtLeastOne": "Choose at least one project.",
+ "selectedProjects": "Selected projects",
+ "selectedProjectsDescription": "Only access the projects you choose.",
+ "updateError": "Failed to update project access",
+ "updateSuccess": "Project access updated",
+ "archived": "Archived"
}
},
"publicProject": {
diff --git a/tests/api-integration/github-import-bounds.test.ts b/tests/api-integration/github-import-bounds.test.ts
index e3a4fe298..fc4ae85c2 100644
--- a/tests/api-integration/github-import-bounds.test.ts
+++ b/tests/api-integration/github-import-bounds.test.ts
@@ -1147,12 +1147,12 @@ it.each(["labels", "comments"])(
await moveTask({
taskId: task!.id,
destinationProjectId: destination.id,
- userId: member.user.id,
+ currentUserId: member.user.id,
});
await moveTask({
taskId: task!.id,
destinationProjectId: project.id,
- userId: member.user.id,
+ currentUserId: member.user.id,
});
return {
repository: {
diff --git a/tests/api-integration/helpers/project-access.ts b/tests/api-integration/helpers/project-access.ts
new file mode 100644
index 000000000..6a4ccf310
--- /dev/null
+++ b/tests/api-integration/helpers/project-access.ts
@@ -0,0 +1,96 @@
+import { randomUUID } from "node:crypto";
+import { eq } from "drizzle-orm";
+import db, { schema } from "../../../apps/api/src/database";
+import { replaceMemberProjectAccess } from "../../../apps/api/src/project-access/member-project-access";
+import { createProjectFixture, createWorkspaceMember } from "./fixtures";
+
+export async function addWorkspaceMember(workspaceId: string, role = "member") {
+ const userId = `user-${randomUUID()}`;
+ const [user] = await db
+ .insert(schema.userTable)
+ .values({
+ id: userId,
+ email: `${userId}@example.com`,
+ emailVerified: true,
+ name: `Member ${role}`,
+ })
+ .returning();
+ await db.insert(schema.workspaceUserTable).values({
+ workspaceId,
+ userId: user.id,
+ role,
+ joinedAt: new Date(),
+ });
+ return user;
+}
+
+export async function restrictToProjects(
+ workspaceId: string,
+ userId: string,
+ projectIds: string[],
+) {
+ await replaceMemberProjectAccess(db, {
+ workspaceId,
+ userId,
+ projectAccess: "selected",
+ projectIds,
+ });
+}
+
+async function createTask(
+ project: Awaited<ReturnType<typeof createProjectFixture>>,
+ title: string,
+ assigneeId: string,
+) {
+ const [task] = await db
+ .insert(schema.taskTable)
+ .values({
+ projectId: project.project.id,
+ title,
+ status: project.columns.todo.slug,
+ columnId: project.columns.todo.id,
+ userId: assigneeId,
+ number: 1,
+ })
+ .returning();
+ await db
+ .update(schema.projectTable)
+ .set({ lastTaskNumber: 1 })
+ .where(eq(schema.projectTable.id, project.project.id));
+ return task;
+}
+
+export async function createRestrictedWorkspace() {
+ const { user: owner, workspace } = await createWorkspaceMember({
+ role: "owner",
+ });
+ const alpha = await createProjectFixture({
+ workspaceId: workspace.id,
+ name: "Alpha",
+ slug: "alpha",
+ });
+ const beta = await createProjectFixture({
+ workspaceId: workspace.id,
+ name: "Beta",
+ slug: "beta",
+ });
+ const restricted = await addWorkspaceMember(workspace.id);
+ await restrictToProjects(workspace.id, restricted.id, [alpha.project.id]);
+
+ const alphaTask = await createTask(
+ alpha,
+ "Visible alpha task",
+ restricted.id,
+ );
+ const betaTask = await createTask(beta, "Hidden beta task", restricted.id);
+
+ return {
+ owner,
+ workspace,
+ restricted,
+ alpha: alpha.project,
+ beta: beta.project,
+ alphaTask,
+ betaTask,
+ };
+}
diff --git a/tests/api-integration/integration-pr-task-ownership.test.ts b/tests/api-integration/integration-pr-task-ownership.test.ts
index c31946119..21b2bd35a 100644
--- a/tests/api-integration/integration-pr-task-ownership.test.ts
+++ b/tests/api-integration/integration-pr-task-ownership.test.ts
@@ -217,13 +217,13 @@ it.each(cases)(
await moveTask({
taskId: task.id,
destinationProjectId: destination.id,
- userId: user.id,
+ currentUserId: user.id,
});
if (race === "returned")
await moveTask({
taskId: task.id,
destinationProjectId: project.id,
- userId: user.id,
+ currentUserId: user.id,
});
return transaction(apply, config);
});
diff --git a/tests/api-integration/integration-push-task-ownership.test.ts b/tests/api-integration/integration-push-task-ownership.test.ts
index 36b3cc18c..b0a452b5a 100644
--- a/tests/api-integration/integration-push-task-ownership.test.ts
+++ b/tests/api-integration/integration-push-task-ownership.test.ts
@@ -103,7 +103,7 @@ it.each(
await moveTask({
taskId: task.id,
destinationProjectId: destination.id,
- userId: user.id,
+ currentUserId: user.id,
});
return transaction(apply, config);
})
diff --git a/tests/api-integration/integration-task-ownership.test.ts b/tests/api-integration/integration-task-ownership.test.ts
index 5121c7b46..ca3e0ac22 100644
--- a/tests/api-integration/integration-task-ownership.test.ts
+++ b/tests/api-integration/integration-task-ownership.test.ts
@@ -418,7 +418,7 @@ it("reports a concurrent move as a conflict without deleting links", async () =>
moveTask({
taskId: f.task.id,
destinationProjectId: f.destination.id,
- userId: f.source.user.id,
+ currentUserId: f.source.user.id,
}),
).rejects.toMatchObject({ status: 409 });
expect(await db.query.externalLinkTable.findMany()).toHaveLength(1);
@@ -443,7 +443,7 @@ it("preserves legacy links belonging to the destination integration when moving
await moveTask({
taskId: f.task.id,
destinationProjectId: f.destination.id,
- userId: f.source.user.id,
+ currentUserId: f.source.user.id,
});
expect(await db.query.externalLinkTable.findMany()).toEqual([compatible]);
});
@@ -566,12 +566,12 @@ it.each(["edit", "labels", "comment"])(
await moveTask({
taskId: f.task.id,
destinationProjectId: f.destination.id,
- userId: f.source.user.id,
+ currentUserId: f.source.user.id,
});
await moveTask({
taskId: f.task.id,
destinationProjectId: f.project.id,
- userId: f.source.user.id,
+ currentUserId: f.source.user.id,
});
return transaction(apply, config);
});
diff --git a/tests/api-integration/project-access-management.test.ts b/tests/api-integration/project-access-management.test.ts
new file mode 100644
index 000000000..bc90cb704
--- /dev/null
+++ b/tests/api-integration/project-access-management.test.ts
@@ -0,0 +1,365 @@
+import { and, eq } from "drizzle-orm";
+import { beforeEach, describe, expect, it } from "vite-plus/test";
+import db, { schema } from "../../apps/api/src/database";
+import { createApp } from "../../apps/api/src/index";
+import { mockAuthenticatedSession } from "./helpers/auth";
+import { signUpWithSession } from "./helpers/auth-session";
+import { resetTestDatabase } from "./helpers/database";
+import { createProjectFixture } from "./helpers/fixtures";
+import {
+ addWorkspaceMember,
+ createRestrictedWorkspace,
+ restrictToProjects,
+} from "./helpers/project-access";
+
+beforeEach(resetTestDatabase);
+
+const origin = "http://localhost:5173";
+
+function client(headers: Record<string, string> = {}) {
+ const { app } = createApp();
+ return (path: string, init: { method?: string; body?: unknown } = {}) =>
+ app.request(`/api${path}`, {
+ method: init.method ?? "GET",
+ headers: { "content-type": "application/json", origin, ...headers },
+ body: init.body === undefined ? undefined : JSON.stringify(init.body),
+ });
+}
+
+function setAccess(
+ request: ReturnType<typeof client>,
+ workspaceId: string,
+ userId: string,
+ body: { projectAccess: string; projectIds?: string[] },
+) {
+ return request(`/workspace/${workspaceId}/members/${userId}/project-access`, {
+ method: "PUT",
+ body,
+ });
+}
+
+async function accessRows(workspaceId: string, userId: string) {
+ const rules = await db
+ .select()
+ .from(schema.workspaceMemberAccessTable)
+ .where(
+ and(
+ eq(schema.workspaceMemberAccessTable.workspaceId, workspaceId),
+ eq(schema.workspaceMemberAccessTable.userId, userId),
+ ),
+ );
+ const grants = await db
+ .select()
+ .from(schema.workspaceMemberProjectTable)
+ .where(
+ and(
+ eq(schema.workspaceMemberProjectTable.workspaceId, workspaceId),
+ eq(schema.workspaceMemberProjectTable.userId, userId),
+ ),
+ );
+ return { rules, grants };
+}
+
+describe("managing member project access", () => {
+ it("restricts a member and lifts the restriction again", async () => {
+ const ctx = await createRestrictedWorkspace();
+ const member = await addWorkspaceMember(ctx.workspace.id);
+ mockAuthenticatedSession(ctx.owner);
+ const request = client();
+
+ const restricted = await setAccess(request, ctx.workspace.id, member.id, {
+ projectAccess: "selected",
+ projectIds: [ctx.beta.id],
+ });
+ expect(restricted.status).toBe(200);
+ expect(await restricted.json()).toEqual({
+ userId: member.id,
+ projectAccess: "selected",
+ projectIds: [ctx.beta.id],
+ });
+
+ const listed = await request(
+ `/workspace/${ctx.workspace.id}/project-access`,
+ );
+ expect(listed.status).toBe(200);
+ expect(await listed.json()).toEqual(
+ expect.arrayContaining([
+ {
+ userId: member.id,
+ projectAccess: "selected",
+ projectIds: [ctx.beta.id],
+ },
+ {
+ userId: ctx.restricted.id,
+ projectAccess: "selected",
+ projectIds: [ctx.alpha.id],
+ },
+ ]),
+ );
+
+ mockAuthenticatedSession(member);
+ expect((await client()(`/project/${ctx.alpha.id}`)).status).toBe(403);
+ expect((await client()(`/project/${ctx.beta.id}`)).status).toBe(200);
+
+ mockAuthenticatedSession(ctx.owner);
+ const lifted = await setAccess(client(), ctx.workspace.id, member.id, {
+ projectAccess: "all",
+ });
+ expect(lifted.status).toBe(200);
+ expect(await accessRows(ctx.workspace.id, member.id)).toEqual({
+ rules: [],
+ grants: [],
+ });
+
+ mockAuthenticatedSession(member);
+ expect((await client()(`/project/${ctx.alpha.id}`)).status).toBe(200);
+ });
+
+ it("refuses to restrict owners or yourself", async () => {
+ const ctx = await createRestrictedWorkspace();
+ const admin = await addWorkspaceMember(ctx.workspace.id, "admin");
+ mockAuthenticatedSession(admin);
+ const request = client();
+
+ const owner = await setAccess(request, ctx.workspace.id, ctx.owner.id, {
+ projectAccess: "selected",
+ projectIds: [ctx.alpha.id],
+ });
+ expect(owner.status).toBe(400);
+
+ const self = await setAccess(request, ctx.workspace.id, admin.id, {
+ projectAccess: "selected",
+ projectIds: [ctx.alpha.id],
+ });
+ expect(self.status).toBe(403);
+ });
+
+ it("requires permission to manage members", async () => {
+ const ctx = await createRestrictedWorkspace();
+ const member = await addWorkspaceMember(ctx.workspace.id);
+ mockAuthenticatedSession(member);
+ const request = client();
+
+ expect(
+ (await request(`/workspace/${ctx.workspace.id}/project-access`)).status,
+ ).toBe(403);
+ expect(
+ (
+ await setAccess(request, ctx.workspace.id, ctx.restricted.id, {
+ projectAccess: "all",
+ })
+ ).status,
+ ).toBe(403);
+ });
+
+ it("stops a restricted admin from granting more than they can see", async () => {
+ const ctx = await createRestrictedWorkspace();
+ const admin = await addWorkspaceMember(ctx.workspace.id, "admin");
+ await restrictToProjects(ctx.workspace.id, admin.id, [ctx.alpha.id]);
+ const unrestricted = await addWorkspaceMember(ctx.workspace.id);
+ const member = await addWorkspaceMember(ctx.workspace.id);
+ await restrictToProjects(ctx.workspace.id, member.id, [ctx.beta.id]);
+ mockAuthenticatedSession(admin);
+ const request = client();
+
+ const hidden = await setAccess(request, ctx.workspace.id, member.id, {
+ projectAccess: "selected",
+ projectIds: [ctx.beta.id],
+ });
+ expect(hidden.status).toBe(403);
+
+ const everything = await setAccess(request, ctx.workspace.id, member.id, {
+ projectAccess: "all",
+ });
+ expect(everything.status).toBe(403);
+
+ const narrowed = await setAccess(
+ request,
+ ctx.workspace.id,
+ unrestricted.id,
+ { projectAccess: "selected", projectIds: [ctx.alpha.id] },
+ );
+ expect(narrowed.status).toBe(403);
+
+ const visible = await setAccess(request, ctx.workspace.id, member.id, {
+ projectAccess: "selected",
+ projectIds: [ctx.alpha.id],
+ });
+ expect(visible.status).toBe(200);
+ expect(
+ ((await visible.json()) as { projectIds: string[] }).projectIds.sort(),
+ ).toEqual([ctx.alpha.id, ctx.beta.id].sort());
+ });
+
+ it("rejects projects from another workspace", async () => {
+ const ctx = await createRestrictedWorkspace();
+ const other = await createRestrictedWorkspace();
+ mockAuthenticatedSession(ctx.owner);
+
+ const response = await setAccess(
+ client(),
+ ctx.workspace.id,
+ ctx.restricted.id,
+ { projectAccess: "selected", projectIds: [other.alpha.id] },
+ );
+
+ expect(response.status).toBe(400);
+ });
+});
+
+describe("invitations with project access", () => {
+ async function workspaceWithInvitee() {
+ const { app } = createApp();
+ const owner = await signUpWithSession(app, {
+ email: "[email protected]",
+ name: "Owner",
+ });
+ const ownerRequest = client({ cookie: owner.cookies });
+ const created = await ownerRequest("/auth/organization/create", {
+ method: "POST",
+ body: { name: "Agency", slug: "agency" },
+ });
+ expect(created.status).toBe(200);
+ const workspace = (await created.json()) as { id: string };
+ const alpha = await createProjectFixture({
+ workspaceId: workspace.id,
+ name: "Alpha",
+ slug: "alpha",
+ });
+ const beta = await createProjectFixture({
+ workspaceId: workspace.id,
+ name: "Beta",
+ slug: "beta",
+ });
+ return {
+ app,
+ ownerRequest,
+ workspaceId: workspace.id,
+ alpha: alpha.project,
+ beta: beta.project,
+ };
+ }
+
+ it("applies the invitation's project selection when it's accepted", async () => {
+ const ctx = await workspaceWithInvitee();
+
+ const invited = await ctx.ownerRequest("/auth/organization/invite-member", {
+ method: "POST",
+ body: {
+ organizationId: ctx.workspaceId,
+ email: "[email protected]",
+ role: "member",
+ projectAccess: "selected",
+ projectIds: [ctx.alpha.id],
+ },
+ });
+ expect(invited.status).toBe(200);
+ const invitation = (await invited.json()) as { id: string };
+ const [stored] = await db
+ .select()
+ .from(schema.invitationTable)
+ .where(eq(schema.invitationTable.id, invitation.id));
+ expect(stored).toMatchObject({
+ projectAccess: "selected",
+ projectIds: [ctx.alpha.id],
+ });
+
+ const invitee = await signUpWithSession(ctx.app, {
+ email: "[email protected]",
+ name: "Client",
+ });
+ const inviteeRequest = client({ cookie: invitee.cookies });
+ const accepted = await inviteeRequest(
+ "/auth/organization/accept-invitation",
+ {
+ method: "POST",
+ body: { invitationId: invitation.id },
+ },
+ );
+ expect(accepted.status).toBe(200);
+
+ const rows = await accessRows(ctx.workspaceId, invitee.userId);
+ expect(rows.rules.map((rule) => rule.projectAccess)).toEqual(["selected"]);
+ expect(rows.grants.map((grant) => grant.projectId)).toEqual([ctx.alpha.id]);
+
+ const projects = await inviteeRequest(
+ `/project?workspaceId=${ctx.workspaceId}`,
+ );
+ expect(projects.status).toBe(200);
+ expect(
+ ((await projects.json()) as { id: string }[]).map(
+ (project) => project.id,
+ ),
+ ).toEqual([ctx.alpha.id]);
+
+ const [membership] = await db
+ .select({ id: schema.workspaceUserTable.id })
+ .from(schema.workspaceUserTable)
+ .where(eq(schema.workspaceUserTable.userId, invitee.userId));
+ const removed = await ctx.ownerRequest("/auth/organization/remove-member", {
+ method: "POST",
+ body: {
+ organizationId: ctx.workspaceId,
+ memberIdOrEmail: membership?.id,
+ },
+ });
+ expect(removed.status).toBe(200);
+ expect(await accessRows(ctx.workspaceId, invitee.userId)).toEqual({
+ rules: [],
+ grants: [],
+ });
+ });
+
+ it("gives every project to an invitation without a selection", async () => {
+ const ctx = await workspaceWithInvitee();
+
+ const invited = await ctx.ownerRequest("/auth/organization/invite-member", {
+ method: "POST",
+ body: {
+ organizationId: ctx.workspaceId,
+ email: "[email protected]",
+ role: "member",
+ },
+ });
+ expect(invited.status).toBe(200);
+ const invitation = (await invited.json()) as { id: string };
+
+ const invitee = await signUpWithSession(ctx.app, {
+ email: "[email protected]",
+ name: "Teammate",
+ });
+ const inviteeRequest = client({ cookie: invitee.cookies });
+ expect(
+ (
+ await inviteeRequest("/auth/organization/accept-invitation", {
+ method: "POST",
+ body: { invitationId: invitation.id },
+ })
+ ).status,
+ ).toBe(200);
+
+ const projects = await inviteeRequest(
+ `/project?workspaceId=${ctx.workspaceId}`,
+ );
+ expect(await projects.json()).toHaveLength(2);
+ });
+
+ it("rejects an invitation for projects outside the workspace", async () => {
+ const ctx = await workspaceWithInvitee();
+ const other = await createRestrictedWorkspace();
+
+ const invited = await ctx.ownerRequest("/auth/organization/invite-member", {
+ method: "POST",
+ body: {
+ organizationId: ctx.workspaceId,
+ email: "[email protected]",
+ role: "member",
+ projectAccess: "selected",
+ projectIds: [other.alpha.id],
+ },
+ });
+
+ expect(invited.status).toBe(400);
+ expect(await db.select().from(schema.invitationTable)).toHaveLength(0);
+ });
+});
diff --git a/tests/api-integration/project-access.test.ts b/tests/api-integration/project-access.test.ts
new file mode 100644
index 000000000..0425d8cf7
--- /dev/null
+++ b/tests/api-integration/project-access.test.ts
@@ -0,0 +1,299 @@
+import { createHash, randomUUID } from "node:crypto";
+import { eq } from "drizzle-orm";
+import { beforeEach, describe, expect, it } from "vite-plus/test";
+import db, { schema } from "../../apps/api/src/database";
+import { createApp } from "../../apps/api/src/index";
+import { mockAnonymousSession, mockAuthenticatedSession } from "./helpers/auth";
+import { resetTestDatabase } from "./helpers/database";
+import {
+ addWorkspaceMember,
+ createRestrictedWorkspace,
+} from "./helpers/project-access";
+
+beforeEach(resetTestDatabase);
+
+function client(headers: Record<string, string> = {}) {
+ const { app } = createApp();
+ return (path: string, init: { method?: string; body?: unknown } = {}) =>
+ app.request(`/api${path}`, {
+ method: init.method ?? "GET",
+ headers: { "content-type": "application/json", ...headers },
+ body: init.body === undefined ? undefined : JSON.stringify(init.body),
+ });
+}
+
+describe("project access enforcement", () => {
+ it("lists only the projects a restricted member can access", async () => {
+ const ctx = await createRestrictedWorkspace();
+ mockAuthenticatedSession(ctx.restricted);
+
+ const response = await client()(`/project?workspaceId=${ctx.workspace.id}`);
+
+ expect(response.status).toBe(200);
+ const projects = (await response.json()) as { id: string }[];
+ expect(projects.map((project) => project.id)).toEqual([ctx.alpha.id]);
+ });
+
+ it("blocks every read of a project outside the selection", async () => {
+ const ctx = await createRestrictedWorkspace();
+ mockAuthenticatedSession(ctx.restricted);
+ const request = client();
+
+ const hidden = [
+ `/project/${ctx.beta.id}`,
+ `/task/tasks/${ctx.beta.id}`,
+ `/task/${ctx.betaTask.id}`,
+ `/task/${ctx.betaTask.id}/description`,
+ `/task/export/${ctx.beta.id}`,
+ `/column/${ctx.beta.id}`,
+ `/comment/${ctx.betaTask.id}`,
+ `/activity/${ctx.betaTask.id}`,
+ `/label/task/${ctx.betaTask.id}`,
+ `/time-entry/task/${ctx.betaTask.id}`,
+ `/task-relation/${ctx.betaTask.id}`,
+ `/custom-field/project/${ctx.beta.id}`,
+ `/external-link/task/${ctx.betaTask.id}`,
+ `/workflow-rule/${ctx.beta.id}`,
+ ];
+ for (const path of hidden) {
+ expect({ path, status: (await request(path)).status }).toEqual({
+ path,
+ status: 403,
+ });
+ }
+
+ for (const path of [
+ `/project/${ctx.alpha.id}`,
+ `/task/tasks/${ctx.alpha.id}`,
+ `/task/${ctx.alphaTask.id}`,
+ ]) {
+ expect({ path, status: (await request(path)).status }).toEqual({
+ path,
+ status: 200,
+ });
+ }
+ });
+
+ it("blocks writes to a project outside the selection", async () => {
+ const ctx = await createRestrictedWorkspace();
+ mockAuthenticatedSession(ctx.restricted);
+ const request = client();
+
+ const title = await request(`/task/title/${ctx.betaTask.id}`, {
+ method: "PUT",
+ body: { title: "Renamed" },
+ });
+ expect(title.status).toBe(403);
+
+ const created = await request(`/task/${ctx.beta.id}`, {
+ method: "POST",
+ body: {
+ title: "Sneaky",
+ description: "",
+ priority: "low",
+ status: "to-do",
+ },
+ });
+ expect(created.status).toBe(403);
+
+ const bulk = await request("/task/bulk", {
+ method: "PATCH",
+ body: {
+ taskIds: [ctx.alphaTask.id, ctx.betaTask.id],
+ operation: "updatePriority",
+ value: "high",
+ },
+ });
+ expect(bulk.status).toBe(403);
+
+ const moved = await request(`/task/move/${ctx.alphaTask.id}`, {
+ method: "PUT",
+ body: { destinationProjectId: ctx.beta.id },
+ });
+ expect(moved.status).toBe(403);
+ });
+
+ it("filters search, assigned tasks and ticket lookups", async () => {
+ const ctx = await createRestrictedWorkspace();
+ mockAuthenticatedSession(ctx.restricted);
+ const request = client();
+
+ const search = await request(
+ `/search?workspaceId=${ctx.workspace.id}&q=task&type=tasks`,
+ );
+ expect(search.status).toBe(200);
+ const searchBody = JSON.stringify(await search.json());
+ expect(searchBody).toContain("Visible alpha task");
+ expect(searchBody).not.toContain("Hidden beta task");
+
+ const assigned = await request(
+ `/task/assigned?workspaceId=${ctx.workspace.id}`,
+ );
+ expect(assigned.status).toBe(200);
+ const assignedBody = JSON.stringify(await assigned.json());
+ expect(assignedBody).toContain("Visible alpha task");
+ expect(assignedBody).not.toContain("Hidden beta task");
+
+ expect((await request("/task/by-ticket-id/ALPHA-1")).status).toBe(200);
+ expect((await request("/task/by-ticket-id/BETA-1")).status).toBe(404);
+ });
+
+ it("hides notifications about tasks in other projects", async () => {
+ const ctx = await createRestrictedWorkspace();
+ await db.insert(schema.notificationTable).values([
+ {
+ userId: ctx.restricted.id,
+ resourceType: "task",
+ resourceId: ctx.alphaTask.id,
+ eventData: { taskTitle: "Visible alpha task" },
+ },
+ {
+ userId: ctx.restricted.id,
+ resourceType: "task",
+ resourceId: ctx.betaTask.id,
+ eventData: { taskTitle: "Hidden beta task" },
+ },
+ ]);
+ mockAuthenticatedSession(ctx.restricted);
+
+ const response = await client()("/notification");
+
+ expect(response.status).toBe(200);
+ const body = JSON.stringify(await response.json());
+ expect(body).toContain("Visible alpha task");
+ expect(body).not.toContain("Hidden beta task");
+ });
+
+ it("leaves owners and unrestricted members unaffected", async () => {
+ const ctx = await createRestrictedWorkspace();
+ const unrestricted = await addWorkspaceMember(ctx.workspace.id);
+
+ for (const user of [ctx.owner, unrestricted]) {
+ mockAuthenticatedSession(user);
+ const response = await client()(
+ `/project?workspaceId=${ctx.workspace.id}`,
+ );
+ expect(response.status).toBe(200);
+ expect(await response.json()).toHaveLength(2);
+ expect((await client()(`/task/${ctx.betaTask.id}`)).status).toBe(200);
+ }
+ });
+
+ it("applies the member's project access to their API keys", async () => {
+ const ctx = await createRestrictedWorkspace();
+ mockAnonymousSession();
+ const key = `kaneo_test_${randomUUID()}`;
+ await db.insert(schema.apikeyTable).values({
+ referenceId: ctx.restricted.id,
+ userId: ctx.restricted.id,
+ key: createHash("sha256").update(key).digest("base64url"),
+ name: "restricted key",
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ enabled: true,
+ });
+ const request = client({ Authorization: `Bearer ${key}` });
+
+ expect((await request(`/project/${ctx.beta.id}`)).status).toBe(403);
+ expect((await request(`/project/${ctx.alpha.id}`)).status).toBe(200);
+ });
+
+ it("only offers and accepts assignees who can see the project", async () => {
+ const ctx = await createRestrictedWorkspace();
+ await db
+ .update(schema.taskTable)
+ .set({ userId: null })
+ .where(eq(schema.taskTable.id, ctx.betaTask.id));
+ mockAuthenticatedSession(ctx.owner);
+ const request = client();
+
+ const members = await request(
+ `/workspace/${ctx.workspace.id}/members?projectId=${ctx.beta.id}`,
+ );
+ expect(members.status).toBe(200);
+ const memberIds = ((await members.json()) as { id: string }[]).map(
+ (member) => member.id,
+ );
+ expect(memberIds).toContain(ctx.owner.id);
+ expect(memberIds).not.toContain(ctx.restricted.id);
+
+ const assigned = await request(`/task/assignee/${ctx.betaTask.id}`, {
+ method: "PUT",
+ body: { userId: ctx.restricted.id },
+ });
+ expect(assigned.status).toBe(403);
+ expect(await assigned.text()).toContain(
+ "Assignee does not have access to this project",
+ );
+
+ mockAuthenticatedSession(ctx.restricted);
+ const peek = await client()(
+ `/workspace/${ctx.workspace.id}/members?projectId=${ctx.beta.id}`,
+ );
+ expect(peek.status).toBe(403);
+ });
+
+ it("unassigns a task moved into a project its assignee can't see", async () => {
+ const ctx = await createRestrictedWorkspace();
+ mockAuthenticatedSession(ctx.owner);
+
+ const moved = await client()(`/task/move/${ctx.alphaTask.id}`, {
+ method: "PUT",
+ body: { destinationProjectId: ctx.beta.id },
+ });
+
+ expect(moved.status).toBe(200);
+ const [task] = await db
+ .select({ userId: schema.taskTable.userId })
+ .from(schema.taskTable)
+ .where(eq(schema.taskTable.id, ctx.alphaTask.id));
+ expect(task?.userId).toBeNull();
+ });
+
+ it("keeps tasks editable after their assignee loses access", async () => {
+ const ctx = await createRestrictedWorkspace();
+ mockAuthenticatedSession(ctx.owner);
+ const request = client();
+
+ const updated = await request(`/task/${ctx.betaTask.id}`, {
+ method: "PUT",
+ body: {
+ title: "Still editable",
+ priority: "high",
+ status: ctx.betaTask.status,
+ projectId: ctx.beta.id,
+ position: 0,
+ userId: ctx.restricted.id,
+ },
+ });
+ expect(updated.status).toBe(200);
+
+ const duplicated = await request(`/task/duplicate/${ctx.betaTask.id}`, {
+ method: "POST",
+ body: {},
+ });
+ expect(duplicated.status).toBe(200);
+ const copy = (await duplicated.json()) as { userId: string | null };
+ expect(copy.userId).toBeNull();
+ });
+
+ it("keeps a restricted member's access to projects they create", async () => {
+ const ctx = await createRestrictedWorkspace();
+ mockAuthenticatedSession(ctx.restricted);
+ const request = client();
+
+ const created = await request("/project", {
+ method: "POST",
+ body: {
+ name: "Gamma",
+ workspaceId: ctx.workspace.id,
+ icon: "Layout",
+ slug: "gamma",
+ },
+ });
+ expect(created.status).toBe(200);
+ const project = (await created.json()) as { id: string };
+
+ expect((await request(`/project/${project.id}`)).status).toBe(200);
+ });
+});
diff --git a/tests/api-integration/subtask-counts.test.ts b/tests/api-integration/subtask-counts.test.ts
index 6c86d505c..55750ec42 100644
--- a/tests/api-integration/subtask-counts.test.ts
+++ b/tests/api-integration/subtask-counts.test.ts
@@ -128,7 +128,11 @@ describe("API integration: subtask counters", () => {
completed: 1,
total: 4,
});
- const relations = await getTaskRelations(parent.id, member.workspace.id);
+ const relations = await getTaskRelations(
+ parent.id,
+ member.workspace.id,
+ member.user.id,
+ );
expect(
relations.filter((relation) => relation.targetTask?.isCompleted),
).toHaveLength(1);
diff --git a/tests/api/label/assign-and-unassign-label.test.ts b/tests/api/label/assign-and-unassign-label.test.ts
index 7d39ee688..c36c9f2c0 100644
--- a/tests/api/label/assign-and-unassign-label.test.ts
+++ b/tests/api/label/assign-and-unassign-label.test.ts
@@ -17,6 +17,7 @@ const mockRemoveLabelFromGitHub = vi.fn();
const mockRemoveLabelFromGitea = vi.fn();
const mockSyncLabelToGitHub = vi.fn();
const mockSyncLabelToGitea = vi.fn();
+const mockAssertProjectAccess = vi.fn();
function createMockTxContext() {
return {
@@ -54,6 +55,10 @@ vi.mock("../../../apps/api/src/events", () => ({
publishEvent: (...args: unknown[]) => mockPublishEvent(...args),
}));
+vi.mock("../../../apps/api/src/project-access/assert-project-access", () => ({
+ assertProjectAccess: (...args: unknown[]) => mockAssertProjectAccess(...args),
+}));
+
vi.mock(
"../../../apps/api/src/plugins/github/utils/sync-label-to-github",
() => ({
@@ -352,6 +357,25 @@ describe("assignLabelToTask", () => {
expect(mockDelete).not.toHaveBeenCalled();
expect(mockInsert).not.toHaveBeenCalled();
});
+
+ it("rejects a target task in a project the caller cannot access", async () => {
+ mockFindFirst.mockResolvedValue(WORKSPACE_LABEL);
+ mockSelect.mockReturnValue(makeSelectMock([TASK]));
+ mockAssertProjectAccess.mockRejectedValue(
+ Object.assign(new Error("You don't have access to this project"), {
+ status: 403,
+ }),
+ );
+
+ await expect(
+ assignLabelToTask("label-ws-1", "task-1", "user-1"),
+ ).rejects.toMatchObject({ status: 403 });
+
+ expect(mockAssertProjectAccess).toHaveBeenCalledWith("user-1", "proj-1");
+ expect(mockTransaction).not.toHaveBeenCalled();
+ expect(mockInsert).not.toHaveBeenCalled();
+ expect(mockPublishEvent).not.toHaveBeenCalled();
+ });
});
vi.mock(
diff --git a/tests/api/utils/authorize-asset-access.test.ts b/tests/api/utils/authorize-asset-access.test.ts
index cbf51bd2c..bde1838a0 100644
--- a/tests/api/utils/authorize-asset-access.test.ts
+++ b/tests/api/utils/authorize-asset-access.test.ts
@@ -7,6 +7,17 @@ const { state } = vi.hoisted(() => ({
resolveCalls: 0,
validateCalls: [] as { userId: string; workspaceId: string }[],
caller: "anonymous" as "anonymous" | "member" | "outsider",
+ restrictedProjects: new Set<string>(),
+ },
+}));
+
+vi.mock("../../../apps/api/src/project-access/assert-project-access", () => ({
+ assertProjectAccess: async (_userId: string, projectId: string) => {
+ if (state.restrictedProjects.has(projectId)) {
+ throw new HTTPException(403, {
+ message: "You don't have access to this project",
+ });
+ }
},
}));
@@ -52,12 +63,14 @@ describe("authorizeAssetAccess", () => {
state.resolveCalls = 0;
state.validateCalls = [];
state.caller = "anonymous";
+ state.restrictedProjects = new Set();
});
it("allows an anonymous caller to read an asset of a public project", async () => {
const status = await statusOf(
authorizeAssetAccess(context, {
workspaceId: "workspace-1",
+ projectId: "project-1",
surface: "description",
isPublic: true,
}),
@@ -73,6 +86,7 @@ describe("authorizeAssetAccess", () => {
const status = await statusOf(
authorizeAssetAccess(context, {
workspaceId: "workspace-1",
+ projectId: "project-1",
surface: "description",
isPublic: false,
}),
@@ -87,6 +101,7 @@ describe("authorizeAssetAccess", () => {
const status = await statusOf(
authorizeAssetAccess(context, {
workspaceId: "workspace-1",
+ projectId: "project-1",
surface: "description",
isPublic: null,
}),
@@ -101,6 +116,7 @@ describe("authorizeAssetAccess", () => {
const status = await statusOf(
authorizeAssetAccess(context, {
workspaceId: "workspace-1",
+ projectId: "project-1",
surface: "description",
isPublic: false,
}),
@@ -114,7 +130,12 @@ describe("authorizeAssetAccess", () => {
it.each(["comment", "unknown"])(
"keeps %s assets private even in a public project",
async (surface) => {
- const asset = { workspaceId: "workspace-1", isPublic: true, surface };
+ const asset = {
+ workspaceId: "workspace-1",
+ projectId: "project-1",
+ isPublic: true,
+ surface,
+ };
expect(isPublicAsset(asset)).toBe(false);
expect(await statusOf(authorizeAssetAccess(context, asset))).toBe(401);
state.caller = "outsider";
@@ -129,6 +150,7 @@ describe("authorizeAssetAccess", () => {
state.caller = "member";
const asset = {
workspaceId: "workspace-1",
+ projectId: "project-1",
isPublic: true,
surface,
createdBy: "user-other-member",
@@ -143,4 +165,37 @@ describe("authorizeAssetAccess", () => {
).toBe(200);
},
);
+ it.each(["description", "comment", "draft"])(
+ "rejects a workspace member restricted from the project for %s assets",
+ async (surface) => {
+ state.caller = "member";
+ state.restrictedProjects.add("project-1");
+ const asset = {
+ workspaceId: "workspace-1",
+ projectId: "project-1",
+ isPublic: false,
+ surface,
+ createdBy: "user-member",
+ };
+ expect(await statusOf(authorizeAssetAccess(context, asset))).toBe(403);
+ expect(
+ await statusOf(
+ authorizeAssetAccess(context, { ...asset, projectId: "project-2" }),
+ ),
+ ).toBe(200);
+ },
+ );
+ it("keeps public project description assets public for restricted members", async () => {
+ state.caller = "member";
+ state.restrictedProjects.add("project-1");
+ const status = await statusOf(
+ authorizeAssetAccess(context, {
+ workspaceId: "workspace-1",
+ projectId: "project-1",
+ surface: "description",
+ isPublic: true,
+ }),
+ );
+ expect(status).toBe(200);
+ });
});
diff --git a/tests/api/ws/broadcast.test.ts b/tests/api/ws/broadcast.test.ts
index 505edc706..5721f86ab 100644
--- a/tests/api/ws/broadcast.test.ts
+++ b/tests/api/ws/broadcast.test.ts
@@ -271,6 +271,13 @@ describe("broadcastToProject", () => {
});
});
+vi.mock(
+ "../../../apps/api/src/project-access/filter-users-with-project-access",
+ () => ({
+ filterUsersWithProjectAccess: async (userIds: Iterable<string>) =>
+ new Set(userIds),
+ }),
+);
vi.mock("../../../apps/api/src/database", () => ({
default: {
select: (fields: Record<string, unknown>) => ({
diff --git a/tests/api/ws/label-deletion-backpressure.test.ts b/tests/api/ws/label-deletion-backpressure.test.ts
index 6edb37cde..14917432d 100644
--- a/tests/api/ws/label-deletion-backpressure.test.ts
+++ b/tests/api/ws/label-deletion-backpressure.test.ts
@@ -122,6 +122,13 @@ describe("awaited label deletion broadcasts", () => {
});
});
+vi.mock(
+ "../../../apps/api/src/project-access/filter-users-with-project-access",
+ () => ({
+ filterUsersWithProjectAccess: async (userIds: Iterable<string>) =>
+ new Set(userIds),
+ }),
+);
vi.mock("../../../apps/api/src/database", () => ({
default: {
select: (fields: Record<string, unknown>) => ({
diff --git a/tests/api/ws/project-move.test.ts b/tests/api/ws/project-move.test.ts
index 13b56334e..806c683b6 100644
--- a/tests/api/ws/project-move.test.ts
+++ b/tests/api/ws/project-move.test.ts
@@ -19,11 +19,14 @@ import {
revokeUserConnections,
shutdownWebSocketAdapter,
} from "../../../apps/api/src/ws";
+import { subscribeToEvent } from "../../../apps/api/src/events";
const m = vi.hoisted(() => ({
lookup: vi.fn(),
members: vi.fn(),
admins: vi.fn(),
+ projectAccess: vi.fn(),
+ inaccessible: vi.fn(),
redis: false,
publish: vi.fn(),
on: vi.fn(),
@@ -42,7 +45,24 @@ vi.mock("../../../apps/api/src/database", () => ({
}),
},
}));
+vi.mock(
+ "../../../apps/api/src/project-access/filter-users-with-project-access",
+ () => ({
+ filterUsersWithProjectAccess: async () =>
+ new Set(
+ ((await m.projectAccess()) as { userId: string }[]).map(
+ (row) => row.userId,
+ ),
+ ),
+ }),
+);
vi.mock("../../../apps/api/src/events", () => ({ subscribeToEvent: vi.fn() }));
+vi.mock("../../../apps/api/src/project-access/assert-project-access", () => ({
+ findInaccessibleProjectIds: m.inaccessible,
+}));
+const projectAccessUpdated = vi
+ .mocked(subscribeToEvent)
+ .mock.calls.find(([eventName]) => eventName === "project_access.updated")![1];
vi.mock("../../../apps/api/src/redis", () => ({
isRedisConfigured: () => m.redis,
getRedisPub: () => ({ publish: m.publish }),
@@ -78,6 +98,8 @@ beforeEach(() => {
m.redis = false;
m.admins.mockResolvedValue([]);
m.members.mockResolvedValue([{ userId: "user" }]);
+ m.projectAccess.mockResolvedValue([{ userId: "user" }]);
+ m.inaccessible.mockResolvedValue([]);
m.lookup.mockResolvedValue([{ workspaceId: "old" }]);
m.publish.mockResolvedValue(1);
});
@@ -114,15 +136,13 @@ describe("project move revocation", () => {
expect(old.close).toHaveBeenCalled();
expect(current.send).toHaveBeenCalledWith(JSON.stringify(update));
});
- it.each(["workspace", "membership"])(
- "skips delivery without revoking access on transient %s lookup failure",
+ it.each(["lookup", "members", "projectAccess"] as const)(
+ "skips delivery without revoking access on transient %s failure",
async (lookup) => {
vi.useFakeTimers();
await initializeWebSocketAdapter();
const old = connect();
- (lookup === "workspace" ? m.lookup : m.members).mockRejectedValueOnce(
- new Error("Database unavailable"),
- );
+ m[lookup].mockRejectedValueOnce(new Error("Database unavailable"));
broadcastToProject("project", update);
await vi.advanceTimersByTimeAsync(100);
expect(old.send).not.toHaveBeenCalled();
@@ -258,6 +278,114 @@ describe("workspace membership revocation", () => {
});
});
+describe("project access revocation", () => {
+ it("stops broadcasts to a member who lost project access even when the change was missed", async () => {
+ vi.useFakeTimers();
+ await initializeWebSocketAdapter();
+ const ws = connect();
+ m.projectAccess.mockResolvedValue([]);
+ broadcastToProject("project", update);
+ await vi.advanceTimersByTimeAsync(100);
+ expect(ws.send).not.toHaveBeenCalled();
+ expect(ws.close).toHaveBeenCalledWith(1008, "Project access revoked");
+ });
+
+ it("closes only the inaccessible project sockets and notifies every tab", async () => {
+ await initializeWebSocketAdapter();
+ const revoked = connect();
+ const kept = connect("kept-project");
+ const elsewhere = connect("other-project", "other-workspace");
+ const tab = { send: vi.fn(), close: vi.fn() };
+ const conn = addUserConnection("user", tab as unknown as WSContext);
+ m.inaccessible.mockResolvedValue(["project"]);
+ try {
+ await projectAccessUpdated({ workspaceId: "old", userId: "user" });
+ await vi.waitFor(() =>
+ expect(revoked.close).toHaveBeenCalledWith(
+ 1008,
+ "Project access revoked",
+ ),
+ );
+ expect(m.inaccessible).toHaveBeenCalledWith("user", [
+ "project",
+ "kept-project",
+ ]);
+ expect(kept.close).not.toHaveBeenCalled();
+ expect(elsewhere.close).not.toHaveBeenCalled();
+ expect(tab.send).toHaveBeenCalledWith(
+ JSON.stringify({ type: "PROJECT_ACCESS_CHANGED", workspaceId: "old" }),
+ );
+ expect(tab.close).not.toHaveBeenCalled();
+ } finally {
+ removeUserConnection("user", conn);
+ }
+ });
+
+ it("keeps project sockets open when the access check fails", async () => {
+ await initializeWebSocketAdapter();
+ const ws = connect();
+ m.inaccessible.mockRejectedValueOnce(new Error("database unavailable"));
+ await projectAccessUpdated({ workspaceId: "old", userId: "user" });
+ await vi.waitFor(() => expect(m.inaccessible).toHaveBeenCalled());
+ await Promise.resolve();
+ expect(ws.close).not.toHaveBeenCalled();
+ });
+
+ it("fans the change out to other instances through the user Redis channel", async () => {
+ m.redis = true;
+ await initializeWebSocketAdapter();
+ await projectAccessUpdated({ workspaceId: "old", userId: "user" });
+ expect(m.publish).toHaveBeenCalledWith(
+ "kaneo:ws-user:user:broadcast",
+ expect.any(String),
+ );
+ expect(JSON.parse(m.publish.mock.calls[0][1])).toMatchObject({
+ userId: "user",
+ message: { type: "PROJECT_ACCESS_CHANGED", workspaceId: "old" },
+ });
+ });
+
+ it("revokes remote project sockets on a Redis project access change", async () => {
+ m.redis = true;
+ await initializeWebSocketAdapter();
+ const ws = connect();
+ m.inaccessible.mockResolvedValue(["project"]);
+ const handler = m.on.mock.calls[1][1];
+ handler(
+ "kaneo:ws-user:*:broadcast",
+ "kaneo:ws-user:user:broadcast",
+ JSON.stringify({
+ userId: "user",
+ origin: "remote-instance",
+ message: { type: "PROJECT_ACCESS_CHANGED", workspaceId: "old" },
+ }),
+ );
+ await vi.waitFor(() =>
+ expect(ws.close).toHaveBeenCalledWith(1008, "Project access revoked"),
+ );
+ });
+
+ it("does not let a pending project access change replace a workspace revocation", async () => {
+ vi.useFakeTimers();
+ m.redis = true;
+ await initializeWebSocketAdapter();
+ m.publish.mockRejectedValueOnce(new Error("Redis unavailable"));
+ m.publish.mockRejectedValueOnce(new Error("Redis unavailable"));
+ await revokeWorkspaceConnections("user", "old", { force: true });
+ await projectAccessUpdated({ workspaceId: "old", userId: "user" });
+ await vi.advanceTimersByTimeAsync(1_000);
+ const types = m.publish.mock.calls.map(
+ ([, data]) => JSON.parse(data).message.type,
+ );
+ expect(
+ types.filter((type) => type === "WORKSPACE_ACCESS_REVOKED"),
+ ).toHaveLength(2);
+ expect(
+ types.filter((type) => type === "PROJECT_ACCESS_CHANGED"),
+ ).toHaveLength(2);
+ });
+});
+
it("coalesces authorization checks across a bulk broadcast burst", async () => {
vi.useFakeTimers();
await initializeWebSocketAdapter();
@@ -267,6 +395,7 @@ it("coalesces authorization checks across a bulk broadcast burst", async () => {
await vi.advanceTimersByTimeAsync(100);
expect(connection.send).toHaveBeenCalledTimes(50);
expect(m.members).toHaveBeenCalledTimes(1);
+ expect(m.projectAccess).toHaveBeenCalledTimes(1);
});
it("does not reuse an older flush's membership snapshot for a later Redis broadcast", async () => {
diff --git a/tests/api/ws/reorder-delivery.test.ts b/tests/api/ws/reorder-delivery.test.ts
index ae4f7cf52..27b0b2080 100644
--- a/tests/api/ws/reorder-delivery.test.ts
+++ b/tests/api/ws/reorder-delivery.test.ts
@@ -7,6 +7,13 @@ import {
removeConnection,
shutdownWebSocketAdapter,
} from "../../../apps/api/src/ws";
+vi.mock(
+ "../../../apps/api/src/project-access/filter-users-with-project-access",
+ () => ({
+ filterUsersWithProjectAccess: async (userIds: Iterable<string>) =>
+ new Set(userIds),
+ }),
+);
vi.mock("../../../apps/api/src/database", () => ({
default: {
select: (fields: Record<string, unknown>) => ({