Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(contact): external contacts of a workspace (#23202)

Arvin Xuf73d4ff52daf
diff --git a/apps/server/src/routers/lambda/contact.ts b/apps/server/src/routers/lambda/contact.ts
index 84a64186c76..23f22729274 100644
--- a/apps/server/src/routers/lambda/contact.ts
+++ b/apps/server/src/routers/lambda/contact.ts
@@ -14,9 +14,9 @@ import { notifyContactRequestAfterResponse } from '@/server/services/contact/not
/**
* The address book belongs to the Channel experience: contacts are who you can message there.
- * People are personal and listed only in the personal space; a workspace's colleagues are its
- * members. Shared Agents belong to the active scope: the caller's own in the personal space, the
- * workspace's β€” seen by every member β€” in a workspace.
+ * Everything in it belongs to the active scope. People: personal contacts in the personal space;
+ * in a workspace, its external contacts (colleagues are its members). Shared Agents: the caller's
+ * own in the personal space, the workspace's β€” seen by every member β€” in a workspace.
*/
const contactProcedure = wsCompatProcedure.use(serverDatabase).use(async ({ ctx, next }) => {
if (!(await isChannelEnabled(ctx.userId)))
@@ -45,7 +45,9 @@ export const contactRouter = router({
listRequests: contactProcedure.query(async ({ ctx }) => ctx.contactModel.listRequests()),
+ // In a workspace this invites someone outside it to be an external contact: a member's act.
sendRequest: contactProcedure
+ .use(requireWorkspaceRoleWhenScoped('member'))
.input(
z.object({
message: z.string().max(CONTACT_REQUEST_MESSAGE_MAX_LENGTH).optional(),
@@ -96,6 +98,24 @@ export const contactRouter = router({
return { success: true };
}),
+ /** A member opens themselves to one of the workspace's external contacts. */
+ openToExternal: contactProcedure
+ .use(requireWorkspaceRoleWhenScoped('member'))
+ .input(z.object({ userId }))
+ .mutation(async ({ ctx, input }) => {
+ await ctx.contactModel.openTo(input.userId);
+ return { success: true };
+ }),
+
+ /** An owner or admin removes an external contact from the workspace. */
+ removeExternal: contactProcedure
+ .use(requireWorkspaceRoleWhenScoped('admin'))
+ .input(z.object({ userId }))
+ .mutation(async ({ ctx, input }) => {
+ await ctx.contactModel.removeExternal(input.userId);
+ return { success: true };
+ }),
+
/** A person's profile, their relation to me and the Agents they share by link. */
userProfile: contactProcedure.input(z.object({ userId })).query(async ({ ctx, input }) => {
const [user, relation, sharedAgents] = await Promise.all([
diff --git a/docs/development/database-schema.dbml b/docs/development/database-schema.dbml
index b70b98cefb0..6d90e3bea83 100644
--- a/docs/development/database-schema.dbml
+++ b/docs/development/database-schema.dbml
@@ -1896,6 +1896,7 @@ table user_contact_requests {
id uuid [pk, not null, default: `gen_random_uuid()`]
requester_id text [not null]
addressee_id text [not null]
+ workspace_id text
message text
status text [not null, default: 'pending']
responded_at "timestamp with time zone"
@@ -1905,8 +1906,10 @@ table user_contact_requests {
indexes {
(requester_id, addressee_id) [name: 'user_contact_requests_pending_unique', unique]
+ (workspace_id, requester_id, addressee_id) [name: 'user_contact_requests_workspace_pending_unique', unique]
(addressee_id, status) [name: 'user_contact_requests_addressee_status_idx']
(requester_id, status) [name: 'user_contact_requests_requester_status_idx']
+ workspace_id [name: 'user_contact_requests_workspace_id_idx']
}
}
@@ -1959,10 +1962,12 @@ table user_contacts {
indexes {
(user_id, contact_user_id) [name: 'user_contacts_user_unique', unique]
+ (workspace_id, user_id, contact_user_id) [name: 'user_contacts_workspace_user_unique', unique]
(user_id, agent_id) [name: 'user_contacts_agent_unique', unique]
(workspace_id, agent_id) [name: 'user_contacts_workspace_agent_unique', unique]
contact_user_id [name: 'user_contacts_contact_user_id_idx']
agent_id [name: 'user_contacts_agent_id_idx']
+ workspace_id [name: 'user_contacts_workspace_id_idx']
}
}
diff --git a/packages/database/migrations/0219_contacts_external_contacts.sql b/packages/database/migrations/0219_contacts_external_contacts.sql
new file mode 100644
index 00000000000..8a5eea8c07a
--- /dev/null
+++ b/packages/database/migrations/0219_contacts_external_contacts.sql
@@ -0,0 +1,11 @@
+DROP INDEX IF EXISTS "user_contact_requests_pending_unique";--> statement-breakpoint
+DROP INDEX IF EXISTS "user_contacts_user_unique";--> statement-breakpoint
+ALTER TABLE "user_contact_requests" ADD COLUMN IF NOT EXISTS "workspace_id" text;--> statement-breakpoint
+ALTER TABLE "user_contact_requests" DROP CONSTRAINT IF EXISTS "user_contact_requests_workspace_id_workspaces_id_fk";--> statement-breakpoint
+ALTER TABLE "user_contact_requests" ADD CONSTRAINT "user_contact_requests_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "user_contact_requests_workspace_pending_unique" ON "user_contact_requests" USING btree ("workspace_id","requester_id","addressee_id") WHERE "user_contact_requests"."status" = 'pending' AND "user_contact_requests"."workspace_id" IS NOT NULL;--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "user_contact_requests_workspace_id_idx" ON "user_contact_requests" USING btree ("workspace_id");--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "user_contacts_workspace_user_unique" ON "user_contacts" USING btree ("workspace_id","user_id","contact_user_id") WHERE "user_contacts"."contact_user_id" IS NOT NULL AND "user_contacts"."workspace_id" IS NOT NULL;--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "user_contacts_workspace_id_idx" ON "user_contacts" USING btree ("workspace_id");--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "user_contact_requests_pending_unique" ON "user_contact_requests" USING btree ("requester_id","addressee_id") WHERE "user_contact_requests"."status" = 'pending' AND "user_contact_requests"."workspace_id" IS NULL;--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "user_contacts_user_unique" ON "user_contacts" USING btree ("user_id","contact_user_id") WHERE "user_contacts"."contact_user_id" IS NOT NULL AND "user_contacts"."workspace_id" IS NULL;
diff --git a/packages/database/migrations/meta/0209_snapshot.json b/packages/database/migrations/meta/0219_snapshot.json
similarity index 93%
rename from packages/database/migrations/meta/0209_snapshot.json
rename to packages/database/migrations/meta/0219_snapshot.json
index 43a8ba7abb2..2e9d27b6221 100644
--- a/packages/database/migrations/meta/0209_snapshot.json
+++ b/packages/database/migrations/meta/0219_snapshot.json
@@ -6,9 +6,9 @@
},
"dialect": "postgresql",
"enums": {},
- "id": "c1058806-e910-4f65-99ad-9f434bc92441",
+ "id": "f353e57e-aad8-4a85-81e3-07fad5564c60",
"policies": {},
- "prevId": "1e746038-7134-4368-b581-34f87c1b9b32",
+ "prevId": "f333c27e-af69-4fc7-bb95-59bf849ced71",
"roles": {},
"schemas": {},
"sequences": {
@@ -132,6 +132,12 @@
"primaryKey": false,
"notNull": false
},
+ "review_mark_id": {
+ "name": "review_mark_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
"client_id": {
"name": "client_id",
"type": "text",
@@ -300,6 +306,21 @@
"concurrently": false,
"method": "btree",
"with": {}
+ },
+ "acceptance_comments_review_mark_id_idx": {
+ "name": "acceptance_comments_review_mark_id_idx",
+ "columns": [
+ {
+ "expression": "review_mark_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
}
},
"foreignKeys": {
@@ -366,6 +387,15 @@
"onDelete": "set null",
"onUpdate": "no action"
},
+ "acceptance_comments_review_mark_id_acceptance_review_marks_id_fk": {
+ "name": "acceptance_comments_review_mark_id_acceptance_review_marks_id_fk",
+ "tableFrom": "acceptance_comments",
+ "tableTo": "acceptance_review_marks",
+ "columnsFrom": ["review_mark_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
"acceptance_comments_resolved_by_user_id_users_id_fk": {
"name": "acceptance_comments_resolved_by_user_id_users_id_fk",
"tableFrom": "acceptance_comments",
@@ -741,6 +771,450 @@
"checkConstraints": {},
"isRLSEnabled": false
},
+ "public.acceptance_review_marks": {
+ "name": "acceptance_review_marks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "review_id": {
+ "name": "review_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "seq": {
+ "name": "seq",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "page_meta": {
+ "name": "page_meta",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rect_document": {
+ "name": "rect_document",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rect_viewport": {
+ "name": "rect_viewport",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scroll": {
+ "name": "scroll",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "viewport": {
+ "name": "viewport",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "regions": {
+ "name": "regions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "region_refs": {
+ "name": "region_refs",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "targets": {
+ "name": "targets",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sketch": {
+ "name": "sketch",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "context": {
+ "name": "context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "screenshot_file_id": {
+ "name": "screenshot_file_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "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": {
+ "acceptance_review_marks_review_id_client_id_unique": {
+ "name": "acceptance_review_marks_review_id_client_id_unique",
+ "columns": [
+ {
+ "expression": "review_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_review_marks_review_id_seq_unique": {
+ "name": "acceptance_review_marks_review_id_seq_unique",
+ "columns": [
+ {
+ "expression": "review_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "seq",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_review_marks_route_key_review_id_idx": {
+ "name": "acceptance_review_marks_route_key_review_id_idx",
+ "columns": [
+ {
+ "expression": "route_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "review_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "acceptance_review_marks_review_id_acceptance_reviews_id_fk": {
+ "name": "acceptance_review_marks_review_id_acceptance_reviews_id_fk",
+ "tableFrom": "acceptance_review_marks",
+ "tableTo": "acceptance_reviews",
+ "columnsFrom": ["review_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "acceptance_review_marks_screenshot_file_id_files_id_fk": {
+ "name": "acceptance_review_marks_screenshot_file_id_files_id_fk",
+ "tableFrom": "acceptance_review_marks",
+ "tableTo": "files",
+ "columnsFrom": ["screenshot_file_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.acceptance_reviews": {
+ "name": "acceptance_reviews",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "site_id": {
+ "name": "site_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'draft'"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_mark_seq": {
+ "name": "last_mark_seq",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "submitted_at": {
+ "name": "submitted_at",
+ "type": "timestamp with time zone",
+ "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": {
+ "acceptance_reviews_site_id_created_at_idx": {
+ "name": "acceptance_reviews_site_id_created_at_idx",
+ "columns": [
+ {
+ "expression": "site_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_reviews_task_id_idx": {
+ "name": "acceptance_reviews_task_id_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_reviews_user_id_idx": {
+ "name": "acceptance_reviews_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_reviews_workspace_id_idx": {
+ "name": "acceptance_reviews_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_reviews_one_draft_per_user_unique": {
+ "name": "acceptance_reviews_one_draft_per_user_unique",
+ "columns": [
+ {
+ "expression": "site_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"acceptance_reviews\".\"status\" = 'draft'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "acceptance_reviews_site_id_project_sites_id_fk": {
+ "name": "acceptance_reviews_site_id_project_sites_id_fk",
+ "tableFrom": "acceptance_reviews",
+ "tableTo": "project_sites",
+ "columnsFrom": ["site_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "acceptance_reviews_user_id_users_id_fk": {
+ "name": "acceptance_reviews_user_id_users_id_fk",
+ "tableFrom": "acceptance_reviews",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "acceptance_reviews_workspace_id_workspaces_id_fk": {
+ "name": "acceptance_reviews_workspace_id_workspaces_id_fk",
+ "tableFrom": "acceptance_reviews",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "acceptance_reviews_project_id_projects_id_fk": {
+ "name": "acceptance_reviews_project_id_projects_id_fk",
+ "tableFrom": "acceptance_reviews",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "acceptance_reviews_task_id_tasks_id_fk": {
+ "name": "acceptance_reviews_task_id_tasks_id_fk",
+ "tableFrom": "acceptance_reviews",
+ "tableTo": "tasks",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
"public.agents": {
"name": "agents",
"schema": "",
@@ -7383,6 +7857,27 @@
"method": "btree",
"with": {}
},
+ "agent_operations_workspace_id_created_at_idx": {
+ "name": "agent_operations_workspace_id_created_at_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": {}
+ },
"agent_operations_metadata_idx": {
"name": "agent_operations_metadata_idx",
"columns": [
@@ -10432,8 +10927,8 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.async_tasks": {
- "name": "async_tasks",
+ "public.artboard_boards": {
+ "name": "artboard_boards",
"schema": "",
"columns": {
"id": {
@@ -10443,26 +10938,402 @@
"notNull": true,
"default": "gen_random_uuid()"
},
+ "artboard_id": {
+ "name": "artboard_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "page_id": {
+ "name": "page_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "round_id": {
+ "name": "round_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "acceptance_flow_node_id": {
+ "name": "acceptance_flow_node_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
"notNull": false
},
- "status": {
- "name": "status",
+ "expected": {
+ "name": "expected",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "error": {
- "name": "error",
+ "rect": {
+ "name": "rect",
"type": "jsonb",
"primaryKey": false,
+ "notNull": true
+ },
+ "source_work_version_id": {
+ "name": "source_work_version_id",
+ "type": "uuid",
+ "primaryKey": false,
"notNull": false
},
- "inference_id": {
- "name": "inference_id",
+ "source_path": {
+ "name": "source_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_file_id": {
+ "name": "source_file_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "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": {
+ "artboard_boards_artboard_id_idx": {
+ "name": "artboard_boards_artboard_id_idx",
+ "columns": [
+ {
+ "expression": "artboard_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_boards_page_id_idx": {
+ "name": "artboard_boards_page_id_idx",
+ "columns": [
+ {
+ "expression": "page_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_boards_group_id_idx": {
+ "name": "artboard_boards_group_id_idx",
+ "columns": [
+ {
+ "expression": "group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"artboard_boards\".\"group_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_boards_round_id_idx": {
+ "name": "artboard_boards_round_id_idx",
+ "columns": [
+ {
+ "expression": "round_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"artboard_boards\".\"round_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_boards_project_id_idx": {
+ "name": "artboard_boards_project_id_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"artboard_boards\".\"project_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_boards_acceptance_flow_node_id_unique": {
+ "name": "artboard_boards_acceptance_flow_node_id_unique",
+ "columns": [
+ {
+ "expression": "acceptance_flow_node_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"artboard_boards\".\"acceptance_flow_node_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_boards_source_work_version_id_idx": {
+ "name": "artboard_boards_source_work_version_id_idx",
+ "columns": [
+ {
+ "expression": "source_work_version_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"artboard_boards\".\"source_work_version_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_boards_user_id_idx": {
+ "name": "artboard_boards_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_boards_workspace_id_idx": {
+ "name": "artboard_boards_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"artboard_boards\".\"workspace_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "artboard_boards_artboard_id_artboards_id_fk": {
+ "name": "artboard_boards_artboard_id_artboards_id_fk",
+ "tableFrom": "artboard_boards",
+ "tableTo": "artboards",
+ "columnsFrom": ["artboard_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "artboard_boards_page_id_artboard_pages_id_fk": {
+ "name": "artboard_boards_page_id_artboard_pages_id_fk",
+ "tableFrom": "artboard_boards",
+ "tableTo": "artboard_pages",
+ "columnsFrom": ["page_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "artboard_boards_group_id_artboard_groups_id_fk": {
+ "name": "artboard_boards_group_id_artboard_groups_id_fk",
+ "tableFrom": "artboard_boards",
+ "tableTo": "artboard_groups",
+ "columnsFrom": ["group_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "artboard_boards_round_id_artboard_rounds_id_fk": {
+ "name": "artboard_boards_round_id_artboard_rounds_id_fk",
+ "tableFrom": "artboard_boards",
+ "tableTo": "artboard_rounds",
+ "columnsFrom": ["round_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "artboard_boards_user_id_users_id_fk": {
+ "name": "artboard_boards_user_id_users_id_fk",
+ "tableFrom": "artboard_boards",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "artboard_boards_workspace_id_workspaces_id_fk": {
+ "name": "artboard_boards_workspace_id_workspaces_id_fk",
+ "tableFrom": "artboard_boards",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "artboard_boards_project_id_projects_id_fk": {
+ "name": "artboard_boards_project_id_projects_id_fk",
+ "tableFrom": "artboard_boards",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "artboard_boards_source_work_version_id_work_versions_id_fk": {
+ "name": "artboard_boards_source_work_version_id_work_versions_id_fk",
+ "tableFrom": "artboard_boards",
+ "tableTo": "work_versions",
+ "columnsFrom": ["source_work_version_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "artboard_boards_source_file_id_files_id_fk": {
+ "name": "artboard_boards_source_file_id_files_id_fk",
+ "tableFrom": "artboard_boards",
+ "tableTo": "files",
+ "columnsFrom": ["source_file_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "artboard_boards_single_source_check": {
+ "name": "artboard_boards_single_source_check",
+ "value": "num_nonnulls(\"artboard_boards\".\"source_work_version_id\", \"artboard_boards\".\"source_file_id\") <= 1"
+ },
+ "artboard_boards_decision_no_source_check": {
+ "name": "artboard_boards_decision_no_source_check",
+ "value": "\"artboard_boards\".\"type\" <> 'decision' OR num_nonnulls(\"artboard_boards\".\"source_work_version_id\", \"artboard_boards\".\"source_file_id\", \"artboard_boards\".\"source_path\") = 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.artboard_comments": {
+ "name": "artboard_comments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "artboard_id": {
+ "name": "artboard_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_comment_id": {
+ "name": "parent_comment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_user_id": {
+ "name": "author_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_agent_id": {
+ "name": "author_agent_id",
"type": "text",
"primaryKey": false,
"notNull": false
@@ -10479,24 +11350,65 @@
"primaryKey": false,
"notNull": false
},
- "duration": {
- "name": "duration",
- "type": "integer",
+ "page_id": {
+ "name": "page_id",
+ "type": "text",
"primaryKey": false,
"notNull": false
},
- "parent_id": {
- "name": "parent_id",
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "board_id": {
+ "name": "board_id",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "anchor": {
+ "name": "anchor",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "delivered_at": {
+ "name": "delivered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolved_at": {
+ "name": "resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolved_by_user_id": {
+ "name": "resolved_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
"metadata": {
"name": "metadata",
"type": "jsonb",
"primaryKey": false,
- "notNull": true,
- "default": "'{}'"
+ "notNull": false
},
"accessed_at": {
"name": "accessed_at",
@@ -10521,11 +11433,44 @@
}
},
"indexes": {
- "async_tasks_user_id_idx": {
- "name": "async_tasks_user_id_idx",
+ "artboard_comments_artboard_id_author_user_id_client_id_unique": {
+ "name": "artboard_comments_artboard_id_author_user_id_client_id_unique",
"columns": [
{
- "expression": "user_id",
+ "expression": "artboard_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "author_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_comments_artboard_id_created_at_idx": {
+ "name": "artboard_comments_artboard_id_created_at_idx",
+ "columns": [
+ {
+ "expression": "artboard_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -10536,11 +11481,11 @@
"method": "btree",
"with": {}
},
- "async_tasks_parent_id_idx": {
- "name": "async_tasks_parent_id_idx",
+ "artboard_comments_parent_comment_id_idx": {
+ "name": "artboard_comments_parent_comment_id_idx",
"columns": [
{
- "expression": "parent_id",
+ "expression": "parent_comment_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -10551,17 +11496,26 @@
"method": "btree",
"with": {}
},
- "async_tasks_type_status_idx": {
- "name": "async_tasks_type_status_idx",
+ "artboard_comments_board_id_idx": {
+ "name": "artboard_comments_board_id_idx",
"columns": [
{
- "expression": "type",
+ "expression": "board_id",
"isExpression": false,
"asc": true,
"nulls": "last"
- },
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_comments_user_id_idx": {
+ "name": "artboard_comments_user_id_idx",
+ "columns": [
{
- "expression": "status",
+ "expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -10572,26 +11526,27 @@
"method": "btree",
"with": {}
},
- "async_tasks_inference_id_idx": {
- "name": "async_tasks_inference_id_idx",
+ "artboard_comments_workspace_id_idx": {
+ "name": "artboard_comments_workspace_id_idx",
"columns": [
{
- "expression": "inference_id",
+ "expression": "workspace_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
+ "where": "\"artboard_comments\".\"workspace_id\" IS NOT NULL",
"concurrently": false,
"method": "btree",
"with": {}
},
- "async_tasks_metadata_idx": {
- "name": "async_tasks_metadata_idx",
+ "artboard_comments_page_id_idx": {
+ "name": "artboard_comments_page_id_idx",
"columns": [
{
- "expression": "metadata",
+ "expression": "page_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -10599,43 +11554,116 @@
],
"isUnique": false,
"concurrently": false,
- "method": "gin",
+ "method": "btree",
"with": {}
},
- "async_tasks_workspace_id_idx": {
- "name": "async_tasks_workspace_id_idx",
+ "artboard_comments_group_id_idx": {
+ "name": "artboard_comments_group_id_idx",
"columns": [
{
- "expression": "workspace_id",
+ "expression": "group_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
+ "where": "\"artboard_comments\".\"group_id\" IS NOT NULL",
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
- "async_tasks_user_id_users_id_fk": {
- "name": "async_tasks_user_id_users_id_fk",
- "tableFrom": "async_tasks",
+ "artboard_comments_artboard_id_artboards_id_fk": {
+ "name": "artboard_comments_artboard_id_artboards_id_fk",
+ "tableFrom": "artboard_comments",
+ "tableTo": "artboards",
+ "columnsFrom": ["artboard_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "artboard_comments_parent_comment_id_artboard_comments_id_fk": {
+ "name": "artboard_comments_parent_comment_id_artboard_comments_id_fk",
+ "tableFrom": "artboard_comments",
+ "tableTo": "artboard_comments",
+ "columnsFrom": ["parent_comment_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "artboard_comments_author_user_id_users_id_fk": {
+ "name": "artboard_comments_author_user_id_users_id_fk",
+ "tableFrom": "artboard_comments",
+ "tableTo": "users",
+ "columnsFrom": ["author_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "artboard_comments_author_agent_id_agents_id_fk": {
+ "name": "artboard_comments_author_agent_id_agents_id_fk",
+ "tableFrom": "artboard_comments",
+ "tableTo": "agents",
+ "columnsFrom": ["author_agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "artboard_comments_user_id_users_id_fk": {
+ "name": "artboard_comments_user_id_users_id_fk",
+ "tableFrom": "artboard_comments",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "async_tasks_workspace_id_workspaces_id_fk": {
- "name": "async_tasks_workspace_id_workspaces_id_fk",
- "tableFrom": "async_tasks",
+ "artboard_comments_workspace_id_workspaces_id_fk": {
+ "name": "artboard_comments_workspace_id_workspaces_id_fk",
+ "tableFrom": "artboard_comments",
"tableTo": "workspaces",
"columnsFrom": ["workspace_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
+ },
+ "artboard_comments_page_id_artboard_pages_id_fk": {
+ "name": "artboard_comments_page_id_artboard_pages_id_fk",
+ "tableFrom": "artboard_comments",
+ "tableTo": "artboard_pages",
+ "columnsFrom": ["page_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "artboard_comments_group_id_artboard_groups_id_fk": {
+ "name": "artboard_comments_group_id_artboard_groups_id_fk",
+ "tableFrom": "artboard_comments",
+ "tableTo": "artboard_groups",
+ "columnsFrom": ["group_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "artboard_comments_board_id_artboard_boards_id_fk": {
+ "name": "artboard_comments_board_id_artboard_boards_id_fk",
+ "tableFrom": "artboard_comments",
+ "tableTo": "artboard_boards",
+ "columnsFrom": ["board_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "artboard_comments_resolved_by_user_id_users_id_fk": {
+ "name": "artboard_comments_resolved_by_user_id_users_id_fk",
+ "tableFrom": "artboard_comments",
+ "tableTo": "users",
+ "columnsFrom": ["resolved_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
@@ -10644,93 +11672,188 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.accounts": {
- "name": "accounts",
+ "public.artboard_edges": {
+ "name": "artboard_edges",
"schema": "",
"columns": {
- "access_token": {
- "name": "access_token",
- "type": "text",
- "primaryKey": false,
- "notNull": false
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
},
- "access_token_expires_at": {
- "name": "access_token_expires_at",
- "type": "timestamp",
+ "artboard_id": {
+ "name": "artboard_id",
+ "type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "account_id": {
- "name": "account_id",
- "type": "text",
+ "source_board_id": {
+ "name": "source_board_id",
+ "type": "uuid",
"primaryKey": false,
"notNull": true
},
- "created_at": {
- "name": "created_at",
- "type": "timestamp",
+ "target_board_id": {
+ "name": "target_board_id",
+ "type": "uuid",
"primaryKey": false,
- "notNull": true,
- "default": "now()"
+ "notNull": true
},
- "id": {
- "name": "id",
+ "user_id": {
+ "name": "user_id",
"type": "text",
- "primaryKey": true,
+ "primaryKey": false,
"notNull": true
},
- "id_token": {
- "name": "id_token",
+ "workspace_id": {
+ "name": "workspace_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "password": {
- "name": "password",
- "type": "text",
+ "acceptance_flow_edge_id": {
+ "name": "acceptance_flow_edge_id",
+ "type": "uuid",
"primaryKey": false,
"notNull": false
},
- "provider_id": {
- "name": "provider_id",
+ "label": {
+ "name": "label",
"type": "text",
"primaryKey": false,
- "notNull": true
+ "notNull": true,
+ "default": "''"
},
- "refresh_token": {
- "name": "refresh_token",
+ "condition": {
+ "name": "condition",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "refresh_token_expires_at": {
- "name": "refresh_token_expires_at",
- "type": "timestamp",
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
"primaryKey": false,
- "notNull": false
+ "notNull": true,
+ "default": false
},
- "scope": {
- "name": "scope",
- "type": "text",
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
"primaryKey": false,
"notNull": false
},
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp",
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": true
+ "notNull": true,
+ "default": "now()"
},
- "user_id": {
- "name": "user_id",
- "type": "text",
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": true
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
}
},
"indexes": {
- "account_userId_idx": {
- "name": "account_userId_idx",
+ "artboard_edges_artboard_id_idx": {
+ "name": "artboard_edges_artboard_id_idx",
+ "columns": [
+ {
+ "expression": "artboard_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_edges_source_board_id_idx": {
+ "name": "artboard_edges_source_board_id_idx",
+ "columns": [
+ {
+ "expression": "source_board_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_edges_source_board_id_default_unique": {
+ "name": "artboard_edges_source_board_id_default_unique",
+ "columns": [
+ {
+ "expression": "source_board_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"artboard_edges\".\"is_default\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_edges_target_board_id_idx": {
+ "name": "artboard_edges_target_board_id_idx",
+ "columns": [
+ {
+ "expression": "target_board_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_edges_acceptance_flow_edge_id_unique": {
+ "name": "artboard_edges_acceptance_flow_edge_id_unique",
+ "columns": [
+ {
+ "expression": "acceptance_flow_edge_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"artboard_edges\".\"acceptance_flow_edge_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_edges_user_id_idx": {
+ "name": "artboard_edges_user_id_idx",
"columns": [
{
"expression": "user_id",
@@ -10743,17 +11866,69 @@
"concurrently": false,
"method": "btree",
"with": {}
+ },
+ "artboard_edges_workspace_id_idx": {
+ "name": "artboard_edges_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"artboard_edges\".\"workspace_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
}
},
"foreignKeys": {
- "accounts_user_id_users_id_fk": {
- "name": "accounts_user_id_users_id_fk",
- "tableFrom": "accounts",
+ "artboard_edges_artboard_id_artboards_id_fk": {
+ "name": "artboard_edges_artboard_id_artboards_id_fk",
+ "tableFrom": "artboard_edges",
+ "tableTo": "artboards",
+ "columnsFrom": ["artboard_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "artboard_edges_source_board_id_artboard_boards_id_fk": {
+ "name": "artboard_edges_source_board_id_artboard_boards_id_fk",
+ "tableFrom": "artboard_edges",
+ "tableTo": "artboard_boards",
+ "columnsFrom": ["source_board_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "artboard_edges_target_board_id_artboard_boards_id_fk": {
+ "name": "artboard_edges_target_board_id_artboard_boards_id_fk",
+ "tableFrom": "artboard_edges",
+ "tableTo": "artboard_boards",
+ "columnsFrom": ["target_board_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "artboard_edges_user_id_users_id_fk": {
+ "name": "artboard_edges_user_id_users_id_fk",
+ "tableFrom": "artboard_edges",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
+ },
+ "artboard_edges_workspace_id_workspaces_id_fk": {
+ "name": "artboard_edges_workspace_id_workspaces_id_fk",
+ "tableFrom": "artboard_edges",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
@@ -10762,116 +11937,188 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.passkey": {
- "name": "passkey",
+ "public.artboard_groups": {
+ "name": "artboard_groups",
"schema": "",
"columns": {
- "aaguid": {
- "name": "aaguid",
+ "id": {
+ "name": "id",
"type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "backedUp": {
- "name": "backedUp",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
+ "primaryKey": true,
+ "notNull": true
},
- "counter": {
- "name": "counter",
- "type": "integer",
+ "artboard_id": {
+ "name": "artboard_id",
+ "type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "createdAt": {
- "name": "createdAt",
- "type": "timestamp",
+ "page_id": {
+ "name": "page_id",
+ "type": "text",
"primaryKey": false,
- "notNull": false,
- "default": "now()"
+ "notNull": true
},
- "credentialID": {
- "name": "credentialID",
+ "user_id": {
+ "name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "deviceType": {
- "name": "deviceType",
+ "workspace_id": {
+ "name": "workspace_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "id": {
- "name": "id",
+ "kind": {
+ "name": "kind",
"type": "text",
- "primaryKey": true,
+ "primaryKey": false,
"notNull": true
},
- "name": {
- "name": "name",
+ "title": {
+ "name": "title",
"type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "publicKey": {
- "name": "publicKey",
+ "description": {
+ "name": "description",
"type": "text",
"primaryKey": false,
+ "notNull": false
+ },
+ "rect": {
+ "name": "rect",
+ "type": "jsonb",
+ "primaryKey": false,
"notNull": true
},
- "transports": {
- "name": "transports",
- "type": "text",
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
"primaryKey": false,
"notNull": false
},
- "userId": {
- "name": "userId",
- "type": "text",
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": true
+ "notNull": true,
+ "default": "now()"
+ },
+ "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": {
- "passkey_credential_id_unique": {
- "name": "passkey_credential_id_unique",
+ "artboard_groups_artboard_id_idx": {
+ "name": "artboard_groups_artboard_id_idx",
"columns": [
{
- "expression": "credentialID",
+ "expression": "artboard_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
- "isUnique": true,
+ "isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
- "passkey_user_id_idx": {
- "name": "passkey_user_id_idx",
+ "artboard_groups_page_id_idx": {
+ "name": "artboard_groups_page_id_idx",
"columns": [
{
- "expression": "userId",
+ "expression": "page_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_groups_user_id_idx": {
+ "name": "artboard_groups_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_groups_workspace_id_idx": {
+ "name": "artboard_groups_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
+ "where": "\"artboard_groups\".\"workspace_id\" IS NOT NULL",
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
- "passkey_userId_users_id_fk": {
- "name": "passkey_userId_users_id_fk",
- "tableFrom": "passkey",
+ "artboard_groups_artboard_id_artboards_id_fk": {
+ "name": "artboard_groups_artboard_id_artboards_id_fk",
+ "tableFrom": "artboard_groups",
+ "tableTo": "artboards",
+ "columnsFrom": ["artboard_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "artboard_groups_page_id_artboard_pages_id_fk": {
+ "name": "artboard_groups_page_id_artboard_pages_id_fk",
+ "tableFrom": "artboard_groups",
+ "tableTo": "artboard_pages",
+ "columnsFrom": ["page_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "artboard_groups_user_id_users_id_fk": {
+ "name": "artboard_groups_user_id_users_id_fk",
+ "tableFrom": "artboard_groups",
"tableTo": "users",
- "columnsFrom": ["userId"],
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "artboard_groups_workspace_id_workspaces_id_fk": {
+ "name": "artboard_groups_workspace_id_workspaces_id_fk",
+ "tableFrom": "artboard_groups",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
@@ -10883,124 +12130,177 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.auth_sessions": {
- "name": "auth_sessions",
+ "public.artboard_pages": {
+ "name": "artboard_pages",
"schema": "",
"columns": {
- "created_at": {
- "name": "created_at",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
- "impersonated_by": {
- "name": "impersonated_by",
+ "artboard_id": {
+ "name": "artboard_id",
"type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "ip_address": {
- "name": "ip_address",
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "token": {
- "name": "token",
+ "name": {
+ "name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp",
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
"primaryKey": false,
- "notNull": true
+ "notNull": true,
+ "default": 0
},
- "user_agent": {
- "name": "user_agent",
- "type": "text",
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
"primaryKey": false,
"notNull": false
},
- "user_id": {
- "name": "user_id",
- "type": "text",
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "auth_session_userId_idx": {
- "name": "auth_session_userId_idx",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
+ "notNull": true,
+ "default": "now()"
+ },
+ "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": {
+ "artboard_pages_artboard_id_idx": {
+ "name": "artboard_pages_artboard_id_idx",
+ "columns": [
+ {
+ "expression": "artboard_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_pages_user_id_idx": {
+ "name": "artboard_pages_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_pages_workspace_id_idx": {
+ "name": "artboard_pages_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
"nulls": "last"
}
],
"isUnique": false,
+ "where": "\"artboard_pages\".\"workspace_id\" IS NOT NULL",
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
- "auth_sessions_user_id_users_id_fk": {
- "name": "auth_sessions_user_id_users_id_fk",
- "tableFrom": "auth_sessions",
+ "artboard_pages_artboard_id_artboards_id_fk": {
+ "name": "artboard_pages_artboard_id_artboards_id_fk",
+ "tableFrom": "artboard_pages",
+ "tableTo": "artboards",
+ "columnsFrom": ["artboard_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "artboard_pages_user_id_users_id_fk": {
+ "name": "artboard_pages_user_id_users_id_fk",
+ "tableFrom": "artboard_pages",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
+ },
+ "artboard_pages_workspace_id_workspaces_id_fk": {
+ "name": "artboard_pages_workspace_id_workspaces_id_fk",
+ "tableFrom": "artboard_pages",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
- "uniqueConstraints": {
- "auth_sessions_token_unique": {
- "name": "auth_sessions_token_unique",
- "nullsNotDistinct": false,
- "columns": ["token"]
- }
- },
+ "uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.two_factor": {
- "name": "two_factor",
+ "public.artboard_rounds": {
+ "name": "artboard_rounds",
"schema": "",
"columns": {
- "backup_codes": {
- "name": "backup_codes",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
"id": {
"name": "id",
- "type": "text",
+ "type": "uuid",
"primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "artboard_id": {
+ "name": "artboard_id",
+ "type": "text",
+ "primaryKey": false,
"notNull": true
},
- "secret": {
- "name": "secret",
+ "page_id": {
+ "name": "page_id",
"type": "text",
"primaryKey": false,
"notNull": true
@@ -11010,14 +12310,84 @@
"type": "text",
"primaryKey": false,
"notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "recommended_board_id": {
+ "name": "recommended_board_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "chosen_board_id": {
+ "name": "chosen_board_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "selected_by": {
+ "name": "selected_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "selected_at": {
+ "name": "selected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "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": {
- "two_factor_secret_idx": {
- "name": "two_factor_secret_idx",
+ "artboard_rounds_artboard_id_idx": {
+ "name": "artboard_rounds_artboard_id_idx",
"columns": [
{
- "expression": "secret",
+ "expression": "artboard_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -11028,8 +12398,23 @@
"method": "btree",
"with": {}
},
- "two_factor_user_id_idx": {
- "name": "two_factor_user_id_idx",
+ "artboard_rounds_page_id_idx": {
+ "name": "artboard_rounds_page_id_idx",
+ "columns": [
+ {
+ "expression": "page_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_rounds_user_id_idx": {
+ "name": "artboard_rounds_user_id_idx",
"columns": [
{
"expression": "user_id",
@@ -11042,17 +12427,119 @@
"concurrently": false,
"method": "btree",
"with": {}
+ },
+ "artboard_rounds_workspace_id_idx": {
+ "name": "artboard_rounds_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"artboard_rounds\".\"workspace_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_rounds_recommended_board_id_idx": {
+ "name": "artboard_rounds_recommended_board_id_idx",
+ "columns": [
+ {
+ "expression": "recommended_board_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"artboard_rounds\".\"recommended_board_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboard_rounds_chosen_board_id_idx": {
+ "name": "artboard_rounds_chosen_board_id_idx",
+ "columns": [
+ {
+ "expression": "chosen_board_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"artboard_rounds\".\"chosen_board_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
}
},
"foreignKeys": {
- "two_factor_user_id_users_id_fk": {
- "name": "two_factor_user_id_users_id_fk",
- "tableFrom": "two_factor",
+ "artboard_rounds_artboard_id_artboards_id_fk": {
+ "name": "artboard_rounds_artboard_id_artboards_id_fk",
+ "tableFrom": "artboard_rounds",
+ "tableTo": "artboards",
+ "columnsFrom": ["artboard_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "artboard_rounds_page_id_artboard_pages_id_fk": {
+ "name": "artboard_rounds_page_id_artboard_pages_id_fk",
+ "tableFrom": "artboard_rounds",
+ "tableTo": "artboard_pages",
+ "columnsFrom": ["page_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "artboard_rounds_user_id_users_id_fk": {
+ "name": "artboard_rounds_user_id_users_id_fk",
+ "tableFrom": "artboard_rounds",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
+ },
+ "artboard_rounds_workspace_id_workspaces_id_fk": {
+ "name": "artboard_rounds_workspace_id_workspaces_id_fk",
+ "tableFrom": "artboard_rounds",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "artboard_rounds_recommended_board_id_artboard_boards_id_fk": {
+ "name": "artboard_rounds_recommended_board_id_artboard_boards_id_fk",
+ "tableFrom": "artboard_rounds",
+ "tableTo": "artboard_boards",
+ "columnsFrom": ["recommended_board_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "artboard_rounds_chosen_board_id_artboard_boards_id_fk": {
+ "name": "artboard_rounds_chosen_board_id_artboard_boards_id_fk",
+ "tableFrom": "artboard_rounds",
+ "tableTo": "artboard_boards",
+ "columnsFrom": ["chosen_board_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "artboard_rounds_selected_by_users_id_fk": {
+ "name": "artboard_rounds_selected_by_users_id_fk",
+ "tableFrom": "artboard_rounds",
+ "tableTo": "users",
+ "columnsFrom": ["selected_by"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
@@ -11061,108 +12548,96 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.verifications": {
- "name": "verifications",
+ "public.artboards": {
+ "name": "artboards",
"schema": "",
"columns": {
- "created_at": {
- "name": "created_at",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "expires_at": {
- "name": "expires_at",
- "type": "timestamp",
- "primaryKey": false,
- "notNull": true
- },
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
- "identifier": {
- "name": "identifier",
+ "user_id": {
+ "name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp",
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
"primaryKey": false,
- "notNull": true,
- "default": "now()"
+ "notNull": false
},
- "value": {
- "name": "value",
+ "topic_id": {
+ "name": "topic_id",
"type": "text",
"primaryKey": false,
- "notNull": true
- }
- },
- "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.channel_audit": {
- "name": "channel_audit",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
+ "notNull": false
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "acceptance_id": {
+ "name": "acceptance_id",
"type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
+ "primaryKey": false,
+ "notNull": false
},
- "channel_id": {
- "name": "channel_id",
+ "title": {
+ "name": "title",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "event": {
- "name": "event",
+ "description": {
+ "name": "description",
"type": "text",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
- "target_id": {
- "name": "target_id",
+ "content": {
+ "name": "content",
"type": "text",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
- "details": {
- "name": "details",
+ "phase": {
+ "name": "phase",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'discuss'"
+ },
+ "revision": {
+ "name": "revision",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "metadata": {
+ "name": "metadata",
"type": "jsonb",
"primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
"notNull": true,
- "default": "'{}'::jsonb"
+ "default": "now()"
},
"created_at": {
"name": "created_at",
@@ -11170,53 +12645,1870 @@
"primaryKey": false,
"notNull": true,
"default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
}
},
"indexes": {
- "channel_audit_channel_event_idx": {
- "name": "channel_audit_channel_event_idx",
+ "artboards_user_id_idx": {
+ "name": "artboards_user_id_idx",
"columns": [
{
- "expression": "channel_id",
+ "expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
- },
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboards_workspace_id_idx": {
+ "name": "artboards_workspace_id_idx",
+ "columns": [
{
- "expression": "event",
+ "expression": "workspace_id",
"isExpression": false,
"asc": true,
"nulls": "last"
- },
+ }
+ ],
+ "isUnique": false,
+ "where": "\"artboards\".\"workspace_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboards_topic_id_idx": {
+ "name": "artboards_topic_id_idx",
+ "columns": [
{
- "expression": "created_at",
+ "expression": "topic_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
+ "where": "\"artboards\".\"topic_id\" IS NOT NULL",
"concurrently": false,
"method": "btree",
"with": {}
},
- "channel_audit_target_event_idx": {
- "name": "channel_audit_target_event_idx",
+ "artboards_task_id_idx": {
+ "name": "artboards_task_id_idx",
"columns": [
{
- "expression": "target_id",
+ "expression": "task_id",
"isExpression": false,
"asc": true,
"nulls": "last"
- },
+ }
+ ],
+ "isUnique": false,
+ "where": "\"artboards\".\"task_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboards_project_id_idx": {
+ "name": "artboards_project_id_idx",
+ "columns": [
{
- "expression": "event",
+ "expression": "project_id",
"isExpression": false,
"asc": true,
"nulls": "last"
- },
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboards_phase_idx": {
+ "name": "artboards_phase_idx",
+ "columns": [
+ {
+ "expression": "phase",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboards_created_at_idx": {
+ "name": "artboards_created_at_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "artboards_updated_at_idx": {
+ "name": "artboards_updated_at_idx",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "artboards_user_id_users_id_fk": {
+ "name": "artboards_user_id_users_id_fk",
+ "tableFrom": "artboards",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "artboards_workspace_id_workspaces_id_fk": {
+ "name": "artboards_workspace_id_workspaces_id_fk",
+ "tableFrom": "artboards",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "artboards_topic_id_topics_id_fk": {
+ "name": "artboards_topic_id_topics_id_fk",
+ "tableFrom": "artboards",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "artboards_task_id_tasks_id_fk": {
+ "name": "artboards_task_id_tasks_id_fk",
+ "tableFrom": "artboards",
+ "tableTo": "tasks",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "artboards_project_id_projects_id_fk": {
+ "name": "artboards_project_id_projects_id_fk",
+ "tableFrom": "artboards",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "artboards_acceptance_id_acceptances_id_fk": {
+ "name": "artboards_acceptance_id_acceptances_id_fk",
+ "tableFrom": "artboards",
+ "tableTo": "acceptances",
+ "columnsFrom": ["acceptance_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.async_tasks": {
+ "name": "async_tasks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error": {
+ "name": "error",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inference_id": {
+ "name": "inference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "duration": {
+ "name": "duration",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "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": {
+ "async_tasks_user_id_idx": {
+ "name": "async_tasks_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "async_tasks_parent_id_idx": {
+ "name": "async_tasks_parent_id_idx",
+ "columns": [
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "async_tasks_type_status_idx": {
+ "name": "async_tasks_type_status_idx",
+ "columns": [
+ {
+ "expression": "type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "async_tasks_inference_id_idx": {
+ "name": "async_tasks_inference_id_idx",
+ "columns": [
+ {
+ "expression": "inference_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "async_tasks_metadata_idx": {
+ "name": "async_tasks_metadata_idx",
+ "columns": [
+ {
+ "expression": "metadata",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "gin",
+ "with": {}
+ },
+ "async_tasks_workspace_id_idx": {
+ "name": "async_tasks_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "async_tasks_user_id_users_id_fk": {
+ "name": "async_tasks_user_id_users_id_fk",
+ "tableFrom": "async_tasks",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "async_tasks_workspace_id_workspaces_id_fk": {
+ "name": "async_tasks_workspace_id_workspaces_id_fk",
+ "tableFrom": "async_tasks",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.accounts": {
+ "name": "accounts",
+ "schema": "",
+ "columns": {
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "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
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "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": {
+ "accounts_user_id_users_id_fk": {
+ "name": "accounts_user_id_users_id_fk",
+ "tableFrom": "accounts",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.passkey": {
+ "name": "passkey",
+ "schema": "",
+ "columns": {
+ "aaguid": {
+ "name": "aaguid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backedUp": {
+ "name": "backedUp",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "counter": {
+ "name": "counter",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "now()"
+ },
+ "credentialID": {
+ "name": "credentialID",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deviceType": {
+ "name": "deviceType",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "publicKey": {
+ "name": "publicKey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transports": {
+ "name": "transports",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "passkey_credential_id_unique": {
+ "name": "passkey_credential_id_unique",
+ "columns": [
+ {
+ "expression": "credentialID",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "passkey_user_id_idx": {
+ "name": "passkey_user_id_idx",
+ "columns": [
+ {
+ "expression": "userId",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "passkey_userId_users_id_fk": {
+ "name": "passkey_userId_users_id_fk",
+ "tableFrom": "passkey",
+ "tableTo": "users",
+ "columnsFrom": ["userId"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.auth_sessions": {
+ "name": "auth_sessions",
+ "schema": "",
+ "columns": {
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "impersonated_by": {
+ "name": "impersonated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "auth_session_userId_idx": {
+ "name": "auth_session_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "auth_sessions_user_id_users_id_fk": {
+ "name": "auth_sessions_user_id_users_id_fk",
+ "tableFrom": "auth_sessions",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "auth_sessions_token_unique": {
+ "name": "auth_sessions_token_unique",
+ "nullsNotDistinct": false,
+ "columns": ["token"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.two_factor": {
+ "name": "two_factor",
+ "schema": "",
+ "columns": {
+ "backup_codes": {
+ "name": "backup_codes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "secret": {
+ "name": "secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "two_factor_secret_idx": {
+ "name": "two_factor_secret_idx",
+ "columns": [
+ {
+ "expression": "secret",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "two_factor_user_id_idx": {
+ "name": "two_factor_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "two_factor_user_id_users_id_fk": {
+ "name": "two_factor_user_id_users_id_fk",
+ "tableFrom": "two_factor",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verifications": {
+ "name": "verifications",
+ "schema": "",
+ "columns": {
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "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.channel_audit": {
+ "name": "channel_audit",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event": {
+ "name": "event",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_id": {
+ "name": "target_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "details": {
+ "name": "details",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "channel_audit_channel_event_idx": {
+ "name": "channel_audit_channel_event_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_audit_target_event_idx": {
+ "name": "channel_audit_target_event_idx",
+ "columns": [
+ {
+ "expression": "target_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "channel_audit_channel_id_channels_id_fk": {
+ "name": "channel_audit_channel_id_channels_id_fk",
+ "tableFrom": "channel_audit",
+ "tableTo": "channels",
+ "columnsFrom": ["channel_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.channel_jobs": {
+ "name": "channel_jobs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "member_id": {
+ "name": "member_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requester_member_id": {
+ "name": "requester_member_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "blocked_reason": {
+ "name": "blocked_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_code": {
+ "name": "blocked_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "operation_id": {
+ "name": "operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wake": {
+ "name": "wake",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "manifest": {
+ "name": "manifest",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "execution_config": {
+ "name": "execution_config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "working_directory": {
+ "name": "working_directory",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lease_owner": {
+ "name": "lease_owner",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lease_expires_at": {
+ "name": "lease_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "writer_held": {
+ "name": "writer_held",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "isolated_at": {
+ "name": "isolated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draft": {
+ "name": "draft",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "publication_revoked": {
+ "name": "publication_revoked",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "published_message_id": {
+ "name": "published_message_id",
+ "type": "uuid",
+ "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": {
+ "channel_jobs_delivery_unique": {
+ "name": "channel_jobs_delivery_unique",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "member_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_jobs_channel_status_idx": {
+ "name": "channel_jobs_channel_status_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_jobs_continuation_idx": {
+ "name": "channel_jobs_continuation_idx",
+ "columns": [
+ {
+ "expression": "member_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "requester_member_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_jobs_topic_idx": {
+ "name": "channel_jobs_topic_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "published_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_jobs_member_queue_idx": {
+ "name": "channel_jobs_member_queue_idx",
+ "columns": [
+ {
+ "expression": "member_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_jobs_lease_expires_idx": {
+ "name": "channel_jobs_lease_expires_idx",
+ "columns": [
+ {
+ "expression": "lease_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"channel_jobs\".\"writer_held\" AND \"channel_jobs\".\"isolated_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_jobs_active_directory_idx": {
+ "name": "channel_jobs_active_directory_idx",
+ "columns": [
+ {
+ "expression": "device_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "working_directory",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"channel_jobs\".\"writer_held\"",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "channel_jobs_channel_id_channels_id_fk": {
+ "name": "channel_jobs_channel_id_channels_id_fk",
+ "tableFrom": "channel_jobs",
+ "tableTo": "channels",
+ "columnsFrom": ["channel_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "channel_jobs_topic_id_topics_id_fk": {
+ "name": "channel_jobs_topic_id_topics_id_fk",
+ "tableFrom": "channel_jobs",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "channel_jobs_operation_id_agent_operations_id_fk": {
+ "name": "channel_jobs_operation_id_agent_operations_id_fk",
+ "tableFrom": "channel_jobs",
+ "tableTo": "agent_operations",
+ "columnsFrom": ["operation_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "channel_jobs_member_fk": {
+ "name": "channel_jobs_member_fk",
+ "tableFrom": "channel_jobs",
+ "tableTo": "channel_members",
+ "columnsFrom": ["channel_id", "member_id"],
+ "columnsTo": ["channel_id", "id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "channel_jobs_requester_fk": {
+ "name": "channel_jobs_requester_fk",
+ "tableFrom": "channel_jobs",
+ "tableTo": "channel_members",
+ "columnsFrom": ["channel_id", "requester_member_id"],
+ "columnsTo": ["channel_id", "id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "channel_jobs_message_fk": {
+ "name": "channel_jobs_message_fk",
+ "tableFrom": "channel_jobs",
+ "tableTo": "channel_messages",
+ "columnsFrom": ["channel_id", "message_id"],
+ "columnsTo": ["channel_id", "id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "channel_jobs_thread_fk": {
+ "name": "channel_jobs_thread_fk",
+ "tableFrom": "channel_jobs",
+ "tableTo": "channel_threads",
+ "columnsFrom": ["channel_id", "thread_id"],
+ "columnsTo": ["channel_id", "id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "channel_jobs_operation_id_unique": {
+ "name": "channel_jobs_operation_id_unique",
+ "nullsNotDistinct": false,
+ "columns": ["operation_id"]
+ },
+ "channel_jobs_scope_unique": {
+ "name": "channel_jobs_scope_unique",
+ "nullsNotDistinct": false,
+ "columns": ["channel_id", "id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.channel_member_grants": {
+ "name": "channel_member_grants",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "member_id": {
+ "name": "member_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_owner_id": {
+ "name": "device_owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "working_directory": {
+ "name": "working_directory",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_by_member_id": {
+ "name": "requested_by_member_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "decided_at": {
+ "name": "decided_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoke_reason": {
+ "name": "revoke_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "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": {
+ "channel_member_grants_member_unique": {
+ "name": "channel_member_grants_member_unique",
+ "columns": [
+ {
+ "expression": "member_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_member_grants_owner_status_idx": {
+ "name": "channel_member_grants_owner_status_idx",
+ "columns": [
+ {
+ "expression": "device_owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "channel_member_grants_channel_id_channels_id_fk": {
+ "name": "channel_member_grants_channel_id_channels_id_fk",
+ "tableFrom": "channel_member_grants",
+ "tableTo": "channels",
+ "columnsFrom": ["channel_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "channel_member_grants_device_owner_id_users_id_fk": {
+ "name": "channel_member_grants_device_owner_id_users_id_fk",
+ "tableFrom": "channel_member_grants",
+ "tableTo": "users",
+ "columnsFrom": ["device_owner_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "channel_member_grants_member_fk": {
+ "name": "channel_member_grants_member_fk",
+ "tableFrom": "channel_member_grants",
+ "tableTo": "channel_members",
+ "columnsFrom": ["channel_id", "member_id"],
+ "columnsTo": ["channel_id", "id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "channel_member_grants_requester_fk": {
+ "name": "channel_member_grants_requester_fk",
+ "tableFrom": "channel_member_grants",
+ "tableTo": "channel_members",
+ "columnsFrom": ["channel_id", "requested_by_member_id"],
+ "columnsTo": ["channel_id", "id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.channel_members": {
+ "name": "channel_members",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_type": {
+ "name": "actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_read_sequence": {
+ "name": "last_read_sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pinned_at": {
+ "name": "pinned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "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": {
+ "channel_members_channel_user_unique": {
+ "name": "channel_members_channel_user_unique",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"channel_members\".\"user_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_members_user_id_idx": {
+ "name": "channel_members_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_members_agent_id_idx": {
+ "name": "channel_members_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "channel_members_channel_id_channels_id_fk": {
+ "name": "channel_members_channel_id_channels_id_fk",
+ "tableFrom": "channel_members",
+ "tableTo": "channels",
+ "columnsFrom": ["channel_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "channel_members_user_id_users_id_fk": {
+ "name": "channel_members_user_id_users_id_fk",
+ "tableFrom": "channel_members",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "channel_members_agent_id_agents_id_fk": {
+ "name": "channel_members_agent_id_agents_id_fk",
+ "tableFrom": "channel_members",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "channel_members_scope_unique": {
+ "name": "channel_members_scope_unique",
+ "nullsNotDistinct": false,
+ "columns": ["channel_id", "id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "channel_members_actor_type_check": {
+ "name": "channel_members_actor_type_check",
+ "value": "\"channel_members\".\"actor_type\" IN ('user', 'agent')"
+ },
+ "channel_members_user_shape_check": {
+ "name": "channel_members_user_shape_check",
+ "value": "\"channel_members\".\"actor_type\" <> 'user' OR \"channel_members\".\"role\" IS NOT NULL"
+ },
+ "channel_members_agent_shape_check": {
+ "name": "channel_members_agent_shape_check",
+ "value": "\"channel_members\".\"actor_type\" <> 'agent' OR (\"channel_members\".\"name\" IS NOT NULL AND \"channel_members\".\"config\" IS NOT NULL)"
+ },
+ "channel_members_user_id_owner_check": {
+ "name": "channel_members_user_id_owner_check",
+ "value": "\"channel_members\".\"user_id\" IS NULL OR \"channel_members\".\"actor_type\" = 'user'"
+ },
+ "channel_members_role_owner_check": {
+ "name": "channel_members_role_owner_check",
+ "value": "\"channel_members\".\"role\" IS NULL OR \"channel_members\".\"actor_type\" = 'user'"
+ },
+ "channel_members_agent_id_owner_check": {
+ "name": "channel_members_agent_id_owner_check",
+ "value": "\"channel_members\".\"agent_id\" IS NULL OR \"channel_members\".\"actor_type\" = 'agent'"
+ },
+ "channel_members_config_owner_check": {
+ "name": "channel_members_config_owner_check",
+ "value": "\"channel_members\".\"config\" IS NULL OR \"channel_members\".\"actor_type\" <> 'user'"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.channel_message_files": {
+ "name": "channel_message_files",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_id": {
+ "name": "file_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "channel_message_files_file_idx": {
+ "name": "channel_message_files_file_idx",
+ "columns": [
{
- "expression": "created_at",
+ "expression": "file_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -11229,24 +14521,39 @@
}
},
"foreignKeys": {
- "channel_audit_channel_id_channels_id_fk": {
- "name": "channel_audit_channel_id_channels_id_fk",
- "tableFrom": "channel_audit",
- "tableTo": "channels",
- "columnsFrom": ["channel_id"],
+ "channel_message_files_message_id_channel_messages_id_fk": {
+ "name": "channel_message_files_message_id_channel_messages_id_fk",
+ "tableFrom": "channel_message_files",
+ "tableTo": "channel_messages",
+ "columnsFrom": ["message_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "channel_message_files_file_id_files_id_fk": {
+ "name": "channel_message_files_file_id_files_id_fk",
+ "tableFrom": "channel_message_files",
+ "tableTo": "files",
+ "columnsFrom": ["file_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
- "uniqueConstraints": {},
+ "uniqueConstraints": {
+ "channel_message_files_message_file_unique": {
+ "name": "channel_message_files_message_file_unique",
+ "nullsNotDistinct": false,
+ "columns": ["message_id", "file_id"]
+ }
+ },
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.channel_jobs": {
- "name": "channel_jobs",
+ "public.channel_messages": {
+ "name": "channel_messages",
"schema": "",
"columns": {
"id": {
@@ -11262,146 +14569,93 @@
"primaryKey": false,
"notNull": true
},
- "member_id": {
- "name": "member_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "message_id": {
- "name": "message_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
"thread_id": {
"name": "thread_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "requester_member_id": {
- "name": "requester_member_id",
- "type": "uuid",
+ "sequence": {
+ "name": "sequence",
+ "type": "integer",
"primaryKey": false,
"notNull": true
},
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'queued'"
- },
- "blocked_reason": {
- "name": "blocked_reason",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "blocked_code": {
- "name": "blocked_code",
+ "content": {
+ "name": "content",
"type": "text",
"primaryKey": false,
- "notNull": false
- },
- "claimed_at": {
- "name": "claimed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "topic_id": {
- "name": "topic_id",
+ "user_id": {
+ "name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "operation_id": {
- "name": "operation_id",
+ "agent_id": {
+ "name": "agent_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "wake": {
- "name": "wake",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "manifest": {
- "name": "manifest",
+ "mentions": {
+ "name": "mentions",
"type": "jsonb",
"primaryKey": false,
- "notNull": false
+ "notNull": true,
+ "default": "'[]'::jsonb"
},
- "execution_config": {
- "name": "execution_config",
- "type": "jsonb",
+ "request_key": {
+ "name": "request_key",
+ "type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "device_id": {
- "name": "device_id",
- "type": "varchar(64)",
+ "reply_to_id": {
+ "name": "reply_to_id",
+ "type": "uuid",
"primaryKey": false,
"notNull": false
},
- "working_directory": {
- "name": "working_directory",
+ "routing_status": {
+ "name": "routing_status",
"type": "text",
"primaryKey": false,
- "notNull": false
- },
- "accepted_at": {
- "name": "accepted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "lease_owner": {
- "name": "lease_owner",
+ "routing_source": {
+ "name": "routing_source",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "lease_expires_at": {
- "name": "lease_expires_at",
- "type": "timestamp with time zone",
+ "routing_reason": {
+ "name": "routing_reason",
+ "type": "text",
"primaryKey": false,
"notNull": false
},
- "writer_held": {
- "name": "writer_held",
- "type": "boolean",
+ "routing_attempt": {
+ "name": "routing_attempt",
+ "type": "integer",
"primaryKey": false,
"notNull": true,
- "default": false
- },
- "isolated_at": {
- "name": "isolated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "draft": {
- "name": "draft",
- "type": "text",
- "primaryKey": false,
- "notNull": false
+ "default": 0
},
- "publication_revoked": {
- "name": "publication_revoked",
- "type": "boolean",
+ "recipient_member_ids": {
+ "name": "recipient_member_ids",
+ "type": "jsonb",
"primaryKey": false,
"notNull": true,
- "default": false
+ "default": "'[]'::jsonb"
},
- "published_message_id": {
- "name": "published_message_id",
- "type": "uuid",
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
"primaryKey": false,
- "notNull": false
+ "notNull": false,
+ "default": "'{}'::jsonb"
},
"created_at": {
"name": "created_at",
@@ -11409,27 +14663,20 @@
"primaryKey": false,
"notNull": true,
"default": "now()"
- },
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
}
},
"indexes": {
- "channel_jobs_delivery_unique": {
- "name": "channel_jobs_delivery_unique",
+ "channel_messages_sequence_unique": {
+ "name": "channel_messages_sequence_unique",
"columns": [
{
- "expression": "message_id",
+ "expression": "channel_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
- "expression": "member_id",
+ "expression": "sequence",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -11440,8 +14687,8 @@
"method": "btree",
"with": {}
},
- "channel_jobs_channel_status_idx": {
- "name": "channel_jobs_channel_status_idx",
+ "channel_messages_request_key_unique": {
+ "name": "channel_messages_request_key_unique",
"columns": [
{
"expression": "channel_id",
@@ -11450,28 +14697,22 @@
"nulls": "last"
},
{
- "expression": "status",
+ "expression": "request_key",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
- "isUnique": false,
+ "isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
},
- "channel_jobs_continuation_idx": {
- "name": "channel_jobs_continuation_idx",
+ "channel_messages_thread_sequence_idx": {
+ "name": "channel_messages_thread_sequence_idx",
"columns": [
{
- "expression": "member_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "requester_member_id",
+ "expression": "channel_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -11483,28 +14724,7 @@
"nulls": "last"
},
{
- "expression": "claimed_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "channel_jobs_topic_idx": {
- "name": "channel_jobs_topic_idx",
- "columns": [
- {
- "expression": "topic_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "published_message_id",
+ "expression": "sequence",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -11515,146 +14735,88 @@
"method": "btree",
"with": {}
},
- "channel_jobs_member_queue_idx": {
- "name": "channel_jobs_member_queue_idx",
+ "channel_messages_request_sequence_idx": {
+ "name": "channel_messages_request_sequence_idx",
"columns": [
{
- "expression": "member_id",
+ "expression": "channel_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
- "expression": "status",
+ "expression": "thread_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
- "expression": "created_at",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "channel_jobs_lease_expires_idx": {
- "name": "channel_jobs_lease_expires_idx",
- "columns": [
- {
- "expression": "lease_expires_at",
+ "expression": "sequence",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
- "where": "\"channel_jobs\".\"writer_held\" AND \"channel_jobs\".\"isolated_at\" IS NULL",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "channel_jobs_active_member_unique": {
- "name": "channel_jobs_active_member_unique",
- "columns": [
- {
- "expression": "member_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"channel_jobs\".\"writer_held\" AND \"channel_jobs\".\"isolated_at\" IS NULL",
+ "where": "\"channel_messages\".\"routing_status\" <> 'reply'",
"concurrently": false,
"method": "btree",
"with": {}
},
- "channel_jobs_active_directory_unique": {
- "name": "channel_jobs_active_directory_unique",
+ "channel_messages_routing_pending_idx": {
+ "name": "channel_messages_routing_pending_idx",
"columns": [
{
- "expression": "device_id",
+ "expression": "channel_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
- "expression": "working_directory",
+ "expression": "id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
- "isUnique": true,
- "where": "\"channel_jobs\".\"device_id\" IS NOT NULL AND \"channel_jobs\".\"working_directory\" IS NOT NULL AND \"channel_jobs\".\"writer_held\"",
+ "isUnique": false,
+ "where": "\"channel_messages\".\"routing_status\" = 'pending'",
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
- "channel_jobs_channel_id_channels_id_fk": {
- "name": "channel_jobs_channel_id_channels_id_fk",
- "tableFrom": "channel_jobs",
+ "channel_messages_channel_id_channels_id_fk": {
+ "name": "channel_messages_channel_id_channels_id_fk",
+ "tableFrom": "channel_messages",
"tableTo": "channels",
"columnsFrom": ["channel_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "channel_jobs_topic_id_topics_id_fk": {
- "name": "channel_jobs_topic_id_topics_id_fk",
- "tableFrom": "channel_jobs",
- "tableTo": "topics",
- "columnsFrom": ["topic_id"],
+ "channel_messages_user_id_users_id_fk": {
+ "name": "channel_messages_user_id_users_id_fk",
+ "tableFrom": "channel_messages",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "set null",
"onUpdate": "no action"
},
- "channel_jobs_operation_id_agent_operations_id_fk": {
- "name": "channel_jobs_operation_id_agent_operations_id_fk",
- "tableFrom": "channel_jobs",
- "tableTo": "agent_operations",
- "columnsFrom": ["operation_id"],
+ "channel_messages_agent_id_agents_id_fk": {
+ "name": "channel_messages_agent_id_agents_id_fk",
+ "tableFrom": "channel_messages",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
"columnsTo": ["id"],
"onDelete": "set null",
"onUpdate": "no action"
},
- "channel_jobs_member_fk": {
- "name": "channel_jobs_member_fk",
- "tableFrom": "channel_jobs",
- "tableTo": "channel_members",
- "columnsFrom": ["channel_id", "member_id"],
- "columnsTo": ["channel_id", "id"],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "channel_jobs_requester_fk": {
- "name": "channel_jobs_requester_fk",
- "tableFrom": "channel_jobs",
- "tableTo": "channel_members",
- "columnsFrom": ["channel_id", "requester_member_id"],
- "columnsTo": ["channel_id", "id"],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "channel_jobs_message_fk": {
- "name": "channel_jobs_message_fk",
- "tableFrom": "channel_jobs",
- "tableTo": "channel_messages",
- "columnsFrom": ["channel_id", "message_id"],
- "columnsTo": ["channel_id", "id"],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "channel_jobs_thread_fk": {
- "name": "channel_jobs_thread_fk",
- "tableFrom": "channel_jobs",
+ "channel_messages_thread_fk": {
+ "name": "channel_messages_thread_fk",
+ "tableFrom": "channel_messages",
"tableTo": "channel_threads",
"columnsFrom": ["channel_id", "thread_id"],
"columnsTo": ["channel_id", "id"],
@@ -11664,31 +14826,34 @@
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
- "channel_jobs_operation_id_unique": {
- "name": "channel_jobs_operation_id_unique",
- "nullsNotDistinct": false,
- "columns": ["operation_id"]
- },
- "channel_jobs_scope_unique": {
- "name": "channel_jobs_scope_unique",
+ "channel_messages_scope_unique": {
+ "name": "channel_messages_scope_unique",
"nullsNotDistinct": false,
"columns": ["channel_id", "id"]
}
},
"policies": {},
- "checkConstraints": {},
+ "checkConstraints": {
+ "channel_messages_sender_check": {
+ "name": "channel_messages_sender_check",
+ "value": "\"channel_messages\".\"user_id\" IS NULL OR \"channel_messages\".\"agent_id\" IS NULL"
+ },
+ "channel_messages_user_sender_check": {
+ "name": "channel_messages_user_sender_check",
+ "value": "\"channel_messages\".\"routing_status\" <> 'reply' OR \"channel_messages\".\"user_id\" IS NULL"
+ }
+ },
"isRLSEnabled": false
},
- "public.channel_member_grants": {
- "name": "channel_member_grants",
+ "public.channel_threads": {
+ "name": "channel_threads",
"schema": "",
"columns": {
"id": {
"name": "id",
- "type": "uuid",
+ "type": "text",
"primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
+ "notNull": true
},
"channel_id": {
"name": "channel_id",
@@ -11696,186 +14861,123 @@
"primaryKey": false,
"notNull": true
},
- "member_id": {
- "name": "member_id",
+ "root_message_id": {
+ "name": "root_message_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
- "device_owner_id": {
- "name": "device_owner_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "device_id": {
- "name": "device_id",
- "type": "varchar(64)",
- "primaryKey": false,
- "notNull": true
- },
- "working_directory": {
- "name": "working_directory",
- "type": "text",
+ "root_sequence": {
+ "name": "root_sequence",
+ "type": "integer",
"primaryKey": false,
"notNull": true
},
- "requested_by_member_id": {
- "name": "requested_by_member_id",
- "type": "uuid",
+ "follower_member_ids": {
+ "name": "follower_member_ids",
+ "type": "jsonb",
"primaryKey": false,
- "notNull": true
+ "notNull": true,
+ "default": "'[]'::jsonb"
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
- "default": "'pending'"
+ "default": "'active'"
},
- "decided_at": {
- "name": "decided_at",
- "type": "timestamp with time zone",
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
"primaryKey": false,
- "notNull": false
+ "notNull": false,
+ "default": "'{}'::jsonb"
},
- "revoked_at": {
- "name": "revoked_at",
+ "deleted_at": {
+ "name": "deleted_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": false
},
- "revoke_reason": {
- "name": "revoke_reason",
- "type": "text",
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
"primaryKey": false,
"notNull": false
},
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false,
- "default": "'{}'::jsonb"
- },
"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": {
- "channel_member_grants_member_unique": {
- "name": "channel_member_grants_member_unique",
- "columns": [
- {
- "expression": "member_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "channel_member_grants_owner_status_idx": {
- "name": "channel_member_grants_owner_status_idx",
+ "channel_threads_root_unique": {
+ "name": "channel_threads_root_unique",
"columns": [
{
- "expression": "device_owner_id",
+ "expression": "channel_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
- "expression": "status",
+ "expression": "root_message_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
- "isUnique": false,
+ "isUnique": true,
+ "where": "\"channel_threads\".\"is_deleted\" IS NOT TRUE",
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
- "channel_member_grants_channel_id_channels_id_fk": {
- "name": "channel_member_grants_channel_id_channels_id_fk",
- "tableFrom": "channel_member_grants",
+ "channel_threads_channel_id_channels_id_fk": {
+ "name": "channel_threads_channel_id_channels_id_fk",
+ "tableFrom": "channel_threads",
"tableTo": "channels",
"columnsFrom": ["channel_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "channel_member_grants_device_owner_id_users_id_fk": {
- "name": "channel_member_grants_device_owner_id_users_id_fk",
- "tableFrom": "channel_member_grants",
- "tableTo": "users",
- "columnsFrom": ["device_owner_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "channel_member_grants_member_fk": {
- "name": "channel_member_grants_member_fk",
- "tableFrom": "channel_member_grants",
- "tableTo": "channel_members",
- "columnsFrom": ["channel_id", "member_id"],
- "columnsTo": ["channel_id", "id"],
- "onDelete": "no action",
- "onUpdate": "no action"
- },
- "channel_member_grants_requester_fk": {
- "name": "channel_member_grants_requester_fk",
- "tableFrom": "channel_member_grants",
- "tableTo": "channel_members",
- "columnsFrom": ["channel_id", "requested_by_member_id"],
+ "channel_threads_root_fk": {
+ "name": "channel_threads_root_fk",
+ "tableFrom": "channel_threads",
+ "tableTo": "channel_messages",
+ "columnsFrom": ["channel_id", "root_message_id"],
"columnsTo": ["channel_id", "id"],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
- "uniqueConstraints": {},
+ "uniqueConstraints": {
+ "channel_threads_scope_unique": {
+ "name": "channel_threads_scope_unique",
+ "nullsNotDistinct": false,
+ "columns": ["channel_id", "id"]
+ }
+ },
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
- },
- "public.channel_members": {
- "name": "channel_members",
+ },
+ "public.channels": {
+ "name": "channels",
"schema": "",
"columns": {
"id": {
"name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
- },
- "channel_id": {
- "name": "channel_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "actor_type": {
- "name": "actor_type",
"type": "text",
- "primaryKey": false,
+ "primaryKey": true,
"notNull": true
},
"user_id": {
@@ -11884,15 +14986,15 @@
"primaryKey": false,
"notNull": false
},
- "role": {
- "name": "role",
+ "workspace_id": {
+ "name": "workspace_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "last_read_sequence": {
- "name": "last_read_sequence",
- "type": "integer",
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
"primaryKey": false,
"notNull": false
},
@@ -11902,18 +15004,44 @@
"primaryKey": false,
"notNull": false
},
- "name": {
- "name": "name",
+ "peer_user_id": {
+ "name": "peer_user_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "description": {
- "name": "description",
+ "agent_pair_key": {
+ "name": "agent_pair_key",
"type": "text",
"primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "integer",
+ "primaryKey": false,
"notNull": true,
- "default": "''"
+ "default": 0
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'private'"
},
"config": {
"name": "config",
@@ -11928,12 +15056,17 @@
"notNull": false,
"default": "'{}'::jsonb"
},
- "status": {
- "name": "status",
- "type": "text",
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": true,
- "default": "'active'"
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
},
"created_at": {
"name": "created_at",
@@ -11951,11 +15084,26 @@
}
},
"indexes": {
- "channel_members_channel_user_unique": {
- "name": "channel_members_channel_user_unique",
+ "channels_user_id_idx": {
+ "name": "channels_user_id_idx",
"columns": [
{
- "expression": "channel_id",
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channels_direct_unique": {
+ "name": "channels_direct_unique",
+ "columns": [
+ {
+ "expression": "agent_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -11965,151 +15113,75 @@
"isExpression": false,
"asc": true,
"nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"workspace_id\", '')",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
}
],
"isUnique": true,
- "where": "\"channel_members\".\"user_id\" IS NOT NULL",
+ "where": "\"channels\".\"agent_id\" IS NOT NULL",
"concurrently": false,
"method": "btree",
"with": {}
},
- "channel_members_user_id_idx": {
- "name": "channel_members_user_id_idx",
+ "channels_agent_pair_unique": {
+ "name": "channels_agent_pair_unique",
"columns": [
+ {
+ "expression": "agent_pair_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
{
"expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"workspace_id\", '')",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
}
],
- "isUnique": false,
+ "isUnique": true,
+ "where": "\"channels\".\"agent_pair_key\" IS NOT NULL",
"concurrently": false,
"method": "btree",
"with": {}
},
- "channel_members_agent_id_idx": {
- "name": "channel_members_agent_id_idx",
+ "channels_project_id_idx": {
+ "name": "channels_project_id_idx",
"columns": [
{
- "expression": "agent_id",
+ "expression": "project_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
+ "where": "\"channels\".\"project_id\" IS NOT NULL",
"concurrently": false,
"method": "btree",
"with": {}
- }
- },
- "foreignKeys": {
- "channel_members_channel_id_channels_id_fk": {
- "name": "channel_members_channel_id_channels_id_fk",
- "tableFrom": "channel_members",
- "tableTo": "channels",
- "columnsFrom": ["channel_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "channel_members_user_id_users_id_fk": {
- "name": "channel_members_user_id_users_id_fk",
- "tableFrom": "channel_members",
- "tableTo": "users",
- "columnsFrom": ["user_id"],
- "columnsTo": ["id"],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "channel_members_agent_id_agents_id_fk": {
- "name": "channel_members_agent_id_agents_id_fk",
- "tableFrom": "channel_members",
- "tableTo": "agents",
- "columnsFrom": ["agent_id"],
- "columnsTo": ["id"],
- "onDelete": "set null",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "channel_members_scope_unique": {
- "name": "channel_members_scope_unique",
- "nullsNotDistinct": false,
- "columns": ["channel_id", "id"]
- }
- },
- "policies": {},
- "checkConstraints": {
- "channel_members_actor_type_check": {
- "name": "channel_members_actor_type_check",
- "value": "\"channel_members\".\"actor_type\" IN ('user', 'agent')"
- },
- "channel_members_user_shape_check": {
- "name": "channel_members_user_shape_check",
- "value": "\"channel_members\".\"actor_type\" <> 'user' OR \"channel_members\".\"role\" IS NOT NULL"
- },
- "channel_members_agent_shape_check": {
- "name": "channel_members_agent_shape_check",
- "value": "\"channel_members\".\"actor_type\" <> 'agent' OR (\"channel_members\".\"name\" IS NOT NULL AND \"channel_members\".\"config\" IS NOT NULL)"
- },
- "channel_members_user_id_owner_check": {
- "name": "channel_members_user_id_owner_check",
- "value": "\"channel_members\".\"user_id\" IS NULL OR \"channel_members\".\"actor_type\" = 'user'"
- },
- "channel_members_role_owner_check": {
- "name": "channel_members_role_owner_check",
- "value": "\"channel_members\".\"role\" IS NULL OR \"channel_members\".\"actor_type\" = 'user'"
- },
- "channel_members_agent_id_owner_check": {
- "name": "channel_members_agent_id_owner_check",
- "value": "\"channel_members\".\"agent_id\" IS NULL OR \"channel_members\".\"actor_type\" = 'agent'"
- },
- "channel_members_config_owner_check": {
- "name": "channel_members_config_owner_check",
- "value": "\"channel_members\".\"config\" IS NULL OR \"channel_members\".\"actor_type\" <> 'user'"
- }
- },
- "isRLSEnabled": false
- },
- "public.channel_message_files": {
- "name": "channel_message_files",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
- "type": "uuid",
- "primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
},
- "message_id": {
- "name": "message_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "file_id": {
- "name": "file_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "sort_order": {
- "name": "sort_order",
- "type": "integer",
- "primaryKey": false,
- "notNull": true
- }
- },
- "indexes": {
- "channel_message_files_file_idx": {
- "name": "channel_message_files_file_idx",
+ "channels_workspace_visibility_idx": {
+ "name": "channels_workspace_visibility_idx",
"columns": [
{
- "expression": "file_id",
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -12122,141 +15194,177 @@
}
},
"foreignKeys": {
- "channel_message_files_message_id_channel_messages_id_fk": {
- "name": "channel_message_files_message_id_channel_messages_id_fk",
- "tableFrom": "channel_message_files",
- "tableTo": "channel_messages",
- "columnsFrom": ["message_id"],
+ "channels_user_id_users_id_fk": {
+ "name": "channels_user_id_users_id_fk",
+ "tableFrom": "channels",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "channels_workspace_id_workspaces_id_fk": {
+ "name": "channels_workspace_id_workspaces_id_fk",
+ "tableFrom": "channels",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "channel_message_files_file_id_files_id_fk": {
- "name": "channel_message_files_file_id_files_id_fk",
- "tableFrom": "channel_message_files",
- "tableTo": "files",
- "columnsFrom": ["file_id"],
+ "channels_project_id_projects_id_fk": {
+ "name": "channels_project_id_projects_id_fk",
+ "tableFrom": "channels",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "channels_agent_id_agents_id_fk": {
+ "name": "channels_agent_id_agents_id_fk",
+ "tableFrom": "channels",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "channels_peer_user_id_users_id_fk": {
+ "name": "channels_peer_user_id_users_id_fk",
+ "tableFrom": "channels",
+ "tableTo": "users",
+ "columnsFrom": ["peer_user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
- "uniqueConstraints": {
- "channel_message_files_message_file_unique": {
- "name": "channel_message_files_message_file_unique",
- "nullsNotDistinct": false,
- "columns": ["message_id", "file_id"]
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "channels_direct_visibility_check": {
+ "name": "channels_direct_visibility_check",
+ "value": "\"channels\".\"agent_id\" IS NULL OR \"channels\".\"visibility\" = 'private'"
}
},
- "policies": {},
- "checkConstraints": {},
"isRLSEnabled": false
},
- "public.channel_messages": {
- "name": "channel_messages",
+ "public.chat_groups": {
+ "name": "chat_groups",
"schema": "",
"columns": {
"id": {
"name": "id",
- "type": "uuid",
+ "type": "text",
"primaryKey": true,
- "notNull": true,
- "default": "gen_random_uuid()"
+ "notNull": true
},
- "channel_id": {
- "name": "channel_id",
+ "title": {
+ "name": "title",
"type": "text",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
- "thread_id": {
- "name": "thread_id",
+ "description": {
+ "name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "sequence": {
- "name": "sequence",
- "type": "integer",
+ "avatar": {
+ "name": "avatar",
+ "type": "text",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
- "content": {
- "name": "content",
+ "background_color": {
+ "name": "background_color",
"type": "text",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
- "user_id": {
- "name": "user_id",
+ "market_identifier": {
+ "name": "market_identifier",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "agent_id": {
- "name": "agent_id",
+ "content": {
+ "name": "content",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "mentions": {
- "name": "mentions",
+ "editor_data": {
+ "name": "editor_data",
"type": "jsonb",
"primaryKey": false,
- "notNull": true,
- "default": "'[]'::jsonb"
+ "notNull": false
},
- "request_key": {
- "name": "request_key",
- "type": "text",
+ "config": {
+ "name": "config",
+ "type": "jsonb",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
- "reply_to_id": {
- "name": "reply_to_id",
- "type": "uuid",
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
"primaryKey": false,
"notNull": false
},
- "routing_status": {
- "name": "routing_status",
+ "user_id": {
+ "name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "routing_source": {
- "name": "routing_source",
+ "workspace_id": {
+ "name": "workspace_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "routing_reason": {
- "name": "routing_reason",
+ "group_id": {
+ "name": "group_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "routing_attempt": {
- "name": "routing_attempt",
- "type": "integer",
+ "pinned": {
+ "name": "pinned",
+ "type": "boolean",
"primaryKey": false,
- "notNull": true,
- "default": 0
+ "notNull": false,
+ "default": false
},
- "recipient_member_ids": {
- "name": "recipient_member_ids",
- "type": "jsonb",
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
"primaryKey": false,
"notNull": true,
- "default": "'[]'::jsonb"
+ "default": "'public'"
},
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": false,
- "default": "'{}'::jsonb"
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
},
"created_at": {
"name": "created_at",
@@ -12264,20 +15372,27 @@
"primaryKey": false,
"notNull": true,
"default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
}
},
"indexes": {
- "channel_messages_sequence_unique": {
- "name": "channel_messages_sequence_unique",
+ "chat_groups_client_id_user_id_unique": {
+ "name": "chat_groups_client_id_user_id_unique",
"columns": [
{
- "expression": "channel_id",
+ "expression": "client_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
- "expression": "sequence",
+ "expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -12288,44 +15403,26 @@
"method": "btree",
"with": {}
},
- "channel_messages_request_key_unique": {
- "name": "channel_messages_request_key_unique",
+ "chat_groups_user_id_idx": {
+ "name": "chat_groups_user_id_idx",
"columns": [
{
- "expression": "channel_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "request_key",
+ "expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
- "isUnique": true,
+ "isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
- "channel_messages_thread_sequence_idx": {
- "name": "channel_messages_thread_sequence_idx",
+ "chat_groups_group_id_idx": {
+ "name": "chat_groups_group_id_idx",
"columns": [
{
- "expression": "channel_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "thread_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "sequence",
+ "expression": "group_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -12336,180 +15433,139 @@
"method": "btree",
"with": {}
},
- "channel_messages_request_sequence_idx": {
- "name": "channel_messages_request_sequence_idx",
+ "chat_groups_workspace_id_idx": {
+ "name": "chat_groups_workspace_id_idx",
"columns": [
{
- "expression": "channel_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "thread_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "sequence",
+ "expression": "workspace_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
- "where": "\"channel_messages\".\"routing_status\" <> 'reply'",
"concurrently": false,
"method": "btree",
"with": {}
},
- "channel_messages_routing_pending_idx": {
- "name": "channel_messages_routing_pending_idx",
+ "chat_groups_workspace_visibility_idx": {
+ "name": "chat_groups_workspace_visibility_idx",
"columns": [
{
- "expression": "channel_id",
+ "expression": "workspace_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
- "expression": "id",
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
- "where": "\"channel_messages\".\"routing_status\" = 'pending'",
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
- "channel_messages_channel_id_channels_id_fk": {
- "name": "channel_messages_channel_id_channels_id_fk",
- "tableFrom": "channel_messages",
- "tableTo": "channels",
- "columnsFrom": ["channel_id"],
+ "chat_groups_user_id_users_id_fk": {
+ "name": "chat_groups_user_id_users_id_fk",
+ "tableFrom": "chat_groups",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "channel_messages_user_id_users_id_fk": {
- "name": "channel_messages_user_id_users_id_fk",
- "tableFrom": "channel_messages",
- "tableTo": "users",
- "columnsFrom": ["user_id"],
+ "chat_groups_workspace_id_workspaces_id_fk": {
+ "name": "chat_groups_workspace_id_workspaces_id_fk",
+ "tableFrom": "chat_groups",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
"columnsTo": ["id"],
- "onDelete": "set null",
+ "onDelete": "cascade",
"onUpdate": "no action"
},
- "channel_messages_agent_id_agents_id_fk": {
- "name": "channel_messages_agent_id_agents_id_fk",
- "tableFrom": "channel_messages",
- "tableTo": "agents",
- "columnsFrom": ["agent_id"],
+ "chat_groups_group_id_session_groups_id_fk": {
+ "name": "chat_groups_group_id_session_groups_id_fk",
+ "tableFrom": "chat_groups",
+ "tableTo": "session_groups",
+ "columnsFrom": ["group_id"],
"columnsTo": ["id"],
"onDelete": "set null",
"onUpdate": "no action"
- },
- "channel_messages_thread_fk": {
- "name": "channel_messages_thread_fk",
- "tableFrom": "channel_messages",
- "tableTo": "channel_threads",
- "columnsFrom": ["channel_id", "thread_id"],
- "columnsTo": ["channel_id", "id"],
- "onDelete": "no action",
- "onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
- "uniqueConstraints": {
- "channel_messages_scope_unique": {
- "name": "channel_messages_scope_unique",
- "nullsNotDistinct": false,
- "columns": ["channel_id", "id"]
- }
- },
+ "uniqueConstraints": {},
"policies": {},
- "checkConstraints": {
- "channel_messages_sender_check": {
- "name": "channel_messages_sender_check",
- "value": "\"channel_messages\".\"user_id\" IS NULL OR \"channel_messages\".\"agent_id\" IS NULL"
- },
- "channel_messages_user_sender_check": {
- "name": "channel_messages_user_sender_check",
- "value": "\"channel_messages\".\"routing_status\" <> 'reply' OR \"channel_messages\".\"user_id\" IS NULL"
- },
- "channel_messages_agent_sender_check": {
- "name": "channel_messages_agent_sender_check",
- "value": "\"channel_messages\".\"routing_status\" = 'reply' OR \"channel_messages\".\"agent_id\" IS NULL"
- }
- },
+ "checkConstraints": {},
"isRLSEnabled": false
},
- "public.channel_threads": {
- "name": "channel_threads",
+ "public.chat_groups_agents": {
+ "name": "chat_groups_agents",
"schema": "",
"columns": {
- "id": {
- "name": "id",
+ "chat_group_id": {
+ "name": "chat_group_id",
"type": "text",
- "primaryKey": true,
+ "primaryKey": false,
"notNull": true
},
- "channel_id": {
- "name": "channel_id",
+ "agent_id": {
+ "name": "agent_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "root_message_id": {
- "name": "root_message_id",
- "type": "uuid",
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
"primaryKey": false,
"notNull": true
},
- "root_sequence": {
- "name": "root_sequence",
- "type": "integer",
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
- "follower_member_ids": {
- "name": "follower_member_ids",
- "type": "jsonb",
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
"primaryKey": false,
- "notNull": true,
- "default": "'[]'::jsonb"
+ "notNull": false,
+ "default": true
},
- "status": {
- "name": "status",
- "type": "text",
+ "order": {
+ "name": "order",
+ "type": "integer",
"primaryKey": false,
- "notNull": true,
- "default": "'active'"
+ "notNull": false,
+ "default": 0
},
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
+ "role": {
+ "name": "role",
+ "type": "text",
"primaryKey": false,
"notNull": false,
- "default": "'{}'::jsonb"
+ "default": "'participant'"
},
- "deleted_at": {
- "name": "deleted_at",
+ "accessed_at": {
+ "name": "accessed_at",
"type": "timestamp with time zone",
"primaryKey": false,
- "notNull": false
- },
- "is_deleted": {
- "name": "is_deleted",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
+ "notNull": true,
+ "default": "now()"
},
"created_at": {
"name": "created_at",
@@ -12517,79 +15573,118 @@
"primaryKey": false,
"notNull": true,
"default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
}
},
"indexes": {
- "channel_threads_root_unique": {
- "name": "channel_threads_root_unique",
+ "chat_groups_agents_user_id_idx": {
+ "name": "chat_groups_agents_user_id_idx",
"columns": [
{
- "expression": "channel_id",
+ "expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
- },
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "chat_groups_agents_workspace_id_idx": {
+ "name": "chat_groups_agents_workspace_id_idx",
+ "columns": [
{
- "expression": "root_message_id",
+ "expression": "workspace_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
- "isUnique": true,
- "where": "\"channel_threads\".\"is_deleted\" IS NOT TRUE",
+ "isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
- "channel_threads_channel_id_channels_id_fk": {
- "name": "channel_threads_channel_id_channels_id_fk",
- "tableFrom": "channel_threads",
- "tableTo": "channels",
- "columnsFrom": ["channel_id"],
+ "chat_groups_agents_chat_group_id_chat_groups_id_fk": {
+ "name": "chat_groups_agents_chat_group_id_chat_groups_id_fk",
+ "tableFrom": "chat_groups_agents",
+ "tableTo": "chat_groups",
+ "columnsFrom": ["chat_group_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "channel_threads_root_fk": {
- "name": "channel_threads_root_fk",
- "tableFrom": "channel_threads",
- "tableTo": "channel_messages",
- "columnsFrom": ["channel_id", "root_message_id"],
- "columnsTo": ["channel_id", "id"],
- "onDelete": "no action",
+ "chat_groups_agents_agent_id_agents_id_fk": {
+ "name": "chat_groups_agents_agent_id_agents_id_fk",
+ "tableFrom": "chat_groups_agents",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "chat_groups_agents_user_id_users_id_fk": {
+ "name": "chat_groups_agents_user_id_users_id_fk",
+ "tableFrom": "chat_groups_agents",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "chat_groups_agents_workspace_id_workspaces_id_fk": {
+ "name": "chat_groups_agents_workspace_id_workspaces_id_fk",
+ "tableFrom": "chat_groups_agents",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
"onUpdate": "no action"
}
},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {
- "channel_threads_scope_unique": {
- "name": "channel_threads_scope_unique",
- "nullsNotDistinct": false,
- "columns": ["channel_id", "id"]
+ "compositePrimaryKeys": {
+ "chat_groups_agents_chat_group_id_agent_id_pk": {
+ "name": "chat_groups_agents_chat_group_id_agent_id_pk",
+ "columns": ["chat_group_id", "agent_id"]
}
},
+ "uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.channels": {
- "name": "channels",
+ "public.user_connector_tools": {
+ "name": "user_connector_tools",
"schema": "",
"columns": {
"id": {
"name": "id",
- "type": "text",
+ "type": "uuid",
"primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_connector_id": {
+ "name": "user_connector_id",
+ "type": "uuid",
+ "primaryKey": false,
"notNull": true
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
"workspace_id": {
"name": "workspace_id",
@@ -12597,69 +15692,85 @@
"primaryKey": false,
"notNull": false
},
- "project_id": {
- "name": "project_id",
- "type": "text",
+ "tool_name": {
+ "name": "tool_name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "display_name": {
+ "name": "display_name",
+ "type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
- "agent_id": {
- "name": "agent_id",
+ "description": {
+ "name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "title": {
- "name": "title",
+ "input_schema": {
+ "name": "input_schema",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output_schema": {
+ "name": "output_schema",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "crud_type": {
+ "name": "crud_type",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "sequence": {
- "name": "sequence",
- "type": "integer",
+ "render_config": {
+ "name": "render_config",
+ "type": "jsonb",
"primaryKey": false,
- "notNull": true,
- "default": 0
+ "notNull": false
},
- "status": {
- "name": "status",
+ "permission": {
+ "name": "permission",
"type": "text",
"primaryKey": false,
- "notNull": true,
- "default": "'active'"
+ "notNull": true
},
- "visibility": {
- "name": "visibility",
- "type": "text",
+ "is_work_artifact": {
+ "name": "is_work_artifact",
+ "type": "boolean",
"primaryKey": false,
"notNull": true,
- "default": "'private'"
+ "default": false
},
- "config": {
- "name": "config",
+ "work_artifact_config": {
+ "name": "work_artifact_config",
"type": "jsonb",
"primaryKey": false,
"notNull": false
},
- "metadata": {
- "name": "metadata",
+ "limit_config": {
+ "name": "limit_config",
"type": "jsonb",
"primaryKey": false,
- "notNull": false,
- "default": "'{}'::jsonb"
+ "notNull": false
},
- "deleted_at": {
- "name": "deleted_at",
- "type": "timestamp with time zone",
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
"primaryKey": false,
"notNull": false
},
- "is_deleted": {
- "name": "is_deleted",
- "type": "boolean",
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": false
+ "notNull": true,
+ "default": "now()"
},
"created_at": {
"name": "created_at",
@@ -12677,79 +15788,65 @@
}
},
"indexes": {
- "channels_user_id_idx": {
- "name": "channels_user_id_idx",
+ "user_connector_tools_connector_tool_unique": {
+ "name": "user_connector_tools_connector_tool_unique",
"columns": [
{
- "expression": "user_id",
+ "expression": "user_connector_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "tool_name",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
- "isUnique": false,
+ "isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
},
- "channels_direct_unique": {
- "name": "channels_direct_unique",
+ "user_connector_tools_user_id_idx": {
+ "name": "user_connector_tools_user_id_idx",
"columns": [
- {
- "expression": "agent_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
{
"expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
- },
- {
- "expression": "coalesce(\"workspace_id\", '')",
- "asc": true,
- "isExpression": true,
- "nulls": "last"
}
],
- "isUnique": true,
- "where": "\"channels\".\"agent_id\" IS NOT NULL",
+ "isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
- "channels_project_id_idx": {
- "name": "channels_project_id_idx",
+ "user_connector_tools_connector_id_idx": {
+ "name": "user_connector_tools_connector_id_idx",
"columns": [
{
- "expression": "project_id",
+ "expression": "user_connector_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
- "where": "\"channels\".\"project_id\" IS NOT NULL",
"concurrently": false,
"method": "btree",
"with": {}
},
- "channels_workspace_visibility_idx": {
- "name": "channels_workspace_visibility_idx",
+ "user_connector_tools_workspace_id_idx": {
+ "name": "user_connector_tools_workspace_id_idx",
"columns": [
{
"expression": "workspace_id",
"isExpression": false,
"asc": true,
"nulls": "last"
- },
- {
- "expression": "visibility",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
}
],
"isUnique": false,
@@ -12759,38 +15856,29 @@
}
},
"foreignKeys": {
- "channels_user_id_users_id_fk": {
- "name": "channels_user_id_users_id_fk",
- "tableFrom": "channels",
- "tableTo": "users",
- "columnsFrom": ["user_id"],
- "columnsTo": ["id"],
- "onDelete": "set null",
- "onUpdate": "no action"
- },
- "channels_workspace_id_workspaces_id_fk": {
- "name": "channels_workspace_id_workspaces_id_fk",
- "tableFrom": "channels",
- "tableTo": "workspaces",
- "columnsFrom": ["workspace_id"],
+ "user_connector_tools_user_connector_id_user_connectors_id_fk": {
+ "name": "user_connector_tools_user_connector_id_user_connectors_id_fk",
+ "tableFrom": "user_connector_tools",
+ "tableTo": "user_connectors",
+ "columnsFrom": ["user_connector_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "channels_project_id_projects_id_fk": {
- "name": "channels_project_id_projects_id_fk",
- "tableFrom": "channels",
- "tableTo": "projects",
- "columnsFrom": ["project_id"],
+ "user_connector_tools_user_id_users_id_fk": {
+ "name": "user_connector_tools_user_id_users_id_fk",
+ "tableFrom": "user_connector_tools",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
"columnsTo": ["id"],
- "onDelete": "set null",
+ "onDelete": "cascade",
"onUpdate": "no action"
},
- "channels_agent_id_agents_id_fk": {
- "name": "channels_agent_id_agents_id_fk",
- "tableFrom": "channels",
- "tableTo": "agents",
- "columnsFrom": ["agent_id"],
+ "user_connector_tools_workspace_id_workspaces_id_fk": {
+ "name": "user_connector_tools_workspace_id_workspaces_id_fk",
+ "tableFrom": "user_connector_tools",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
@@ -12799,102 +15887,110 @@
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
- "checkConstraints": {
- "channels_direct_visibility_check": {
- "name": "channels_direct_visibility_check",
- "value": "\"channels\".\"agent_id\" IS NULL OR \"channels\".\"visibility\" = 'private'"
- }
- },
+ "checkConstraints": {},
"isRLSEnabled": false
},
- "public.chat_groups": {
- "name": "chat_groups",
+ "public.user_connectors": {
+ "name": "user_connectors",
"schema": "",
"columns": {
"id": {
"name": "id",
- "type": "text",
+ "type": "uuid",
"primaryKey": true,
- "notNull": true
+ "notNull": true,
+ "default": "gen_random_uuid()"
},
- "title": {
- "name": "title",
+ "user_id": {
+ "name": "user_id",
"type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "description": {
- "name": "description",
+ "workspace_id": {
+ "name": "workspace_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "avatar": {
- "name": "avatar",
+ "agent_id": {
+ "name": "agent_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "background_color": {
- "name": "background_color",
- "type": "text",
+ "identifier": {
+ "name": "identifier",
+ "type": "varchar(255)",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "market_identifier": {
- "name": "market_identifier",
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_type": {
+ "name": "source_type",
"type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "content": {
- "name": "content",
+ "mcp_server_url": {
+ "name": "mcp_server_url",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "editor_data": {
- "name": "editor_data",
- "type": "jsonb",
+ "mcp_connection_type": {
+ "name": "mcp_connection_type",
+ "type": "text",
"primaryKey": false,
"notNull": false
},
- "config": {
- "name": "config",
+ "mcp_stdio_config": {
+ "name": "mcp_stdio_config",
"type": "jsonb",
"primaryKey": false,
"notNull": false
},
- "client_id": {
- "name": "client_id",
+ "status": {
+ "name": "status",
"type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "user_id": {
- "name": "user_id",
- "type": "text",
+ "is_enabled": {
+ "name": "is_enabled",
+ "type": "boolean",
"primaryKey": false,
- "notNull": true
+ "notNull": true,
+ "default": true
},
- "workspace_id": {
- "name": "workspace_id",
- "type": "text",
+ "oidc_config": {
+ "name": "oidc_config",
+ "type": "jsonb",
"primaryKey": false,
"notNull": false
},
- "group_id": {
- "name": "group_id",
+ "credentials": {
+ "name": "credentials",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "pinned": {
- "name": "pinned",
- "type": "boolean",
+ "token_expires_at": {
+ "name": "token_expires_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": false,
- "default": false
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
},
"visibility": {
"name": "visibility",
@@ -12903,18 +15999,6 @@
"notNull": true,
"default": "'public'"
},
- "deleted_at": {
- "name": "deleted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "is_deleted": {
- "name": "is_deleted",
- "type": "boolean",
- "primaryKey": false,
- "notNull": false
- },
"accessed_at": {
"name": "accessed_at",
"type": "timestamp with time zone",
@@ -12938,47 +16022,83 @@
}
},
"indexes": {
- "chat_groups_client_id_user_id_unique": {
- "name": "chat_groups_client_id_user_id_unique",
+ "user_connectors_personal_identifier_idx": {
+ "name": "user_connectors_personal_identifier_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"user_connectors\".\"workspace_id\" IS NULL AND \"user_connectors\".\"agent_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_connectors_workspace_identifier_idx": {
+ "name": "user_connectors_workspace_identifier_idx",
"columns": [
{
- "expression": "client_id",
+ "expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
- "expression": "user_id",
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "identifier",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
- "isUnique": true,
+ "isUnique": false,
+ "where": "\"user_connectors\".\"workspace_id\" IS NOT NULL AND \"user_connectors\".\"agent_id\" IS NULL",
"concurrently": false,
"method": "btree",
"with": {}
},
- "chat_groups_user_id_idx": {
- "name": "chat_groups_user_id_idx",
+ "user_connectors_agent_identifier_idx": {
+ "name": "user_connectors_agent_identifier_idx",
"columns": [
{
- "expression": "user_id",
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "identifier",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
+ "where": "\"user_connectors\".\"agent_id\" IS NOT NULL",
"concurrently": false,
"method": "btree",
"with": {}
},
- "chat_groups_group_id_idx": {
- "name": "chat_groups_group_id_idx",
+ "user_connectors_user_id_idx": {
+ "name": "user_connectors_user_id_idx",
"columns": [
{
- "expression": "group_id",
+ "expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -12989,11 +16109,11 @@
"method": "btree",
"with": {}
},
- "chat_groups_workspace_id_idx": {
- "name": "chat_groups_workspace_id_idx",
+ "user_connectors_token_expires_at_idx": {
+ "name": "user_connectors_token_expires_at_idx",
"columns": [
{
- "expression": "workspace_id",
+ "expression": "token_expires_at",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -13004,23 +16124,26 @@
"method": "btree",
"with": {}
},
- "chat_groups_workspace_visibility_idx": {
- "name": "chat_groups_workspace_visibility_idx",
+ "user_connectors_workspace_id_idx": {
+ "name": "user_connectors_workspace_id_idx",
"columns": [
{
"expression": "workspace_id",
"isExpression": false,
"asc": true,
"nulls": "last"
- },
- {
- "expression": "visibility",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_connectors_agent_id_idx": {
+ "name": "user_connectors_agent_id_idx",
+ "columns": [
{
- "expression": "user_id",
+ "expression": "agent_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -13033,31 +16156,31 @@
}
},
"foreignKeys": {
- "chat_groups_user_id_users_id_fk": {
- "name": "chat_groups_user_id_users_id_fk",
- "tableFrom": "chat_groups",
+ "user_connectors_user_id_users_id_fk": {
+ "name": "user_connectors_user_id_users_id_fk",
+ "tableFrom": "user_connectors",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "chat_groups_workspace_id_workspaces_id_fk": {
- "name": "chat_groups_workspace_id_workspaces_id_fk",
- "tableFrom": "chat_groups",
+ "user_connectors_workspace_id_workspaces_id_fk": {
+ "name": "user_connectors_workspace_id_workspaces_id_fk",
+ "tableFrom": "user_connectors",
"tableTo": "workspaces",
"columnsFrom": ["workspace_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "chat_groups_group_id_session_groups_id_fk": {
- "name": "chat_groups_group_id_session_groups_id_fk",
- "tableFrom": "chat_groups",
- "tableTo": "session_groups",
- "columnsFrom": ["group_id"],
+ "user_connectors_agent_id_agents_id_fk": {
+ "name": "user_connectors_agent_id_agents_id_fk",
+ "tableFrom": "user_connectors",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
"columnsTo": ["id"],
- "onDelete": "set null",
+ "onDelete": "cascade",
"onUpdate": "no action"
}
},
@@ -13067,54 +16190,57 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.chat_groups_agents": {
- "name": "chat_groups_agents",
+ "public.user_installed_plugins": {
+ "name": "user_installed_plugins",
"schema": "",
"columns": {
- "chat_group_id": {
- "name": "chat_group_id",
+ "user_id": {
+ "name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "agent_id": {
- "name": "agent_id",
+ "workspace_id": {
+ "name": "workspace_id",
"type": "text",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
- "user_id": {
- "name": "user_id",
+ "identifier": {
+ "name": "identifier",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "workspace_id": {
- "name": "workspace_id",
+ "type": {
+ "name": "type",
"type": "text",
"primaryKey": false,
+ "notNull": true
+ },
+ "manifest": {
+ "name": "manifest",
+ "type": "jsonb",
+ "primaryKey": false,
"notNull": false
},
- "enabled": {
- "name": "enabled",
- "type": "boolean",
+ "settings": {
+ "name": "settings",
+ "type": "jsonb",
"primaryKey": false,
- "notNull": false,
- "default": true
+ "notNull": false
},
- "order": {
- "name": "order",
- "type": "integer",
+ "custom_params": {
+ "name": "custom_params",
+ "type": "jsonb",
"primaryKey": false,
- "notNull": false,
- "default": 0
+ "notNull": false
},
- "role": {
- "name": "role",
- "type": "text",
+ "source": {
+ "name": "source",
+ "type": "varchar(255)",
"primaryKey": false,
- "notNull": false,
- "default": "'participant'"
+ "notNull": false
},
"accessed_at": {
"name": "accessed_at",
@@ -13139,23 +16265,8 @@
}
},
"indexes": {
- "chat_groups_agents_user_id_idx": {
- "name": "chat_groups_agents_user_id_idx",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "chat_groups_agents_workspace_id_idx": {
- "name": "chat_groups_agents_workspace_id_idx",
+ "user_installed_plugins_workspace_id_idx": {
+ "name": "user_installed_plugins_workspace_id_idx",
"columns": [
{
"expression": "workspace_id",
@@ -13171,36 +16282,18 @@
}
},
"foreignKeys": {
- "chat_groups_agents_chat_group_id_chat_groups_id_fk": {
- "name": "chat_groups_agents_chat_group_id_chat_groups_id_fk",
- "tableFrom": "chat_groups_agents",
- "tableTo": "chat_groups",
- "columnsFrom": ["chat_group_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "chat_groups_agents_agent_id_agents_id_fk": {
- "name": "chat_groups_agents_agent_id_agents_id_fk",
- "tableFrom": "chat_groups_agents",
- "tableTo": "agents",
- "columnsFrom": ["agent_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "chat_groups_agents_user_id_users_id_fk": {
- "name": "chat_groups_agents_user_id_users_id_fk",
- "tableFrom": "chat_groups_agents",
+ "user_installed_plugins_user_id_users_id_fk": {
+ "name": "user_installed_plugins_user_id_users_id_fk",
+ "tableFrom": "user_installed_plugins",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "chat_groups_agents_workspace_id_workspaces_id_fk": {
- "name": "chat_groups_agents_workspace_id_workspaces_id_fk",
- "tableFrom": "chat_groups_agents",
+ "user_installed_plugins_workspace_id_workspaces_id_fk": {
+ "name": "user_installed_plugins_workspace_id_workspaces_id_fk",
+ "tableFrom": "user_installed_plugins",
"tableTo": "workspaces",
"columnsFrom": ["workspace_id"],
"columnsTo": ["id"],
@@ -13209,9 +16302,9 @@
}
},
"compositePrimaryKeys": {
- "chat_groups_agents_chat_group_id_agent_id_pk": {
- "name": "chat_groups_agents_chat_group_id_agent_id_pk",
- "columns": ["chat_group_id", "agent_id"]
+ "user_installed_plugins_user_id_identifier_pk": {
+ "name": "user_installed_plugins_user_id_identifier_pk",
+ "columns": ["user_id", "identifier"]
}
},
"uniqueConstraints": {},
@@ -13219,8 +16312,8 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.user_connector_tools": {
- "name": "user_connector_tools",
+ "public.user_contact_requests": {
+ "name": "user_contact_requests",
"schema": "",
"columns": {
"id": {
@@ -13230,14 +16323,14 @@
"notNull": true,
"default": "gen_random_uuid()"
},
- "user_connector_id": {
- "name": "user_connector_id",
- "type": "uuid",
+ "requester_id": {
+ "name": "requester_id",
+ "type": "text",
"primaryKey": false,
"notNull": true
},
- "user_id": {
- "name": "user_id",
+ "addressee_id": {
+ "name": "addressee_id",
"type": "text",
"primaryKey": false,
"notNull": true
@@ -13248,76 +16341,22 @@
"primaryKey": false,
"notNull": false
},
- "tool_name": {
- "name": "tool_name",
- "type": "varchar(255)",
- "primaryKey": false,
- "notNull": true
- },
- "display_name": {
- "name": "display_name",
- "type": "varchar(255)",
- "primaryKey": false,
- "notNull": false
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "input_schema": {
- "name": "input_schema",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "output_schema": {
- "name": "output_schema",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "crud_type": {
- "name": "crud_type",
+ "message": {
+ "name": "message",
"type": "text",
"primaryKey": false,
- "notNull": true
- },
- "render_config": {
- "name": "render_config",
- "type": "jsonb",
- "primaryKey": false,
"notNull": false
},
- "permission": {
- "name": "permission",
+ "status": {
+ "name": "status",
"type": "text",
"primaryKey": false,
- "notNull": true
- },
- "is_work_artifact": {
- "name": "is_work_artifact",
- "type": "boolean",
- "primaryKey": false,
"notNull": true,
- "default": false
- },
- "work_artifact_config": {
- "name": "work_artifact_config",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "limit_config": {
- "name": "limit_config",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
+ "default": "'pending'"
},
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
+ "responded_at": {
+ "name": "responded_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
"notNull": false
},
@@ -13344,32 +16383,67 @@
}
},
"indexes": {
- "user_connector_tools_connector_tool_unique": {
- "name": "user_connector_tools_connector_tool_unique",
+ "user_contact_requests_pending_unique": {
+ "name": "user_contact_requests_pending_unique",
"columns": [
{
- "expression": "user_connector_id",
+ "expression": "requester_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
- "expression": "tool_name",
+ "expression": "addressee_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
+ "where": "\"user_contact_requests\".\"status\" = 'pending' AND \"user_contact_requests\".\"workspace_id\" IS NULL",
"concurrently": false,
"method": "btree",
"with": {}
},
- "user_connector_tools_user_id_idx": {
- "name": "user_connector_tools_user_id_idx",
+ "user_contact_requests_workspace_pending_unique": {
+ "name": "user_contact_requests_workspace_pending_unique",
"columns": [
{
- "expression": "user_id",
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "requester_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "addressee_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"user_contact_requests\".\"status\" = 'pending' AND \"user_contact_requests\".\"workspace_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_contact_requests_addressee_status_idx": {
+ "name": "user_contact_requests_addressee_status_idx",
+ "columns": [
+ {
+ "expression": "addressee_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -13380,11 +16454,17 @@
"method": "btree",
"with": {}
},
- "user_connector_tools_connector_id_idx": {
- "name": "user_connector_tools_connector_id_idx",
+ "user_contact_requests_requester_status_idx": {
+ "name": "user_contact_requests_requester_status_idx",
"columns": [
{
- "expression": "user_connector_id",
+ "expression": "requester_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -13395,8 +16475,8 @@
"method": "btree",
"with": {}
},
- "user_connector_tools_workspace_id_idx": {
- "name": "user_connector_tools_workspace_id_idx",
+ "user_contact_requests_workspace_id_idx": {
+ "name": "user_contact_requests_workspace_id_idx",
"columns": [
{
"expression": "workspace_id",
@@ -13412,27 +16492,27 @@
}
},
"foreignKeys": {
- "user_connector_tools_user_connector_id_user_connectors_id_fk": {
- "name": "user_connector_tools_user_connector_id_user_connectors_id_fk",
- "tableFrom": "user_connector_tools",
- "tableTo": "user_connectors",
- "columnsFrom": ["user_connector_id"],
+ "user_contact_requests_requester_id_users_id_fk": {
+ "name": "user_contact_requests_requester_id_users_id_fk",
+ "tableFrom": "user_contact_requests",
+ "tableTo": "users",
+ "columnsFrom": ["requester_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "user_connector_tools_user_id_users_id_fk": {
- "name": "user_connector_tools_user_id_users_id_fk",
- "tableFrom": "user_connector_tools",
+ "user_contact_requests_addressee_id_users_id_fk": {
+ "name": "user_contact_requests_addressee_id_users_id_fk",
+ "tableFrom": "user_contact_requests",
"tableTo": "users",
- "columnsFrom": ["user_id"],
+ "columnsFrom": ["addressee_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "user_connector_tools_workspace_id_workspaces_id_fk": {
- "name": "user_connector_tools_workspace_id_workspaces_id_fk",
- "tableFrom": "user_connector_tools",
+ "user_contact_requests_workspace_id_workspaces_id_fk": {
+ "name": "user_contact_requests_workspace_id_workspaces_id_fk",
+ "tableFrom": "user_contact_requests",
"tableTo": "workspaces",
"columnsFrom": ["workspace_id"],
"columnsTo": ["id"],
@@ -13443,11 +16523,16 @@
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
- "checkConstraints": {},
+ "checkConstraints": {
+ "user_contact_requests_not_self_check": {
+ "name": "user_contact_requests_not_self_check",
+ "value": "\"user_contact_requests\".\"requester_id\" <> \"user_contact_requests\".\"addressee_id\""
+ }
+ },
"isRLSEnabled": false
},
- "public.user_connectors": {
- "name": "user_connectors",
+ "public.user_contact_tag_assignments": {
+ "name": "user_contact_tag_assignments",
"schema": "",
"columns": {
"id": {
@@ -13457,96 +16542,169 @@
"notNull": true,
"default": "gen_random_uuid()"
},
- "user_id": {
- "name": "user_id",
- "type": "text",
+ "tag_id": {
+ "name": "tag_id",
+ "type": "uuid",
"primaryKey": false,
"notNull": true
},
- "workspace_id": {
- "name": "workspace_id",
- "type": "text",
+ "contact_id": {
+ "name": "contact_id",
+ "type": "uuid",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "agent_id": {
- "name": "agent_id",
+ "user_id": {
+ "name": "user_id",
"type": "text",
"primaryKey": false,
- "notNull": false
- },
- "identifier": {
- "name": "identifier",
- "type": "varchar(255)",
- "primaryKey": false,
"notNull": true
},
- "name": {
- "name": "name",
- "type": "varchar(255)",
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": true
+ "notNull": true,
+ "default": "now()"
},
- "source_type": {
- "name": "source_type",
- "type": "text",
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": true
+ "notNull": true,
+ "default": "now()"
},
- "mcp_server_url": {
- "name": "mcp_server_url",
- "type": "text",
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": false
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_contact_tag_assignments_tag_id_contact_id_unique": {
+ "name": "user_contact_tag_assignments_tag_id_contact_id_unique",
+ "columns": [
+ {
+ "expression": "tag_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "contact_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
},
- "mcp_connection_type": {
- "name": "mcp_connection_type",
- "type": "text",
- "primaryKey": false,
- "notNull": false
+ "user_contact_tag_assignments_contact_id_idx": {
+ "name": "user_contact_tag_assignments_contact_id_idx",
+ "columns": [
+ {
+ "expression": "contact_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
},
- "mcp_stdio_config": {
- "name": "mcp_stdio_config",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
+ "user_contact_tag_assignments_user_id_idx": {
+ "name": "user_contact_tag_assignments_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_contact_tag_assignments_tag_id_user_contact_tags_id_fk": {
+ "name": "user_contact_tag_assignments_tag_id_user_contact_tags_id_fk",
+ "tableFrom": "user_contact_tag_assignments",
+ "tableTo": "user_contact_tags",
+ "columnsFrom": ["tag_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
},
- "status": {
- "name": "status",
- "type": "text",
- "primaryKey": false,
- "notNull": true
+ "user_contact_tag_assignments_contact_id_user_contacts_id_fk": {
+ "name": "user_contact_tag_assignments_contact_id_user_contacts_id_fk",
+ "tableFrom": "user_contact_tag_assignments",
+ "tableTo": "user_contacts",
+ "columnsFrom": ["contact_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
},
- "is_enabled": {
- "name": "is_enabled",
- "type": "boolean",
- "primaryKey": false,
+ "user_contact_tag_assignments_user_id_users_id_fk": {
+ "name": "user_contact_tag_assignments_user_id_users_id_fk",
+ "tableFrom": "user_contact_tag_assignments",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_contact_tags": {
+ "name": "user_contact_tags",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
"notNull": true,
- "default": true
+ "default": "gen_random_uuid()"
},
- "oidc_config": {
- "name": "oidc_config",
- "type": "jsonb",
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "credentials": {
- "name": "credentials",
+ "name": {
+ "name": "name",
"type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "token_expires_at": {
- "name": "token_expires_at",
- "type": "timestamp with time zone",
+ "color": {
+ "name": "color",
+ "type": "text",
"primaryKey": false,
"notNull": false
},
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
"primaryKey": false,
- "notNull": false
+ "notNull": true,
+ "default": 0
},
"accessed_at": {
"name": "accessed_at",
@@ -13571,8 +16729,8 @@
}
},
"indexes": {
- "user_connectors_personal_identifier_idx": {
- "name": "user_connectors_personal_identifier_idx",
+ "user_contact_tags_user_id_name_unique": {
+ "name": "user_contact_tags_user_id_name_unique",
"columns": [
{
"expression": "user_id",
@@ -13581,20 +16739,125 @@
"nulls": "last"
},
{
- "expression": "identifier",
+ "expression": "name",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
- "isUnique": false,
- "where": "\"user_connectors\".\"workspace_id\" IS NULL AND \"user_connectors\".\"agent_id\" IS NULL",
+ "isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_contact_tags_user_id_users_id_fk": {
+ "name": "user_contact_tags_user_id_users_id_fk",
+ "tableFrom": "user_contact_tags",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_contacts": {
+ "name": "user_contacts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
},
- "user_connectors_workspace_identifier_idx": {
- "name": "user_connectors_workspace_identifier_idx",
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "contact_user_id": {
+ "name": "contact_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "remark": {
+ "name": "remark",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "phones": {
+ "name": "phones",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "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": {
+ "user_contacts_user_unique": {
+ "name": "user_contacts_user_unique",
"columns": [
{
"expression": "user_id",
@@ -13602,6 +16865,22 @@
"asc": true,
"nulls": "last"
},
+ {
+ "expression": "contact_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"user_contacts\".\"contact_user_id\" IS NOT NULL AND \"user_contacts\".\"workspace_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_contacts_workspace_user_unique": {
+ "name": "user_contacts_workspace_user_unique",
+ "columns": [
{
"expression": "workspace_id",
"isExpression": false,
@@ -13609,60 +16888,73 @@
"nulls": "last"
},
{
- "expression": "identifier",
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "contact_user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
- "isUnique": false,
- "where": "\"user_connectors\".\"workspace_id\" IS NOT NULL AND \"user_connectors\".\"agent_id\" IS NULL",
+ "isUnique": true,
+ "where": "\"user_contacts\".\"contact_user_id\" IS NOT NULL AND \"user_contacts\".\"workspace_id\" IS NOT NULL",
"concurrently": false,
"method": "btree",
"with": {}
},
- "user_connectors_agent_identifier_idx": {
- "name": "user_connectors_agent_identifier_idx",
+ "user_contacts_agent_unique": {
+ "name": "user_contacts_agent_unique",
"columns": [
{
- "expression": "agent_id",
+ "expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
- "expression": "identifier",
+ "expression": "agent_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
- "isUnique": false,
- "where": "\"user_connectors\".\"agent_id\" IS NOT NULL",
+ "isUnique": true,
+ "where": "\"user_contacts\".\"agent_id\" IS NOT NULL AND \"user_contacts\".\"workspace_id\" IS NULL",
"concurrently": false,
"method": "btree",
"with": {}
},
- "user_connectors_user_id_idx": {
- "name": "user_connectors_user_id_idx",
+ "user_contacts_workspace_agent_unique": {
+ "name": "user_contacts_workspace_agent_unique",
"columns": [
{
- "expression": "user_id",
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "agent_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
- "isUnique": false,
+ "isUnique": true,
+ "where": "\"user_contacts\".\"agent_id\" IS NOT NULL AND \"user_contacts\".\"workspace_id\" IS NOT NULL",
"concurrently": false,
"method": "btree",
"with": {}
},
- "user_connectors_token_expires_at_idx": {
- "name": "user_connectors_token_expires_at_idx",
+ "user_contacts_contact_user_id_idx": {
+ "name": "user_contacts_contact_user_id_idx",
"columns": [
{
- "expression": "token_expires_at",
+ "expression": "contact_user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -13673,11 +16965,11 @@
"method": "btree",
"with": {}
},
- "user_connectors_workspace_id_idx": {
- "name": "user_connectors_workspace_id_idx",
+ "user_contacts_agent_id_idx": {
+ "name": "user_contacts_agent_id_idx",
"columns": [
{
- "expression": "workspace_id",
+ "expression": "agent_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -13688,11 +16980,11 @@
"method": "btree",
"with": {}
},
- "user_connectors_agent_id_idx": {
- "name": "user_connectors_agent_id_idx",
+ "user_contacts_workspace_id_idx": {
+ "name": "user_contacts_workspace_id_idx",
"columns": [
{
- "expression": "agent_id",
+ "expression": "workspace_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -13705,157 +16997,44 @@
}
},
"foreignKeys": {
- "user_connectors_user_id_users_id_fk": {
- "name": "user_connectors_user_id_users_id_fk",
- "tableFrom": "user_connectors",
+ "user_contacts_user_id_users_id_fk": {
+ "name": "user_contacts_user_id_users_id_fk",
+ "tableFrom": "user_contacts",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "user_connectors_workspace_id_workspaces_id_fk": {
- "name": "user_connectors_workspace_id_workspaces_id_fk",
- "tableFrom": "user_connectors",
+ "user_contacts_workspace_id_workspaces_id_fk": {
+ "name": "user_contacts_workspace_id_workspaces_id_fk",
+ "tableFrom": "user_contacts",
"tableTo": "workspaces",
"columnsFrom": ["workspace_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "user_connectors_agent_id_agents_id_fk": {
- "name": "user_connectors_agent_id_agents_id_fk",
- "tableFrom": "user_connectors",
- "tableTo": "agents",
- "columnsFrom": ["agent_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.user_installed_plugins": {
- "name": "user_installed_plugins",
- "schema": "",
- "columns": {
- "user_id": {
- "name": "user_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "workspace_id": {
- "name": "workspace_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "identifier": {
- "name": "identifier",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "type": {
- "name": "type",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "manifest": {
- "name": "manifest",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "settings": {
- "name": "settings",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "custom_params": {
- "name": "custom_params",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "source": {
- "name": "source",
- "type": "varchar(255)",
- "primaryKey": false,
- "notNull": false
- },
- "accessed_at": {
- "name": "accessed_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": true,
- "default": "now()"
- },
- "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": {
- "user_installed_plugins_workspace_id_idx": {
- "name": "user_installed_plugins_workspace_id_idx",
- "columns": [
- {
- "expression": "workspace_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "user_installed_plugins_user_id_users_id_fk": {
- "name": "user_installed_plugins_user_id_users_id_fk",
- "tableFrom": "user_installed_plugins",
+ "user_contacts_contact_user_id_users_id_fk": {
+ "name": "user_contacts_contact_user_id_users_id_fk",
+ "tableFrom": "user_contacts",
"tableTo": "users",
- "columnsFrom": ["user_id"],
+ "columnsFrom": ["contact_user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "user_installed_plugins_workspace_id_workspaces_id_fk": {
- "name": "user_installed_plugins_workspace_id_workspaces_id_fk",
- "tableFrom": "user_installed_plugins",
- "tableTo": "workspaces",
- "columnsFrom": ["workspace_id"],
+ "user_contacts_agent_id_agents_id_fk": {
+ "name": "user_contacts_agent_id_agents_id_fk",
+ "tableFrom": "user_contacts",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
- "compositePrimaryKeys": {
- "user_installed_plugins_user_id_identifier_pk": {
- "name": "user_installed_plugins_user_id_identifier_pk",
- "columns": ["user_id", "identifier"]
- }
- },
+ "compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
@@ -18445,6 +21624,12 @@
"primaryKey": false,
"notNull": false
},
+ "created_by_agent_id": {
+ "name": "created_by_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
"visibility": {
"name": "visibility",
"type": "text",
@@ -22556,6 +25741,338 @@
"checkConstraints": {},
"isRLSEnabled": false
},
+ "public.inbound_webhooks": {
+ "name": "inbound_webhooks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instructions": {
+ "name": "instructions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "secret": {
+ "name": "secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verification": {
+ "name": "verification",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "connector_id": {
+ "name": "connector_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "next_maintenance_at": {
+ "name": "next_maintenance_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "maintenance_failures": {
+ "name": "maintenance_failures",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "last_delivery_at": {
+ "name": "last_delivery_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wake_count": {
+ "name": "wake_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "wake_window_started_at": {
+ "name": "wake_window_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "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": {
+ "inbound_webhooks_user_kind_dedupe_unique": {
+ "name": "inbound_webhooks_user_kind_dedupe_unique",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "dedupe_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"inbound_webhooks\".\"dedupe_key\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "inbound_webhooks_next_maintenance_idx": {
+ "name": "inbound_webhooks_next_maintenance_idx",
+ "columns": [
+ {
+ "expression": "next_maintenance_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"inbound_webhooks\".\"next_maintenance_at\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "inbound_webhooks_user_idx": {
+ "name": "inbound_webhooks_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "inbound_webhooks_workspace_idx": {
+ "name": "inbound_webhooks_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "inbound_webhooks_topic_idx": {
+ "name": "inbound_webhooks_topic_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "inbound_webhooks_agent_idx": {
+ "name": "inbound_webhooks_agent_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "inbound_webhooks_connector_idx": {
+ "name": "inbound_webhooks_connector_idx",
+ "columns": [
+ {
+ "expression": "connector_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "inbound_webhooks_user_id_users_id_fk": {
+ "name": "inbound_webhooks_user_id_users_id_fk",
+ "tableFrom": "inbound_webhooks",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "inbound_webhooks_workspace_id_workspaces_id_fk": {
+ "name": "inbound_webhooks_workspace_id_workspaces_id_fk",
+ "tableFrom": "inbound_webhooks",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "inbound_webhooks_agent_id_agents_id_fk": {
+ "name": "inbound_webhooks_agent_id_agents_id_fk",
+ "tableFrom": "inbound_webhooks",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "inbound_webhooks_topic_id_topics_id_fk": {
+ "name": "inbound_webhooks_topic_id_topics_id_fk",
+ "tableFrom": "inbound_webhooks",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "inbound_webhooks_connector_id_user_connectors_id_fk": {
+ "name": "inbound_webhooks_connector_id_user_connectors_id_fk",
+ "tableFrom": "inbound_webhooks",
+ "tableTo": "user_connectors",
+ "columnsFrom": ["connector_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
"public.linear_connections": {
"name": "linear_connections",
"schema": "",
@@ -48545,6 +52062,13 @@
"primaryKey": false,
"notNull": false
},
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
"joined_at": {
"name": "joined_at",
"type": "timestamp with time zone",
diff --git a/packages/database/migrations/meta/_journal.json b/packages/database/migrations/meta/_journal.json
index 05fe4f7b35b..fa9e480f827 100644
--- a/packages/database/migrations/meta/_journal.json
+++ b/packages/database/migrations/meta/_journal.json
@@ -1533,6 +1533,13 @@
"when": 1794852458535,
"tag": "0218_channel_and_contacts_schema",
"breakpoints": true
+ },
+ {
+ "idx": 219,
+ "version": "7",
+ "when": 1794890771557,
+ "tag": "0219_contacts_external_contacts",
+ "breakpoints": true
}
],
"version": "6"
diff --git a/packages/database/src/models/__tests__/contact.test.ts b/packages/database/src/models/__tests__/contact.test.ts
index ab33ae97d25..45fc17a94c4 100644
--- a/packages/database/src/models/__tests__/contact.test.ts
+++ b/packages/database/src/models/__tests__/contact.test.ts
@@ -9,6 +9,7 @@ import {
userContactRequests,
userContacts,
users,
+ workspaceMembers,
workspaces,
} from '../../schemas';
import type { LobeChatDatabase } from '../../type';
@@ -28,6 +29,9 @@ const carolModel = new ContactModel(serverDB, carol);
const teamId = 'contact-test-team';
const aliceInTeam = new ContactModel(serverDB, alice, teamId);
const carolInTeam = new ContactModel(serverDB, carol, teamId);
+// A model resolves the caller's role in the scope once, like one request; Bob's changes as he
+// joins, so each use gets a fresh one.
+const bobInTeam = () => new ContactModel(serverDB, bob, teamId);
let bobShareId: string;
@@ -41,6 +45,11 @@ beforeEach(async () => {
await serverDB
.insert(workspaces)
.values({ id: teamId, name: 'Team', primaryOwnerId: alice, slug: teamId });
+ // Alice owns the team and Carol is a member; Bob stays outside it.
+ await serverDB.insert(workspaceMembers).values([
+ { role: 'owner', userId: alice, workspaceId: teamId },
+ { role: 'member', userId: carol, workspaceId: teamId },
+ ]);
await serverDB.insert(agents).values([
{ id: bobAgent, title: 'Bob Helper', userId: bob },
{ id: aliceAgent, title: 'Alice Helper', userId: alice },
@@ -259,7 +268,9 @@ describe('shared Agents in a workspace', () => {
expect(await aliceModel.list()).toMatchObject([{ type: 'user', user: { id: bob } }]);
// A personal contact is not a colleague: the workspace lists its members instead.
expect(await aliceInTeam.list()).toEqual([]);
- expect(await aliceInTeam.isContact(bob)).toBe(true);
+ expect(await aliceInTeam.isContact(bob)).toBe(false);
+ // Nor does it let Bob into the workspace.
+ await expect(bobInTeam().list()).rejects.toThrow('Not a member of this workspace');
});
it('holds an Agent once per workspace, apart from personal entries', async () => {
@@ -275,6 +286,107 @@ describe('shared Agents in a workspace', () => {
});
});
+describe('external contacts of a workspace', () => {
+ /** Alice invites Bob from the team and Bob accepts it from his personal space. */
+ const inviteBob = async () => {
+ const { requestId } = await aliceInTeam.sendRequest(bob, 'Join us');
+ const [invitation] = await bobModel.listRequests();
+ expect(invitation).toMatchObject({
+ direction: 'incoming',
+ id: requestId,
+ user: { id: alice },
+ workspace: { id: teamId, name: 'Team' },
+ });
+ expect(await bobModel.acceptRequest(requestId)).toEqual({
+ contactUserId: alice,
+ workspaceId: teamId,
+ });
+ };
+
+ it('keeps the invitation in its own scope until it is answered', async () => {
+ await aliceInTeam.sendRequest(bob);
+ // The inviter sees it in the team, not in her personal space.
+ expect(await aliceInTeam.listRequests()).toMatchObject([
+ { direction: 'outgoing', user: { id: bob } },
+ ]);
+ expect(await aliceModel.listRequests()).toEqual([]);
+ expect(await carolInTeam.listRequests()).toEqual([]);
+ expect(await aliceInTeam.relationTo(bob)).toBe('request_sent');
+ expect(await aliceModel.relationTo(bob)).toBe('none');
+ // A personal request between the same two people is separate.
+ expect(await aliceModel.sendRequest(bob)).toMatchObject({ status: 'pending' });
+ });
+
+ it('invites only people outside the workspace, and only as a member', async () => {
+ await expect(aliceInTeam.sendRequest(carol)).rejects.toThrow('Already a member');
+ expect(await aliceInTeam.relationTo(carol)).toBe('member');
+ await inviteBob();
+ await expect(bobInTeam().sendRequest(carol)).rejects.toThrow('Only members add contacts');
+ });
+
+ it('shows an external contact only the inviter, and nothing else of the workspace', async () => {
+ await carolInTeam.addAgent('bob-helper');
+ await inviteBob();
+
+ expect(await bobInTeam().list()).toMatchObject([{ type: 'user', user: { id: alice } }]);
+ expect(await bobInTeam().search('carol')).toEqual([]);
+ expect(await bobInTeam().listRequests()).toEqual([]);
+ expect(await bobInTeam().findAgentAccess(bobAgent)).toBeUndefined();
+ // His personal address book is untouched.
+ expect(await bobModel.list()).toEqual([]);
+ });
+
+ it('lists every external contact to every member, marking who is open to them', async () => {
+ await inviteBob();
+ const externals = (items: Awaited<ReturnType<ContactModel['list']>>) =>
+ items.filter((item) => item.type === 'user');
+
+ expect(externals(await aliceInTeam.list())).toMatchObject([
+ { external: { openedToMe: true }, user: { id: bob } },
+ ]);
+ expect(externals(await carolInTeam.list())).toMatchObject([
+ { external: { openedToMe: false }, user: { id: bob } },
+ ]);
+
+ // Carol opens herself; Bob now sees her too.
+ await carolInTeam.openTo(bob);
+ expect(externals(await carolInTeam.list())).toMatchObject([
+ { external: { openedToMe: true }, user: { id: bob } },
+ ]);
+ expect((await bobInTeam().list()).map((item) => item.type === 'user' && item.user.id)).toEqual(
+ expect.arrayContaining([alice, carol]),
+ );
+
+ // Closing again only removes her own pairing.
+ await carolInTeam.removeUser(bob);
+ expect(await bobInTeam().list()).toMatchObject([{ user: { id: alice } }]);
+ });
+
+ it('opens only to an external contact, never a stranger or a colleague', async () => {
+ await expect(carolInTeam.openTo(bob)).rejects.toThrow('External contact not found');
+ await expect(carolInTeam.openTo(alice)).rejects.toThrow('External contact not found');
+ });
+
+ it('lets an owner or admin remove an external contact from the workspace', async () => {
+ await inviteBob();
+ await carolInTeam.openTo(bob);
+ await expect(carolInTeam.removeExternal(bob)).rejects.toThrow('Only owners and admins');
+
+ await aliceInTeam.removeExternal(bob);
+ expect(await carolInTeam.list()).toEqual([]);
+ await expect(bobInTeam().list()).rejects.toThrow('Not a member of this workspace');
+ });
+
+ it('lets the invitation lapse once the inviter leaves the workspace', async () => {
+ const { requestId } = await carolInTeam.sendRequest(bob);
+ await serverDB
+ .update(workspaceMembers)
+ .set({ deletedAt: new Date() })
+ .where(eq(workspaceMembers.userId, carol));
+ await expect(bobModel.acceptRequest(requestId)).rejects.toThrow('Request not found');
+ });
+});
+
describe('search', () => {
it('finds people by exact username, case-insensitively, with their relation', async () => {
const [result] = await aliceModel.search('@BOB');
diff --git a/packages/database/src/models/contact.ts b/packages/database/src/models/contact.ts
index 3f6bf71e826..e6dee20222d 100644
--- a/packages/database/src/models/contact.ts
+++ b/packages/database/src/models/contact.ts
@@ -8,10 +8,19 @@ import type {
ContactUserItem,
} from '@lobechat/types';
import { TRPCError } from '@trpc/server';
-import { and, desc, eq, isNull, or, sql } from 'drizzle-orm';
+import type { SQLWrapper } from 'drizzle-orm';
+import { and, desc, eq, exists, inArray, isNotNull, isNull, not, or, sql } from 'drizzle-orm';
import { alias } from 'drizzle-orm/pg-core';
-import { agents, agentShares, userContactRequests, userContacts, users } from '../schemas';
+import {
+ agents,
+ agentShares,
+ userContactRequests,
+ userContacts,
+ users,
+ workspaceMembers,
+ workspaces,
+} from '../schemas';
import type { LobeChatDatabase } from '../type';
import { normalizeInboxAgentAvatar, normalizeInboxAgentTitle } from '../utils/inboxAgent';
import { notTrashed } from '../utils/softDelete';
@@ -26,6 +35,19 @@ const userProfileColumns = {
const owners = alias(users, 'contact_agent_owner');
+/** Who the caller is in the active scope. */
+type ScopeRole = 'personal' | 'member' | 'external';
+
+const WORKSPACE_MANAGER_ROLES = ['owner', 'admin'];
+
+/** `userId` (a value or a column) is an active member of the workspace. */
+const activeMemberWhere = (workspaceId: string, userId: string | SQLWrapper) =>
+ and(
+ eq(workspaceMembers.workspaceId, workspaceId),
+ eq(workspaceMembers.userId, userId as string),
+ isNull(workspaceMembers.deletedAt),
+ );
+
/** Columns of an Agent reached through its share, with the owner joined as `owners`. */
const agentProfileColumns = {
agentAvatar: agents.avatar,
@@ -85,10 +107,15 @@ export const parseContactHandle = (query: string): string | undefined => {
};
/**
- * A person's address book and contact requests. Every method acts as `userId`; another
- * person's rows are only touched as the second half of a mutual relation. People are personal: a
- * workspace lists none, its colleagues being its members. Agents are the scope's: in the personal space the caller's own, in a workspace
- * the ones any member added there, which every member sees and may remove.
+ * A person's address book and contact requests in one scope. Every method acts as `userId`;
+ * another person's rows are only touched as the second half of a mutual relation.
+ *
+ * People are the scope's. In the personal space they are personal contacts. In a workspace,
+ * colleagues are its members and need no entry; the address book holds its external contacts,
+ * people outside it paired with the members who opened themselves to them. A member sees every
+ * external contact; an external contact sees only the members paired with them and nothing else
+ * of the workspace. Agents are the scope's too: in the personal space the caller's own, in a
+ * workspace the ones any member added there, which every member sees and may remove.
*/
export class ContactModel {
private readonly db: LobeChatDatabase;
@@ -101,6 +128,53 @@ export class ContactModel {
this.workspaceId = workspaceId || null;
}
+ #scopeRole?: Promise<ScopeRole>;
+
+ /**
+ * Who the caller is in the active scope. In a workspace, an entry pairing them with a member
+ * makes them an external contact; anyone else is refused.
+ */
+ private scopeRole = (): Promise<ScopeRole> => (this.#scopeRole ??= this.loadScopeRole());
+
+ private async loadScopeRole(): Promise<ScopeRole> {
+ if (!this.workspaceId) return 'personal';
+ if (await this.isMember(this.userId)) return 'member';
+ const [entry] = await this.db
+ .select({ id: userContacts.id })
+ .from(userContacts)
+ .where(and(this.userEntryWhere(), eq(userContacts.userId, this.userId)))
+ .limit(1);
+ if (entry) return 'external';
+ throw new TRPCError({ code: 'FORBIDDEN', message: 'Not a member of this workspace' });
+ }
+
+ private async isMember(userId: string) {
+ if (!this.workspaceId) return false;
+ const [row] = await this.db
+ .select({ userId: workspaceMembers.userId })
+ .from(workspaceMembers)
+ .where(activeMemberWhere(this.workspaceId, userId))
+ .limit(1);
+ return !!row;
+ }
+
+ /** The person entries of this scope's address book. */
+ private userEntryWhere() {
+ return and(
+ eq(userContacts.type, 'user'),
+ this.workspaceId
+ ? eq(userContacts.workspaceId, this.workspaceId)
+ : isNull(userContacts.workspaceId),
+ );
+ }
+
+ /** Requests of this scope: personal ones, or the ones members sent from this workspace. */
+ private requestScopeWhere() {
+ return this.workspaceId
+ ? eq(userContactRequests.workspaceId, this.workspaceId)
+ : isNull(userContactRequests.workspaceId);
+ }
+
/** The Agent entries of this scope's address book. */
private agentEntryWhere() {
return this.workspaceId
@@ -113,30 +187,22 @@ export class ContactModel {
}
list = async (): Promise<ContactItem[]> => {
- const [people, sharedAgents] = await Promise.all([
- this.workspaceId
+ const role = await this.scopeRole();
+ const [userItems, sharedAgents] = await Promise.all([
+ role === 'member' ? this.listExternals() : this.listOwnPeople(role),
+ // The workspace's Agents are its members' business, not an external contact's.
+ role === 'external'
? []
: this.db
- .select({ createdAt: userContacts.createdAt, user: userProfileColumns })
+ .select({ createdAt: userContacts.createdAt, ...agentProfileColumns })
.from(userContacts)
- .innerJoin(users, eq(users.id, userContacts.contactUserId))
- .where(and(eq(userContacts.userId, this.userId), eq(userContacts.type, 'user')))
+ .innerJoin(agents, eq(agents.id, userContacts.agentId))
+ .innerJoin(agentShares, eq(agentShares.agentId, agents.id))
+ .leftJoin(owners, eq(owners.id, agents.userId))
+ .where(this.agentEntryWhere())
.orderBy(desc(userContacts.createdAt)),
- this.db
- .select({ createdAt: userContacts.createdAt, ...agentProfileColumns })
- .from(userContacts)
- .innerJoin(agents, eq(agents.id, userContacts.agentId))
- .innerJoin(agentShares, eq(agentShares.agentId, agents.id))
- .leftJoin(owners, eq(owners.id, agents.userId))
- .where(this.agentEntryWhere())
- .orderBy(desc(userContacts.createdAt)),
]);
- const userItems: ContactUserItem[] = people.map((row) => ({
- createdAt: row.createdAt,
- type: 'user',
- user: row.user,
- }));
const agentItems: ContactAgentItem[] = sharedAgents.map((row) => ({
agent: toAgentProfile(row),
available: row.visibility === 'link' && !row.isDeleted,
@@ -147,14 +213,78 @@ export class ContactModel {
return [...userItems, ...agentItems];
};
+ /**
+ * My own entries: personal contacts, or, for an external contact, the members paired with them
+ * who are still members.
+ */
+ private async listOwnPeople(role: ScopeRole): Promise<ContactUserItem[]> {
+ const rows = await this.db
+ .select({ createdAt: userContacts.createdAt, user: userProfileColumns })
+ .from(userContacts)
+ .innerJoin(users, eq(users.id, userContacts.contactUserId))
+ .where(
+ and(
+ this.userEntryWhere(),
+ eq(userContacts.userId, this.userId),
+ role === 'external' ? this.contactIsMember() : undefined,
+ ),
+ )
+ .orderBy(desc(userContacts.createdAt));
+ return rows.map((row) => ({ createdAt: row.createdAt, type: 'user', user: row.user }));
+ }
+
+ /** The entry's `contact_user_id` is an active member of the workspace. */
+ private contactIsMember() {
+ return exists(
+ this.db
+ .select({ userId: workspaceMembers.userId })
+ .from(workspaceMembers)
+ .where(activeMemberWhere(this.workspaceId!, userContacts.contactUserId)),
+ );
+ }
+
+ /** Every external contact of the workspace, as a member sees them. */
+ private async listExternals(): Promise<ContactUserItem[]> {
+ const rows = await this.db
+ .select({
+ createdAt: userContacts.createdAt,
+ pairedUserId: userContacts.userId,
+ user: userProfileColumns,
+ })
+ .from(userContacts)
+ .innerJoin(users, eq(users.id, userContacts.contactUserId))
+ .where(and(this.userEntryWhere(), not(this.contactIsMember())))
+ .orderBy(userContacts.createdAt);
+
+ const byUser = new Map<string, ContactUserItem>();
+ for (const row of rows) {
+ const openedToMe = row.pairedUserId === this.userId;
+ const item = byUser.get(row.user.id);
+ if (item) item.external!.openedToMe ||= openedToMe;
+ else
+ byUser.set(row.user.id, {
+ createdAt: row.createdAt,
+ external: { openedToMe },
+ type: 'user',
+ user: row.user,
+ });
+ }
+ return [...byUser.values()].reverse();
+ }
+
// ── People ────────────────────────────────────────────────────────────
+ /** Whether I am paired with the person in this scope. */
isContact = async (contactUserId: string): Promise<boolean> => {
const [row] = await this.db
.select({ id: userContacts.id })
.from(userContacts)
.where(
- and(eq(userContacts.userId, this.userId), eq(userContacts.contactUserId, contactUserId)),
+ and(
+ this.userEntryWhere(),
+ eq(userContacts.userId, this.userId),
+ eq(userContacts.contactUserId, contactUserId),
+ ),
)
.limit(1);
return !!row;
@@ -172,11 +302,19 @@ export class ContactModel {
relationTo = async (otherUserId: string): Promise<ContactRelation> => {
if (otherUserId === this.userId) return 'self';
+ if ((await this.scopeRole()) === 'member' && (await this.isMember(otherUserId)))
+ return 'member';
if (await this.isContact(otherUserId)) return 'contact';
const [pending] = await this.db
.select({ requesterId: userContactRequests.requesterId })
.from(userContactRequests)
- .where(and(eq(userContactRequests.status, 'pending'), this.pairWhere(otherUserId)))
+ .where(
+ and(
+ eq(userContactRequests.status, 'pending'),
+ this.requestScopeWhere(),
+ this.pairWhere(otherUserId),
+ ),
+ )
.limit(1);
if (!pending) return 'none';
return pending.requesterId === this.userId ? 'request_sent' : 'request_received';
@@ -184,7 +322,8 @@ export class ContactModel {
/**
* Ask `addresseeId` to become mutual contacts. Repeating a pending request returns it; a
- * request sent while theirs is pending accepts theirs instead.
+ * personal request sent while theirs is pending accepts theirs instead. In a workspace only a
+ * member asks, and only someone outside it: it invites them to be its external contact.
*/
sendRequest = async (
addresseeId: string,
@@ -192,6 +331,11 @@ export class ContactModel {
): Promise<{ requestId: string; status: 'accepted' | 'pending' }> => {
if (addresseeId === this.userId)
throw new TRPCError({ code: 'BAD_REQUEST', message: 'You cannot add yourself' });
+ const role = await this.scopeRole();
+ if (role === 'external')
+ throw new TRPCError({ code: 'FORBIDDEN', message: 'Only members add contacts here' });
+ if (role === 'member' && (await this.isMember(addresseeId)))
+ throw new TRPCError({ code: 'CONFLICT', message: 'Already a member of this workspace' });
return this.db.transaction(async (tx) => {
const [addressee] = await tx
@@ -208,7 +352,11 @@ export class ContactModel {
.select({ id: userContacts.id })
.from(userContacts)
.where(
- and(eq(userContacts.userId, this.userId), eq(userContacts.contactUserId, addresseeId)),
+ and(
+ this.userEntryWhere(),
+ eq(userContacts.userId, this.userId),
+ eq(userContacts.contactUserId, addresseeId),
+ ),
)
.limit(1);
if (existing) throw new TRPCError({ code: 'CONFLICT', message: 'Already a contact' });
@@ -216,46 +364,76 @@ export class ContactModel {
const [pending] = await tx
.select({ id: userContactRequests.id, requesterId: userContactRequests.requesterId })
.from(userContactRequests)
- .where(and(eq(userContactRequests.status, 'pending'), this.pairWhere(addresseeId)))
+ .where(
+ and(
+ eq(userContactRequests.status, 'pending'),
+ this.requestScopeWhere(),
+ this.pairWhere(addresseeId),
+ ),
+ )
.limit(1);
if (pending?.requesterId === this.userId) return { requestId: pending.id, status: 'pending' };
// Their pending request is answered by mine, unless they withdrew it meanwhile; then mine
// goes out as a new request.
- if (pending && (await this.accept(tx, pending.id, addresseeId)))
+ if (pending && (await this.accept(tx, pending.id, addresseeId, this.workspaceId)))
return { requestId: pending.id, status: 'accepted' };
const [created] = await tx
.insert(userContactRequests)
- .values({ addresseeId, message: message?.trim() || null, requesterId: this.userId })
+ .values({
+ addresseeId,
+ message: message?.trim() || null,
+ requesterId: this.userId,
+ workspaceId: this.workspaceId,
+ })
.returning({ id: userContactRequests.id });
return { requestId: created.id, status: 'pending' };
});
};
+ /**
+ * Pending requests of this scope. The personal space has personal requests both ways plus the
+ * invitations members sent me from their workspaces, which I answer there before I can enter
+ * the workspace. A member sees the invitations they sent from this workspace; an external
+ * contact sees none.
+ */
listRequests = async (): Promise<ContactRequestItem[]> => {
+ const role = await this.scopeRole();
+ if (role === 'external') return [];
+ const scope =
+ role === 'member'
+ ? and(this.requestScopeWhere(), eq(userContactRequests.requesterId, this.userId))
+ : or(
+ and(
+ this.requestScopeWhere(),
+ or(
+ eq(userContactRequests.requesterId, this.userId),
+ eq(userContactRequests.addresseeId, this.userId),
+ ),
+ ),
+ and(
+ isNotNull(userContactRequests.workspaceId),
+ eq(userContactRequests.addresseeId, this.userId),
+ ),
+ );
const rows = await this.db
.select({
- addresseeId: userContactRequests.addresseeId,
createdAt: userContactRequests.createdAt,
id: userContactRequests.id,
message: userContactRequests.message,
requesterId: userContactRequests.requesterId,
user: userProfileColumns,
+ workspaceAvatar: workspaces.avatar,
+ workspaceId: workspaces.id,
+ workspaceName: workspaces.name,
})
.from(userContactRequests)
.innerJoin(
users,
sql`${users.id} = CASE WHEN ${userContactRequests.requesterId} = ${this.userId} THEN ${userContactRequests.addresseeId} ELSE ${userContactRequests.requesterId} END`,
)
- .where(
- and(
- eq(userContactRequests.status, 'pending'),
- or(
- eq(userContactRequests.requesterId, this.userId),
- eq(userContactRequests.addresseeId, this.userId),
- ),
- ),
- )
+ .leftJoin(workspaces, eq(workspaces.id, userContactRequests.workspaceId))
+ .where(and(eq(userContactRequests.status, 'pending'), scope))
.orderBy(desc(userContactRequests.createdAt));
return rows.map((row) => ({
@@ -264,17 +442,43 @@ export class ContactModel {
id: row.id,
message: row.message,
user: row.user,
+ workspace: row.workspaceId
+ ? { avatar: row.workspaceAvatar, id: row.workspaceId, name: row.workspaceName ?? '' }
+ : null,
}));
};
- /** Accept a pending request sent to me; both people become each other's contact. */
- acceptRequest = async (requestId: string): Promise<{ contactUserId: string }> =>
+ /**
+ * Accept a pending request sent to me; both people become each other's contact in the
+ * request's scope. Accepting a member's invitation makes me an external contact of their
+ * workspace, paired with them; it lapses once they leave it.
+ */
+ acceptRequest = async (
+ requestId: string,
+ ): Promise<{ contactUserId: string; workspaceId: string | null }> =>
this.db.transaction(async (tx) => {
const request = await this.incomingPending(tx, requestId);
- await this.lockPair(tx, request.requesterId);
- if (!(await this.accept(tx, request.id, request.requesterId)))
+ const { requesterId, workspaceId } = request;
+ if (workspaceId) {
+ const members = await tx
+ .select({ userId: workspaceMembers.userId })
+ .from(workspaceMembers)
+ .where(
+ and(
+ eq(workspaceMembers.workspaceId, workspaceId),
+ inArray(workspaceMembers.userId, [requesterId, this.userId]),
+ isNull(workspaceMembers.deletedAt),
+ ),
+ );
+ if (!members.some((member) => member.userId === requesterId))
+ throw new TRPCError({ code: 'NOT_FOUND', message: 'Request not found' });
+ if (members.some((member) => member.userId === this.userId))
+ throw new TRPCError({ code: 'CONFLICT', message: 'Already a member of this workspace' });
+ }
+ await this.lockPair(tx, requesterId, workspaceId);
+ if (!(await this.accept(tx, request.id, requesterId, workspaceId)))
throw new TRPCError({ code: 'NOT_FOUND', message: 'Request not found' });
- return { contactUserId: request.requesterId };
+ return { contactUserId: requesterId, workspaceId };
});
declineRequest = async (requestId: string) => {
@@ -309,18 +513,107 @@ export class ContactModel {
if (!cancelled) throw new TRPCError({ code: 'NOT_FOUND', message: 'Request not found' });
};
- /** Remove a person from my contacts; the relation is mutual, so both entries go. */
+ /**
+ * Remove a person from my contacts in this scope; the relation is mutual, so both entries go.
+ * A member closes themselves to an external contact this way, and an external contact drops a
+ * member; once an external contact has no member left, the workspace is gone for them.
+ */
removeUser = async (contactUserId: string) => {
+ await this.scopeRole();
await this.db
.delete(userContacts)
- .where(
- or(
- and(eq(userContacts.userId, this.userId), eq(userContacts.contactUserId, contactUserId)),
- and(eq(userContacts.userId, contactUserId), eq(userContacts.contactUserId, this.userId)),
- ),
- );
+ .where(and(this.userEntryWhere(), this.entryPairWhere(contactUserId)));
};
+ /**
+ * A member opens themselves to an external contact of the workspace, who can then see and
+ * message them. Each member opens only themselves; the inviter is paired on accepting.
+ */
+ openTo = async (externalUserId: string) => {
+ if ((await this.scopeRole()) !== 'member')
+ throw new TRPCError({ code: 'FORBIDDEN', message: 'Only members open themselves' });
+ if (externalUserId === this.userId || !(await this.isExternal(externalUserId)))
+ throw new TRPCError({ code: 'NOT_FOUND', message: 'External contact not found' });
+ await this.db
+ .insert(userContacts)
+ .values([
+ {
+ contactUserId: externalUserId,
+ type: 'user',
+ userId: this.userId,
+ workspaceId: this.workspaceId,
+ },
+ {
+ contactUserId: this.userId,
+ type: 'user',
+ userId: externalUserId,
+ workspaceId: this.workspaceId,
+ },
+ ])
+ .onConflictDoNothing();
+ };
+
+ /**
+ * An owner or admin removes an external contact from the workspace: every pairing goes, and
+ * so do the invitations still pending for them.
+ */
+ removeExternal = async (externalUserId: string) => {
+ if ((await this.scopeRole()) !== 'member' || !(await this.isManager()))
+ throw new TRPCError({ code: 'FORBIDDEN', message: 'Only owners and admins remove them' });
+ if (!(await this.isExternal(externalUserId)))
+ throw new TRPCError({ code: 'NOT_FOUND', message: 'External contact not found' });
+ await this.db.transaction(async (tx) => {
+ await tx
+ .delete(userContacts)
+ .where(
+ and(
+ this.userEntryWhere(),
+ or(
+ eq(userContacts.userId, externalUserId),
+ eq(userContacts.contactUserId, externalUserId),
+ ),
+ ),
+ );
+ await tx
+ .update(userContactRequests)
+ .set({ respondedAt: new Date(), status: 'cancelled', updatedAt: new Date() })
+ .where(
+ and(
+ this.requestScopeWhere(),
+ eq(userContactRequests.addresseeId, externalUserId),
+ eq(userContactRequests.status, 'pending'),
+ ),
+ );
+ });
+ };
+
+ /** Someone paired with a member here who is not a member themselves. */
+ private async isExternal(userId: string) {
+ if (await this.isMember(userId)) return false;
+ const [entry] = await this.db
+ .select({ id: userContacts.id })
+ .from(userContacts)
+ .where(and(this.userEntryWhere(), eq(userContacts.userId, userId)))
+ .limit(1);
+ return !!entry;
+ }
+
+ private async isManager() {
+ const [row] = await this.db
+ .select({ role: workspaceMembers.role })
+ .from(workspaceMembers)
+ .where(activeMemberWhere(this.workspaceId!, this.userId))
+ .limit(1);
+ return !!row && WORKSPACE_MANAGER_ROLES.includes(row.role);
+ }
+
+ private entryPairWhere(otherUserId: string) {
+ return or(
+ and(eq(userContacts.userId, this.userId), eq(userContacts.contactUserId, otherUserId)),
+ and(eq(userContacts.userId, otherUserId), eq(userContacts.contactUserId, this.userId)),
+ );
+ }
+
// ── Agents ────────────────────────────────────────────────────────────
/** Add another person's Agent in this scope through its link share (share id or handle). */
@@ -354,6 +647,7 @@ export class ContactModel {
* share.
*/
findAgentAccess = async (agentId: string) => {
+ if ((await this.scopeRole()) === 'external') return undefined;
const [row] = await this.db
.select({
agentId: agents.id,
@@ -408,7 +702,8 @@ export class ContactModel {
*/
search = async (query: string): Promise<ContactSearchResult[]> => {
const handle = parseContactHandle(query);
- if (!handle) return [];
+ // An external contact finds nothing of the workspace by searching.
+ if (!handle || (await this.scopeRole()) === 'external') return [];
const results: ContactSearchResult[] = [];
const [person] = await this.db
@@ -448,17 +743,26 @@ export class ContactModel {
);
}
- /** Transaction-scoped advisory lock on the unordered pair. */
- private async lockPair(tx: Pick<LobeChatDatabase, 'execute'>, otherUserId: string) {
+ /** Transaction-scoped advisory lock on the unordered pair in one scope. */
+ private async lockPair(
+ tx: Pick<LobeChatDatabase, 'execute'>,
+ otherUserId: string,
+ workspaceId: string | null = this.workspaceId,
+ ) {
const [a, b] = [this.userId, otherUserId].sort();
- await tx.execute(sql`SELECT pg_advisory_xact_lock(hashtext(${`contact:${a}:${b}`}))`);
+ const key = `contact:${workspaceId ?? 'personal'}:${a}:${b}`;
+ await tx.execute(sql`SELECT pg_advisory_xact_lock(hashtext(${key}))`);
}
private async incomingPending(tx: Pick<LobeChatDatabase, 'select'>, requestId: string) {
if (!isUuid(requestId))
throw new TRPCError({ code: 'NOT_FOUND', message: 'Request not found' });
const [request] = await tx
- .select({ id: userContactRequests.id, requesterId: userContactRequests.requesterId })
+ .select({
+ id: userContactRequests.id,
+ requesterId: userContactRequests.requesterId,
+ workspaceId: userContactRequests.workspaceId,
+ })
.from(userContactRequests)
.where(
and(
@@ -481,6 +785,7 @@ export class ContactModel {
tx: Pick<LobeChatDatabase, 'insert' | 'update'>,
requestId: string,
requesterId: string,
+ workspaceId: string | null,
): Promise<boolean> {
const now = new Date();
const [accepted] = await tx
@@ -492,8 +797,8 @@ export class ContactModel {
await tx
.insert(userContacts)
.values([
- { contactUserId: requesterId, type: 'user', userId: this.userId },
- { contactUserId: this.userId, type: 'user', userId: requesterId },
+ { contactUserId: requesterId, type: 'user', userId: this.userId, workspaceId },
+ { contactUserId: this.userId, type: 'user', userId: requesterId, workspaceId },
])
.onConflictDoNothing();
return true;
diff --git a/packages/database/src/repositories/channel/README.md b/packages/database/src/repositories/channel/README.md
index 151f7a078f4..15b177f2da1 100644
--- a/packages/database/src/repositories/channel/README.md
+++ b/packages/database/src/repositories/channel/README.md
@@ -97,11 +97,16 @@ never take one. The claim freezes `executionConfig.share` (owner, share and the
## Conversations between contacts
-`channels.peerUserId` marks a personal conversation between two people who are mutual contacts
-(`openPeer`). One exists per pair, whoever opened it: no unique index backs this, so `openPeer` takes an advisory lock on the pair before looking for it. Both people are owner members. It takes no
-Agents and no third person, so messages never route. Sending rechecks the contact relation in
-both directions: removing a contact silences the conversation and keeps its history. The list
-reports `peerUserId` relative to the viewer. Either account's deletion removes it.
+`channels.peerUserId` marks a one-on-one conversation between two people (`openPeer`). One
+exists per pair and scope, whoever opened it: no unique index backs this, so `openPeer` takes an
+advisory lock on the pair and scope before looking for it. Both people are owner members. It takes
+no Agents and no third person, so messages never route. The list reports `peerUserId` relative to
+the viewer. Either account's deletion removes it.
+
+Who may talk (`requirePeerRelation`, rechecked on every send so a lapsed relation silences the
+conversation and keeps its history): in the personal space, mutual contacts; in a workspace, two
+members, or a member and an external contact of the workspace paired with them in
+`user_contacts`. Two external contacts never talk to each other there.
## Delivery-key retirement rollout
diff --git a/packages/database/src/repositories/channel/__tests__/peer.test.ts b/packages/database/src/repositories/channel/__tests__/peer.test.ts
index 9d5d4bacdb2..03cc7a9fbb8 100644
--- a/packages/database/src/repositories/channel/__tests__/peer.test.ts
+++ b/packages/database/src/repositories/channel/__tests__/peer.test.ts
@@ -4,7 +4,7 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { getTestDB } from '../../../core/getTestDB';
import { ContactModel } from '../../../models/contact';
-import { agents, userContacts, workspaceMembers } from '../../../schemas';
+import { agents, userContacts, users, workspaceMembers } from '../../../schemas';
import { ChannelRepository } from '..';
import { createChannelFixture, jobsOf } from './testUtils';
@@ -152,3 +152,51 @@ describe('a conversation between two workspace members', () => {
).rejects.toThrow('Workspace member not found');
});
});
+
+describe('a conversation with an external contact of a workspace', () => {
+ const carol = 'channel-peer-carol';
+ const inTeam = (userId: string) => new ChannelRepository(db, userId, fixture.workspaceId);
+ const contactsInTeam = (userId: string) => new ContactModel(db, userId, fixture.workspaceId);
+
+ /** Alice and Carol are members; Alice invites Bob, who stays outside the workspace. */
+ const inviteBob = async () => {
+ await db.insert(users).values({ id: carol }).onConflictDoNothing();
+ await db.insert(workspaceMembers).values(
+ [alice, carol].map((userId) => ({
+ role: 'member',
+ userId,
+ workspaceId: fixture.workspaceId,
+ })),
+ );
+ const { requestId } = await contactsInTeam(alice).sendRequest(bob);
+ await new ContactModel(db, bob).acceptRequest(requestId);
+ };
+
+ afterEach(async () => {
+ await db.delete(users).where(eq(users.id, carol));
+ });
+
+ it('is open between the external contact and the members paired with them', async () => {
+ await inviteBob();
+ const { channel } = await inTeam(bob).openPeer(alice, 'Olivia');
+ expect(channel).toMatchObject({ peerUserId: alice, workspaceId: fixture.workspaceId });
+ expect((await inTeam(alice).openPeer(bob, 'Mia')).channel.id).toBe(channel.id);
+
+ // Carol has not opened herself to Bob, so neither of them can start one.
+ await expect(inTeam(bob).openPeer(carol, 'Carol')).rejects.toThrow(
+ 'Workspace member not found',
+ );
+ await expect(inTeam(carol).openPeer(bob, 'Mia')).rejects.toThrow('Workspace member not found');
+ await contactsInTeam(carol).openTo(bob);
+ expect(await inTeam(carol).openPeer(bob, 'Mia')).toBeDefined();
+ });
+
+ it('goes silent once the member closes themselves to them', async () => {
+ await inviteBob();
+ const { channel } = await inTeam(alice).openPeer(bob, 'Mia');
+ await contactsInTeam(alice).removeUser(bob);
+ await expect(
+ inTeam(bob).send(channel.id, { content: 'Hello?', requestKey: 'x', routing: 'fallback' }),
+ ).rejects.toThrow('Workspace member not found');
+ });
+});
diff --git a/packages/database/src/repositories/channel/peer.ts b/packages/database/src/repositories/channel/peer.ts
index 372bbeca6cc..8d2b7123604 100644
--- a/packages/database/src/repositories/channel/peer.ts
+++ b/packages/database/src/repositories/channel/peer.ts
@@ -1,19 +1,18 @@
import { and, eq, isNull, or, sql } from 'drizzle-orm';
import type { ChannelItem } from '../../schemas';
-import { channelMembers, channels, userContacts } from '../../schemas';
+import { channelMembers, channels, userContacts, workspaceMembers } from '../../schemas';
import type { Transaction } from '../../type';
import { ChannelError } from './error';
-import { requireWorkspaceMember } from './people';
import type { ChannelAccess } from './types';
/**
- * A personal conversation between two people exists only between contacts. Opening one and
- * sending in it both require the relation to still hold in both directions, so removing a
- * contact silences the conversation without deleting its history.
+ * Whether two people are contacts in a scope, both directions still holding. Removing a contact
+ * silences their conversation without deleting its history.
*/
-export const requireMutualContacts = async (
+const areMutualContacts = async (
tx: Transaction,
+ workspaceId: string | null,
userId: string,
peerUserId: string,
) => {
@@ -21,18 +20,38 @@ export const requireMutualContacts = async (
.select({ userId: userContacts.userId })
.from(userContacts)
.where(
- or(
- and(eq(userContacts.userId, userId), eq(userContacts.contactUserId, peerUserId)),
- and(eq(userContacts.userId, peerUserId), eq(userContacts.contactUserId, userId)),
+ and(
+ eq(userContacts.type, 'user'),
+ workspaceId ? eq(userContacts.workspaceId, workspaceId) : isNull(userContacts.workspaceId),
+ or(
+ and(eq(userContacts.userId, userId), eq(userContacts.contactUserId, peerUserId)),
+ and(eq(userContacts.userId, peerUserId), eq(userContacts.contactUserId, userId)),
+ ),
),
);
- if (rows.length < 2) throw new ChannelError('FORBIDDEN', 'You are not contacts');
+ return rows.length >= 2;
+};
+
+const isWorkspaceMember = async (tx: Transaction, workspaceId: string, userId: string) => {
+ const [member] = await tx
+ .select({ userId: workspaceMembers.userId })
+ .from(workspaceMembers)
+ .where(
+ and(
+ eq(workspaceMembers.workspaceId, workspaceId),
+ eq(workspaceMembers.userId, userId),
+ isNull(workspaceMembers.deletedAt),
+ ),
+ )
+ .for('share');
+ return !!member;
};
/**
* What lets two people talk one-on-one in a scope: in the personal space they must be mutual
- * contacts; in a workspace, both must still be its members. Checked on opening and on every send,
- * so removing a contact or leaving the workspace silences the conversation and keeps its history.
+ * contacts. In a workspace both are its members, or one is a member still paired with the other,
+ * an external contact. Checked on opening and on every send, so removing a contact, closing to an
+ * external contact or leaving the workspace silences the conversation and keeps its history.
*/
export const requirePeerRelation = async (
tx: Transaction,
@@ -40,9 +59,23 @@ export const requirePeerRelation = async (
userId: string,
peerUserId: string,
) => {
- if (!workspaceId) return requireMutualContacts(tx, userId, peerUserId);
- await requireWorkspaceMember(tx, workspaceId, userId);
- await requireWorkspaceMember(tx, workspaceId, peerUserId);
+ if (!workspaceId) {
+ if (!(await areMutualContacts(tx, null, userId, peerUserId)))
+ throw new ChannelError('FORBIDDEN', 'You are not contacts');
+ return;
+ }
+ const [userIsMember, peerIsMember] = [
+ await isWorkspaceMember(tx, workspaceId, userId),
+ await isWorkspaceMember(tx, workspaceId, peerUserId),
+ ];
+ if (userIsMember && peerIsMember) return;
+ // An external contact talks only with the members paired with them, never another outsider.
+ if (
+ (userIsMember || peerIsMember) &&
+ (await areMutualContacts(tx, workspaceId, userId, peerUserId))
+ )
+ return;
+ throw new ChannelError('NOT_FOUND', 'Workspace member not found');
};
/** The other person of a conversation between two people, relative to `viewerId`. */
diff --git a/packages/database/src/schemas/contact.ts b/packages/database/src/schemas/contact.ts
index 49374fbe0cc..0cc1a4dc520 100644
--- a/packages/database/src/schemas/contact.ts
+++ b/packages/database/src/schemas/contact.ts
@@ -17,12 +17,19 @@ import { users } from './user';
import { workspaces } from './workspace';
/**
- * One entry in an address book. People are personal: their entries pin `user_id` and are listed
- * only in the personal space, since a workspace's colleagues are its members. An `agent` entry belongs to the scope it was added in: with no `workspace_id` it
- * is its owner's alone; with one it is the workspace's, shown to every member there, and
- * `user_id` only records who added it.
+ * One entry in an address book. Every entry belongs to the scope it was made in.
*
- * A `user` entry exists only for an accepted contact request, and always in both directions.
+ * A `user` entry pins `user_id`. Without `workspace_id` it is a personal contact, listed only in
+ * the personal space. With one it pairs a member of that workspace with an external contact: a
+ * person outside it who accepted a member's invitation. Colleagues need no entry, they are the
+ * workspace's members; an external contact sees only the members paired with them there, the
+ * inviter first, and each member opens or closes only themselves.
+ *
+ * An `agent` entry with no `workspace_id` is its owner's alone; with one it is the workspace's,
+ * shown to every member there, and `user_id` only records who added it.
+ *
+ * A `user` entry exists only for an accepted contact request or a member opening themselves to
+ * an external contact, and always in both directions.
* An `agent` entry is another person's Agent added through its share link. It references the
* Agent, not the share: an Agent has at most one share row, and access is rechecked against
* that live row on every read and run, so pausing the share disables the entry without
@@ -43,7 +50,7 @@ export const userContacts = pgTable(
.references(() => users.id, { onDelete: 'cascade' })
.notNull(),
- /** Only on `agent` entries: the workspace whose address book holds it; null is personal. */
+ /** The workspace whose address book holds the entry; null is personal. */
workspaceId: text('workspace_id').references(() => workspaces.id, { onDelete: 'cascade' }),
type: text('type').$type<ContactType>().notNull(),
@@ -63,7 +70,10 @@ export const userContacts = pgTable(
(t) => [
uniqueIndex('user_contacts_user_unique')
.on(t.userId, t.contactUserId)
- .where(sql`${t.contactUserId} IS NOT NULL`),
+ .where(sql`${t.contactUserId} IS NOT NULL AND ${t.workspaceId} IS NULL`),
+ uniqueIndex('user_contacts_workspace_user_unique')
+ .on(t.workspaceId, t.userId, t.contactUserId)
+ .where(sql`${t.contactUserId} IS NOT NULL AND ${t.workspaceId} IS NOT NULL`),
uniqueIndex('user_contacts_agent_unique')
.on(t.userId, t.agentId)
.where(sql`${t.agentId} IS NOT NULL AND ${t.workspaceId} IS NULL`),
@@ -73,13 +83,18 @@ export const userContacts = pgTable(
// Neither partial index serves the cascades from users and agents.
index('user_contacts_contact_user_id_idx').on(t.contactUserId),
index('user_contacts_agent_id_idx').on(t.agentId),
+ index('user_contacts_workspace_id_idx').on(t.workspaceId),
],
);
/**
- * A request to become mutual contacts. At most one pending request exists per ordered pair;
- * a request sent while the other person's request is pending accepts it instead. Answered
+ * A request to become mutual contacts. At most one pending request exists per ordered pair and
+ * scope; a personal request sent while the other person's is pending accepts it instead. Answered
* rows are kept for their status, and a new request may follow a declined or cancelled one.
+ *
+ * With `workspace_id` it is a member inviting someone outside the workspace to be its external
+ * contact. The addressee answers it from their personal space, since they cannot enter the
+ * workspace before accepting.
*/
export const userContactRequests = pgTable(
'user_contact_requests',
@@ -94,6 +109,9 @@ export const userContactRequests = pgTable(
.references(() => users.id, { onDelete: 'cascade' })
.notNull(),
+ /** The workspace a member sent it from, for an external contact; null is personal. */
+ workspaceId: text('workspace_id').references(() => workspaces.id, { onDelete: 'cascade' }),
+
message: text('message'),
status: text('status').$type<ContactRequestStatus>().notNull().default('pending'),
respondedAt: timestamptz('responded_at'),
@@ -103,9 +121,13 @@ export const userContactRequests = pgTable(
(t) => [
uniqueIndex('user_contact_requests_pending_unique')
.on(t.requesterId, t.addresseeId)
- .where(sql`${t.status} = 'pending'`),
+ .where(sql`${t.status} = 'pending' AND ${t.workspaceId} IS NULL`),
+ uniqueIndex('user_contact_requests_workspace_pending_unique')
+ .on(t.workspaceId, t.requesterId, t.addresseeId)
+ .where(sql`${t.status} = 'pending' AND ${t.workspaceId} IS NOT NULL`),
index('user_contact_requests_addressee_status_idx').on(t.addresseeId, t.status),
index('user_contact_requests_requester_status_idx').on(t.requesterId, t.status),
+ index('user_contact_requests_workspace_id_idx').on(t.workspaceId),
check('user_contact_requests_not_self_check', sql`${t.requesterId} <> ${t.addresseeId}`),
],
);
diff --git a/packages/types/src/contact.ts b/packages/types/src/contact.ts
index 92148e473f6..f5fe4285f83 100644
--- a/packages/types/src/contact.ts
+++ b/packages/types/src/contact.ts
@@ -34,6 +34,11 @@ export interface ContactAgentProfile {
export interface ContactUserItem {
createdAt: Date;
+ /**
+ * Set in a workspace's address book as a member sees it: the person is an external contact
+ * of the workspace. `openedToMe` says whether the caller is paired with them and can talk.
+ */
+ external?: { openedToMe: boolean };
type: 'user';
user: ContactUserProfile;
}
@@ -59,10 +64,22 @@ export interface ContactRequestItem {
message: string | null;
/** The other person. */
user: ContactUserProfile;
+ /** Set when a member invited the addressee to be an external contact of this workspace. */
+ workspace?: ContactRequestWorkspace | null;
+}
+
+export interface ContactRequestWorkspace {
+ avatar: string | null;
+ id: string;
+ name: string;
}
-/** Relation of a search result or profile to the current user. */
-export type ContactRelation = 'self' | 'contact' | 'request_sent' | 'request_received' | 'none';
+/**
+ * Relation of a search result or profile to the current user, in the active scope. `member`:
+ * a fellow member of the active workspace, reachable without being a contact.
+ */
+export type ContactRelation =
+ 'self' | 'contact' | 'member' | 'request_sent' | 'request_received' | 'none';
export type ContactSearchResult =
| { relation: ContactRelation; type: 'user'; user: ContactUserProfile }