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(admin): manage workspace archive and deletion lifecycle

Tin967da7be8f65
diff --git a/apps/api/drizzle/0069_workspace_archive.sql b/apps/api/drizzle/0069_workspace_archive.sql
new file mode 100644
index 000000000..2ada2cd0b
--- /dev/null
+++ b/apps/api/drizzle/0069_workspace_archive.sql
@@ -0,0 +1,3 @@
+ALTER TABLE "workspace" ADD COLUMN "archived_at" timestamp;--> statement-breakpoint
+ALTER TABLE "workspace" ADD COLUMN "archived_by" text;--> statement-breakpoint
+ALTER TABLE "workspace" ADD CONSTRAINT "workspace_archived_by_user_id_fk" FOREIGN KEY ("archived_by") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;
\ No newline at end of file
diff --git a/apps/api/drizzle/meta/0069_snapshot.json b/apps/api/drizzle/meta/0069_snapshot.json
new file mode 100644
index 000000000..55001f9c5
--- /dev/null
+++ b/apps/api/drizzle/meta/0069_snapshot.json
@@ -0,0 +1,5630 @@
+{
+ "id": "625483fe-9827-48be-add5-d3a6fa358a2b",
+ "prevId": "e284b6f6-263e-4df0-9ce4-80dcc200d7b0",
+ "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() AT TIME ZONE 'utc')"
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "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.admin_audit_log": {
+ "name": "admin_audit_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_email": {
+ "name": "actor_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_type": {
+ "name": "target_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_id": {
+ "name": "target_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_label": {
+ "name": "target_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "indexes": {
+ "admin_audit_log_createdAt_idx": {
+ "name": "admin_audit_log_createdAt_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "admin_audit_log_actorUserId_idx": {
+ "name": "admin_audit_log_actorUserId_idx",
+ "columns": [
+ {
+ "expression": "actor_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "admin_audit_log_target_idx": {
+ "name": "admin_audit_log_target_idx",
+ "columns": [
+ {
+ "expression": "target_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "target_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "admin_audit_log_actor_user_id_user_id_fk": {
+ "name": "admin_audit_log_actor_user_id_user_id_fk",
+ "tableFrom": "admin_audit_log",
+ "tableTo": "user",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "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() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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
+ },
+ "hidden_options": {
+ "name": "hidden_options",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ }
+ },
+ "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.import_run": {
+ "name": "import_run",
+ "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": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'running'"
+ },
+ "include_comments": {
+ "name": "include_comments",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "projects": {
+ "name": "projects",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "error": {
+ "name": "error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heartbeat_at": {
+ "name": "heartbeat_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "import_run_workspace_created_idx": {
+ "name": "import_run_workspace_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "import_run_workspace_id_workspace_id_fk": {
+ "name": "import_run_workspace_id_workspace_id_fk",
+ "tableFrom": "import_run",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "import_run_user_id_user_id_fk": {
+ "name": "import_run_user_id_user_id_fk",
+ "tableFrom": "import_run",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "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
+ },
+ "oidc_sid": {
+ "name": "oidc_sid",
+ "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": {}
+ },
+ "session_oidcSid_idx": {
+ "name": "session_oidcSid_idx",
+ "columns": [
+ {
+ "expression": "oidc_sid",
+ "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() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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
+ },
+ "recurrence": {
+ "name": "recurrence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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_project_scheduled_id_idx": {
+ "name": "task_project_scheduled_id_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"task\".\"start_date\" is not null or \"task\".\"due_date\" is not null",
+ "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
+ },
+ "member_count": {
+ "name": "member_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "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
+ },
+ "membership_key": {
+ "name": "membership_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "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": {
+ "team_member_membership_key_unique": {
+ "name": "team_member_membership_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "membership_key"
+ ]
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_by": {
+ "name": "archived_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "workspace_archived_by_user_id_fk": {
+ "name": "workspace_archived_by_user_id_fk",
+ "tableFrom": "workspace",
+ "tableTo": "user",
+ "columnsFrom": [
+ "archived_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "(now() AT TIME ZONE 'utc')"
+ }
+ },
+ "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() AT TIME ZONE 'utc')"
+ }
+ },
+ "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 05930bf1c..b6a1557e9 100644
--- a/apps/api/drizzle/meta/_journal.json
+++ b/apps/api/drizzle/meta/_journal.json
@@ -484,6 +484,13 @@
"when": 1793128120924,
"tag": "0068_admin_audit_log",
"breakpoints": true
+ },
+ {
+ "idx": 69,
+ "version": "7",
+ "when": 1793128486906,
+ "tag": "0069_workspace_archive",
+ "breakpoints": true
}
]
-}
\ No newline at end of file
+}
diff --git a/apps/api/src/admin/controllers/archive-workspace.ts b/apps/api/src/admin/controllers/archive-workspace.ts
new file mode 100644
index 000000000..41dd422d7
--- /dev/null
+++ b/apps/api/src/admin/controllers/archive-workspace.ts
@@ -0,0 +1,47 @@
+import { publishEvent } from "../../events";
+import { eq } from "drizzle-orm";
+import db, { schema } from "../../database";
+import { ApiError } from "../../errors/api-error";
+import { listWorkspaceAudience } from "../../workspace/lifecycle/list-workspace-audience";
+import { revokeWorkspaceAudience } from "../../workspace/lifecycle/revoke-workspace-audience";
+import type { AdminAuditRequest } from "../audit/admin-audit-request";
+import { recordAdminAction } from "../audit/record-admin-action";
+import { lockWorkspaceRow } from "../../workspace/lifecycle/lock-workspace-row";
+
+async function archiveWorkspace(workspaceId: string, audit: AdminAuditRequest) {
+ const archivedAt = new Date();
+ const userIds = await db.transaction(async (tx) => {
+ const workspace = await lockWorkspaceRow(tx, workspaceId);
+ if (workspace.archivedAt) {
+ throw new ApiError(409, {
+ code: "WORKSPACE_ALREADY_ARCHIVED",
+ message: "The workspace is already archived",
+ });
+ }
+
+ await tx
+ .update(schema.workspaceTable)
+ .set({ archivedAt, archivedBy: audit.actorUserId })
+ .where(eq(schema.workspaceTable.id, workspaceId));
+ await recordAdminAction(
+ {
+ ...audit,
+ action: "workspace.archived",
+ targetType: "workspace",
+ targetId: workspace.id,
+ targetLabel: workspace.name,
+ metadata: { slug: workspace.slug },
+ },
+ tx,
+ );
+ return listWorkspaceAudience(workspaceId, tx);
+ });
+
+ // Open boards and the user socket learn the workspace is gone right away.
+ await revokeWorkspaceAudience(userIds, workspaceId, "archived");
+
+ await publishEvent("workspace.archived", { workspaceId });
+ return { id: workspaceId, archivedAt: archivedAt.toISOString() };
+}
+
+export default archiveWorkspace;
diff --git a/apps/api/src/admin/controllers/delete-workspace.ts b/apps/api/src/admin/controllers/delete-workspace.ts
new file mode 100644
index 000000000..9786026a3
--- /dev/null
+++ b/apps/api/src/admin/controllers/delete-workspace.ts
@@ -0,0 +1,9 @@
+import { deleteWorkspaceData } from "../../workspace/lifecycle/delete-workspace-data";
+import type { AdminAuditRequest } from "../audit/admin-audit-request";
+
+async function deleteWorkspace(workspaceId: string, audit: AdminAuditRequest) {
+ const workspace = await deleteWorkspaceData(workspaceId, audit);
+ return { id: workspace.id };
+}
+
+export default deleteWorkspace;
diff --git a/apps/api/src/admin/controllers/list-workspaces.ts b/apps/api/src/admin/controllers/list-workspaces.ts
index b90e7e6cc..8573bd1f2 100644
--- a/apps/api/src/admin/controllers/list-workspaces.ts
+++ b/apps/api/src/admin/controllers/list-workspaces.ts
@@ -1,4 +1,5 @@
import { and, count, desc, eq, ilike, inArray, or, sql } from "drizzle-orm";
+import { alias } from "drizzle-orm/pg-core";
import db from "../../database";
import {
projectTable,
@@ -8,6 +9,8 @@ import {
} from "../../database/schema";
import { escapeLikePattern } from "../../search/like-pattern";
+const archiver = alias(userTable, "archiver");
+
type ListWorkspacesInput = {
search?: string;
page: number;
@@ -31,8 +34,13 @@ async function listWorkspaces({ search, page, limit }: ListWorkspacesInput) {
name: workspaceTable.name,
slug: workspaceTable.slug,
createdAt: workspaceTable.createdAt,
+ archivedAt: workspaceTable.archivedAt,
+ archiverId: archiver.id,
+ archiverName: archiver.name,
+ archiverEmail: archiver.email,
})
.from(workspaceTable)
+ .leftJoin(archiver, eq(archiver.id, workspaceTable.archivedBy))
.where(where)
.orderBy(desc(workspaceTable.createdAt), desc(workspaceTable.id))
.limit(limit)
@@ -84,15 +92,22 @@ async function listWorkspaces({ search, page, limit }: ListWorkspacesInput) {
);
return {
- workspaces: rows.map((row) => ({
- ...row,
- createdAt: row.createdAt.toISOString(),
- memberCount: members.get(row.id) ?? 0,
- projectCount: projects.get(row.id) ?? 0,
- owners: owners
- .filter((owner) => owner.workspaceId === row.id)
- .map(({ id, name, email }) => ({ id, name, email })),
- })),
+ workspaces: rows.map(
+ ({ archiverId, archiverName, archiverEmail, ...row }) => ({
+ ...row,
+ createdAt: row.createdAt.toISOString(),
+ archivedAt: row.archivedAt?.toISOString() ?? null,
+ archivedBy:
+ archiverId && archiverName && archiverEmail
+ ? { id: archiverId, name: archiverName, email: archiverEmail }
+ : null,
+ memberCount: members.get(row.id) ?? 0,
+ projectCount: projects.get(row.id) ?? 0,
+ owners: owners
+ .filter((owner) => owner.workspaceId === row.id)
+ .map(({ id, name, email }) => ({ id, name, email })),
+ }),
+ ),
total: totalRow?.value ?? 0,
};
}
diff --git a/apps/api/src/admin/controllers/restore-workspace.ts b/apps/api/src/admin/controllers/restore-workspace.ts
new file mode 100644
index 000000000..c1352ffbf
--- /dev/null
+++ b/apps/api/src/admin/controllers/restore-workspace.ts
@@ -0,0 +1,51 @@
+import { publishEvent } from "../../events";
+import { eq } from "drizzle-orm";
+import db, { schema } from "../../database";
+import { ApiError } from "../../errors/api-error";
+import { listWorkspaceAudience } from "../../workspace/lifecycle/list-workspace-audience";
+import { broadcastToUser } from "../../ws";
+import type { AdminAuditRequest } from "../audit/admin-audit-request";
+import { recordAdminAction } from "../audit/record-admin-action";
+import { lockWorkspaceRow } from "../../workspace/lifecycle/lock-workspace-row";
+
+async function restoreWorkspace(workspaceId: string, audit: AdminAuditRequest) {
+ const userIds = await db.transaction(async (tx) => {
+ const workspace = await lockWorkspaceRow(tx, workspaceId);
+ if (!workspace.archivedAt) {
+ throw new ApiError(409, {
+ code: "WORKSPACE_NOT_ARCHIVED",
+ message: "The workspace is not archived",
+ });
+ }
+
+ await tx
+ .update(schema.workspaceTable)
+ .set({ archivedAt: null, archivedBy: null })
+ .where(eq(schema.workspaceTable.id, workspaceId));
+ await recordAdminAction(
+ {
+ ...audit,
+ action: "workspace.restored",
+ targetType: "workspace",
+ targetId: workspace.id,
+ targetLabel: workspace.name,
+ metadata: {
+ slug: workspace.slug,
+ archivedAt: workspace.archivedAt.toISOString(),
+ },
+ },
+ tx,
+ );
+ return listWorkspaceAudience(workspaceId, tx);
+ });
+
+ // Lets open clients show the workspace again without a reload.
+ for (const userId of userIds) {
+ broadcastToUser(userId, { type: "WORKSPACE_RESTORED", workspaceId });
+ }
+
+ await publishEvent("workspace.restored", { workspaceId });
+ return { id: workspaceId, archivedAt: null };
+}
+
+export default restoreWorkspace;
diff --git a/apps/api/src/admin/index.ts b/apps/api/src/admin/index.ts
index 9143cf3c3..e3b458d32 100644
--- a/apps/api/src/admin/index.ts
+++ b/apps/api/src/admin/index.ts
@@ -8,6 +8,8 @@ import { requireInstanceAdmin } from "../utils/require-instance-admin";
import { requireUserSession } from "../utils/require-user-session";
import { adminAuditRequest } from "./audit/admin-audit-request";
import addWorkspaceMember from "./controllers/add-workspace-member";
+import archiveWorkspace from "./controllers/archive-workspace";
+import deleteWorkspace from "./controllers/delete-workspace";
import listAuditLog from "./controllers/list-audit-log";
import getSystemStatus from "./controllers/get-system-status";
import listUsers from "./controllers/list-users";
@@ -16,12 +18,15 @@ import listWorkspaceRoles from "./controllers/list-workspace-roles";
import listWorkspaces from "./controllers/list-workspaces";
import removeWorkspaceMember from "./controllers/remove-workspace-member";
import sendAdminTestEmail from "./controllers/send-test-email";
+import restoreWorkspace from "./controllers/restore-workspace";
import transferWorkspaceOwnership from "./controllers/transfer-workspace-ownership";
import updateWorkspaceMemberRole from "./controllers/update-workspace-member-role";
import adminUserRoutes from "./user-routes";
import {
adminAuditLogSchema,
+ adminDeletedWorkspaceSchema,
adminUserListSchema,
+ adminWorkspaceArchiveStateSchema,
adminWorkspaceListSchema,
adminWorkspaceMemberListSchema,
adminWorkspaceRoleListSchema,
@@ -70,7 +75,7 @@ const listWorkspacesRoute = createRoute({
tags: ["Admin"],
summary: "List instance workspaces",
description:
- "Page through every workspace on this instance with its owners, member count and project count, optionally filtered by a case-insensitive name or slug search. Requires an instance administrator session; API keys are rejected.",
+ "Page through every workspace on this instance with its owners, member count, project count and archive state, optionally filtered by a case-insensitive name or slug search. Requires an instance administrator session; API keys are rejected.",
middleware: [requireUserSession, requireInstanceAdmin] as const,
request: { query: listAdminWorkspacesQuery },
responses: {
@@ -225,6 +230,72 @@ const transferWorkspaceOwnershipRoute = createRoute({
},
});
+const archiveWorkspaceRoute = createRoute({
+ method: "post",
+ operationId: "archiveAdminWorkspace",
+ path: "/workspaces/{workspaceId}/archive",
+ tags: ["Admin"],
+ summary: "Archive a workspace",
+ description:
+ "Disable a workspace without deleting anything. Its members, API keys, MCP clients, public links, calendar feeds, notifications, and integrations stop working, and requests for it return 403 with the code WORKSPACE_ARCHIVED. Open realtime connections are closed. Restore it to undo. Requires an instance administrator session; API keys are rejected.",
+ middleware: [requireUserSession, requireInstanceAdmin] as const,
+ request: { params: adminWorkspaceParam },
+ responses: {
+ 200: jsonResponse(
+ "The workspace's archive state",
+ adminWorkspaceArchiveStateSchema,
+ ),
+ 403: forbidden,
+ 404: errorResponse("Workspace not found"),
+ 409: errorResponse(
+ "The workspace is already archived (code WORKSPACE_ALREADY_ARCHIVED)",
+ ),
+ },
+});
+
+const restoreWorkspaceRoute = createRoute({
+ method: "post",
+ operationId: "restoreAdminWorkspace",
+ path: "/workspaces/{workspaceId}/restore",
+ tags: ["Admin"],
+ summary: "Restore an archived workspace",
+ description:
+ "Make an archived workspace usable again, with all of its data, members, and integrations as they were. Requires an instance administrator session; API keys are rejected.",
+ middleware: [requireUserSession, requireInstanceAdmin] as const,
+ request: { params: adminWorkspaceParam },
+ responses: {
+ 200: jsonResponse(
+ "The workspace's archive state",
+ adminWorkspaceArchiveStateSchema,
+ ),
+ 403: forbidden,
+ 404: errorResponse("Workspace not found"),
+ 409: errorResponse(
+ "The workspace is not archived (code WORKSPACE_NOT_ARCHIVED)",
+ ),
+ },
+});
+
+const deleteWorkspaceRoute = createRoute({
+ method: "delete",
+ operationId: "deleteAdminWorkspace",
+ path: "/workspaces/{workspaceId}",
+ tags: ["Admin"],
+ summary: "Delete a workspace",
+ description:
+ "Permanently delete a workspace and everything in it, archived or not, the same way its owner can: projects, tasks, members, invitations and uploaded files go, and open realtime connections are closed. The administrator does not need to be a member. Requires an instance administrator session; API keys are rejected.",
+ middleware: [requireUserSession, requireInstanceAdmin] as const,
+ request: { params: adminWorkspaceParam },
+ responses: {
+ 200: jsonResponse("The deleted workspace", adminDeletedWorkspaceSchema),
+ 403: forbidden,
+ 404: errorResponse("Workspace not found"),
+ 409: errorResponse(
+ "The workspace still has an active subscription (code WORKSPACE_HAS_ACTIVE_SUBSCRIPTION)",
+ ),
+ },
+});
+
const listAuditLogRoute = createRoute({
method: "get",
operationId: "listAdminAuditLog",
@@ -342,6 +413,33 @@ const admin = apiRouter()
200,
),
)
+ .openapi(archiveWorkspaceRoute, async (c) =>
+ c.json(
+ await archiveWorkspace(
+ c.req.valid("param").workspaceId,
+ adminAuditRequest(c),
+ ),
+ 200,
+ ),
+ )
+ .openapi(restoreWorkspaceRoute, async (c) =>
+ c.json(
+ await restoreWorkspace(
+ c.req.valid("param").workspaceId,
+ adminAuditRequest(c),
+ ),
+ 200,
+ ),
+ )
+ .openapi(deleteWorkspaceRoute, async (c) =>
+ c.json(
+ await deleteWorkspace(
+ c.req.valid("param").workspaceId,
+ adminAuditRequest(c),
+ ),
+ 200,
+ ),
+ )
.openapi(listAuditLogRoute, async (c) =>
c.json(await listAuditLog(c.req.valid("query")), 200),
)
diff --git a/apps/api/src/admin/response.ts b/apps/api/src/admin/response.ts
index 4ce02fa80..4a6e28122 100644
--- a/apps/api/src/admin/response.ts
+++ b/apps/api/src/admin/response.ts
@@ -51,9 +51,28 @@ export const adminWorkspaceSchema = z
memberCount: z.number().int(),
projectCount: z.number().int(),
owners: z.array(adminWorkspaceOwnerSchema),
+ archivedAt: isoTimestamp.nullable().openapi({
+ description:
+ "When an administrator archived the workspace, or null when it is active.",
+ }),
+ archivedBy: adminWorkspaceOwnerSchema.nullable().openapi({
+ description:
+ "The administrator who archived it. Null when active or when that account was deleted.",
+ }),
})
.openapi("AdminWorkspace");
+export const adminWorkspaceArchiveStateSchema = z
+ .object({
+ id: z.string(),
+ archivedAt: isoTimestamp.nullable(),
+ })
+ .openapi("AdminWorkspaceArchiveState");
+
+export const adminDeletedWorkspaceSchema = z
+ .object({ id: z.string() })
+ .openapi("AdminDeletedWorkspace");
+
export const adminWorkspaceListSchema = z
.object({
workspaces: z.array(adminWorkspaceSchema),
diff --git a/apps/api/src/auth.ts b/apps/api/src/auth.ts
index 5a1f606dc..9d1b4a70e 100644
--- a/apps/api/src/auth.ts
+++ b/apps/api/src/auth.ts
@@ -1,3 +1,5 @@
+import { readClientIp } from "./utils/client-ip";
+import { deleteNativeWorkspace } from "./workspace/lifecycle/delete-native-workspace";
import {
revokeApiKeyConnections,
revokeSessionConnections,
@@ -51,10 +53,6 @@ import {
rememberSignInSessionId,
takeSignInSessionId,
} from "./backchannel-logout/sign-in-session-id";
-import {
- findBillableWorkspaces,
- formatBillableWorkspacesMessage,
-} from "./billing/controllers/find-billable-workspaces";
import db, { schema } from "./database";
import { authDatabaseAdapter } from "./database/auth-adapter";
import { lockedSessionRevocation } from "./utils/locked-session-revocation";
@@ -79,6 +77,8 @@ import {
assertNativeOrganizationReadAllowed,
readableNativeOrganizations,
} from "./utils/native-organization-read-access";
+import { assertNativeOrganizationActive } from "./workspace/archive/assert-native-organization-active";
+import { dropArchivedInvitations } from "./workspace/archive/drop-archived-invitations";
import { satisfies } from "./utils/role-permissions";
import { captureAuthAdminAudit } from "./admin/audit/capture-auth-admin-audit";
import { recordAuthAdminAudit } from "./admin/audit/record-auth-admin-audit";
@@ -113,10 +113,7 @@ import {
getWorkspaceInvitationEmailCopy,
} from "./utils/get-workspace-invitation-email-copy";
import { getGithubSsoOAuthCredentials } from "./utils/github-sso-env";
-import {
- hasInstanceAdminRole,
- instanceAdminRoleSql,
-} from "./utils/instance-admin-role";
+import { hasInstanceAdminRole } from "./utils/instance-admin-role";
import {
hasRegisteredUsers,
promoteInitialAdministrator,
@@ -286,8 +283,6 @@ function getDeviceAuthVerificationUri(): string {
return `${base}/device`;
}
-const deletedWorkspaceMembers = new WeakMap<object, string[]>();
-
export const auth = betterAuth({
baseURL: baseURLWithoutPath,
trustedOrigins,
@@ -598,47 +593,6 @@ export const auth = betterAuth({
ownerId: user.id,
});
},
- beforeDeleteOrganization: async ({ organization }, ctx) => {
- const billable = await findBillableWorkspaces([organization.id]);
- if (billable.length > 0) {
- throw new APIError("CONFLICT", {
- code: "WORKSPACE_HAS_ACTIVE_SUBSCRIPTION",
- message: formatBillableWorkspacesMessage(
- billable.map((workspace) => workspace.name),
- ),
- });
- }
- if (ctx) {
- const members = await db
- .select({ userId: schema.workspaceUserTable.userId })
- .from(schema.workspaceUserTable)
- .where(
- eq(schema.workspaceUserTable.workspaceId, organization.id),
- );
- const admins = await db
- .select({ userId: schema.userTable.id })
- .from(schema.userTable)
- .where(instanceAdminRoleSql(schema.userTable.role));
- deletedWorkspaceMembers.set(ctx.context, [
- ...new Set(
- [...members, ...admins].map((member) => member.userId),
- ),
- ]);
- }
- },
- afterDeleteOrganization: async ({ organization }, ctx) => {
- const userIds = ctx
- ? (deletedWorkspaceMembers.get(ctx.context) ?? [])
- : [];
- if (ctx) deletedWorkspaceMembers.delete(ctx.context);
- await Promise.all(
- userIds.map((userId) =>
- revokeWorkspaceConnections(userId, organization.id, {
- force: true,
- }),
- ),
- );
- },
beforeCreateInvitation: async ({ invitation }) => {
const access = await resolveInvitationProjectAccess(invitation);
return { data: access };
@@ -880,199 +834,232 @@ export const auth = betterAuth({
},
},
hooks: {
- before: createAuthMiddleware(async (ctx): Promise<void> => {
- // Runs before provider hooks can turn a key into its owner's session.
- await assertNativeAuthApiKeyAllowed(ctx);
- let organizationViewer: {
- user: { id: string };
- session: {
- id?: string;
- activeOrganizationId?: unknown;
- activeTeamId?: unknown;
- };
- } | null = null;
- if (ctx.path.startsWith("/organization/")) {
- const key = nativeAuthApiKey(ctx);
- // Resolve real bearer sessions through the provider's bearer hook as
- // well as cookies. The nested /get-session call does not enter here.
- organizationViewer = key
- ? { user: { id: key.userId }, session: {} }
- : await auth.api.getSession({ headers: new Headers(ctx.headers) });
- await assertNativeOrganizationReadAllowed(ctx, organizationViewer);
- }
- // Before removal prep deletes account data the entry needs to name.
- await captureAuthAdminAudit(ctx, (headers) =>
- auth.api.getSession({ headers, query: { disableRefresh: true } }),
- );
- if (ctx.path === "/admin/remove-user") {
- await prepareAdminUserRemoval(ctx);
- }
-
- if (ctx.path === "/organization/invite-member") {
- if (ctx.body?.resend === true && typeof ctx.body.email === "string") {
- const viewer = organizationViewer;
- const workspaceId =
- ctx.body.organizationId || viewer?.session.activeOrganizationId;
- if (viewer && typeof workspaceId === "string") {
- await assertOwnerInvitationResendAllowed(
- viewer.user.id,
- workspaceId,
- ctx.body.email,
- );
- }
+ before: createAuthMiddleware(
+ async (
+ ctx,
+ ): Promise<void | Awaited<ReturnType<typeof deleteNativeWorkspace>>> => {
+ // Runs before provider hooks can turn a key into its owner's session.
+ await assertNativeAuthApiKeyAllowed(ctx);
+ let organizationViewer: {
+ user: { id: string };
+ session: {
+ id?: string;
+ activeOrganizationId?: unknown;
+ activeTeamId?: unknown;
+ };
+ } | null = null;
+ if (ctx.path.startsWith("/organization/")) {
+ const key = nativeAuthApiKey(ctx);
+ // Resolve real bearer sessions through the provider's bearer hook as
+ // well as cookies. The nested /get-session call does not enter here.
+ organizationViewer = key
+ ? { user: { id: key.userId }, session: {} }
+ : await auth.api.getSession({ headers: new Headers(ctx.headers) });
+ // First, so members of an archived workspace get its stable code.
+ await assertNativeOrganizationActive(ctx, organizationViewer);
+ await assertNativeOrganizationReadAllowed(ctx, organizationViewer);
}
- // Better Auth swallows email failures in runInBackgroundOrAwait.
- // Invitation callers need the delivery result, including on resend.
- ctx.context.runInBackgroundOrAwait = async (promise) => {
- try {
- await promise;
- } catch {
- throw new APIError("BAD_GATEWAY", {
- code: "INVITATION_EMAIL_FAILED",
- message:
- "Invitation saved, but email delivery failed. Check SMTP settings and resend the invitation.",
+ if (ctx.path === "/organization/delete") {
+ // This short-circuits the provider endpoint; retain its key usage check.
+ if (nativeAuthApiKey(ctx)) {
+ const session = await auth.api.getSession({
+ headers: new Headers(ctx.headers),
});
+ if (!session) throw new APIError("UNAUTHORIZED");
}
- };
- }
-
- if (isLoginFormDisabled && isLocalSignInPath(ctx.path)) {
- throw new APIError("FORBIDDEN", {
- code: "LOCAL_SIGN_IN_DISABLED",
- message:
- "Local sign-in is disabled. Please use a configured social or OIDC sign-in method.",
- });
- }
-
- if (ctx.path === "/request-password-reset" && !isSmtpConfigured()) {
- throw new APIError("FORBIDDEN", {
- code: "EMAIL_DELIVERY_NOT_CONFIGURED",
- message: "Password reset requires email delivery to be configured.",
- });
- }
-
- if (ctx.path === "/sign-in/anonymous") {
- await assertGuestRegistrationAllowed();
- }
-
- if (authCaptchaPaths.has(ctx.path)) {
- const verdict = await verifyTurnstile(
- ctx.headers?.get("x-turnstile-token") ?? ctx.body?.turnstileToken,
+ return ctx.json(
+ await deleteNativeWorkspace(
+ ctx.body?.organizationId,
+ organizationViewer?.user.id,
+ {
+ ipAddress: readClientIp(new Headers(ctx.headers)),
+ userAgent: ctx.headers?.get("user-agent") ?? null,
+ },
+ ),
+ );
+ }
+ // Before removal prep deletes account data the entry needs to name.
+ await captureAuthAdminAudit(ctx, (headers) =>
+ auth.api.getSession({ headers, query: { disableRefresh: true } }),
);
- if (!verdict.ok)
- throw new APIError("FORBIDDEN", {
- code: "CAPTCHA_FAILED",
- message: verdict.reason,
- });
- }
+ if (ctx.path === "/admin/remove-user") {
+ await prepareAdminUserRemoval(ctx);
+ }
- if (
- (ctx.path === "/email-otp/send-verification-otp" &&
- ctx.body?.type === "sign-in") ||
- ctx.path === "/sign-in/magic-link"
- ) {
- await assertEmailCodeRecipientAllowed(ctx.body?.email);
- }
+ if (ctx.path === "/organization/invite-member") {
+ if (ctx.body?.resend === true && typeof ctx.body.email === "string") {
+ const viewer = organizationViewer;
+ const workspaceId =
+ ctx.body.organizationId || viewer?.session.activeOrganizationId;
+ if (viewer && typeof workspaceId === "string") {
+ await assertOwnerInvitationResendAllowed(
+ viewer.user.id,
+ workspaceId,
+ ctx.body.email,
+ );
+ }
+ }
+ // Better Auth swallows email failures in runInBackgroundOrAwait.
+ // Invitation callers need the delivery result, including on resend.
+ ctx.context.runInBackgroundOrAwait = async (promise) => {
+ try {
+ await promise;
+ } catch {
+ throw new APIError("BAD_GATEWAY", {
+ code: "INVITATION_EMAIL_FAILED",
+ message:
+ "Invitation saved, but email delivery failed. Check SMTP settings and resend the invitation.",
+ });
+ }
+ };
+ }
- // Block invite-member calls on cloud from anonymous users or to
- // disposable-email addresses. The 2026-05-28 incident saw ~14k phishing
- // invites sent from throwaway disposable-email signups; gating here
- // shuts that path off without affecting self-hosted instances.
- if (ctx.path === "/organization/invite-member" && isCloud()) {
- // `before` hooks don't auto-populate ctx.context.session; load it
- // explicitly. `disableRefresh` keeps this gate cheap: we only need
- // the user record, not a session refresh side-effect.
- const session = await getSessionFromCtx(ctx, {
- disableRefresh: true,
- }).catch(() => null);
- const sessionUser = session?.user as
- | { isAnonymous?: boolean | null }
- | undefined;
- if (sessionUser?.isAnonymous) {
+ if (isLoginFormDisabled && isLocalSignInPath(ctx.path)) {
throw new APIError("FORBIDDEN", {
- code: "GUEST_INVITATIONS_NOT_ALLOWED",
- message: "Guest accounts may not send workspace invitations.",
- });
- }
- const inviteeEmail = (ctx.body?.email as string | undefined) ?? "";
- if (inviteeEmail && isDisposableEmail(inviteeEmail)) {
- throw new APIError("BAD_REQUEST", {
- code: "DISPOSABLE_EMAIL_NOT_ALLOWED",
+ code: "LOCAL_SIGN_IN_DISABLED",
message:
- "Invitations to disposable-email addresses are not allowed.",
+ "Local sign-in is disabled. Please use a configured social or OIDC sign-in method.",
});
}
- }
- if (
- ((ctx.path === "/callback/:id" &&
- ctx.params?.id === "custom" &&
- !isCustomOAuthCallback()) ||
- (ctx.path === "/sign-in/social" &&
- ctx.body?.provider === "custom" &&
- ctx.body?.idToken)) &&
- (parseManagedProfileFields().length > 0 ||
- resolveBackchannelLogoutConfig().enabled)
- ) {
- throw new APIError("NOT_FOUND");
- }
+ if (ctx.path === "/request-password-reset" && !isSmtpConfigured()) {
+ throw new APIError("FORBIDDEN", {
+ code: "EMAIL_DELIVERY_NOT_CONFIGURED",
+ message: "Password reset requires email delivery to be configured.",
+ });
+ }
- const isSignUpPath =
- ctx.path === "/sign-up/email" ||
- ctx.path.startsWith("/callback/") ||
- ctx.path.startsWith("/sign-in/social");
+ if (
+ ((ctx.path === "/callback/:id" &&
+ ctx.params?.id === "custom" &&
+ !isCustomOAuthCallback()) ||
+ (ctx.path === "/sign-in/social" &&
+ ctx.body?.provider === "custom" &&
+ ctx.body?.idToken)) &&
+ (parseManagedProfileFields().length > 0 ||
+ resolveBackchannelLogoutConfig().enabled)
+ ) {
+ throw new APIError("NOT_FOUND");
+ }
+ if (ctx.path === "/sign-in/anonymous") {
+ await assertGuestRegistrationAllowed();
+ }
- if (!isSignUpPath) {
- return;
- }
+ if (authCaptchaPaths.has(ctx.path)) {
+ const verdict = await verifyTurnstile(
+ ctx.headers?.get("x-turnstile-token") ?? ctx.body?.turnstileToken,
+ );
+ if (!verdict.ok)
+ throw new APIError("FORBIDDEN", {
+ code: "CAPTCHA_FAILED",
+ message: verdict.reason,
+ });
+ }
- const isInstanceAdminSetup = !(await hasRegisteredUsers());
+ if (
+ (ctx.path === "/email-otp/send-verification-otp" &&
+ ctx.body?.type === "sign-in") ||
+ ctx.path === "/sign-in/magic-link"
+ ) {
+ await assertEmailCodeRecipientAllowed(ctx.body?.email);
+ }
- if (ctx.path === "/sign-up/email") {
- if (isPasswordRegistrationDisabled && !isInstanceAdminSetup) {
- throw new APIError("FORBIDDEN", {
- code: "PASSWORD_REGISTRATION_DISABLED",
- message:
- "Password registration is currently disabled. Please use a configured social or OIDC sign-in method.",
- });
+ // Block invite-member calls on cloud from anonymous users or to
+ // disposable-email addresses. The 2026-05-28 incident saw ~14k phishing
+ // invites sent from throwaway disposable-email signups; gating here
+ // shuts that path off without affecting self-hosted instances.
+ if (ctx.path === "/organization/invite-member" && isCloud()) {
+ // `before` hooks don't auto-populate ctx.context.session; load it
+ // explicitly. `disableRefresh` keeps this gate cheap: we only need
+ // the user record, not a session refresh side-effect.
+ const session = await getSessionFromCtx(ctx, {
+ disableRefresh: true,
+ }).catch(() => null);
+ const sessionUser = session?.user as
+ | { isAnonymous?: boolean | null }
+ | undefined;
+ if (sessionUser?.isAnonymous) {
+ throw new APIError("FORBIDDEN", {
+ code: "GUEST_INVITATIONS_NOT_ALLOWED",
+ message: "Guest accounts may not send workspace invitations.",
+ });
+ }
+ const inviteeEmail = (ctx.body?.email as string | undefined) ?? "";
+ if (inviteeEmail && isDisposableEmail(inviteeEmail)) {
+ throw new APIError("BAD_REQUEST", {
+ code: "DISPOSABLE_EMAIL_NOT_ALLOWED",
+ message:
+ "Invitations to disposable-email addresses are not allowed.",
+ });
+ }
}
if (
- isCloud() &&
- !isInstanceAdminSetup &&
- isEmailCodeSignInAvailable()
+ ctx.path === "/callback/:id" &&
+ ctx.params?.id === "custom" &&
+ (parseManagedProfileFields().length > 0 ||
+ resolveBackchannelLogoutConfig().enabled)
) {
- throw new APIError("FORBIDDEN", {
- code: "EMAIL_CODE_REGISTRATION_REQUIRED",
- message: "Create your account with an email code.",
- });
+ throw new APIError("NOT_FOUND");
}
- }
- if (!isRegistrationDisabled || isInstanceAdminSetup) {
- return;
- }
+ const isSignUpPath =
+ ctx.path === "/sign-up/email" ||
+ ctx.path.startsWith("/callback/") ||
+ ctx.path.startsWith("/sign-in/social");
- const email =
- ctx.body?.email ||
- ctx.query?.email ||
- ctx.headers?.get("x-invitation-email");
- const invitationId = normalizeInvitationId(
- ctx.body?.invitationId ||
- ctx.query?.invitationId ||
- ctx.headers?.get("x-invitation-id"),
- );
+ if (!isSignUpPath) {
+ return;
+ }
- if (ctx.path === "/sign-up/email") {
- const result = await checkRegistrationAllowed(email, invitationId);
- if (!result.allowed) {
- throw new APIError("FORBIDDEN", {
- code: "REGISTRATION_NOT_ALLOWED",
- message: result.reason,
- });
+ const isInstanceAdminSetup = !(await hasRegisteredUsers());
+
+ if (ctx.path === "/sign-up/email") {
+ if (isPasswordRegistrationDisabled && !isInstanceAdminSetup) {
+ throw new APIError("FORBIDDEN", {
+ code: "PASSWORD_REGISTRATION_DISABLED",
+ message:
+ "Password registration is currently disabled. Please use a configured social or OIDC sign-in method.",
+ });
+ }
+
+ if (
+ isCloud() &&
+ !isInstanceAdminSetup &&
+ isEmailCodeSignInAvailable()
+ ) {
+ throw new APIError("FORBIDDEN", {
+ code: "EMAIL_CODE_REGISTRATION_REQUIRED",
+ message: "Create your account with an email code.",
+ });
+ }
}
- }
- }),
+
+ if (!isRegistrationDisabled || isInstanceAdminSetup) {
+ return;
+ }
+
+ const email =
+ ctx.body?.email ||
+ ctx.query?.email ||
+ ctx.headers?.get("x-invitation-email");
+ const invitationId = normalizeInvitationId(
+ ctx.body?.invitationId ||
+ ctx.query?.invitationId ||
+ ctx.headers?.get("x-invitation-id"),
+ );
+
+ if (ctx.path === "/sign-up/email") {
+ const result = await checkRegistrationAllowed(email, invitationId);
+ if (!result.allowed) {
+ throw new APIError("FORBIDDEN", {
+ code: "REGISTRATION_NOT_ALLOWED",
+ message: result.reason,
+ });
+ }
+ }
+ },
+ ),
after: createAuthMiddleware(async (ctx) => {
await recordAuthAdminAudit(ctx);
if (ctx.path === "/api-key/delete" && !isAPIError(ctx.context.returned)) {
@@ -1082,6 +1069,14 @@ export const auth = betterAuth({
if (viewer && typeof keyId === "string")
await revokeApiKeyConnections(viewer.user.id, [keyId]);
}
+ if (
+ ctx.path === "/organization/list-user-invitations" &&
+ Array.isArray(ctx.context.returned)
+ ) {
+ await dropArchivedInvitations(
+ ctx.context.returned as { organizationId?: unknown }[],
+ );
+ }
if (
(ctx.path === "/organization/list" ||
ctx.path === "/organization/list-user-teams") &&
diff --git a/apps/api/src/calendar-feed/service.ts b/apps/api/src/calendar-feed/service.ts
index c405a078f..7d86f6a4b 100644
--- a/apps/api/src/calendar-feed/service.ts
+++ b/apps/api/src/calendar-feed/service.ts
@@ -22,6 +22,7 @@ import {
taskTable,
} from "../database/schema";
import { boundedTaskRead } from "../task/bounded-read";
+import { workspaceIsActive } from "../workspace/archive/active-workspace-sql";
import { type CalendarTask, streamCalendar } from "./ical";
export const CALENDAR_TASK_BATCH_SIZE = 50;
@@ -158,7 +159,13 @@ export async function getCalendarFeed(token: string) {
})
.from(calendarFeedTable)
.innerJoin(projectTable, eq(projectTable.id, calendarFeedTable.projectId))
- .where(eq(calendarFeedTable.token, token));
+ .where(
+ and(
+ eq(calendarFeedTable.token, token),
+ // Subscriptions pause while the workspace is archived.
+ workspaceIsActive(projectTable.workspaceId),
+ ),
+ );
if (!record)
throw new HTTPException(404, { message: "Calendar feed not found" });
const { feed, project } = record;
diff --git a/apps/api/src/database/schema.ts b/apps/api/src/database/schema.ts
index 78a971d01..6cf538ca6 100644
--- a/apps/api/src/database/schema.ts
+++ b/apps/api/src/database/schema.ts
@@ -205,6 +205,12 @@ export const workspaceTable = pgTable("workspace", {
metadata: text("metadata"),
description: text("description"),
createdAt: timestamp("created_at", { mode: "date" }).notNull(),
+ // Set by an instance administrator. Archived workspaces keep their data but
+ // members, API keys, integrations, and public links can no longer use them.
+ archivedAt: timestamp("archived_at", { mode: "date" }),
+ archivedBy: text("archived_by").references(() => userTable.id, {
+ onDelete: "set null",
+ }),
});
export const workspaceUserTable = pgTable(
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index 13e554063..8d2f56e11 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -543,12 +543,17 @@ export function createApp() {
workspaceId: schema.assetTable.workspaceId,
projectId: schema.assetTable.projectId,
isPublic: schema.projectTable.isPublic,
+ workspaceArchived: sql<boolean>`${schema.workspaceTable.archivedAt} is not null`,
})
.from(schema.assetTable)
.innerJoin(
schema.projectTable,
eq(schema.assetTable.projectId, schema.projectTable.id),
)
+ .innerJoin(
+ schema.workspaceTable,
+ eq(schema.projectTable.workspaceId, schema.workspaceTable.id),
+ )
.where(eq(schema.assetTable.id, id))
.limit(1);
diff --git a/apps/api/src/notification/resource-access.ts b/apps/api/src/notification/resource-access.ts
index f3a23e0f8..0e8c9c782 100644
--- a/apps/api/src/notification/resource-access.ts
+++ b/apps/api/src/notification/resource-access.ts
@@ -13,7 +13,8 @@ import { notBannedCondition } from "../utils/user-ban";
import { workspacePermissionGrants } from "../utils/workspace-permission-grants";
// Membership, rather than public visibility or global admin privileges, defines
-// who may be subscribed to private task activity. Use the same predicate when
+// who may be subscribed to private task activity. Archived workspaces hide
+// their notifications until restored. Use the same predicate when
// creating, reading and delivering notifications, including historical rows.
export function notificationResourceAccess(
userId: string,
@@ -36,13 +37,17 @@ export function notificationResourceAccess(
SELECT 1 FROM task AS notification_task
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
+ JOIN workspace AS notification_workspace ON notification_workspace.id = notification_project.workspace_id
WHERE notification_task.id = ${resourceId} AND notification_member.user_id = ${userId}
+ AND notification_workspace.archived_at IS NULL
AND ${projectAccessCondition(userId, sql`notification_project.id`)}
AND ${taskRead}
))
OR (${resourceType}::text = 'workspace' AND EXISTS (
SELECT 1 FROM workspace_member AS notification_member
+ JOIN workspace AS notification_workspace ON notification_workspace.id = notification_member.workspace_id
WHERE notification_member.workspace_id = ${resourceId} AND notification_member.user_id = ${userId}
+ AND notification_workspace.archived_at IS NULL
AND ${workspaceRead}
))
)`;
diff --git a/apps/api/src/plugins/active-integration-condition.ts b/apps/api/src/plugins/active-integration-condition.ts
new file mode 100644
index 000000000..de8abb1be
--- /dev/null
+++ b/apps/api/src/plugins/active-integration-condition.ts
@@ -0,0 +1,14 @@
+import { and, eq } from "drizzle-orm";
+import { integrationTable } from "../database/schema";
+import { projectInActiveWorkspace } from "../workspace/archive/active-workspace-sql";
+
+/**
+ * An integration acts (webhooks in or out, syncs, reminders) only while it is
+ * enabled and its workspace is not archived.
+ */
+export function activeIntegrationCondition() {
+ return and(
+ eq(integrationTable.isActive, true),
+ projectInActiveWorkspace(integrationTable.projectId),
+ );
+}
diff --git a/apps/api/src/plugins/gitea/services/integration-lookup.ts b/apps/api/src/plugins/gitea/services/integration-lookup.ts
index 078939da6..7c4bf0675 100644
--- a/apps/api/src/plugins/gitea/services/integration-lookup.ts
+++ b/apps/api/src/plugins/gitea/services/integration-lookup.ts
@@ -3,6 +3,7 @@ import db from "../../../database";
import { integrationTable } from "../../../database/schema";
import type { GiteaConfig } from "../config";
import { normalizeGiteaBaseUrl } from "../config";
+import { activeIntegrationCondition } from "../../active-integration-condition";
export async function findAllIntegrationsByGiteaRepo(
baseUrl: string,
@@ -13,7 +14,7 @@ export async function findAllIntegrationsByGiteaRepo(
const normalized = normalizeGiteaBaseUrl(baseUrl);
const conditions = [
eq(integrationTable.type, "gitea"),
- eq(integrationTable.isActive, true),
+ activeIntegrationCondition(),
];
if (integrationId) {
conditions.push(eq(integrationTable.id, integrationId));
diff --git a/apps/api/src/plugins/github/services/deferred-issue-edits.ts b/apps/api/src/plugins/github/services/deferred-issue-edits.ts
index 6a8dfc1a4..fbeaafbe6 100644
--- a/apps/api/src/plugins/github/services/deferred-issue-edits.ts
+++ b/apps/api/src/plugins/github/services/deferred-issue-edits.ts
@@ -1,3 +1,4 @@
+import { integrationInActiveWorkspace } from "../../../workspace/archive/active-workspace-sql";
import { canSyncTask } from "../../sync/eligibility";
import { and, asc, gt, sql } from "drizzle-orm";
import db from "../../../database";
@@ -121,6 +122,7 @@ async function replayClaimedIssueEdits() {
const links = await db.query.externalLinkTable.findMany({
where: and(
sql`${externalLinkTable.resourceType} = 'issue' AND ${externalLinkTable.metadata} LIKE '%"deferredIssueEdit":%'`,
+ integrationInActiveWorkspace(externalLinkTable.integrationId),
cursor ? gt(externalLinkTable.id, cursor) : undefined,
),
with: { integration: true },
diff --git a/apps/api/src/plugins/github/services/integration-task-scope.ts b/apps/api/src/plugins/github/services/integration-task-scope.ts
index 5304e0d4e..30c522eba 100644
--- a/apps/api/src/plugins/github/services/integration-task-scope.ts
+++ b/apps/api/src/plugins/github/services/integration-task-scope.ts
@@ -6,6 +6,7 @@ import {
projectTable,
taskTable,
} from "../../../database/schema";
+import { activeIntegrationCondition } from "../../active-integration-condition";
export type IntegrationDatabase =
| typeof db
@@ -40,7 +41,7 @@ export async function withIntegrationTask<T>(
.where(
and(
eq(integrationTable.id, integration.id),
- eq(integrationTable.isActive, true),
+ activeIntegrationCondition(),
),
)
.for("no key update");
@@ -80,7 +81,7 @@ export async function withIntegrationTask<T>(
expectedBinding.type === undefined
? undefined
: eq(integrationTable.type, expectedBinding.type),
- eq(integrationTable.isActive, true),
+ activeIntegrationCondition(),
),
)
.for("share");
diff --git a/apps/api/src/plugins/github/services/task-service.ts b/apps/api/src/plugins/github/services/task-service.ts
index 995042f71..2e024d155 100644
--- a/apps/api/src/plugins/github/services/task-service.ts
+++ b/apps/api/src/plugins/github/services/task-service.ts
@@ -10,6 +10,7 @@ import { type GitHubConfig, hasVerifiedGitHubBinding } from "../config";
import { extractTaskLinks } from "../utils/task-references";
import type { IntegrationDatabase } from "./integration-task-scope";
+import { activeIntegrationCondition } from "../../active-integration-condition";
export type TaskRow = InferSelectModel<typeof taskTable>;
@@ -164,7 +165,7 @@ export async function findAllIntegrationsByRepo(source: GitHubWebhookSource) {
const integrations = await db.query.integrationTable.findMany({
where: and(
eq(integrationTable.type, "github"),
- eq(integrationTable.isActive, true),
+ activeIntegrationCondition(),
),
with: { project: true },
});
diff --git a/apps/api/src/plugins/gitlab/services/integration-lookup.ts b/apps/api/src/plugins/gitlab/services/integration-lookup.ts
index 7fc75a6a4..db90d5350 100644
--- a/apps/api/src/plugins/gitlab/services/integration-lookup.ts
+++ b/apps/api/src/plugins/gitlab/services/integration-lookup.ts
@@ -3,6 +3,7 @@ import db from "../../../database";
import { integrationTable } from "../../../database/schema";
import type { GitlabConfig } from "../config";
import { normalizeGitlabBaseUrl, normalizeProjectPath } from "../config";
+import { activeIntegrationCondition } from "../../active-integration-condition";
export async function findAllIntegrationsByGitlabProject(
baseUrl: string,
@@ -13,7 +14,7 @@ export async function findAllIntegrationsByGitlabProject(
const normalizedPath = normalizeProjectPath(projectPath);
const conditions = [
eq(integrationTable.type, "gitlab"),
- eq(integrationTable.isActive, true),
+ activeIntegrationCondition(),
];
if (integrationId) {
conditions.push(eq(integrationTable.id, integrationId));
diff --git a/apps/api/src/plugins/registry.ts b/apps/api/src/plugins/registry.ts
index b0ce87578..a3f4ef61f 100644
--- a/apps/api/src/plugins/registry.ts
+++ b/apps/api/src/plugins/registry.ts
@@ -18,6 +18,7 @@ import type {
TaskTitleChangedEvent,
TaskUnassignedEvent,
} from "./types";
+import { activeIntegrationCondition } from "./active-integration-condition";
const plugins = new Map<string, IntegrationPlugin>();
let eventSubscriptionsInitialized = false;
@@ -276,7 +277,7 @@ async function getActiveIntegrations(projectId: string) {
return db.query.integrationTable.findMany({
where: and(
eq(integrationTable.projectId, projectId),
- eq(integrationTable.isActive, true),
+ activeIntegrationCondition(),
),
with: {
project: true,
diff --git a/apps/api/src/plugins/sync/integrations.ts b/apps/api/src/plugins/sync/integrations.ts
index 62e94c0af..5fae0fb09 100644
--- a/apps/api/src/plugins/sync/integrations.ts
+++ b/apps/api/src/plugins/sync/integrations.ts
@@ -2,6 +2,7 @@ import { and, eq, inArray } from "drizzle-orm";
import db from "../../database";
import { integrationTable } from "../../database/schema";
import { readSyncRules, syncProviders } from "./rules";
+import { activeIntegrationCondition } from "../active-integration-condition";
export async function getSyncIntegrations(
projectId: string,
@@ -10,7 +11,7 @@ export async function getSyncIntegrations(
const rows = await db.query.integrationTable.findMany({
where: and(
eq(integrationTable.projectId, projectId),
- eq(integrationTable.isActive, true),
+ activeIntegrationCondition(),
inArray(integrationTable.type, [...syncProviders]),
integrationId ? eq(integrationTable.id, integrationId) : undefined,
),
diff --git a/apps/api/src/plugins/sync/replay-deferred-label-fields.ts b/apps/api/src/plugins/sync/replay-deferred-label-fields.ts
index 681199697..d3137e256 100644
--- a/apps/api/src/plugins/sync/replay-deferred-label-fields.ts
+++ b/apps/api/src/plugins/sync/replay-deferred-label-fields.ts
@@ -1,3 +1,4 @@
+import { integrationInActiveWorkspace } from "../../workspace/archive/active-workspace-sql";
import { and, asc, gt, sql } from "drizzle-orm";
import db from "../../database";
import { externalLinkTable } from "../../database/schema";
@@ -25,6 +26,7 @@ async function replayClaimedLabelFields() {
const links = await db.query.externalLinkTable.findMany({
where: and(
sql`${externalLinkTable.resourceType} = 'issue' AND ${externalLinkTable.metadata} LIKE '%"syncLabelFieldsDeferred":"%'`,
+ integrationInActiveWorkspace(externalLinkTable.integrationId),
cursor ? gt(externalLinkTable.id, cursor) : undefined,
),
with: { integration: true },
diff --git a/apps/api/src/project/controllers/get-public-project.ts b/apps/api/src/project/controllers/get-public-project.ts
index c675b0c41..1126d9c90 100644
--- a/apps/api/src/project/controllers/get-public-project.ts
+++ b/apps/api/src/project/controllers/get-public-project.ts
@@ -1,7 +1,8 @@
-import { eq } from "drizzle-orm";
+import { and, eq } from "drizzle-orm";
import { HTTPException } from "hono/http-exception";
import db from "../../database";
import { projectTable } from "../../database/schema";
+import { workspaceIsActive } from "../../workspace/archive/active-workspace-sql";
import getTasks, {
type GetTasksOptions,
} from "../../task/controllers/get-tasks";
@@ -13,7 +14,13 @@ export async function getPublicProject(
const [project] = await db
.select({ isPublic: projectTable.isPublic })
.from(projectTable)
- .where(eq(projectTable.id, id))
+ .where(
+ and(
+ eq(projectTable.id, id),
+ // Public links of an archived workspace stop working until restored.
+ workspaceIsActive(projectTable.workspaceId),
+ ),
+ )
.limit(1);
if (!project) {
diff --git a/apps/api/src/scheduler/due-date-reminders.ts b/apps/api/src/scheduler/due-date-reminders.ts
index 69e704ca0..153884414 100644
--- a/apps/api/src/scheduler/due-date-reminders.ts
+++ b/apps/api/src/scheduler/due-date-reminders.ts
@@ -12,6 +12,7 @@ import {
persistNotification,
dispatchNotification,
} from "../notification/controllers/create-notification";
+import { workspaceIsActive } from "../workspace/archive/active-workspace-sql";
import {
DUE_DATE_DURATION_MS,
REMINDER_WINDOW_MINUTES,
@@ -94,6 +95,7 @@ async function getTasksNeedingReminder(
or(isNull(columnTable.isFinal), eq(columnTable.isFinal, false)),
// Archived tasks keep their due date but should not notify anyone
ne(taskTable.status, "archived"),
+ workspaceIsActive(projectTable.workspaceId),
),
);
diff --git a/apps/api/src/scheduler/project-webhook-reminders.ts b/apps/api/src/scheduler/project-webhook-reminders.ts
index 12a4a1f11..e6606a304 100644
--- a/apps/api/src/scheduler/project-webhook-reminders.ts
+++ b/apps/api/src/scheduler/project-webhook-reminders.ts
@@ -15,6 +15,7 @@ import {
DUE_DATE_DURATION_MS,
REMINDER_WINDOW_MINUTES,
} from "./reminder-timing";
+import { activeIntegrationCondition } from "../plugins/active-integration-condition";
const MINUTE_MS = 60 * 1000;
@@ -32,7 +33,7 @@ export async function checkProjectWebhookReminders(): Promise<{
.where(
and(
eq(integrationTable.type, "generic-webhook"),
- eq(integrationTable.isActive, true),
+ activeIntegrationCondition(),
),
);
let degraded = false;
diff --git a/apps/api/src/scheduler/trial-reminders.ts b/apps/api/src/scheduler/trial-reminders.ts
index 95b66ab47..9a326b4e0 100644
--- a/apps/api/src/scheduler/trial-reminders.ts
+++ b/apps/api/src/scheduler/trial-reminders.ts
@@ -111,6 +111,8 @@ async function getWorkspacesNeedingReminder(
isNull(workspaceBillingTable.creemSubscriptionId),
trialWindow,
eq(userTable.banned, false),
+ // Nobody can upgrade an archived workspace, so do not nag its owners.
+ isNull(workspaceTable.archivedAt),
),
)
.orderBy(
diff --git a/apps/api/src/task/description-pages.ts b/apps/api/src/task/description-pages.ts
index 859528832..f7bf80b9c 100644
--- a/apps/api/src/task/description-pages.ts
+++ b/apps/api/src/task/description-pages.ts
@@ -1,6 +1,7 @@
import { and, asc, eq, gt, sql } from "drizzle-orm";
import { HTTPException } from "hono/http-exception";
import { projectTable, taskTable } from "../database/schema";
+import { workspaceIsActive } from "../workspace/archive/active-workspace-sql";
import { boundedTaskRead } from "./bounded-read";
export const BOARD_DESCRIPTION_MAX_BYTES = 64 * 1024;
@@ -25,6 +26,7 @@ export async function getDescriptionPage(
conditions.push(
eq(taskTable.projectId, options.publicProjectId),
eq(projectTable.isPublic, true),
+ workspaceIsActive(projectTable.workspaceId),
);
if (options.version)
conditions.push(sql`${taskTable}.xmin::text = ${options.version}`);
@@ -100,6 +102,7 @@ export async function getPublicProjectDescriptionPage(
and(
eq(projectTable.id, projectId),
eq(projectTable.isPublic, true),
+ workspaceIsActive(projectTable.workspaceId),
options.version
? sql`${projectTable}.xmin::text = ${options.version}`
: undefined,
diff --git a/apps/api/src/task/recurrence/create-next-occurrence.ts b/apps/api/src/task/recurrence/create-next-occurrence.ts
index 7791cc5c3..7800997da 100644
--- a/apps/api/src/task/recurrence/create-next-occurrence.ts
+++ b/apps/api/src/task/recurrence/create-next-occurrence.ts
@@ -1,3 +1,4 @@
+import { projectInActiveWorkspace } from "../../workspace/archive/active-workspace-sql";
import { and, asc, eq, isNotNull } from "drizzle-orm";
import db from "../../database";
import { columnTable, taskTable } from "../../database/schema";
@@ -21,6 +22,7 @@ async function createInCurrentProject(
and(
eq(taskTable.id, taskId),
isNotNull(taskTable.recurrence),
+ projectInActiveWorkspace(taskTable.projectId),
taskIsCompleted,
),
)
diff --git a/apps/api/src/utils/authorize-asset-access.ts b/apps/api/src/utils/authorize-asset-access.ts
index dc27b75b6..489d65dc9 100644
--- a/apps/api/src/utils/authorize-asset-access.ts
+++ b/apps/api/src/utils/authorize-asset-access.ts
@@ -9,6 +9,8 @@ type AssetAccessTarget = {
workspaceId: string;
projectId: string;
isPublic: boolean | null;
+ /** Archived workspaces keep members out and stop sharing public assets. */
+ workspaceArchived?: boolean;
surface: string;
createdBy?: string | null;
};
@@ -23,7 +25,8 @@ export async function authorizeAssetAccess(
asset: AssetAccessTarget,
): Promise<void> {
if (isPublicAsset(asset)) {
- return;
+ if (!asset.workspaceArchived) return;
+ throw new HTTPException(404, { message: "Asset not found" });
}
const { userId, apiKeyId, apiKeyPermissions } =
diff --git a/apps/api/src/utils/check-registration-allowed.ts b/apps/api/src/utils/check-registration-allowed.ts
index 5bbbbdd4b..39cc18ace 100644
--- a/apps/api/src/utils/check-registration-allowed.ts
+++ b/apps/api/src/utils/check-registration-allowed.ts
@@ -1,4 +1,4 @@
-import { and, eq, gt } from "drizzle-orm";
+import { and, eq, gt, isNull } from "drizzle-orm";
import db from "../database";
import { invitationTable, userTable, workspaceTable } from "../database/schema";
@@ -95,7 +95,11 @@ async function findValidInvitation(
.from(invitationTable)
.innerJoin(
workspaceTable,
- eq(invitationTable.workspaceId, workspaceTable.id),
+ and(
+ eq(invitationTable.workspaceId, workspaceTable.id),
+ // Invitations to archived workspaces cannot be used.
+ isNull(workspaceTable.archivedAt),
+ ),
)
.innerJoin(userTable, eq(invitationTable.inviterId, userTable.id))
.where(and(...conditions))
@@ -142,7 +146,11 @@ export async function getInvitationDetails(
.from(invitationTable)
.innerJoin(
workspaceTable,
- eq(invitationTable.workspaceId, workspaceTable.id),
+ and(
+ eq(invitationTable.workspaceId, workspaceTable.id),
+ // Invitations to archived workspaces cannot be used.
+ isNull(workspaceTable.archivedAt),
+ ),
)
.innerJoin(userTable, eq(invitationTable.inviterId, userTable.id))
.where(eq(invitationTable.id, invitationId))
@@ -231,7 +239,11 @@ export async function getUserPendingInvitations(userEmail: string) {
.from(invitationTable)
.innerJoin(
workspaceTable,
- eq(invitationTable.workspaceId, workspaceTable.id),
+ and(
+ eq(invitationTable.workspaceId, workspaceTable.id),
+ // Invitations to archived workspaces cannot be used.
+ isNull(workspaceTable.archivedAt),
+ ),
)
.innerJoin(userTable, eq(invitationTable.inviterId, userTable.id))
.where(
diff --git a/apps/api/src/utils/native-organization-read-access.ts b/apps/api/src/utils/native-organization-read-access.ts
index fc55419b0..837865421 100644
--- a/apps/api/src/utils/native-organization-read-access.ts
+++ b/apps/api/src/utils/native-organization-read-access.ts
@@ -1,5 +1,5 @@
import { APIError, getSessionFromCtx } from "better-auth/api";
-import { and, eq, inArray } from "drizzle-orm";
+import { and, eq, inArray, isNull } from "drizzle-orm";
import db, { schema } from "../database";
import { rolesAllow, type StoredRolePermission } from "./role-permissions";
import { splitRoles } from "./split-roles";
@@ -18,10 +18,16 @@ export async function readableNativeOrganizations(
role: schema.workspaceUserTable.role,
})
.from(schema.workspaceUserTable)
+ .innerJoin(
+ schema.workspaceTable,
+ eq(schema.workspaceTable.id, schema.workspaceUserTable.workspaceId),
+ )
.where(
and(
eq(schema.workspaceUserTable.userId, userId),
inArray(schema.workspaceUserTable.workspaceId, ids),
+ // Archived workspaces drop out of organization lists.
+ isNull(schema.workspaceTable.archivedAt),
),
);
if (members.length === 0) return new Set<string>();
diff --git a/apps/api/src/utils/validate-workspace-access.ts b/apps/api/src/utils/validate-workspace-access.ts
index 1b6f37c47..0c9c0a8d2 100644
--- a/apps/api/src/utils/validate-workspace-access.ts
+++ b/apps/api/src/utils/validate-workspace-access.ts
@@ -1,6 +1,7 @@
import { and, eq, or } from "drizzle-orm";
import { HTTPException } from "hono/http-exception";
import db, { schema } from "../database";
+import { workspaceArchivedError } from "../workspace/archive/workspace-archived-error";
import { hasInstanceAdminRole } from "./instance-admin-role";
type ValidateWorkspaceAccessOptions = {
@@ -47,31 +48,33 @@ export async function validateWorkspaceAccess(
.where(eq(schema.userTable.id, userId))
.limit(1);
- if (hasInstanceAdminRole(user?.role)) {
- const [workspace] = await db
- .select({ id: schema.workspaceTable.id })
- .from(schema.workspaceTable)
- .where(eq(schema.workspaceTable.id, workspaceId))
- .limit(1);
-
- if (!workspace) {
- throw notFound();
- }
- return;
- }
-
- const membership = await db
- .select()
- .from(schema.workspaceUserTable)
- .where(
- and(
- eq(schema.workspaceUserTable.userId, userId),
- eq(schema.workspaceUserTable.workspaceId, workspaceId),
- ),
- )
- .limit(1);
+ const [workspace] = hasInstanceAdminRole(user?.role)
+ ? await db
+ .select({ archivedAt: schema.workspaceTable.archivedAt })
+ .from(schema.workspaceTable)
+ .where(eq(schema.workspaceTable.id, workspaceId))
+ .limit(1)
+ : await db
+ .select({ archivedAt: schema.workspaceTable.archivedAt })
+ .from(schema.workspaceUserTable)
+ .innerJoin(
+ schema.workspaceTable,
+ eq(schema.workspaceTable.id, schema.workspaceUserTable.workspaceId),
+ )
+ .where(
+ and(
+ eq(schema.workspaceUserTable.userId, userId),
+ eq(schema.workspaceUserTable.workspaceId, workspaceId),
+ ),
+ )
+ .limit(1);
- if (membership.length === 0) {
+ if (!workspace) {
throw notFound();
}
+ // Checked after membership so outsiders cannot learn a workspace is archived.
+ // Instance administrators manage archived workspaces from the admin panel.
+ if (workspace.archivedAt) {
+ throw workspaceArchivedError();
+ }
}
diff --git a/apps/api/src/workspace/archive/active-workspace-sql.ts b/apps/api/src/workspace/archive/active-workspace-sql.ts
new file mode 100644
index 000000000..70199ea66
--- /dev/null
+++ b/apps/api/src/workspace/archive/active-workspace-sql.ts
@@ -0,0 +1,35 @@
+import { type SQLWrapper, sql } from "drizzle-orm";
+
+// Raw aliases keep these subqueries independent of the outer query's tables,
+// which often include `workspace` or `project` themselves.
+
+/** True when the workspace with this id is not archived. */
+export function workspaceIsActive(workspaceId: SQLWrapper) {
+ return sql<boolean>`not exists (
+ select 1 from "workspace" as "archived_workspace"
+ where "archived_workspace"."id" = ${workspaceId}
+ and "archived_workspace"."archived_at" is not null
+ )`;
+}
+
+/** True when the project with this id belongs to a workspace that is not archived. */
+export function projectInActiveWorkspace(projectId: SQLWrapper) {
+ return sql<boolean>`not exists (
+ select 1 from "project" as "archived_project"
+ inner join "workspace" as "archived_workspace"
+ on "archived_workspace"."id" = "archived_project"."workspace_id"
+ where "archived_project"."id" = ${projectId}
+ and "archived_workspace"."archived_at" is not null
+ )`;
+}
+
+/** Pauses deferred integration jobs without discarding their queued work. */
+export function integrationInActiveWorkspace(integrationId: SQLWrapper) {
+ return sql<boolean>`not exists (
+ select 1 from "integration" as "archived_integration"
+ inner join "project" as "archived_project" on "archived_project"."id" = "archived_integration"."project_id"
+ inner join "workspace" as "archived_workspace" on "archived_workspace"."id" = "archived_project"."workspace_id"
+ where "archived_integration"."id" = ${integrationId}
+ and "archived_workspace"."archived_at" is not null
+ )`;
+}
diff --git a/apps/api/src/workspace/archive/assert-native-organization-active.ts b/apps/api/src/workspace/archive/assert-native-organization-active.ts
new file mode 100644
index 000000000..23f925cd2
--- /dev/null
+++ b/apps/api/src/workspace/archive/assert-native-organization-active.ts
@@ -0,0 +1,163 @@
+import { APIError } from "better-auth/api";
+import { and, eq } from "drizzle-orm";
+import db, { schema } from "../../database";
+import { hasInstanceAdminRole } from "../../utils/instance-admin-role";
+import {
+ WORKSPACE_ARCHIVED,
+ WORKSPACE_ARCHIVED_MESSAGE,
+} from "./workspace-archived-error";
+
+// Endpoints that never act on one existing workspace. The list endpoints hide
+// archived workspaces in the after hook instead.
+const UNSCOPED_PATHS = new Set([
+ "/organization/create",
+ "/organization/check-slug",
+ "/organization/list",
+ "/organization/list-user-invitations",
+ "/organization/list-user-teams",
+]);
+
+type OrganizationContext = {
+ path?: string;
+ body?: Record<string, unknown> | null;
+ query?: Record<string, unknown> | null;
+};
+
+type OrganizationViewer = {
+ user: { id: string };
+ session: { activeOrganizationId?: unknown };
+} | null;
+
+type Target = { workspaceId: string; viaInvitation: boolean };
+
+async function workspaceIdBySlug(slug: string) {
+ const [row] = await db
+ .select({ id: schema.workspaceTable.id })
+ .from(schema.workspaceTable)
+ .where(eq(schema.workspaceTable.slug, slug))
+ .limit(1);
+ return row?.id;
+}
+
+async function workspaceIdByTeam(teamId: string) {
+ const [row] = await db
+ .select({ workspaceId: schema.teamTable.workspaceId })
+ .from(schema.teamTable)
+ .where(eq(schema.teamTable.id, teamId))
+ .limit(1);
+ return row?.workspaceId;
+}
+
+/**
+ * Finds the workspace a Better Auth organization request acts on. Returns null
+ * when the request names a target that does not exist (the provider reports
+ * that) or has no target at all.
+ */
+async function resolveTarget(
+ ctx: OrganizationContext,
+ viewer: NonNullable<OrganizationViewer>,
+): Promise<Target | null> {
+ const input =
+ ctx.path === "/organization/get-active-member"
+ ? {}
+ : { ...ctx.query, ...ctx.body };
+ const text = (key: string) =>
+ typeof input[key] === "string" && input[key] ? input[key] : undefined;
+
+ if (ctx.path === "/organization/set-active" && input.organizationId === null)
+ return null;
+
+ const invitationId =
+ text("invitationId") ??
+ (ctx.path === "/organization/get-invitation" ? text("id") : undefined);
+ if (invitationId) {
+ const [invitation] = await db
+ .select({ workspaceId: schema.invitationTable.workspaceId })
+ .from(schema.invitationTable)
+ .where(eq(schema.invitationTable.id, invitationId))
+ .limit(1);
+ return invitation
+ ? { workspaceId: invitation.workspaceId, viaInvitation: true }
+ : null;
+ }
+
+ const slugWins =
+ [
+ "/organization/get-full-organization",
+ "/organization/list-members",
+ "/organization/get-active-member-role",
+ ].includes(ctx.path ?? "") && text("organizationSlug");
+ const organizationId = slugWins ? undefined : text("organizationId");
+ const organizationSlug = text("organizationSlug");
+ const teamId = text("teamId");
+ const explicit = organizationId ?? organizationSlug ?? teamId;
+ const workspaceId = organizationId
+ ? organizationId
+ : organizationSlug
+ ? await workspaceIdBySlug(organizationSlug)
+ : teamId
+ ? await workspaceIdByTeam(teamId)
+ : undefined;
+ if (explicit) {
+ return workspaceId ? { workspaceId, viaInvitation: false } : null;
+ }
+
+ if (ctx.path === "/organization/set-active-team" && input.teamId === null)
+ return null;
+ const active = viewer.session.activeOrganizationId;
+ return typeof active === "string" && active
+ ? { workspaceId: active, viaInvitation: false }
+ : null;
+}
+
+/**
+ * Blocks Better Auth organization endpoints (reads, member changes, invitation
+ * acceptance, set-active, ...) for archived workspaces.
+ */
+export async function assertNativeOrganizationActive(
+ ctx: OrganizationContext,
+ viewer: OrganizationViewer,
+) {
+ if (!ctx.path?.startsWith("/organization/") || UNSCOPED_PATHS.has(ctx.path))
+ return;
+ if (!viewer) return; // Provider retains its normal authentication failure.
+
+ const target = await resolveTarget(ctx, viewer);
+ if (!target) return;
+
+ const [row] = await db
+ .select({
+ archivedAt: schema.workspaceTable.archivedAt,
+ memberId: schema.workspaceUserTable.id,
+ instanceRole: schema.userTable.role,
+ })
+ .from(schema.workspaceTable)
+ .leftJoin(schema.userTable, eq(schema.userTable.id, viewer.user.id))
+ .leftJoin(
+ schema.workspaceUserTable,
+ and(
+ eq(schema.workspaceUserTable.workspaceId, schema.workspaceTable.id),
+ eq(schema.workspaceUserTable.userId, viewer.user.id),
+ ),
+ )
+ .where(eq(schema.workspaceTable.id, target.workspaceId))
+ .limit(1);
+ if (!row?.archivedAt) return;
+
+ // Invitees and members learn why; anyone else gets the provider's usual
+ // permission failure so archived workspaces stay indistinguishable.
+ if (
+ target.viaInvitation ||
+ row.memberId ||
+ hasInstanceAdminRole(row.instanceRole)
+ ) {
+ throw new APIError("FORBIDDEN", {
+ code: WORKSPACE_ARCHIVED,
+ message: WORKSPACE_ARCHIVED_MESSAGE,
+ });
+ }
+ throw new APIError("FORBIDDEN", {
+ code: "MISSING_PERMISSION",
+ message: "Workspace read permission is required",
+ });
+}
diff --git a/apps/api/src/workspace/archive/drop-archived-invitations.ts b/apps/api/src/workspace/archive/drop-archived-invitations.ts
new file mode 100644
index 000000000..a97b0f378
--- /dev/null
+++ b/apps/api/src/workspace/archive/drop-archived-invitations.ts
@@ -0,0 +1,36 @@
+import { and, inArray, isNotNull } from "drizzle-orm";
+import db, { schema } from "../../database";
+
+/** Removes, in place, invitations whose workspace is archived. */
+export async function dropArchivedInvitations(
+ invitations: { organizationId?: unknown }[],
+) {
+ const ids = [
+ ...new Set(
+ invitations.flatMap((invitation) =>
+ typeof invitation.organizationId === "string"
+ ? [invitation.organizationId]
+ : [],
+ ),
+ ),
+ ];
+ if (ids.length === 0) return;
+ const archived = await db
+ .select({ id: schema.workspaceTable.id })
+ .from(schema.workspaceTable)
+ .where(
+ and(
+ inArray(schema.workspaceTable.id, ids),
+ isNotNull(schema.workspaceTable.archivedAt),
+ ),
+ );
+ if (archived.length === 0) return;
+ const hidden = new Set(archived.map((row) => row.id));
+ invitations.splice(
+ 0,
+ invitations.length,
+ ...invitations.filter(
+ (invitation) => !hidden.has(invitation.organizationId as string),
+ ),
+ );
+}
diff --git a/apps/api/src/workspace/archive/workspace-archived-error.ts b/apps/api/src/workspace/archive/workspace-archived-error.ts
new file mode 100644
index 000000000..ab6c9c87f
--- /dev/null
+++ b/apps/api/src/workspace/archive/workspace-archived-error.ts
@@ -0,0 +1,12 @@
+import { ApiError } from "../../errors/api-error";
+
+export const WORKSPACE_ARCHIVED = "WORKSPACE_ARCHIVED";
+export const WORKSPACE_ARCHIVED_MESSAGE =
+ "This workspace is archived. An instance administrator can restore it.";
+
+export function workspaceArchivedError() {
+ return new ApiError(403, {
+ code: WORKSPACE_ARCHIVED,
+ message: WORKSPACE_ARCHIVED_MESSAGE,
+ });
+}
diff --git a/apps/api/src/workspace/controllers/get-workspace.ts b/apps/api/src/workspace/controllers/get-workspace.ts
index 8800eb4a6..b17d2559e 100644
--- a/apps/api/src/workspace/controllers/get-workspace.ts
+++ b/apps/api/src/workspace/controllers/get-workspace.ts
@@ -7,6 +7,7 @@ import {
workspaceUserTable,
} from "../../database/schema";
import { instanceAdminRoleSql } from "../../utils/instance-admin-role";
+import { workspaceArchivedError } from "../archive/workspace-archived-error";
import { workspaceAccessColumns } from "../can-read-workspace";
import { filterReadableWorkspaces } from "../filter-readable-workspaces";
import {
@@ -16,7 +17,11 @@ import {
async function getWorkspace(workspaceId: string, userId: string) {
const rows = await db
- .select({ ...workspaceColumns, ...workspaceAccessColumns })
+ .select({
+ ...workspaceColumns,
+ ...workspaceAccessColumns,
+ archivedAt: workspaceTable.archivedAt,
+ })
.from(workspaceTable)
.innerJoin(userTable, eq(userTable.id, userId))
.leftJoin(
@@ -42,6 +47,9 @@ async function getWorkspace(workspaceId: string, userId: string) {
if (!row) {
throw new HTTPException(404, { message: "Workspace not found" });
}
+ if (row.archivedAt) {
+ throw workspaceArchivedError();
+ }
return toWorkspaceResponse(row);
}
diff --git a/apps/api/src/workspace/controllers/list-workspaces.ts b/apps/api/src/workspace/controllers/list-workspaces.ts
index 48f113abd..827dd4731 100644
--- a/apps/api/src/workspace/controllers/list-workspaces.ts
+++ b/apps/api/src/workspace/controllers/list-workspaces.ts
@@ -1,4 +1,4 @@
-import { and, eq, sql } from "drizzle-orm";
+import { and, eq, isNull, sql } from "drizzle-orm";
import db from "../../database";
import {
userTable,
@@ -29,6 +29,7 @@ async function listWorkspaces(userId: string) {
),
)
.innerJoin(userTable, eq(userTable.id, workspaceUserTable.userId))
+ .where(isNull(workspaceTable.archivedAt))
.orderBy(
sortName,
workspaceTable.id,
diff --git a/apps/api/src/workspace/index.ts b/apps/api/src/workspace/index.ts
index 4028ae937..b16535135 100644
--- a/apps/api/src/workspace/index.ts
+++ b/apps/api/src/workspace/index.ts
@@ -40,7 +40,7 @@ const listWorkspacesRoute = createRoute({
tags: ["Workspaces"],
summary: "List workspaces",
description:
- "List the workspaces where one of the caller's roles grants workspace:read, with the caller's role, sorted by name. Instance admins get every workspace they are a member of, and only those.",
+ "List the workspaces where one of the caller's roles grants workspace:read, with the caller's role, sorted by name. Instance admins get every workspace they are a member of, and only those. Archived workspaces are left out.",
middleware: [requireApiKeyScope({ workspace: ["read"] })] as const,
responses: {
200: jsonResponse("The caller's workspaces", workspaceListSchema),
@@ -55,12 +55,14 @@ const getWorkspaceRoute = createRoute({
tags: ["Workspaces"],
summary: "Get workspace",
description:
- "Get a workspace where one of the caller's roles grants workspace:read, with the caller's role. Instance admins can get any workspace, with a null role when they are not a member.",
+ "Get a workspace where one of the caller's roles grants workspace:read, with the caller's role. Instance admins can get any workspace, with a null role when they are not a member. An archived workspace returns 403 with the code WORKSPACE_ARCHIVED to anyone who could otherwise read it.",
middleware: [requireApiKeyScope({ workspace: ["read"] })] as const,
request: { params: workspaceIdParam },
responses: {
200: jsonResponse("The workspace", workspaceSchema),
- 403: errorResponse("The API key lacks workspace:read"),
+ 403: errorResponse(
+ "The API key lacks workspace:read, or the workspace is archived (code WORKSPACE_ARCHIVED)",
+ ),
404: errorResponse(
"Workspace not found, the caller is not a member of it, or none of their roles grants workspace:read",
),
diff --git a/apps/api/src/workspace/lifecycle/delete-native-workspace.ts b/apps/api/src/workspace/lifecycle/delete-native-workspace.ts
new file mode 100644
index 000000000..e93104029
--- /dev/null
+++ b/apps/api/src/workspace/lifecycle/delete-native-workspace.ts
@@ -0,0 +1,76 @@
+import { APIError } from "better-auth/api";
+import { and, eq } from "drizzle-orm";
+import db, { schema } from "../../database";
+import { ApiError } from "../../errors/api-error";
+import { hasInstanceAdminRole } from "../../utils/instance-admin-role";
+import { roleHasWorkspacePermission } from "../../utils/require-workspace-permission";
+import { deleteWorkspaceData } from "./delete-workspace-data";
+import type { AdminAuditRequest } from "../../admin/audit/admin-audit-request";
+
+/** The native owner endpoint and instance-admin endpoint use one deletion path. */
+export async function deleteNativeWorkspace(
+ workspaceId: unknown,
+ userId: string | undefined,
+ request: Omit<AdminAuditRequest, "actorUserId">,
+) {
+ if (!userId) throw new APIError("UNAUTHORIZED");
+ if (typeof workspaceId !== "string" || !workspaceId)
+ throw new APIError("BAD_REQUEST", { message: "Workspace ID is required" });
+ const [member] = await db
+ .select({
+ role: schema.workspaceUserTable.role,
+ instanceRole: schema.userTable.role,
+ })
+ .from(schema.workspaceUserTable)
+ .innerJoin(
+ schema.userTable,
+ eq(schema.userTable.id, schema.workspaceUserTable.userId),
+ )
+ .where(
+ and(
+ eq(schema.workspaceUserTable.workspaceId, workspaceId),
+ eq(schema.workspaceUserTable.userId, userId),
+ ),
+ );
+ if (
+ !member ||
+ !(await roleHasWorkspacePermission(workspaceId, member.role, {
+ organization: ["delete"],
+ }))
+ )
+ throw new APIError("FORBIDDEN", {
+ message: "Workspace deletion permission is required",
+ });
+ try {
+ const workspace = await deleteWorkspaceData(
+ workspaceId,
+ hasInstanceAdminRole(member.instanceRole)
+ ? { ...request, actorUserId: userId }
+ : undefined,
+ );
+ let metadata: unknown;
+ try {
+ metadata = workspace.metadata
+ ? JSON.parse(workspace.metadata)
+ : undefined;
+ } catch {
+ metadata = undefined;
+ }
+ // Preserve Better Auth's organization response contract.
+ return {
+ id: workspace.id,
+ name: workspace.name,
+ slug: workspace.slug,
+ logo: workspace.logo,
+ createdAt: workspace.createdAt,
+ metadata,
+ };
+ } catch (error) {
+ if (error instanceof ApiError && error.status === 409)
+ throw new APIError("CONFLICT", {
+ code: error.code,
+ message: error.message,
+ });
+ throw error;
+ }
+}
diff --git a/apps/api/src/workspace/lifecycle/delete-workspace-data.ts b/apps/api/src/workspace/lifecycle/delete-workspace-data.ts
new file mode 100644
index 000000000..689f40898
--- /dev/null
+++ b/apps/api/src/workspace/lifecycle/delete-workspace-data.ts
@@ -0,0 +1,84 @@
+import { publishEvent } from "../../events";
+import { count, eq } from "drizzle-orm";
+import db, { schema } from "../../database";
+import {
+ findBillableWorkspaces,
+ formatBillableWorkspacesMessage,
+} from "../../billing/controllers/find-billable-workspaces";
+import { ApiError } from "../../errors/api-error";
+import { queueStorageCleanup } from "../../storage/cleanup-queue";
+import { listWorkspaceAudience } from "./list-workspace-audience";
+import { listWorkspaceObjectKeys } from "./list-workspace-object-keys";
+import { revokeWorkspaceAudience } from "./revoke-workspace-audience";
+import type { AdminAuditRequest } from "../../admin/audit/admin-audit-request";
+import { recordAdminAction } from "../../admin/audit/record-admin-action";
+import { lockWorkspaceRow } from "./lock-workspace-row";
+
+/**
+ * Deletes a workspace the way the owner's "Delete workspace" does: the same
+ * billing guard, cascade, storage cleanup, and realtime revocation, without
+ * requiring the administrator to be a member.
+ */
+export async function deleteWorkspaceData(
+ workspaceId: string,
+ audit?: AdminAuditRequest,
+) {
+ const { audience, workspace } = await db.transaction(async (tx) => {
+ const workspace = await lockWorkspaceRow(tx, workspaceId);
+
+ const billable = await findBillableWorkspaces([workspaceId]);
+ if (billable.length > 0) {
+ throw new ApiError(409, {
+ code: "WORKSPACE_HAS_ACTIVE_SUBSCRIPTION",
+ message: formatBillableWorkspacesMessage(
+ billable.map((entry) => entry.name),
+ ),
+ });
+ }
+
+ const audience = await listWorkspaceAudience(workspaceId, tx);
+ const objectKeys = await listWorkspaceObjectKeys(workspaceId, tx);
+ const [members] = await tx
+ .select({ value: count() })
+ .from(schema.workspaceUserTable)
+ .where(eq(schema.workspaceUserTable.workspaceId, workspaceId));
+ const [projects] = await tx
+ .select({ value: count() })
+ .from(schema.projectTable)
+ .where(eq(schema.projectTable.workspaceId, workspaceId));
+
+ // Queued in the same transaction, so objects are removed only if the
+ // rows that reference them are.
+ await queueStorageCleanup(tx, objectKeys);
+ await tx
+ .update(schema.sessionTable)
+ .set({ activeOrganizationId: null, activeTeamId: null })
+ .where(eq(schema.sessionTable.activeOrganizationId, workspaceId));
+ await tx
+ .delete(schema.workspaceTable)
+ .where(eq(schema.workspaceTable.id, workspaceId));
+ if (audit)
+ await recordAdminAction(
+ {
+ ...audit,
+ action: "workspace.deleted",
+ targetType: "workspace",
+ targetId: workspace.id,
+ targetLabel: workspace.name,
+ metadata: {
+ slug: workspace.slug,
+ memberCount: members?.value ?? 0,
+ projectCount: projects?.value ?? 0,
+ wasArchived: workspace.archivedAt !== null,
+ },
+ },
+ tx,
+ );
+ return { audience, workspace };
+ });
+
+ await revokeWorkspaceAudience(audience, workspaceId);
+ await publishEvent("workspace.deleted", { workspaceId });
+
+ return workspace;
+}
diff --git a/apps/api/src/workspace/lifecycle/list-workspace-audience.ts b/apps/api/src/workspace/lifecycle/list-workspace-audience.ts
new file mode 100644
index 000000000..3a0e3e451
--- /dev/null
+++ b/apps/api/src/workspace/lifecycle/list-workspace-audience.ts
@@ -0,0 +1,24 @@
+import { eq } from "drizzle-orm";
+import db, { schema } from "../../database";
+import type { DbOrTx } from "../../project-access/db-or-tx";
+import { instanceAdminRoleSql } from "../../utils/instance-admin-role";
+
+/**
+ * Everyone who may hold a realtime connection to the workspace: its members
+ * and every instance administrator.
+ */
+export async function listWorkspaceAudience(
+ workspaceId: string,
+ database: DbOrTx = db,
+) {
+ // Sequential: a transaction's connection runs one query at a time.
+ const members = await database
+ .select({ userId: schema.workspaceUserTable.userId })
+ .from(schema.workspaceUserTable)
+ .where(eq(schema.workspaceUserTable.workspaceId, workspaceId));
+ const admins = await database
+ .select({ userId: schema.userTable.id })
+ .from(schema.userTable)
+ .where(instanceAdminRoleSql(schema.userTable.role));
+ return [...new Set([...members, ...admins].map((row) => row.userId))];
+}
diff --git a/apps/api/src/workspace/lifecycle/list-workspace-object-keys.ts b/apps/api/src/workspace/lifecycle/list-workspace-object-keys.ts
new file mode 100644
index 000000000..d8ba7720d
--- /dev/null
+++ b/apps/api/src/workspace/lifecycle/list-workspace-object-keys.ts
@@ -0,0 +1,27 @@
+import { and, eq, isNotNull } from "drizzle-orm";
+import db, { schema } from "../../database";
+import type { DbOrTx } from "../../project-access/db-or-tx";
+
+/** Storage objects (uploads and project backgrounds) owned by a workspace. */
+export async function listWorkspaceObjectKeys(
+ workspaceId: string,
+ database: DbOrTx = db,
+) {
+ // Sequential: a transaction's connection runs one query at a time.
+ const assets = await database
+ .select({ objectKey: schema.assetTable.objectKey })
+ .from(schema.assetTable)
+ .where(eq(schema.assetTable.workspaceId, workspaceId));
+ const backgrounds = await database
+ .select({ objectKey: schema.projectTable.backgroundObjectKey })
+ .from(schema.projectTable)
+ .where(
+ and(
+ eq(schema.projectTable.workspaceId, workspaceId),
+ isNotNull(schema.projectTable.backgroundObjectKey),
+ ),
+ );
+ return [...assets, ...backgrounds].flatMap((row) =>
+ row.objectKey ? [row.objectKey] : [],
+ );
+}
diff --git a/apps/api/src/workspace/lifecycle/lock-workspace-row.ts b/apps/api/src/workspace/lifecycle/lock-workspace-row.ts
new file mode 100644
index 000000000..6c3302a09
--- /dev/null
+++ b/apps/api/src/workspace/lifecycle/lock-workspace-row.ts
@@ -0,0 +1,17 @@
+import { eq } from "drizzle-orm";
+import { HTTPException } from "hono/http-exception";
+import { schema } from "../../database";
+import type { DbOrTx } from "../../project-access/db-or-tx";
+
+/** Locks a workspace row for a lifecycle change and returns what it needs. */
+export async function lockWorkspaceRow(database: DbOrTx, workspaceId: string) {
+ const [workspace] = await database
+ .select()
+ .from(schema.workspaceTable)
+ .where(eq(schema.workspaceTable.id, workspaceId))
+ .for("update");
+ if (!workspace) {
+ throw new HTTPException(404, { message: "Workspace not found" });
+ }
+ return workspace;
+}
diff --git a/apps/api/src/workspace/lifecycle/revoke-workspace-audience.ts b/apps/api/src/workspace/lifecycle/revoke-workspace-audience.ts
new file mode 100644
index 000000000..dcc7e4493
--- /dev/null
+++ b/apps/api/src/workspace/lifecycle/revoke-workspace-audience.ts
@@ -0,0 +1,14 @@
+import { revokeWorkspaceConnections } from "../../ws";
+
+/** Closes the workspace's realtime connections for every listed user. */
+export async function revokeWorkspaceAudience(
+ userIds: string[],
+ workspaceId: string,
+ reason?: "archived",
+) {
+ await Promise.all(
+ userIds.map((userId) =>
+ revokeWorkspaceConnections(userId, workspaceId, { force: true, reason }),
+ ),
+ );
+}
diff --git a/apps/api/src/ws/index.ts b/apps/api/src/ws/index.ts
index 4a61209ab..612482e9c 100644
--- a/apps/api/src/ws/index.ts
+++ b/apps/api/src/ws/index.ts
@@ -9,6 +9,7 @@ import {
projectTable,
sessionTable,
userTable,
+ workspaceTable,
workspaceUserTable,
} from "../database/schema";
import { subscribeToEvent } from "../events";
@@ -584,7 +585,12 @@ export async function revokeApiKeyConnections(
export async function revokeWorkspaceConnections(
userId: string,
workspaceId: string,
- options: { force?: boolean; role?: string | null } = {},
+ options: {
+ force?: boolean;
+ role?: string | null;
+ /** Tells clients why, so they can explain it instead of redirecting. */
+ reason?: "archived";
+ } = {},
) {
if (!options.force) {
try {
@@ -600,9 +606,11 @@ export async function revokeWorkspaceConnections(
console.error("Failed to read role after membership removal:", error);
}
}
+ const reason = options.reason ? { reason: options.reason } : {};
deliverToLocalUserConnections(userId, {
type: "WORKSPACE_ACCESS_REVOKED",
workspaceId,
+ ...reason,
});
await revocationDelivery?.send(
{
@@ -610,6 +618,7 @@ export async function revokeWorkspaceConnections(
message: {
type: "WORKSPACE_ACCESS_REVOKED",
workspaceId,
+ ...reason,
...(options.force ? { force: true } : {}),
},
origin: INSTANCE_ID,
@@ -637,16 +646,29 @@ export async function revokeWorkspaceConnections(
);
}
-const workspaceLookups = new Map<string, Promise<string | null>>();
+const workspaceLookups = new Map<
+ string,
+ Promise<{ workspaceId: string | null; archived: boolean }>
+>();
function currentProjectWorkspace(projectId: string) {
let pending = workspaceLookups.get(projectId);
if (!pending) {
pending = db
- .select({ workspaceId: projectTable.workspaceId })
+ .select({
+ workspaceId: projectTable.workspaceId,
+ archivedAt: workspaceTable.archivedAt,
+ })
.from(projectTable)
+ .innerJoin(
+ workspaceTable,
+ eq(workspaceTable.id, projectTable.workspaceId),
+ )
.where(eq(projectTable.id, projectId))
.limit(1)
- .then(([project]) => project?.workspaceId ?? null)
+ .then(([project]) => ({
+ workspaceId: project?.workspaceId ?? null,
+ archived: !!project?.archivedAt,
+ }))
.finally(() => workspaceLookups.delete(projectId));
workspaceLookups.set(projectId, pending);
}
@@ -684,8 +706,9 @@ function currentBroadcastAccess(
if (!pending) {
pending = (async () => {
let workspaceId: string | null;
+ let archived: boolean;
try {
- workspaceId = await currentProjectWorkspace(projectId);
+ ({ workspaceId, archived } = await currentProjectWorkspace(projectId));
} catch (error) {
console.error("Failed to validate project broadcast access:", error);
return null;
@@ -694,7 +717,9 @@ function currentBroadcastAccess(
let restricted = new Set<string>();
let readers = new Set<string>();
let apiKeys = new Map<string, string>();
- if (workspaceId) {
+ // An archived workspace has no readers: leaving `members` empty closes
+ // any socket a missed revocation left open.
+ if (workspaceId && !archived) {
try {
const [rows, permitted] = await Promise.all([
db
diff --git a/apps/docs/core/operations/administration.mdx b/apps/docs/core/operations/administration.mdx
index 5b7af92e3..3d8310262 100644
--- a/apps/docs/core/operations/administration.mdx
+++ b/apps/docs/core/operations/administration.mdx
@@ -59,6 +59,16 @@ From the members list you can:
The only owner can't be removed or given another role. Transfer ownership to someone else first.
+### Archive or restore a workspace
+
+Choose **Archive workspace** from the workspace's actions menu to pause it without deleting data. Archived workspaces stay visible in the administration directory with an **Archived** badge. Members cannot access them, and they disappear from the workspace switcher. Open boards close their realtime connections and show an archived state.
+
+Archiving also pauses integrations, notifications, reminders, public project links, calendar feeds, and access through API keys and MCP. Existing memberships, invitations, and data remain. Choose **Restore workspace** to make it available again.
+
+### Delete a workspace
+
+Choose **Delete** and type the workspace's exact name to confirm. This permanently removes its projects, tasks, members, invitations, and uploaded files; members' user accounts stay. You can delete active or archived workspaces without being a member. Workspaces with an active paid subscription must have it cancelled in billing settings first.
+
## Review the audit log
Open **Settings → Administration → Audit log** to see what administrators changed, newest first. Each entry shows the action, the administrator who did it, the affected user or workspace, the time, and the IP address the request came from. Filter by users, sessions, API keys, workspaces, or email to narrow the list.
@@ -69,7 +79,7 @@ Kaneo records these actions when they succeed. Rejected or failed attempts aren'
- **Email:** test email sent to the calling administrator.
- **Sessions:** one session or all of a user's sessions revoked.
- **API keys:** a user's API key revoked (its name, never its value).
-- **Workspaces:** member added, member removed, member role changed, and ownership transferred.
+- **Workspaces:** member added, member removed, member role changed, ownership transferred, archived, restored, and deleted.
The first account becoming an administrator on a new instance isn't an administrative action and isn't recorded.
diff --git a/apps/web/src/components/admin/audit-log/get-audit-action-label.ts b/apps/web/src/components/admin/audit-log/get-audit-action-label.ts
index 70eeb8545..a00195418 100644
--- a/apps/web/src/components/admin/audit-log/get-audit-action-label.ts
+++ b/apps/web/src/components/admin/audit-log/get-audit-action-label.ts
@@ -38,6 +38,9 @@ const ACTION_LABEL_KEYS = new Map([
"workspace.owner_transferred",
"settings:adminAuditLog.actions.workspaceOwnerTransferred",
],
+ ["workspace.archived", "settings:adminAuditLog.actions.workspaceArchived"],
+ ["workspace.restored", "settings:adminAuditLog.actions.workspaceRestored"],
+ ["workspace.deleted", "settings:adminAuditLog.actions.workspaceDeleted"],
]);
/** Human wording for an action; actions this client doesn't know show as-is. */
diff --git a/apps/web/src/components/admin/audit-log/get-audit-entry-detail.test.ts b/apps/web/src/components/admin/audit-log/get-audit-entry-detail.test.ts
index bc68c1244..59a54dfa4 100644
--- a/apps/web/src/components/admin/audit-log/get-audit-entry-detail.test.ts
+++ b/apps/web/src/components/admin/audit-log/get-audit-entry-detail.test.ts
@@ -88,4 +88,24 @@ describe("getAuditEntryDetail", () => {
),
).toBe("CI deploys");
});
+
+ it("summarises what a deleted workspace contained", () => {
+ expect(
+ getAuditEntryDetail(
+ {
+ action: "workspace.deleted",
+ metadata: { slug: "acme", memberCount: 3, projectCount: 2 },
+ },
+ t,
+ ),
+ ).toBe(
+ 'settings:adminAuditLog.details.workspaceContents {"members":3,"projects":2}',
+ );
+ expect(
+ getAuditEntryDetail(
+ { action: "workspace.archived", metadata: { slug: "acme" } },
+ t,
+ ),
+ ).toBeNull();
+ });
});
diff --git a/apps/web/src/components/admin/audit-log/get-audit-entry-detail.ts b/apps/web/src/components/admin/audit-log/get-audit-entry-detail.ts
index 6b249e441..85560acb0 100644
--- a/apps/web/src/components/admin/audit-log/get-audit-entry-detail.ts
+++ b/apps/web/src/components/admin/audit-log/get-audit-entry-detail.ts
@@ -104,6 +104,14 @@ export function getAuditEntryDetail(
case "workspace.member_removed":
case "workspace.owner_transferred":
return memberName(metadata);
+ case "workspace.deleted":
+ return typeof metadata.memberCount === "number" &&
+ typeof metadata.projectCount === "number"
+ ? t("settings:adminAuditLog.details.workspaceContents", {
+ members: metadata.memberCount,
+ projects: metadata.projectCount,
+ })
+ : null;
default:
return null;
}
diff --git a/apps/web/src/components/admin/workspace-management/delete-workspace-dialog.tsx b/apps/web/src/components/admin/workspace-management/delete-workspace-dialog.tsx
new file mode 100644
index 000000000..e720660f7
--- /dev/null
+++ b/apps/web/src/components/admin/workspace-management/delete-workspace-dialog.tsx
@@ -0,0 +1,86 @@
+import { useState } from "react";
+import { useTranslation } from "react-i18next";
+import { ConfirmDialog } from "@/components/settings/confirm-dialog";
+import { Field, FieldLabel } from "@/components/ui/field";
+import { Input } from "@/components/ui/input";
+import useDeleteAdminWorkspace from "@/hooks/mutations/admin/use-delete-admin-workspace";
+import { matchesWorkspaceName } from "./matches-workspace-name";
+import type { PendingWorkspaceAction } from "./pending-workspace-action";
+
+type DeleteWorkspaceDialogProps = {
+ action: PendingWorkspaceAction | null;
+ onClose: () => void;
+};
+
+/** Deletes a workspace once the administrator types its name. */
+export function DeleteWorkspaceDialog({
+ action,
+ onClose,
+}: DeleteWorkspaceDialogProps) {
+ const { t } = useTranslation();
+ const [shownAction, setShownAction] = useState(action);
+ const [typed, setTyped] = useState("");
+ const { mutateAsync: deleteWorkspace, isPending } = useDeleteAdminWorkspace();
+ const isOpen = action?.type === "delete";
+
+ if (isOpen && action !== shownAction) {
+ setShownAction(action);
+ setTyped("");
+ }
+
+ const workspace = shownAction?.workspace;
+ const name = workspace?.name ?? "";
+ const confirmed = matchesWorkspaceName(typed, name);
+
+ const handleConfirm = async () => {
+ if (!workspace || !confirmed || isPending) return;
+ try {
+ await deleteWorkspace(workspace.id);
+ onClose();
+ } catch {
+ return;
+ }
+ };
+
+ return (
+ <ConfirmDialog
+ open={isOpen}
+ onOpenChange={(open) => {
+ if (!open && !isPending) onClose();
+ }}
+ title={t("settings:adminWorkspaces.confirm.delete.title", { name })}
+ description={t("settings:adminWorkspaces.confirm.delete.description", {
+ name,
+ members: workspace?.memberCount ?? 0,
+ projects: workspace?.projectCount ?? 0,
+ })}
+ confirmLabel={t("settings:adminWorkspaces.confirm.delete.action")}
+ pendingLabel={t("common:actions.deleting")}
+ pending={isPending}
+ confirmDisabled={!confirmed}
+ onConfirm={handleConfirm}
+ >
+ <form
+ onSubmit={(event) => {
+ event.preventDefault();
+ void handleConfirm();
+ }}
+ >
+ <Field>
+ <FieldLabel htmlFor="admin-delete-workspace-name">
+ {t("settings:adminWorkspaces.confirm.delete.typeName", { name })}
+ </FieldLabel>
+ <Input
+ type="text"
+ id="admin-delete-workspace-name"
+ autoComplete="off"
+ spellCheck={false}
+ value={typed}
+ disabled={isPending}
+ onChange={(event) => setTyped(event.target.value)}
+ />
+ </Field>
+ </form>
+ </ConfirmDialog>
+ );
+}
diff --git a/apps/web/src/components/admin/workspace-management/matches-workspace-name.test.ts b/apps/web/src/components/admin/workspace-management/matches-workspace-name.test.ts
new file mode 100644
index 000000000..1de83b7a0
--- /dev/null
+++ b/apps/web/src/components/admin/workspace-management/matches-workspace-name.test.ts
@@ -0,0 +1,16 @@
+import { describe, expect, it } from "vite-plus/test";
+import { matchesWorkspaceName } from "./matches-workspace-name";
+
+describe("matchesWorkspaceName", () => {
+ it("accepts the exact name, ignoring surrounding spaces", () => {
+ expect(matchesWorkspaceName("Acme", "Acme")).toBe(true);
+ expect(matchesWorkspaceName(" Acme ", "Acme")).toBe(true);
+ });
+
+ it("rejects other casing, partial names, and empty input", () => {
+ expect(matchesWorkspaceName("acme", "Acme")).toBe(false);
+ expect(matchesWorkspaceName("Acm", "Acme")).toBe(false);
+ expect(matchesWorkspaceName("", "Acme")).toBe(false);
+ expect(matchesWorkspaceName("", " ")).toBe(false);
+ });
+});
diff --git a/apps/web/src/components/admin/workspace-management/matches-workspace-name.ts b/apps/web/src/components/admin/workspace-management/matches-workspace-name.ts
new file mode 100644
index 000000000..b8a2d613f
--- /dev/null
+++ b/apps/web/src/components/admin/workspace-management/matches-workspace-name.ts
@@ -0,0 +1,5 @@
+/** Whether the typed confirmation names the workspace exactly. */
+export function matchesWorkspaceName(typed: string, name: string) {
+ const expected = name.trim();
+ return expected !== "" && typed.trim() === expected;
+}
diff --git a/apps/web/src/components/admin/workspace-management/pending-workspace-action.ts b/apps/web/src/components/admin/workspace-management/pending-workspace-action.ts
new file mode 100644
index 000000000..cf9c713cc
--- /dev/null
+++ b/apps/web/src/components/admin/workspace-management/pending-workspace-action.ts
@@ -0,0 +1,6 @@
+import type { AdminWorkspace } from "@/fetchers/admin/workspace-types";
+
+export type PendingWorkspaceAction = {
+ type: "archive" | "restore" | "delete";
+ workspace: AdminWorkspace;
+};
diff --git a/apps/web/src/components/admin/workspace-management/workspace-archived-badge.tsx b/apps/web/src/components/admin/workspace-management/workspace-archived-badge.tsx
new file mode 100644
index 000000000..e2b422a18
--- /dev/null
+++ b/apps/web/src/components/admin/workspace-management/workspace-archived-badge.tsx
@@ -0,0 +1,14 @@
+import { ArchiveIcon } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import { Badge } from "@/components/ui/badge";
+
+export function WorkspaceArchivedBadge() {
+ const { t } = useTranslation();
+
+ return (
+ <Badge variant="warning" className="shrink-0 gap-1 px-1.5">
+ <ArchiveIcon aria-hidden="true" />
+ {t("settings:adminWorkspaces.archived")}
+ </Badge>
+ );
+}
diff --git a/apps/web/src/components/admin/workspace-management/workspace-directory-columns.ts b/apps/web/src/components/admin/workspace-management/workspace-directory-columns.ts
index 5dada6af1..8aacc4c95 100644
--- a/apps/web/src/components/admin/workspace-management/workspace-directory-columns.ts
+++ b/apps/web/src/components/admin/workspace-management/workspace-directory-columns.ts
@@ -3,5 +3,5 @@ export const WORKSPACE_DIRECTORY_COLUMNS = {
members: "w-16",
projects: "w-16",
created: "w-22",
- actions: "w-18",
+ actions: "w-26",
} as const;
diff --git a/apps/web/src/components/admin/workspace-management/workspace-directory-row.tsx b/apps/web/src/components/admin/workspace-management/workspace-directory-row.tsx
index fd91ced11..4403240fa 100644
--- a/apps/web/src/components/admin/workspace-management/workspace-directory-row.tsx
+++ b/apps/web/src/components/admin/workspace-management/workspace-directory-row.tsx
@@ -1,14 +1,22 @@
+import { ArchiveIcon, ArchiveRestoreIcon, Trash2Icon } from "lucide-react";
import { useTranslation } from "react-i18next";
+import {
+ type RowAction,
+ RowActionsMenu,
+} from "@/components/settings/row-actions-menu";
import { Button } from "@/components/ui/button";
import type { AdminWorkspace } from "@/fetchers/admin/workspace-types";
import { cn } from "@/lib/cn";
import { formatDateMedium } from "@/lib/format";
+import type { PendingWorkspaceAction } from "./pending-workspace-action";
+import { WorkspaceArchivedBadge } from "./workspace-archived-badge";
import { WORKSPACE_DIRECTORY_COLUMNS } from "./workspace-directory-columns";
import { WorkspaceOwners } from "./workspace-owners";
type WorkspaceDirectoryRowProps = {
workspace: AdminWorkspace;
onManage: () => void;
+ onAction: (type: PendingWorkspaceAction["type"]) => void;
};
const CELL_CLASS =
@@ -17,15 +25,40 @@ const CELL_CLASS =
export function WorkspaceDirectoryRow({
workspace,
onManage,
+ onAction,
}: WorkspaceDirectoryRowProps) {
const { t } = useTranslation();
+ const isArchived = workspace.archivedAt !== null;
+ const actions: RowAction[] = [
+ isArchived
+ ? {
+ id: "restore",
+ label: t("settings:adminWorkspaces.actions.restore"),
+ icon: ArchiveRestoreIcon,
+ onSelect: () => onAction("restore"),
+ }
+ : {
+ id: "archive",
+ label: t("settings:adminWorkspaces.actions.archive"),
+ icon: ArchiveIcon,
+ onSelect: () => onAction("archive"),
+ },
+ {
+ id: "delete",
+ label: t("common:actions.delete"),
+ icon: Trash2Icon,
+ destructive: true,
+ onSelect: () => onAction("delete"),
+ },
+ ];
return (
<div role="row" className="flex items-center gap-4 px-4 py-3">
<div role="cell" className="min-w-0 flex-1">
- <span className="block truncate text-sm font-medium">
- {workspace.name}
- </span>
+ <div className="flex min-w-0 items-center gap-2">
+ <span className="truncate text-sm font-medium">{workspace.name}</span>
+ {isArchived ? <WorkspaceArchivedBadge /> : null}
+ </div>
<span className="block truncate font-mono text-xs text-muted-foreground">
{workspace.slug}
</span>
@@ -68,7 +101,7 @@ export function WorkspaceDirectoryRow({
<div
role="cell"
className={cn(
- "flex shrink-0 justify-end",
+ "flex shrink-0 items-center justify-end gap-1",
WORKSPACE_DIRECTORY_COLUMNS.actions,
)}
>
@@ -83,6 +116,12 @@ export function WorkspaceDirectoryRow({
>
{t("settings:adminWorkspaces.manage")}
</Button>
+ <RowActionsMenu
+ label={t("settings:adminWorkspaces.actions.open", {
+ name: workspace.name,
+ })}
+ actions={actions}
+ />
</div>
</div>
);
diff --git a/apps/web/src/components/admin/workspace-management/workspace-lifecycle-confirm-dialog.tsx b/apps/web/src/components/admin/workspace-management/workspace-lifecycle-confirm-dialog.tsx
new file mode 100644
index 000000000..1f71068f2
--- /dev/null
+++ b/apps/web/src/components/admin/workspace-management/workspace-lifecycle-confirm-dialog.tsx
@@ -0,0 +1,75 @@
+import { useState } from "react";
+import { useTranslation } from "react-i18next";
+import { ConfirmDialog } from "@/components/settings/confirm-dialog";
+import useArchiveAdminWorkspace from "@/hooks/mutations/admin/use-archive-admin-workspace";
+import useRestoreAdminWorkspace from "@/hooks/mutations/admin/use-restore-admin-workspace";
+import type { PendingWorkspaceAction } from "./pending-workspace-action";
+
+type WorkspaceLifecycleConfirmDialogProps = {
+ action: PendingWorkspaceAction | null;
+ onClose: () => void;
+};
+
+/** Confirms archiving or restoring a workspace. */
+export function WorkspaceLifecycleConfirmDialog({
+ action,
+ onClose,
+}: WorkspaceLifecycleConfirmDialogProps) {
+ const { t } = useTranslation();
+ const [shownAction, setShownAction] = useState(action);
+ const archive = useArchiveAdminWorkspace();
+ const restore = useRestoreAdminWorkspace();
+ const isPending = archive.isPending || restore.isPending;
+ const isOpen = action !== null && action.type !== "delete";
+
+ if (isOpen && action !== shownAction) {
+ setShownAction(action);
+ }
+
+ const handleConfirm = async () => {
+ if (!action) return;
+ try {
+ if (action.type === "archive") {
+ await archive.mutateAsync(action.workspace.id);
+ } else {
+ await restore.mutateAsync(action.workspace.id);
+ }
+ onClose();
+ } catch {
+ return;
+ }
+ };
+
+ const isRestore = shownAction?.type === "restore";
+ const values = { name: shownAction?.workspace.name ?? "" };
+
+ return (
+ <ConfirmDialog
+ open={isOpen}
+ onOpenChange={(open) => {
+ if (!open && !isPending) onClose();
+ }}
+ title={t(
+ isRestore
+ ? "settings:adminWorkspaces.confirm.restore.title"
+ : "settings:adminWorkspaces.confirm.archive.title",
+ values,
+ )}
+ description={t(
+ isRestore
+ ? "settings:adminWorkspaces.confirm.restore.description"
+ : "settings:adminWorkspaces.confirm.archive.description",
+ values,
+ )}
+ confirmLabel={t(
+ isRestore
+ ? "settings:adminWorkspaces.confirm.restore.action"
+ : "settings:adminWorkspaces.confirm.archive.action",
+ )}
+ pendingLabel={t("settings:adminWorkspaces.confirm.working")}
+ pending={isPending}
+ destructive={!isRestore}
+ onConfirm={handleConfirm}
+ />
+ );
+}
diff --git a/apps/web/src/components/admin/workspace-management/workspace-management-panel.test.tsx b/apps/web/src/components/admin/workspace-management/workspace-management-panel.test.tsx
index 593045e60..0c6bd3292 100644
--- a/apps/web/src/components/admin/workspace-management/workspace-management-panel.test.tsx
+++ b/apps/web/src/components/admin/workspace-management/workspace-management-panel.test.tsx
@@ -92,6 +92,18 @@ const mocks = vi.hoisted(() => ({
remove: vi.fn(),
transfer: vi.fn(),
add: vi.fn(),
+ archive: vi.fn(),
+ restore: vi.fn(),
+ deleteWorkspace: vi.fn(),
+}));
+vi.mock("@/hooks/mutations/admin/use-archive-admin-workspace", () => ({
+ default: () => ({ mutateAsync: mocks.archive, isPending: false }),
+}));
+vi.mock("@/hooks/mutations/admin/use-restore-admin-workspace", () => ({
+ default: () => ({ mutateAsync: mocks.restore, isPending: false }),
+}));
+vi.mock("@/hooks/mutations/admin/use-delete-admin-workspace", () => ({
+ default: () => ({ mutateAsync: mocks.deleteWorkspace, isPending: false }),
}));
vi.mock(
"@/hooks/mutations/admin/use-update-admin-workspace-member-role",
@@ -127,6 +139,8 @@ const acme: AdminWorkspace = {
memberCount: 2,
projectCount: 4,
owners: [{ id: "ada", name: "Ada Lovelace", email: "[email protected]" }],
+ archivedAt: null,
+ archivedBy: null,
};
const orphan: AdminWorkspace = {
@@ -137,6 +151,8 @@ const orphan: AdminWorkspace = {
memberCount: 1,
projectCount: 0,
owners: [],
+ archivedAt: "2026-02-01T00:00:00.000Z",
+ archivedBy: { id: "root", name: "Root", email: "[email protected]" },
};
function member(
@@ -194,6 +210,14 @@ function openAcme() {
});
}
+function openWorkspaceMenu(name: string) {
+ fireEvent.click(
+ screen.getByRole("button", {
+ name: `settings:adminWorkspaces.actions.open|${name}`,
+ }),
+ );
+}
+
function openMemberMenu(name: string) {
fireEvent.click(
screen.getByRole("button", {
@@ -454,4 +478,102 @@ describe("WorkspaceManagementPanel", () => {
}),
);
});
+
+ it("marks archived workspaces and offers restore instead of archive", async () => {
+ render(<WorkspaceManagementPanel />);
+
+ const acmeRow = screen
+ .getByText("Acme")
+ .closest('[role="row"]') as HTMLElement;
+ const orphanRow = screen
+ .getByText("Orphaned")
+ .closest('[role="row"]') as HTMLElement;
+ expect(
+ within(acmeRow).queryByText("settings:adminWorkspaces.archived"),
+ ).toBeNull();
+ expect(
+ within(orphanRow).getByText("settings:adminWorkspaces.archived"),
+ ).toBeTruthy();
+
+ openWorkspaceMenu("Orphaned");
+ expect(
+ await screen.findByRole("menuitem", {
+ name: "settings:adminWorkspaces.actions.restore",
+ }),
+ ).toBeTruthy();
+ expect(
+ screen.queryByRole("menuitem", {
+ name: "settings:adminWorkspaces.actions.archive",
+ }),
+ ).toBeNull();
+ });
+
+ it("archives a workspace after confirmation", async () => {
+ render(<WorkspaceManagementPanel />);
+ openWorkspaceMenu("Acme");
+ fireEvent.click(
+ await screen.findByRole("menuitem", {
+ name: "settings:adminWorkspaces.actions.archive",
+ }),
+ );
+
+ const confirm = await screen.findByRole("alertdialog");
+ fireEvent.click(
+ within(confirm).getByRole("button", {
+ name: "settings:adminWorkspaces.confirm.archive.action",
+ }),
+ );
+
+ await waitFor(() => expect(mocks.archive).toHaveBeenCalledWith("acme"));
+ expect(mocks.deleteWorkspace).not.toHaveBeenCalled();
+ });
+
+ it("restores an archived workspace after confirmation", async () => {
+ render(<WorkspaceManagementPanel />);
+ openWorkspaceMenu("Orphaned");
+ fireEvent.click(
+ await screen.findByRole("menuitem", {
+ name: "settings:adminWorkspaces.actions.restore",
+ }),
+ );
+
+ const confirm = await screen.findByRole("alertdialog");
+ fireEvent.click(
+ within(confirm).getByRole("button", {
+ name: "settings:adminWorkspaces.confirm.restore.action",
+ }),
+ );
+
+ await waitFor(() => expect(mocks.restore).toHaveBeenCalledWith("orphan"));
+ });
+
+ it("deletes a workspace only after its name is typed", async () => {
+ render(<WorkspaceManagementPanel />);
+ openWorkspaceMenu("Acme");
+ fireEvent.click(
+ await screen.findByRole("menuitem", { name: "common:actions.delete" }),
+ );
+
+ const confirm = await screen.findByRole("alertdialog");
+ const submit = within(confirm).getByRole("button", {
+ name: "settings:adminWorkspaces.confirm.delete.action",
+ }) as HTMLButtonElement;
+ const input = within(confirm).getByLabelText(
+ "settings:adminWorkspaces.confirm.delete.typeName|Acme",
+ );
+ expect(submit.disabled).toBe(true);
+
+ fireEvent.change(input, { target: { value: "acme" } });
+ expect(submit.disabled).toBe(true);
+ fireEvent.click(submit);
+ expect(mocks.deleteWorkspace).not.toHaveBeenCalled();
+
+ fireEvent.change(input, { target: { value: "Acme" } });
+ expect(submit.disabled).toBe(false);
+ fireEvent.click(submit);
+ await waitFor(() =>
+ expect(mocks.deleteWorkspace).toHaveBeenCalledWith("acme"),
+ );
+ expect(mocks.archive).not.toHaveBeenCalled();
+ });
});
diff --git a/apps/web/src/components/admin/workspace-management/workspace-management-panel.tsx b/apps/web/src/components/admin/workspace-management/workspace-management-panel.tsx
index b91c6084a..208b0a16d 100644
--- a/apps/web/src/components/admin/workspace-management/workspace-management-panel.tsx
+++ b/apps/web/src/components/admin/workspace-management/workspace-management-panel.tsx
@@ -18,8 +18,11 @@ import useAdminWorkspaces, {
ADMIN_WORKSPACES_SEARCH_MAX_LENGTH,
type AdminWorkspace,
} from "@/hooks/queries/admin/use-admin-workspaces";
+import { DeleteWorkspaceDialog } from "./delete-workspace-dialog";
+import type { PendingWorkspaceAction } from "./pending-workspace-action";
import { WorkspaceDirectoryHead } from "./workspace-directory-head";
import { WorkspaceDirectoryRow } from "./workspace-directory-row";
+import { WorkspaceLifecycleConfirmDialog } from "./workspace-lifecycle-confirm-dialog";
import WorkspaceMembersDialog from "./workspace-members-dialog";
function WorkspaceManagementPanel() {
@@ -29,6 +32,8 @@ function WorkspaceManagementPanel() {
const [selectedWorkspace, setSelectedWorkspace] =
useState<AdminWorkspace | null>(null);
const [isMembersOpen, setIsMembersOpen] = useState(false);
+ const [pendingAction, setPendingAction] =
+ useState<PendingWorkspaceAction | null>(null);
const { data, isLoading, isFetching, isError, refetch } = useAdminWorkspaces(
debouncedSearch,
@@ -121,6 +126,7 @@ function WorkspaceManagementPanel() {
setSelectedWorkspace(workspace);
setIsMembersOpen(true);
}}
+ onAction={(type) => setPendingAction({ type, workspace })}
/>
))
)}
@@ -148,6 +154,14 @@ function WorkspaceManagementPanel() {
open={isMembersOpen}
onOpenChange={setIsMembersOpen}
/>
+ <WorkspaceLifecycleConfirmDialog
+ action={pendingAction}
+ onClose={() => setPendingAction(null)}
+ />
+ <DeleteWorkspaceDialog
+ action={pendingAction}
+ onClose={() => setPendingAction(null)}
+ />
</SettingsPage>
);
}
diff --git a/apps/web/src/components/common/workspace-archived.tsx b/apps/web/src/components/common/workspace-archived.tsx
new file mode 100644
index 000000000..fd1834a22
--- /dev/null
+++ b/apps/web/src/components/common/workspace-archived.tsx
@@ -0,0 +1,50 @@
+import { Link } from "@tanstack/react-router";
+import { ArchiveIcon } 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 useAdminAccess from "@/hooks/queries/admin/use-admin-access";
+
+/** Shown in place of a workspace an instance administrator archived. */
+export default function WorkspaceArchived() {
+ const { t } = useTranslation();
+ const { data: isInstanceAdmin } = useAdminAccess();
+ const title = t("workspace:archived.title");
+
+ return (
+ <Empty className="h-full">
+ <PageTitle title={title} />
+ <EmptyHeader>
+ <EmptyMedia variant="icon">
+ <ArchiveIcon />
+ </EmptyMedia>
+ <EmptyTitle role="heading" aria-level={1}>
+ {title}
+ </EmptyTitle>
+ <EmptyDescription>
+ {t("workspace:archived.description")}
+ </EmptyDescription>
+ </EmptyHeader>
+ <EmptyContent>
+ <div className="flex flex-wrap justify-center gap-2">
+ <Button variant="outline" render={<Link to="/dashboard" />}>
+ {t("workspace:archived.otherWorkspaces")}
+ </Button>
+ {isInstanceAdmin ? (
+ <Button render={<Link to="/dashboard/settings/admin/workspaces" />}>
+ {t("workspace:archived.manage")}
+ </Button>
+ ) : null}
+ </div>
+ </EmptyContent>
+ </Empty>
+ );
+}
diff --git a/apps/web/src/fetchers/admin/archive-admin-workspace.ts b/apps/web/src/fetchers/admin/archive-admin-workspace.ts
new file mode 100644
index 000000000..b859e21ff
--- /dev/null
+++ b/apps/web/src/fetchers/admin/archive-admin-workspace.ts
@@ -0,0 +1,14 @@
+import { client } from "@kaneo/libs";
+import { HttpError } from "@/lib/http-error";
+
+export async function archiveAdminWorkspace(workspaceId: string) {
+ const response = await client.admin.workspaces[":workspaceId"].archive.$post({
+ param: { workspaceId },
+ });
+
+ if (!response.ok) {
+ throw await HttpError.fromResponse(response);
+ }
+
+ return response.json();
+}
diff --git a/apps/web/src/fetchers/admin/delete-admin-workspace.ts b/apps/web/src/fetchers/admin/delete-admin-workspace.ts
new file mode 100644
index 000000000..a5cddebd9
--- /dev/null
+++ b/apps/web/src/fetchers/admin/delete-admin-workspace.ts
@@ -0,0 +1,14 @@
+import { client } from "@kaneo/libs";
+import { HttpError } from "@/lib/http-error";
+
+export async function deleteAdminWorkspace(workspaceId: string) {
+ const response = await client.admin.workspaces[":workspaceId"].$delete({
+ param: { workspaceId },
+ });
+
+ if (!response.ok) {
+ throw await HttpError.fromResponse(response);
+ }
+
+ return response.json();
+}
diff --git a/apps/web/src/fetchers/admin/restore-admin-workspace.ts b/apps/web/src/fetchers/admin/restore-admin-workspace.ts
new file mode 100644
index 000000000..e85f1a7fa
--- /dev/null
+++ b/apps/web/src/fetchers/admin/restore-admin-workspace.ts
@@ -0,0 +1,14 @@
+import { client } from "@kaneo/libs";
+import { HttpError } from "@/lib/http-error";
+
+export async function restoreAdminWorkspace(workspaceId: string) {
+ const response = await client.admin.workspaces[":workspaceId"].restore.$post({
+ param: { workspaceId },
+ });
+
+ if (!response.ok) {
+ throw await HttpError.fromResponse(response);
+ }
+
+ return response.json();
+}
diff --git a/apps/web/src/fetchers/workspace/get-workspace.ts b/apps/web/src/fetchers/workspace/get-workspace.ts
new file mode 100644
index 000000000..71d01a90e
--- /dev/null
+++ b/apps/web/src/fetchers/workspace/get-workspace.ts
@@ -0,0 +1,16 @@
+import { client } from "@kaneo/libs";
+import { HttpError } from "@/lib/http-error";
+
+async function getWorkspace(workspaceId: string) {
+ const response = await client.workspace[":workspaceId"].$get({
+ param: { workspaceId },
+ });
+
+ if (!response.ok) {
+ throw await HttpError.fromResponse(response);
+ }
+
+ return response.json();
+}
+
+export default getWorkspace;
diff --git a/apps/web/src/hooks/mutations/admin/refresh-after-workspace-lifecycle.ts b/apps/web/src/hooks/mutations/admin/refresh-after-workspace-lifecycle.ts
new file mode 100644
index 000000000..103911e54
--- /dev/null
+++ b/apps/web/src/hooks/mutations/admin/refresh-after-workspace-lifecycle.ts
@@ -0,0 +1,13 @@
+import type { QueryClient } from "@tanstack/react-query";
+import { ADMIN_WORKSPACES_QUERY_KEY } from "@/hooks/queries/admin/use-admin-workspaces";
+import { authClient } from "@/lib/auth-client";
+
+/**
+ * After an archive, restore, or delete: refresh the admin directory and the
+ * administrator's own workspace switcher, which may include the workspace.
+ */
+export function refreshAfterWorkspaceLifecycle(queryClient: QueryClient) {
+ void queryClient.invalidateQueries({ queryKey: ADMIN_WORKSPACES_QUERY_KEY });
+ void queryClient.invalidateQueries({ queryKey: ["workspaces"] });
+ authClient.$store.notify("$listOrg");
+}
diff --git a/apps/web/src/hooks/mutations/admin/use-archive-admin-workspace.ts b/apps/web/src/hooks/mutations/admin/use-archive-admin-workspace.ts
new file mode 100644
index 000000000..38252123c
--- /dev/null
+++ b/apps/web/src/hooks/mutations/admin/use-archive-admin-workspace.ts
@@ -0,0 +1,30 @@
+import { useMutation, useQueryClient } from "@tanstack/react-query";
+import { ArchiveIcon } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import { archiveAdminWorkspace } from "@/fetchers/admin/archive-admin-workspace";
+import { toast } from "@/lib/toast";
+import { refreshAfterWorkspaceLifecycle } from "./refresh-after-workspace-lifecycle";
+
+function useArchiveAdminWorkspace() {
+ const { t } = useTranslation();
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: archiveAdminWorkspace,
+ onSuccess: () => {
+ toast.success(t("settings:adminWorkspaces.toast.archived"), {
+ icon: ArchiveIcon,
+ });
+ refreshAfterWorkspaceLifecycle(queryClient);
+ },
+ onError: (error) => {
+ toast.error(
+ error instanceof Error && error.message
+ ? error.message
+ : t("settings:adminWorkspaces.toast.archiveError"),
+ );
+ },
+ });
+}
+
+export default useArchiveAdminWorkspace;
diff --git a/apps/web/src/hooks/mutations/admin/use-delete-admin-workspace.ts b/apps/web/src/hooks/mutations/admin/use-delete-admin-workspace.ts
new file mode 100644
index 000000000..24800f95e
--- /dev/null
+++ b/apps/web/src/hooks/mutations/admin/use-delete-admin-workspace.ts
@@ -0,0 +1,30 @@
+import { useMutation, useQueryClient } from "@tanstack/react-query";
+import { Trash2Icon } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import { deleteAdminWorkspace } from "@/fetchers/admin/delete-admin-workspace";
+import { toast } from "@/lib/toast";
+import { refreshAfterWorkspaceLifecycle } from "./refresh-after-workspace-lifecycle";
+
+function useDeleteAdminWorkspace() {
+ const { t } = useTranslation();
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: deleteAdminWorkspace,
+ onSuccess: () => {
+ toast.success(t("settings:adminWorkspaces.toast.deleted"), {
+ icon: Trash2Icon,
+ });
+ refreshAfterWorkspaceLifecycle(queryClient);
+ },
+ onError: (error) => {
+ toast.error(
+ error instanceof Error && error.message
+ ? error.message
+ : t("settings:adminWorkspaces.toast.deleteError"),
+ );
+ },
+ });
+}
+
+export default useDeleteAdminWorkspace;
diff --git a/apps/web/src/hooks/mutations/admin/use-restore-admin-workspace.ts b/apps/web/src/hooks/mutations/admin/use-restore-admin-workspace.ts
new file mode 100644
index 000000000..28dc5025d
--- /dev/null
+++ b/apps/web/src/hooks/mutations/admin/use-restore-admin-workspace.ts
@@ -0,0 +1,30 @@
+import { useMutation, useQueryClient } from "@tanstack/react-query";
+import { ArchiveRestoreIcon } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import { restoreAdminWorkspace } from "@/fetchers/admin/restore-admin-workspace";
+import { toast } from "@/lib/toast";
+import { refreshAfterWorkspaceLifecycle } from "./refresh-after-workspace-lifecycle";
+
+function useRestoreAdminWorkspace() {
+ const { t } = useTranslation();
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: restoreAdminWorkspace,
+ onSuccess: () => {
+ toast.success(t("settings:adminWorkspaces.toast.restored"), {
+ icon: ArchiveRestoreIcon,
+ });
+ refreshAfterWorkspaceLifecycle(queryClient);
+ },
+ onError: (error) => {
+ toast.error(
+ error instanceof Error && error.message
+ ? error.message
+ : t("settings:adminWorkspaces.toast.restoreError"),
+ );
+ },
+ });
+}
+
+export default useRestoreAdminWorkspace;
diff --git a/apps/web/src/hooks/queries/workspace/use-workspace-archived.ts b/apps/web/src/hooks/queries/workspace/use-workspace-archived.ts
new file mode 100644
index 000000000..fe36f2aaa
--- /dev/null
+++ b/apps/web/src/hooks/queries/workspace/use-workspace-archived.ts
@@ -0,0 +1,22 @@
+import { useQuery } from "@tanstack/react-query";
+import getWorkspace from "@/fetchers/workspace/get-workspace";
+import { isWorkspaceArchivedError } from "@/lib/is-workspace-archived-error";
+
+export const workspaceStatusQueryKey = (workspaceId: string) =>
+ ["workspace-status", workspaceId] as const;
+
+/**
+ * Whether the workspace in the URL was archived by an instance administrator.
+ * Pages keep rendering while this loads so boards are never held back.
+ */
+function useWorkspaceArchived(workspaceId: string) {
+ const { error } = useQuery({
+ queryKey: workspaceStatusQueryKey(workspaceId),
+ queryFn: () => getWorkspace(workspaceId),
+ retry: (count, error) => !isWorkspaceArchivedError(error) && count < 2,
+ staleTime: 5 * 60 * 1000,
+ });
+ return isWorkspaceArchivedError(error);
+}
+
+export default useWorkspaceArchived;
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 535485230..5a0880b21 100644
--- a/apps/web/src/hooks/use-user-websocket-lifecycle.test.tsx
+++ b/apps/web/src/hooks/use-user-websocket-lifecycle.test.tsx
@@ -112,6 +112,35 @@ describe("user WebSocket lifecycle", () => {
vi.unstubAllGlobals();
vi.unstubAllEnvs();
});
+ it("keeps an archived board open to show its archived state and refreshes on restore", () => {
+ renderHook(useUserWebSocket);
+ act(() =>
+ TestSocket.instances[0].onmessage?.({
+ data: JSON.stringify({
+ type: "WORKSPACE_ACCESS_REVOKED",
+ workspaceId: "workspace",
+ reason: "archived",
+ }),
+ }),
+ );
+ expect(navigate).not.toHaveBeenCalled();
+ expect(client.invalidateQueries).toHaveBeenCalledWith({
+ queryKey: ["workspace-status", "workspace"],
+ });
+ client.invalidateQueries.mockClear();
+ act(() =>
+ TestSocket.instances[0].onmessage?.({
+ data: JSON.stringify({
+ type: "WORKSPACE_RESTORED",
+ workspaceId: "workspace",
+ }),
+ }),
+ );
+ expect(client.invalidateQueries).toHaveBeenCalledWith({
+ queryKey: ["workspace-status", "workspace"],
+ });
+ expect(auth.notify).toHaveBeenCalledWith("$listOrg");
+ });
it.each([
"/dashboard/settings/workspace/general",
"/dashboard/settings/workspace/roles",
diff --git a/apps/web/src/hooks/use-user-websocket.ts b/apps/web/src/hooks/use-user-websocket.ts
index 35820bec9..450e3ae5a 100644
--- a/apps/web/src/hooks/use-user-websocket.ts
+++ b/apps/web/src/hooks/use-user-websocket.ts
@@ -1,3 +1,4 @@
+import { workspaceStatusQueryKey } from "@/hooks/queries/workspace/use-workspace-archived";
import { windowId } from "@kaneo/libs";
import { useQueryClient } from "@tanstack/react-query";
import { useLocation, useNavigate } from "@tanstack/react-router";
@@ -115,6 +116,7 @@ export function useUserWebSocket() {
type?: string;
workspaceId?: string;
workspaceIds?: string[] | null;
+ reason?: string;
};
if (message.type === "USER_ACCESS_REVOKED") {
leaveSession();
@@ -126,6 +128,9 @@ export function useUserWebSocket() {
message.workspaceIds.every((id) => typeof id === "string")
) {
evictInaccessibleWorkspaceCache(queryClient, message.workspaceIds);
+ void queryClient.invalidateQueries({
+ queryKey: ["workspace-status"],
+ });
for (const workspaceId of message.workspaceIds)
reconcileProjectAccess(queryClient, workspaceId, () => !disposed);
refreshOrganizationState();
@@ -148,9 +153,23 @@ export function useUserWebSocket() {
/^\/dashboard\/settings\/(workspace|projects)(\/|$)/.test(path)
? activeWorkspaceRef.current
: path.match(/^\/dashboard\/workspace\/([^/]+)/)?.[1];
- if (current === message.workspaceId)
+ void queryClient.invalidateQueries({
+ queryKey: workspaceStatusQueryKey(message.workspaceId),
+ });
+ if (
+ current === message.workspaceId &&
+ (message.reason !== "archived" ||
+ !path.startsWith("/dashboard/workspace/"))
+ )
void navigate({ to: "/dashboard" });
}
+ if (message.type === "WORKSPACE_RESTORED" && message.workspaceId) {
+ void queryClient.invalidateQueries({
+ queryKey: workspaceStatusQueryKey(message.workspaceId),
+ });
+ void queryClient.invalidateQueries({ queryKey: ["workspaces"] });
+ refreshOrganizationState();
+ }
if (
message.type === "PROJECT_ACCESS_CHANGED" &&
message.workspaceId
diff --git a/apps/web/src/lib/is-workspace-archived-error.test.ts b/apps/web/src/lib/is-workspace-archived-error.test.ts
new file mode 100644
index 000000000..569b206db
--- /dev/null
+++ b/apps/web/src/lib/is-workspace-archived-error.test.ts
@@ -0,0 +1,23 @@
+import { describe, expect, it } from "vite-plus/test";
+import { HttpError } from "./http-error";
+import { isWorkspaceArchivedError } from "./is-workspace-archived-error";
+
+describe("isWorkspaceArchivedError", () => {
+ it("recognizes the archived workspace code", () => {
+ expect(
+ isWorkspaceArchivedError(
+ new HttpError(403, "Archived", { code: "WORKSPACE_ARCHIVED" }),
+ ),
+ ).toBe(true);
+ });
+
+ it("ignores other errors", () => {
+ expect(
+ isWorkspaceArchivedError(
+ new HttpError(403, "No", { code: "MISSING_PERMISSION" }),
+ ),
+ ).toBe(false);
+ expect(isWorkspaceArchivedError(new Error("Archived"))).toBe(false);
+ expect(isWorkspaceArchivedError(null)).toBe(false);
+ });
+});
diff --git a/apps/web/src/lib/is-workspace-archived-error.ts b/apps/web/src/lib/is-workspace-archived-error.ts
new file mode 100644
index 000000000..88d5b1184
--- /dev/null
+++ b/apps/web/src/lib/is-workspace-archived-error.ts
@@ -0,0 +1,11 @@
+/** The API's stable code for requests to an archived workspace. */
+export const WORKSPACE_ARCHIVED_CODE = "WORKSPACE_ARCHIVED";
+
+export function isWorkspaceArchivedError(error: unknown) {
+ return (
+ typeof error === "object" &&
+ error !== null &&
+ "code" in error &&
+ error.code === WORKSPACE_ARCHIVED_CODE
+ );
+}
diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId.tsx
index 09c40c2dc..28dfc885b 100644
--- a/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId.tsx
+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId.tsx
@@ -1,4 +1,6 @@
import { createFileRoute, Outlet } from "@tanstack/react-router";
+import WorkspaceArchived from "@/components/common/workspace-archived";
+import useWorkspaceArchived from "@/hooks/queries/workspace/use-workspace-archived";
export const Route = createFileRoute(
"/_layout/_authenticated/dashboard/workspace/$workspaceId",
@@ -7,5 +9,8 @@ export const Route = createFileRoute(
});
function RouteComponent() {
- return <Outlet />;
+ const { workspaceId } = Route.useParams();
+ const isArchived = useWorkspaceArchived(workspaceId);
+
+ return isArchived ? <WorkspaceArchived /> : <Outlet />;
}
diff --git a/i18n/az-AZ.json b/i18n/az-AZ.json
index 99597fe0c..b5c4fe0a2 100644
--- a/i18n/az-AZ.json
+++ b/i18n/az-AZ.json
@@ -2077,7 +2077,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "Bütün iş sahələri",
"emptyDescription": "Try another name or slug.",
@@ -2119,8 +2135,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2486,7 +2514,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2514,7 +2545,8 @@
"reason": "Reason: {{reason}}",
"createdWithRole": "Role: {{role}}",
"sessionCount_one": "{{count}} session",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3786,6 +3818,12 @@
},
"empty": "Nothing assigned to you",
"loadError": "Your tasks couldn't be loaded."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/de-DE.json b/i18n/de-DE.json
index 350fb3cef..2058206d9 100644
--- a/i18n/de-DE.json
+++ b/i18n/de-DE.json
@@ -2077,7 +2077,23 @@
"description": "{{name}} wird alleiniger Eigentümer von {{workspace}}. Alle bisherigen Eigentümer werden zu Administratoren.",
"title": "{{name}} zum Eigentümer machen?"
},
- "working": "Wird ausgeführt…"
+ "working": "Wird ausgeführt…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "Alle Workspaces",
"emptyDescription": "Versuche einen anderen Namen oder Slug.",
@@ -2119,8 +2135,20 @@
"removeError": "Mitglied konnte nicht entfernt werden",
"roleError": "Rolle konnte nicht aktualisiert werden",
"roleUpdated": "Rolle aktualisiert",
- "transferError": "Eigentümerschaft konnte nicht übertragen werden"
- }
+ "transferError": "Eigentümerschaft konnte nicht übertragen werden",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2486,7 +2514,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2514,7 +2545,8 @@
"reason": "Reason: {{reason}}",
"createdWithRole": "Role: {{role}}",
"sessionCount_one": "{{count}} session",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3786,6 +3818,12 @@
},
"empty": "Dir ist nichts zugewiesen",
"loadError": "Deine Aufgaben konnten nicht geladen werden."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/el-GR.json b/i18n/el-GR.json
index b33f49f36..01ebe4d63 100644
--- a/i18n/el-GR.json
+++ b/i18n/el-GR.json
@@ -2077,7 +2077,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "Όλοι οι χώροι εργασίας",
"emptyDescription": "Try another name or slug.",
@@ -2119,8 +2135,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2486,7 +2514,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2514,7 +2545,8 @@
"reason": "Reason: {{reason}}",
"createdWithRole": "Role: {{role}}",
"sessionCount_one": "{{count}} session",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3786,6 +3818,12 @@
},
"empty": "Nothing assigned to you",
"loadError": "Your tasks couldn't be loaded."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/en-US.json b/i18n/en-US.json
index 3ee710e84..d4680dfc8 100644
--- a/i18n/en-US.json
+++ b/i18n/en-US.json
@@ -868,6 +868,22 @@
"title": "Remove {{name}}?",
"description": "{{name}} loses access to {{workspace}} and its projects. Their account stays on this instance.",
"action": "Remove member"
+ },
+ "archive": {
+ "title": "Archive {{name}}?",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "action": "Archive workspace"
+ },
+ "restore": {
+ "title": "Restore {{name}}?",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "action": "Restore workspace"
+ },
+ "delete": {
+ "title": "Delete {{name}}?",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "typeName": "Type {{name}} to confirm",
+ "action": "Delete workspace"
}
},
"toast": {
@@ -878,7 +894,19 @@
"removed": "Member removed",
"removeError": "Failed to remove member",
"ownershipTransferred": "Ownership transferred",
- "transferError": "Failed to transfer ownership"
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "restored": "Workspace restored",
+ "deleted": "Workspace deleted",
+ "archiveError": "Could not archive workspace",
+ "restoreError": "Could not restore workspace",
+ "deleteError": "Could not delete workspace"
+ },
+ "archived": "Archived",
+ "actions": {
+ "open": "Actions for {{name}}",
+ "archive": "Archive workspace",
+ "restore": "Restore workspace"
}
},
"adminAuditLog": {
@@ -935,7 +963,10 @@
"userEmailVerified": "Marked email as verified",
"userAvatarChanged": "Changed profile picture",
"userAvatarRemoved": "Removed profile picture",
- "apiKeyRevoked": "Revoked an API key"
+ "apiKeyRevoked": "Revoked an API key",
+ "workspaceArchived": "Workspace archived",
+ "workspaceRestored": "Workspace restored",
+ "workspaceDeleted": "Workspace deleted"
},
"fields": {
"name": "name",
@@ -952,7 +983,8 @@
"memberChange": "{{member}}: {{from}} → {{to}}",
"createdWithRole": "Role: {{role}}",
"sessionCount_one": "{{count}} session",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
}
},
"informationPage": {
@@ -3786,6 +3818,12 @@
"project": "Project"
},
"truncated": "Showing the first {{shown}} of {{total}} tasks."
+ },
+ "archived": {
+ "title": "Workspace archived",
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "otherWorkspaces": "Go to workspaces",
+ "manage": "Manage workspaces"
}
},
"team": {
diff --git a/i18n/es-ES.json b/i18n/es-ES.json
index b6b07a258..72a3c48e0 100644
--- a/i18n/es-ES.json
+++ b/i18n/es-ES.json
@@ -2091,7 +2091,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "Todos los espacios de trabajo",
"emptyDescription": "Try another name or slug.",
@@ -2135,8 +2151,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2528,7 +2556,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2557,7 +2588,8 @@
"createdWithRole": "Role: {{role}}",
"sessionCount_many": "{{count}} sessions",
"sessionCount_one": "{{count}} session",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3859,6 +3891,12 @@
},
"empty": "Nothing assigned to you",
"loadError": "Your tasks couldn't be loaded."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/fr-FR.json b/i18n/fr-FR.json
index 73b484c2b..f4cc03c31 100644
--- a/i18n/fr-FR.json
+++ b/i18n/fr-FR.json
@@ -2091,7 +2091,23 @@
"description": "{{name}} devient l'unique propriétaire de {{workspace}}. Les propriétaires actuels deviennent administrateurs.",
"title": "Définir {{name}} comme propriétaire ?"
},
- "working": "Traitement…"
+ "working": "Traitement…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "Tous les espaces de travail",
"emptyDescription": "Essayez un autre nom ou un autre identifiant d'URL.",
@@ -2135,8 +2151,20 @@
"removeError": "Échec du retrait du membre",
"roleError": "Échec de la mise à jour du rôle",
"roleUpdated": "Rôle mis à jour",
- "transferError": "Échec du transfert de propriété"
- }
+ "transferError": "Échec du transfert de propriété",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2528,7 +2556,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2557,7 +2588,8 @@
"createdWithRole": "Role: {{role}}",
"sessionCount_many": "{{count}} sessions",
"sessionCount_one": "{{count}} session",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3859,6 +3891,12 @@
},
"empty": "Rien ne vous est assigné",
"loadError": "Impossible de charger vos tâches."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/hi-IN.json b/i18n/hi-IN.json
index d9bdf2131..c79cb48ac 100644
--- a/i18n/hi-IN.json
+++ b/i18n/hi-IN.json
@@ -2077,7 +2077,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "सभी वर्कस्पेस",
"emptyDescription": "Try another name or slug.",
@@ -2119,8 +2135,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2486,7 +2514,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2514,7 +2545,8 @@
"reason": "Reason: {{reason}}",
"createdWithRole": "Role: {{role}}",
"sessionCount_one": "{{count}} session",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3786,6 +3818,12 @@
},
"empty": "Nothing assigned to you",
"loadError": "Your tasks couldn't be loaded."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/id-ID.json b/i18n/id-ID.json
index ff1129b8f..5b252c2aa 100644
--- a/i18n/id-ID.json
+++ b/i18n/id-ID.json
@@ -2063,7 +2063,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "Semua ruang kerja",
"emptyDescription": "Try another name or slug.",
@@ -2103,8 +2119,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2444,7 +2472,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2471,7 +2502,8 @@
"noRole": "No role",
"reason": "Reason: {{reason}}",
"createdWithRole": "Role: {{role}}",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3713,6 +3745,12 @@
},
"empty": "Nothing assigned to you",
"loadError": "Your tasks couldn't be loaded."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/it-IT.json b/i18n/it-IT.json
index 7102bdd0a..385e17946 100644
--- a/i18n/it-IT.json
+++ b/i18n/it-IT.json
@@ -2091,7 +2091,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "Tutti i workspace",
"emptyDescription": "Try another name or slug.",
@@ -2135,8 +2151,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2528,7 +2556,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2557,7 +2588,8 @@
"createdWithRole": "Role: {{role}}",
"sessionCount_many": "{{count}} sessions",
"sessionCount_one": "{{count}} session",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3859,6 +3891,12 @@
},
"empty": "Nothing assigned to you",
"loadError": "Your tasks couldn't be loaded."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/ja-JP.json b/i18n/ja-JP.json
index b91180675..152fba7b8 100644
--- a/i18n/ja-JP.json
+++ b/i18n/ja-JP.json
@@ -2063,7 +2063,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "すべてのワークスペース",
"emptyDescription": "Try another name or slug.",
@@ -2103,8 +2119,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2444,7 +2472,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2471,7 +2502,8 @@
"noRole": "No role",
"reason": "Reason: {{reason}}",
"createdWithRole": "Role: {{role}}",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3713,6 +3745,12 @@
},
"empty": "Nothing assigned to you",
"loadError": "Your tasks couldn't be loaded."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/ko-KR.json b/i18n/ko-KR.json
index 1423ff5c6..da50a3d88 100644
--- a/i18n/ko-KR.json
+++ b/i18n/ko-KR.json
@@ -2063,7 +2063,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "모든 워크스페이스",
"emptyDescription": "Try another name or slug.",
@@ -2103,8 +2119,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2444,7 +2472,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2471,7 +2502,8 @@
"noRole": "No role",
"reason": "Reason: {{reason}}",
"createdWithRole": "Role: {{role}}",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3713,6 +3745,12 @@
},
"empty": "Nothing assigned to you",
"loadError": "Your tasks couldn't be loaded."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/mk-MK.json b/i18n/mk-MK.json
index 267fad778..cd101c07e 100644
--- a/i18n/mk-MK.json
+++ b/i18n/mk-MK.json
@@ -2077,7 +2077,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "Сите работни простори",
"emptyDescription": "Try another name or slug.",
@@ -2119,8 +2135,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2486,7 +2514,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2514,7 +2545,8 @@
"reason": "Reason: {{reason}}",
"createdWithRole": "Role: {{role}}",
"sessionCount_one": "{{count}} session",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3786,6 +3818,12 @@
},
"empty": "Nothing assigned to you",
"loadError": "Your tasks couldn't be loaded."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/nl-NL.json b/i18n/nl-NL.json
index 192909cd0..f96d6b746 100644
--- a/i18n/nl-NL.json
+++ b/i18n/nl-NL.json
@@ -2077,7 +2077,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "Alle werkruimtes",
"emptyDescription": "Try another name or slug.",
@@ -2119,8 +2135,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2486,7 +2514,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2514,7 +2545,8 @@
"reason": "Reason: {{reason}}",
"createdWithRole": "Role: {{role}}",
"sessionCount_one": "{{count}} session",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3786,6 +3818,12 @@
},
"empty": "Nothing assigned to you",
"loadError": "Your tasks couldn't be loaded."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/pl-PL.json b/i18n/pl-PL.json
index 1f0f458f7..9be2daa2d 100644
--- a/i18n/pl-PL.json
+++ b/i18n/pl-PL.json
@@ -987,6 +987,12 @@
},
"empty": "Nothing assigned to you",
"loadError": "Your tasks couldn't be loaded."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
@@ -2790,7 +2796,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "Wszystkie obszary robocze",
"emptyDescription": "Try another name or slug.",
@@ -2836,8 +2858,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -3255,7 +3289,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -3285,7 +3322,8 @@
"sessionCount_few": "{{count}} sessions",
"sessionCount_many": "{{count}} sessions",
"sessionCount_one": "{{count}} session",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
diff --git a/i18n/pt-BR.json b/i18n/pt-BR.json
index a34cb9b6e..a0c3ccae4 100644
--- a/i18n/pt-BR.json
+++ b/i18n/pt-BR.json
@@ -2091,7 +2091,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "Todos os espaços de trabalho",
"emptyDescription": "Try another name or slug.",
@@ -2135,8 +2151,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2528,7 +2556,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2557,7 +2588,8 @@
"createdWithRole": "Role: {{role}}",
"sessionCount_many": "{{count}} sessions",
"sessionCount_one": "{{count}} session",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3859,6 +3891,12 @@
},
"empty": "Nothing assigned to you",
"loadError": "Your tasks couldn't be loaded."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/ru-RU.json b/i18n/ru-RU.json
index e22ede216..1aa0b6939 100644
--- a/i18n/ru-RU.json
+++ b/i18n/ru-RU.json
@@ -2113,7 +2113,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "Все рабочие области",
"emptyDescription": "Try another name or slug.",
@@ -2159,8 +2175,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2578,7 +2606,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2608,7 +2639,8 @@
"sessionCount_few": "{{count}} sessions",
"sessionCount_many": "{{count}} sessions",
"sessionCount_one": "{{count}} session",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3984,6 +4016,12 @@
},
"empty": "Nothing assigned to you",
"loadError": "Your tasks couldn't be loaded."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/tr-TR.json b/i18n/tr-TR.json
index eed8dcb25..a690befbb 100644
--- a/i18n/tr-TR.json
+++ b/i18n/tr-TR.json
@@ -2077,7 +2077,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "Tüm çalışma alanları",
"emptyDescription": "Try another name or slug.",
@@ -2119,8 +2135,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2486,7 +2514,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2514,7 +2545,8 @@
"reason": "Reason: {{reason}}",
"createdWithRole": "Role: {{role}}",
"sessionCount_one": "{{count}} session",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3786,6 +3818,12 @@
},
"empty": "Nothing assigned to you",
"loadError": "Your tasks couldn't be loaded."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/uk-UA.json b/i18n/uk-UA.json
index 283ecfd05..5518b0b33 100644
--- a/i18n/uk-UA.json
+++ b/i18n/uk-UA.json
@@ -2105,7 +2105,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "Усі робочі простори",
"emptyDescription": "Try another name or slug.",
@@ -2151,8 +2167,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2570,7 +2598,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2600,7 +2631,8 @@
"sessionCount_few": "{{count}} sessions",
"sessionCount_many": "{{count}} sessions",
"sessionCount_one": "{{count}} session",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3932,6 +3964,12 @@
},
"empty": "Nothing assigned to you",
"loadError": "Your tasks couldn't be loaded."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/vi-VN.json b/i18n/vi-VN.json
index 594c8c2f2..983d10550 100644
--- a/i18n/vi-VN.json
+++ b/i18n/vi-VN.json
@@ -2063,7 +2063,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "Tất cả không gian làm việc",
"emptyDescription": "Try another name or slug.",
@@ -2103,8 +2119,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2444,7 +2472,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2471,7 +2502,8 @@
"noRole": "No role",
"reason": "Reason: {{reason}}",
"createdWithRole": "Role: {{role}}",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3713,6 +3745,12 @@
},
"empty": "Nothing assigned to you",
"loadError": "Your tasks couldn't be loaded."
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/zh-CN.json b/i18n/zh-CN.json
index dd2dbf070..bb5433363 100644
--- a/i18n/zh-CN.json
+++ b/i18n/zh-CN.json
@@ -2063,7 +2063,23 @@
"description": "{{name}} 将成为 {{workspace}} 唯一的所有者,当前的所有者将变为管理员。",
"title": "让 {{name}} 成为所有者?"
},
- "working": "处理中…"
+ "working": "处理中…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "所有工作区",
"emptyDescription": "换个名称或 slug 试试。",
@@ -2103,8 +2119,20 @@
"removeError": "移除成员失败",
"roleError": "更新角色失败",
"roleUpdated": "角色已更新",
- "transferError": "转移所有权失败"
- }
+ "transferError": "转移所有权失败",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2444,7 +2472,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2471,7 +2502,8 @@
"noRole": "No role",
"reason": "Reason: {{reason}}",
"createdWithRole": "Role: {{role}}",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3713,6 +3745,12 @@
},
"empty": "暂时没有指派给你的任务",
"loadError": "你的任务加载失败。"
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/i18n/zh-TW.json b/i18n/zh-TW.json
index ee08f376f..d2d663e3a 100644
--- a/i18n/zh-TW.json
+++ b/i18n/zh-TW.json
@@ -2063,7 +2063,23 @@
"description": "{{name}} becomes the only owner of {{workspace}}. Anyone who owns it now becomes an admin.",
"title": "Make {{name}} the owner?"
},
- "working": "Working…"
+ "working": "Working…",
+ "archive": {
+ "action": "Archive workspace",
+ "description": "Members will lose access and integrations, public links, and calendar feeds will pause. All workspace data stays intact. You can restore it at any time.",
+ "title": "Archive {{name}}?"
+ },
+ "delete": {
+ "action": "Delete workspace",
+ "description": "Permanently delete this workspace, its {{projects}} projects, tasks, and uploaded files. Its {{members}} members will lose access. This cannot be undone.",
+ "title": "Delete {{name}}?",
+ "typeName": "Type {{name}} to confirm"
+ },
+ "restore": {
+ "action": "Restore workspace",
+ "description": "Members will regain access to this workspace. Integrations, public links, and calendar feeds will work again.",
+ "title": "Restore {{name}}?"
+ }
},
"directoryTitle": "所有工作區",
"emptyDescription": "Try another name or slug.",
@@ -2103,8 +2119,20 @@
"removeError": "Failed to remove member",
"roleError": "Failed to update role",
"roleUpdated": "Role updated",
- "transferError": "Failed to transfer ownership"
- }
+ "transferError": "Failed to transfer ownership",
+ "archived": "Workspace archived",
+ "archiveError": "Could not archive workspace",
+ "deleted": "Workspace deleted",
+ "deleteError": "Could not delete workspace",
+ "restored": "Workspace restored",
+ "restoreError": "Could not restore workspace"
+ },
+ "actions": {
+ "archive": "Archive workspace",
+ "open": "Actions for {{name}}",
+ "restore": "Restore workspace"
+ },
+ "archived": "Archived"
},
"workspaceImport": {
"back": {
@@ -2444,7 +2472,10 @@
"userPasswordResetSent": "Sent password reset link",
"userVerificationSent": "Sent verification email",
"apiKeyRevoked": "Revoked an API key",
- "emailTestSent": "Sent test email"
+ "emailTestSent": "Sent test email",
+ "workspaceArchived": "Workspace archived",
+ "workspaceDeleted": "Workspace deleted",
+ "workspaceRestored": "Workspace restored"
},
"categories": {
"all": "All actions",
@@ -2471,7 +2502,8 @@
"noRole": "No role",
"reason": "Reason: {{reason}}",
"createdWithRole": "Role: {{role}}",
- "sessionCount_other": "{{count}} sessions"
+ "sessionCount_other": "{{count}} sessions",
+ "workspaceContents": "{{members}} members, {{projects}} projects"
},
"directoryTitle": "Recorded actions",
"emptyTitle": "No actions recorded",
@@ -3713,6 +3745,12 @@
"project": "專案"
},
"truncated": "顯示 {{total}} 個任務中的前 {{shown}} 個。"
+ },
+ "archived": {
+ "description": "An instance administrator archived this workspace. Your data is saved. Contact an administrator to restore access.",
+ "manage": "Manage workspaces",
+ "otherWorkspaces": "Go to workspaces",
+ "title": "Workspace archived"
}
},
"team": {
diff --git a/tests/api-integration/admin-workspace-lifecycle.test.ts b/tests/api-integration/admin-workspace-lifecycle.test.ts
new file mode 100644
index 000000000..bd53ea063
--- /dev/null
+++ b/tests/api-integration/admin-workspace-lifecycle.test.ts
@@ -0,0 +1,448 @@
+import { randomUUID } from "node:crypto";
+import { eq } from "drizzle-orm";
+import type { WSContext } from "hono/ws";
+import { beforeEach, describe, expect, it, vi } from "vite-plus/test";
+import { auth } from "../../apps/api/src/auth";
+import db, { schema } from "../../apps/api/src/database";
+import { createApp } from "../../apps/api/src/index";
+import {
+ addConnection,
+ addUserConnection,
+ removeConnection,
+ removeUserConnection,
+} from "../../apps/api/src/ws";
+import { createInstanceAdmin } from "./helpers/admin/create-instance-admin";
+import { readAuditLog } from "./helpers/admin/read-audit-log";
+import { mockAnonymousSession, mockAuthenticatedSession } from "./helpers/auth";
+import { resetTestDatabase } from "./helpers/database";
+import {
+ createProjectFixture,
+ createWorkspaceMember,
+} from "./helpers/fixtures";
+import { projectAccessApi } from "./helpers/project-access/project-access-api";
+
+beforeEach(resetTestDatabase);
+
+async function workspaceFixture() {
+ const { user: owner, workspace } = await createWorkspaceMember({
+ role: "owner",
+ workspaceName: "Lifecycle workspace",
+ });
+ const { project } = await createProjectFixture({ workspaceId: workspace.id });
+ return { owner, workspace, project };
+}
+
+async function readWorkspace(workspaceId: string) {
+ const [row] = await db
+ .select()
+ .from(schema.workspaceTable)
+ .where(eq(schema.workspaceTable.id, workspaceId));
+ return row;
+}
+
+function fakeSocket() {
+ return { send: vi.fn(), close: vi.fn() };
+}
+
+function sentMessages(socket: ReturnType<typeof fakeSocket>) {
+ return socket.send.mock.calls.map(([message]) => JSON.parse(message));
+}
+
+const routes = (workspaceId: string) => [
+ { path: `/admin/workspaces/${workspaceId}/archive`, method: "POST" },
+ { path: `/admin/workspaces/${workspaceId}/restore`, method: "POST" },
+ { path: `/admin/workspaces/${workspaceId}`, method: "DELETE" },
+];
+
+describe("admin workspace lifecycle authorization", () => {
+ it("rejects anonymous callers and non-administrators", async () => {
+ const { owner, workspace } = await workspaceFixture();
+
+ for (const route of routes(workspace.id)) {
+ mockAnonymousSession();
+ expect(
+ (await projectAccessApi()(route.path, { method: route.method })).status,
+ ).toBe(401);
+ vi.restoreAllMocks();
+
+ mockAuthenticatedSession(owner);
+ expect(
+ (await projectAccessApi()(route.path, { method: route.method })).status,
+ ).toBe(403);
+ vi.restoreAllMocks();
+ }
+
+ expect((await readWorkspace(workspace.id))?.archivedAt).toBeNull();
+ expect(await readAuditLog()).toEqual([]);
+ });
+
+ it("rejects an administrator's API key", async () => {
+ const { workspace } = await workspaceFixture();
+ const admin = await createInstanceAdmin();
+ const { key } = await auth.api.createApiKey({
+ body: { userId: admin.id, name: "Lifecycle test" },
+ });
+ const { app } = createApp();
+
+ for (const route of routes(workspace.id)) {
+ for (const headers of [
+ { "x-api-key": key },
+ { authorization: `Bearer ${key}` },
+ ]) {
+ const response = await app.request(`/api${route.path}`, {
+ method: route.method,
+ headers,
+ });
+ expect(response.status).toBe(403);
+ }
+ }
+
+ expect(await readWorkspace(workspace.id)).toBeDefined();
+ expect(await readAuditLog()).toEqual([]);
+ });
+
+ it("returns 404 for an unknown workspace", async () => {
+ mockAuthenticatedSession(await createInstanceAdmin());
+ for (const route of routes("missing-workspace")) {
+ expect(
+ (await projectAccessApi()(route.path, { method: route.method })).status,
+ ).toBe(404);
+ }
+ });
+});
+
+describe("archiving and restoring a workspace", () => {
+ it("archives once, revokes realtime access, and records one audit entry", async () => {
+ const { owner, workspace, project } = await workspaceFixture();
+ const admin = await createInstanceAdmin();
+ mockAuthenticatedSession(admin);
+ const userSocket = fakeSocket();
+ const boardSocket = fakeSocket();
+ const userConnection = addUserConnection(
+ owner.id,
+ userSocket as unknown as WSContext,
+ );
+ const boardConnection = addConnection(
+ project.id,
+ boardSocket as unknown as WSContext,
+ owner.id,
+ "window",
+ workspace.id,
+ );
+
+ try {
+ const response = await projectAccessApi()(
+ `/admin/workspaces/${workspace.id}/archive`,
+ { method: "POST" },
+ );
+ expect(response.status).toBe(200);
+ const body = (await response.json()) as {
+ id: string;
+ archivedAt: string;
+ };
+ expect(body.id).toBe(workspace.id);
+ expect(Date.parse(body.archivedAt)).not.toBeNaN();
+
+ expect(boardSocket.close).toHaveBeenCalledWith(
+ 1008,
+ "Workspace access revoked",
+ );
+ expect(sentMessages(userSocket)).toContainEqual({
+ type: "WORKSPACE_ACCESS_REVOKED",
+ workspaceId: workspace.id,
+ reason: "archived",
+ });
+ } finally {
+ removeUserConnection(owner.id, userConnection);
+ removeConnection(project.id, boardConnection);
+ }
+
+ const stored = await readWorkspace(workspace.id);
+ expect(stored?.archivedAt).toBeInstanceOf(Date);
+ expect(stored?.archivedBy).toBe(admin.id);
+
+ const again = await projectAccessApi()(
+ `/admin/workspaces/${workspace.id}/archive`,
+ { method: "POST" },
+ );
+ expect(again.status).toBe(409);
+ expect(((await again.json()) as { code: string }).code).toBe(
+ "WORKSPACE_ALREADY_ARCHIVED",
+ );
+
+ const entries = await readAuditLog();
+ expect(entries).toHaveLength(1);
+ expect(entries[0]).toMatchObject({
+ action: "workspace.archived",
+ actorUserId: admin.id,
+ targetType: "workspace",
+ targetId: workspace.id,
+ targetLabel: "Lifecycle workspace",
+ metadata: { slug: workspace.slug },
+ });
+ });
+
+ it("lists the archive state and who archived it", async () => {
+ const { workspace } = await workspaceFixture();
+ const admin = await createInstanceAdmin();
+ mockAuthenticatedSession(admin);
+ const request = projectAccessApi();
+
+ await request(`/admin/workspaces/${workspace.id}/archive`, {
+ method: "POST",
+ });
+ const list = await request("/admin/workspaces");
+ expect(list.status).toBe(200);
+ const { workspaces } = (await list.json()) as {
+ workspaces: {
+ id: string;
+ archivedAt: string | null;
+ archivedBy: { id: string; name: string; email: string } | null;
+ }[];
+ };
+ expect(workspaces).toEqual([
+ expect.objectContaining({
+ id: workspace.id,
+ archivedAt: expect.any(String),
+ archivedBy: { id: admin.id, name: admin.name, email: admin.email },
+ }),
+ ]);
+ });
+
+ it("restores access, tells open clients, and records one audit entry", async () => {
+ const { owner, workspace } = await workspaceFixture();
+ const admin = await createInstanceAdmin();
+ mockAuthenticatedSession(admin);
+ const request = projectAccessApi();
+
+ const notArchived = await request(
+ `/admin/workspaces/${workspace.id}/restore`,
+ { method: "POST" },
+ );
+ expect(notArchived.status).toBe(409);
+ expect(((await notArchived.json()) as { code: string }).code).toBe(
+ "WORKSPACE_NOT_ARCHIVED",
+ );
+
+ await request(`/admin/workspaces/${workspace.id}/archive`, {
+ method: "POST",
+ });
+ const userSocket = fakeSocket();
+ const userConnection = addUserConnection(
+ owner.id,
+ userSocket as unknown as WSContext,
+ );
+ try {
+ const restored = await request(
+ `/admin/workspaces/${workspace.id}/restore`,
+ { method: "POST" },
+ );
+ expect(restored.status).toBe(200);
+ expect(await restored.json()).toEqual({
+ id: workspace.id,
+ archivedAt: null,
+ });
+ expect(sentMessages(userSocket)).toContainEqual({
+ type: "WORKSPACE_RESTORED",
+ workspaceId: workspace.id,
+ });
+ } finally {
+ removeUserConnection(owner.id, userConnection);
+ }
+
+ const stored = await readWorkspace(workspace.id);
+ expect(stored?.archivedAt).toBeNull();
+ expect(stored?.archivedBy).toBeNull();
+
+ vi.restoreAllMocks();
+ mockAuthenticatedSession(owner);
+ const projects = await projectAccessApi()(
+ `/project?workspaceId=${workspace.id}`,
+ );
+ expect(projects.status).toBe(200);
+
+ expect((await readAuditLog()).map((entry) => entry.action)).toEqual([
+ "workspace.archived",
+ "workspace.restored",
+ ]);
+ });
+});
+
+describe("deleting a workspace", () => {
+ it("removes the workspace and its data, queues its files, and records one audit entry", async () => {
+ const { owner, workspace, project } = await workspaceFixture();
+ const other = await workspaceFixture();
+ const [task] = await db
+ .insert(schema.taskTable)
+ .values({
+ projectId: project.id,
+ title: "Doomed task",
+ number: 1,
+ status: "to-do",
+ })
+ .returning();
+ const objectKey = `uploads/${randomUUID()}`;
+ await db.insert(schema.assetTable).values({
+ workspaceId: workspace.id,
+ projectId: project.id,
+ taskId: task.id,
+ objectKey,
+ filename: "file.png",
+ mimeType: "image/png",
+ size: 3,
+ surface: "description",
+ createdBy: owner.id,
+ });
+ const backgroundKey = `backgrounds/${randomUUID()}`;
+ await db
+ .update(schema.projectTable)
+ .set({ backgroundObjectKey: backgroundKey })
+ .where(eq(schema.projectTable.id, project.id));
+ await db.insert(schema.invitationTable).values({
+ workspaceId: workspace.id,
+ inviterId: owner.id,
+ email: "[email protected]",
+ role: "member",
+ status: "pending",
+ expiresAt: new Date(Date.now() + 86_400_000),
+ });
+
+ const admin = await createInstanceAdmin();
+ mockAuthenticatedSession(admin);
+ const userSocket = fakeSocket();
+ const userConnection = addUserConnection(
+ owner.id,
+ userSocket as unknown as WSContext,
+ );
+ try {
+ const response = await projectAccessApi()(
+ `/admin/workspaces/${workspace.id}`,
+ { method: "DELETE" },
+ );
+ expect(response.status).toBe(200);
+ expect(await response.json()).toEqual({ id: workspace.id });
+ expect(sentMessages(userSocket)).toContainEqual({
+ type: "WORKSPACE_ACCESS_REVOKED",
+ workspaceId: workspace.id,
+ });
+ } finally {
+ removeUserConnection(owner.id, userConnection);
+ }
+
+ expect(await readWorkspace(workspace.id)).toBeUndefined();
+ const projectsLeft = await db
+ .select({ id: schema.projectTable.id })
+ .from(schema.projectTable);
+ expect(projectsLeft).toEqual([{ id: other.project.id }]);
+ expect(
+ await db
+ .select()
+ .from(schema.taskTable)
+ .where(eq(schema.taskTable.id, task.id)),
+ ).toEqual([]);
+ expect(
+ await db
+ .select()
+ .from(schema.invitationTable)
+ .where(eq(schema.invitationTable.workspaceId, workspace.id)),
+ ).toEqual([]);
+ const queued = await db
+ .select({ objectKey: schema.storageCleanupTable.objectKey })
+ .from(schema.storageCleanupTable);
+ expect(queued.map((row) => row.objectKey).sort()).toEqual(
+ [objectKey, backgroundKey].sort(),
+ );
+ // The owner's account stays.
+ expect(
+ await db
+ .select({ id: schema.userTable.id })
+ .from(schema.userTable)
+ .where(eq(schema.userTable.id, owner.id)),
+ ).toHaveLength(1);
+
+ const entries = await readAuditLog();
+ expect(entries).toHaveLength(1);
+ expect(entries[0]).toMatchObject({
+ action: "workspace.deleted",
+ actorUserId: admin.id,
+ targetId: workspace.id,
+ targetLabel: "Lifecycle workspace",
+ metadata: {
+ slug: workspace.slug,
+ memberCount: 1,
+ projectCount: 1,
+ wasArchived: false,
+ },
+ });
+ });
+
+ it("deletes an archived workspace", async () => {
+ const { workspace } = await workspaceFixture();
+ mockAuthenticatedSession(await createInstanceAdmin());
+ const request = projectAccessApi();
+
+ await request(`/admin/workspaces/${workspace.id}/archive`, {
+ method: "POST",
+ });
+ const response = await request(`/admin/workspaces/${workspace.id}`, {
+ method: "DELETE",
+ });
+ expect(response.status).toBe(200);
+ expect(await readWorkspace(workspace.id)).toBeUndefined();
+ const deleted = (await readAuditLog()).find(
+ (entry) => entry.action === "workspace.deleted",
+ );
+ expect(deleted?.metadata).toMatchObject({ wasArchived: true });
+ });
+
+ it("queues the workspace's files when its owner deletes it too", async () => {
+ const { app } = createApp();
+ const signup = await app.request("/api/auth/sign-up/email", {
+ method: "POST",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({
+ email: "[email protected]",
+ password: "correct horse battery staple",
+ name: "Owner",
+ }),
+ });
+ expect(signup.status).toBe(200);
+ const cookie = signup.headers
+ .getSetCookie()
+ .map((entry) => entry.split(";")[0])
+ .join("; ");
+ const created = await app.request("/api/auth/organization/create", {
+ method: "POST",
+ headers: { "content-type": "application/json", cookie },
+ body: JSON.stringify({ name: "Owned", slug: `owned-${randomUUID()}` }),
+ });
+ expect(created.status).toBe(200);
+ const workspace = (await created.json()) as { id: string };
+ const { project } = await createProjectFixture({
+ workspaceId: workspace.id,
+ });
+ const objectKey = `uploads/${randomUUID()}`;
+ await db.insert(schema.assetTable).values({
+ workspaceId: workspace.id,
+ projectId: project.id,
+ objectKey,
+ filename: "file.png",
+ mimeType: "image/png",
+ size: 3,
+ surface: "description",
+ });
+
+ const deleted = await app.request("/api/auth/organization/delete", {
+ method: "POST",
+ headers: { "content-type": "application/json", cookie },
+ body: JSON.stringify({ organizationId: workspace.id }),
+ });
+ expect(deleted.status).toBe(200);
+ expect(await readWorkspace(workspace.id)).toBeUndefined();
+ expect(
+ await db
+ .select({ objectKey: schema.storageCleanupTable.objectKey })
+ .from(schema.storageCleanupTable),
+ ).toEqual([{ objectKey }]);
+ });
+});
diff --git a/tests/api-integration/due-date-reminders.test.ts b/tests/api-integration/due-date-reminders.test.ts
index 80f14fb04..a3eb3b558 100644
--- a/tests/api-integration/due-date-reminders.test.ts
+++ b/tests/api-integration/due-date-reminders.test.ts
@@ -107,6 +107,13 @@ function remindersSentFor(taskId: string) {
.where(eq(schema.taskReminderSentTable.taskId, taskId));
}
+function archive(workspaceId: string) {
+ return db
+ .update(schema.workspaceTable)
+ .set({ archivedAt: new Date() })
+ .where(eq(schema.workspaceTable.id, workspaceId));
+}
+
describe("due date reminders", () => {
beforeEach(async () => {
await resetTestDatabase();
@@ -170,6 +177,18 @@ describe("due date reminders", () => {
expect(await notificationsFor(task.id)).toHaveLength(0);
});
+
+ it("stays silent while the workspace is archived", async () => {
+ const scene = await seedScene();
+ const task = await seedTask(scene, { status: "to-do" });
+ await archive(scene.workspace.id);
+
+ await checkDueDateReminders();
+
+ expect(await notificationsFor(task.id)).toHaveLength(0);
+ // Not claimed either, so nothing is marked as sent while archived.
+ expect(await remindersSentFor(task.id)).toHaveLength(0);
+ });
});
describe("project webhook due date reminders", () => {
@@ -226,4 +245,15 @@ describe("project webhook due date reminders", () => {
}),
]);
});
+
+ it("stays silent while the workspace is archived", async () => {
+ const scene = await seedScene();
+ await seedWebhookIntegration(scene.project.id);
+ await seedTask(scene, { status: "to-do" });
+ await archive(scene.workspace.id);
+
+ await checkProjectWebhookReminders();
+
+ expect(remindedTaskIds()).toEqual([]);
+ });
});
diff --git a/tests/api-integration/websocket-security.test.ts b/tests/api-integration/websocket-security.test.ts
index e2b95794e..146c75c55 100644
--- a/tests/api-integration/websocket-security.test.ts
+++ b/tests/api-integration/websocket-security.test.ts
@@ -380,3 +380,42 @@ describe("project WebSocket read authorization", () => {
expect(leaked).not.toHaveBeenCalled();
});
});
+
+describe("archived workspaces", () => {
+ const archive = () =>
+ db
+ .update(schema.workspaceTable)
+ .set({ archivedAt: new Date() })
+ .where(eq(schema.workspaceTable.id, workspaceId));
+
+ it("refuses project upgrades", async () => {
+ const headers = { authorization: "Bearer valid-test-session" };
+ const before = await connect(projectId, headers);
+ expect(before.status).toBe(101);
+ before.socket.terminate();
+
+ await archive();
+ expect((await connect(projectId, headers)).status).toBe(403);
+ });
+
+ it("closes project sockets a missed revocation left open", async () => {
+ await initializeWebSocketAdapter();
+ const { socket, status } = await connect(projectId, {
+ authorization: "Bearer valid-test-session",
+ });
+ expect(status).toBe(101);
+ const leaked = vi.fn();
+ socket.on("message", leaked);
+
+ // Archived without the admin route, so no revocation is sent.
+ await archive();
+ const closed = once(socket, "close");
+ broadcastToProject(projectId, {
+ type: "TASK_UPDATED",
+ projectId,
+ taskId: "private-task",
+ });
+ expect((await closed)[0]).toBe(1008);
+ expect(leaked).not.toHaveBeenCalled();
+ });
+});
diff --git a/tests/api-integration/workspace-archive-access.test.ts b/tests/api-integration/workspace-archive-access.test.ts
new file mode 100644
index 000000000..54746767b
--- /dev/null
+++ b/tests/api-integration/workspace-archive-access.test.ts
@@ -0,0 +1,423 @@
+import { randomBytes, randomUUID } from "node:crypto";
+import { eq } from "drizzle-orm";
+import { beforeEach, describe, expect, it, vi } from "vite-plus/test";
+import { auth } from "../../apps/api/src/auth";
+import db, { schema } from "../../apps/api/src/database";
+import { createApp } from "../../apps/api/src/index";
+import { findAllIntegrationsByGiteaRepo } from "../../apps/api/src/plugins/gitea/services/integration-lookup";
+import { getSyncIntegrations } from "../../apps/api/src/plugins/sync/integrations";
+import { createInstanceAdmin } from "./helpers/admin/create-instance-admin";
+import { mockAnonymousSession, mockAuthenticatedSession } from "./helpers/auth";
+import { signUpWithSession } from "./helpers/auth-session";
+import { resetTestDatabase } from "./helpers/database";
+import {
+ createProjectFixture,
+ createWorkspaceMember,
+} from "./helpers/fixtures";
+import { projectAccessApi } from "./helpers/project-access/project-access-api";
+
+vi.mock("../../apps/api/src/storage/s3", async (importOriginal) => ({
+ ...(await importOriginal<object>()),
+ getPrivateObject: vi.fn(async () => ({
+ body: new Uint8Array([1, 2, 3]),
+ contentType: "image/png",
+ contentLength: 3,
+ })),
+}));
+
+beforeEach(resetTestDatabase);
+
+function setArchived(workspaceId: string, archived: boolean) {
+ return db
+ .update(schema.workspaceTable)
+ .set({ archivedAt: archived ? new Date() : null })
+ .where(eq(schema.workspaceTable.id, workspaceId));
+}
+
+async function codeOf(response: Response) {
+ return ((await response.json()) as { code?: string }).code;
+}
+
+async function seed() {
+ const { user: member, workspace } = await createWorkspaceMember({
+ role: "owner",
+ });
+ const { project } = await createProjectFixture({ workspaceId: workspace.id });
+ const [task] = await db
+ .insert(schema.taskTable)
+ .values({ projectId: project.id, title: "Task", number: 1 })
+ .returning();
+ return { member, workspace, project, task };
+}
+
+describe("an archived workspace over HTTP", () => {
+ it("returns WORKSPACE_ARCHIVED to members and administrators, and 404 to outsiders", async () => {
+ const { member, workspace, project, task } = await seed();
+ const outsider = await createWorkspaceMember();
+ const admin = await createInstanceAdmin();
+ const paths = [
+ `/project?workspaceId=${workspace.id}`,
+ `/project/${project.id}`,
+ `/task/${task.id}`,
+ `/workspace/${workspace.id}/capabilities`,
+ `/workspace/${workspace.id}`,
+ ];
+
+ mockAuthenticatedSession(member);
+ for (const path of paths) {
+ expect((await projectAccessApi()(path)).status).toBe(200);
+ }
+
+ await setArchived(workspace.id, true);
+ for (const user of [member, admin]) {
+ vi.restoreAllMocks();
+ mockAuthenticatedSession(user);
+ for (const path of paths) {
+ const response = await projectAccessApi()(path);
+ expect(response.status, `${path} for ${user.id}`).toBe(403);
+ expect(await codeOf(response)).toBe("WORKSPACE_ARCHIVED");
+ }
+ }
+
+ vi.restoreAllMocks();
+ mockAuthenticatedSession(outsider.user);
+ for (const path of paths) {
+ expect((await projectAccessApi()(path)).status).toBe(404);
+ }
+ });
+
+ it("drops it from the member's workspace list until it is restored", async () => {
+ const { member, workspace } = await seed();
+ mockAuthenticatedSession(member);
+ const listIds = async () =>
+ (
+ (await (await projectAccessApi()("/workspace")).json()) as {
+ id: string;
+ }[]
+ ).map((entry) => entry.id);
+
+ expect(await listIds()).toEqual([workspace.id]);
+ await setArchived(workspace.id, true);
+ expect(await listIds()).toEqual([]);
+ await setArchived(workspace.id, false);
+ expect(await listIds()).toEqual([workspace.id]);
+ });
+
+ it("rejects the member's API keys, which MCP clients use", async () => {
+ const { member, workspace, task } = await seed();
+ const { key } = await auth.api.createApiKey({
+ body: { userId: member.id, name: "Archive test" },
+ });
+ const { app } = createApp();
+ const request = (headers: Record<string, string>) =>
+ app.request(`/api/task/${task.id}`, { headers });
+
+ expect((await request({ "x-api-key": key })).status).toBe(200);
+ await setArchived(workspace.id, true);
+ for (const headers of [
+ { "x-api-key": key },
+ { authorization: `Bearer ${key}` },
+ ]) {
+ const response = await request(headers);
+ expect(response.status).toBe(403);
+ expect(await codeOf(response)).toBe("WORKSPACE_ARCHIVED");
+ }
+ });
+
+ it("hides its notifications until it is restored", async () => {
+ const { member, workspace, task } = await seed();
+ await db.insert(schema.notificationTable).values({
+ userId: member.id,
+ title: "Task notification",
+ type: "task_assigned",
+ resourceId: task.id,
+ resourceType: "task",
+ });
+ mockAuthenticatedSession(member);
+ const count = async () =>
+ ((await (await projectAccessApi()("/notification")).json()) as unknown[])
+ .length;
+
+ expect(await count()).toBe(1);
+ await setArchived(workspace.id, true);
+ expect(await count()).toBe(0);
+ await setArchived(workspace.id, false);
+ expect(await count()).toBe(1);
+ });
+});
+
+describe("an archived workspace's public links", () => {
+ it("stops serving public boards, descriptions, assets, and calendar feeds", async () => {
+ const { member, workspace, project, task } = await seed();
+ await db
+ .update(schema.projectTable)
+ .set({ isPublic: true })
+ .where(eq(schema.projectTable.id, project.id));
+ const [asset] = await db
+ .insert(schema.assetTable)
+ .values({
+ workspaceId: workspace.id,
+ projectId: project.id,
+ taskId: task.id,
+ objectKey: randomUUID(),
+ filename: "image.png",
+ mimeType: "image/png",
+ size: 3,
+ surface: "description",
+ createdBy: member.id,
+ })
+ .returning();
+ const [feed] = await db
+ .insert(schema.calendarFeedTable)
+ .values({
+ projectId: project.id,
+ userId: member.id,
+ token: randomBytes(32).toString("hex"),
+ labelIds: [],
+ timeZone: "UTC",
+ })
+ .returning();
+ const paths = [
+ `/public-project/${project.id}`,
+ `/public-project/${project.id}/description?offset=0`,
+ `/public-project/${project.id}/task/${task.id}/description?offset=0`,
+ `/asset/${asset.id}`,
+ `/calendar-feed/${feed.token}/calendar.ics`,
+ ];
+ mockAnonymousSession();
+
+ for (const path of paths) {
+ expect((await projectAccessApi()(path)).status, path).toBe(200);
+ }
+ await setArchived(workspace.id, true);
+ for (const path of paths) {
+ expect((await projectAccessApi()(path)).status, path).toBe(404);
+ }
+ await setArchived(workspace.id, false);
+ for (const path of paths) {
+ expect((await projectAccessApi()(path)).status, path).toBe(200);
+ }
+ });
+});
+
+describe("an archived workspace's integrations", () => {
+ it("are skipped by webhook and sync lookups", async () => {
+ const { workspace, project } = await seed();
+ await db.insert(schema.integrationTable).values({
+ projectId: project.id,
+ type: "gitea",
+ isActive: true,
+ config: JSON.stringify({
+ baseUrl: "https://gitea.example.com",
+ repositoryOwner: "acme",
+ repositoryName: "app",
+ syncRules: { taskCreated: true },
+ }),
+ });
+ const lookup = () =>
+ findAllIntegrationsByGiteaRepo(
+ "https://gitea.example.com",
+ "acme",
+ "app",
+ );
+
+ expect(await lookup()).toHaveLength(1);
+ const syncedBefore = await getSyncIntegrations(project.id);
+
+ await setArchived(workspace.id, true);
+ expect(await lookup()).toEqual([]);
+ expect(await getSyncIntegrations(project.id)).toEqual([]);
+
+ await setArchived(workspace.id, false);
+ expect(await lookup()).toHaveLength(1);
+ expect(await getSyncIntegrations(project.id)).toHaveLength(
+ syncedBefore.length,
+ );
+ });
+});
+
+describe("an archived workspace through Better Auth organization endpoints", () => {
+ async function organizationFixture() {
+ const { app } = createApp();
+ const member = await signUpWithSession(app, {
+ email: "[email protected]",
+ name: "Member",
+ });
+ const outsider = await signUpWithSession(app, {
+ email: "[email protected]",
+ name: "Outsider",
+ });
+ const invitee = await signUpWithSession(app, {
+ email: "[email protected]",
+ name: "Invitee",
+ });
+ // Listing one's own invitations requires a verified email.
+ await db
+ .update(schema.userTable)
+ .set({ emailVerified: true })
+ .where(eq(schema.userTable.id, invitee.userId));
+ const [workspace] = await db
+ .insert(schema.workspaceTable)
+ .values({
+ name: "Archived org",
+ slug: `archived-${randomUUID()}`,
+ createdAt: new Date(),
+ })
+ .returning();
+ await db.insert(schema.workspaceUserTable).values({
+ workspaceId: workspace.id,
+ userId: member.userId,
+ role: "owner",
+ joinedAt: new Date(),
+ });
+ const [invitation] = await db
+ .insert(schema.invitationTable)
+ .values({
+ workspaceId: workspace.id,
+ inviterId: member.userId,
+ email: "[email protected]",
+ role: "member",
+ status: "pending",
+ expiresAt: new Date(Date.now() + 86_400_000),
+ })
+ .returning();
+ const call = (
+ cookies: string,
+ path: string,
+ body?: Record<string, unknown>,
+ ) =>
+ app.request(`/api${path}`, {
+ method: body ? "POST" : "GET",
+ headers: {
+ cookie: cookies,
+ origin: "http://localhost:5173",
+ ...(body ? { "content-type": "application/json" } : {}),
+ },
+ body: body ? JSON.stringify(body) : undefined,
+ });
+ return { member, outsider, invitee, workspace, invitation, call };
+ }
+
+ it("hides it from lists and blocks reads, activation, and invitations", async () => {
+ const { member, outsider, invitee, workspace, invitation, call } =
+ await organizationFixture();
+ const listed = async () =>
+ (
+ (await (
+ await call(member.cookies, "/auth/organization/list")
+ ).json()) as { id: string }[]
+ ).map((entry) => entry.id);
+ const invitationIds = async () =>
+ (
+ (await (
+ await call(
+ invitee.cookies,
+ "/auth/organization/list-user-invitations",
+ )
+ ).json()) as { id: string }[]
+ ).map((entry) => entry.id);
+ const pending = async () =>
+ (
+ (await (await call(invitee.cookies, "/invitation/pending")).json()) as {
+ id: string;
+ }[]
+ ).map((entry) => entry.id);
+
+ expect(await listed()).toEqual([workspace.id]);
+ expect(await invitationIds()).toEqual([invitation.id]);
+ expect(await pending()).toEqual([invitation.id]);
+
+ await setArchived(workspace.id, true);
+
+ expect(await listed()).toEqual([]);
+ expect(await invitationIds()).toEqual([]);
+ expect(await pending()).toEqual([]);
+ const details = await call(
+ invitee.cookies,
+ `/invitation/public/${invitation.id}`,
+ );
+ expect(((await details.json()) as { valid: boolean }).valid).toBe(false);
+
+ for (const response of [
+ await call(
+ invitee.cookies,
+ `/auth/organization/get-invitation?id=${invitation.id}`,
+ ),
+ await call(
+ member.cookies,
+ `/auth/organization/get-full-organization?organizationId=${workspace.id}`,
+ ),
+ await call(
+ member.cookies,
+ `/auth/organization/get-full-organization?organizationSlug=${workspace.slug}`,
+ ),
+ await call(member.cookies, "/auth/organization/set-active", {
+ organizationId: workspace.id,
+ }),
+ await call(member.cookies, "/auth/organization/update", {
+ organizationId: workspace.id,
+ data: { name: "Renamed" },
+ }),
+ await call(invitee.cookies, "/auth/organization/accept-invitation", {
+ invitationId: invitation.id,
+ }),
+ ]) {
+ expect(response.status).toBe(403);
+ expect(await codeOf(response)).toBe("WORKSPACE_ARCHIVED");
+ }
+
+ // Outsiders cannot tell an archived workspace from one they cannot read.
+ const probe = await call(
+ outsider.cookies,
+ `/auth/organization/get-full-organization?organizationSlug=${workspace.slug}`,
+ );
+ expect(probe.status).toBe(403);
+ expect(await codeOf(probe)).toBe("MISSING_PERMISSION");
+
+ // Leaving the archived workspace as the active one still works.
+ const cleared = await call(
+ member.cookies,
+ "/auth/organization/set-active",
+ {
+ organizationId: null,
+ },
+ );
+ expect(cleared.status).toBe(200);
+
+ const [stored] = await db
+ .select({ name: schema.workspaceTable.name })
+ .from(schema.workspaceTable)
+ .where(eq(schema.workspaceTable.id, workspace.id));
+ expect(stored?.name).toBe("Archived org");
+ const members = await db
+ .select()
+ .from(schema.workspaceUserTable)
+ .where(eq(schema.workspaceUserTable.workspaceId, workspace.id));
+ expect(members).toHaveLength(1);
+ });
+
+ it("blocks the archived workspace when it is the session's active one", async () => {
+ const { member, workspace, call } = await organizationFixture();
+ expect(
+ (
+ await call(member.cookies, "/auth/organization/set-active", {
+ organizationId: workspace.id,
+ })
+ ).status,
+ ).toBe(200);
+
+ await setArchived(workspace.id, true);
+ const response = await call(
+ member.cookies,
+ "/auth/organization/get-full-organization",
+ );
+ expect(response.status).toBe(403);
+ expect(await codeOf(response)).toBe("WORKSPACE_ARCHIVED");
+
+ await setArchived(workspace.id, false);
+ expect(
+ (await call(member.cookies, "/auth/organization/get-full-organization"))
+ .status,
+ ).toBe(200);
+ });
+});