diff --git a/dataconnect/connector/activityLog/mutations.gql b/dataconnect/connector/activityLog/mutations.gql new file mode 100644 index 00000000..7bf01863 --- /dev/null +++ b/dataconnect/connector/activityLog/mutations.gql @@ -0,0 +1,43 @@ +mutation CreateActivityLog( + $title: String!, + $description: String!, + $activityType: ActivityType!, + $userId: UUID!, + $isRead: Boolean +) @auth(level: USER) { + activityLog_insert( + data: { + title: $title + description: $description + activityType: $activityType + userId: $userId + isRead: $isRead + } + ) +} + +mutation UpdateActivityLog( + $id: UUID!, + $title: String, + $description: String, + $activityType: ActivityType, + $userId: UUID, + $isRead: Boolean +) @auth(level: USER) { + activityLog_update( + id: $id, + data: { + title: $title + description: $description + activityType: $activityType + userId: $userId + isRead: $isRead + } + ) +} + +mutation DeleteActivityLog( + $id: UUID! +) @auth(level: USER) { + activityLog_delete(id: $id) +} diff --git a/dataconnect/connector/activityLog/queries.gql b/dataconnect/connector/activityLog/queries.gql new file mode 100644 index 00000000..c3391d0d --- /dev/null +++ b/dataconnect/connector/activityLog/queries.gql @@ -0,0 +1,44 @@ +query listActivityLog @auth(level: USER) { + activityLogs { + id + title + description + activityType + userId + isRead + } +} + +query getActivityLogById( + $id: UUID! +) @auth(level: USER) { + activityLog(id: $id) { + id + title + description + activityType + userId + isRead + } +} + +query filterActivityLog( + $userId: UUID, + $activityType: ActivityType, + $isRead: Boolean +) @auth(level: USER) { + activityLogs( + where: { + userId: { eq: $userId } + activityType: { eq: $activityType } + isRead: { eq: $isRead } + } + ) { + id + title + description + activityType + userId + isRead + } +} diff --git a/dataconnect/connector/conversation/mutations.gql b/dataconnect/connector/conversation/mutations.gql new file mode 100644 index 00000000..8b5094fd --- /dev/null +++ b/dataconnect/connector/conversation/mutations.gql @@ -0,0 +1,39 @@ +mutation CreateConversation( + $participants: String!, + $conversationType: ConversationType!, + $relatedTo: UUID!, + $status: ConversationStatus +) @auth(level: USER) { + conversation_insert( + data: { + participants: $participants + conversationType: $conversationType + relatedTo: $relatedTo + status: $status + } + ) +} + +mutation UpdateConversation( + $id: UUID!, + $participants: String, + $conversationType: ConversationType, + $relatedTo: UUID!, + $status: ConversationStatus +) @auth(level: USER) { + conversation_update( + id: $id, + data: { + participants: $participants + conversationType: $conversationType + relatedTo: $relatedTo + status: $status + } + ) +} + +mutation DeleteConversation( + $id: UUID! +) @auth(level: USER) { + conversation_delete(id: $id) +} diff --git a/dataconnect/connector/conversation/queries.gql b/dataconnect/connector/conversation/queries.gql new file mode 100644 index 00000000..39dedbe7 --- /dev/null +++ b/dataconnect/connector/conversation/queries.gql @@ -0,0 +1,43 @@ +# dataconnect/connector/conversation/queries.gql + +query listConversation @auth(level: USER) { + conversations { + id + participants + conversationType + relatedTo + status + } +} + +query getConversationById( + $id: UUID! +) @auth(level: USER) { + conversation(id: $id) { + id + participants + conversationType + relatedTo + status + } +} + +query filterConversation( + $conversationType: ConversationType, + $status: ConversationStatus, + $relatedTo: UUID! +) @auth(level: USER) { + conversations( + where: { + conversationType: { eq: $conversationType } + status: { eq: $status } + relatedTo: { eq: $relatedTo } + } + ) { + id + participants + conversationType + relatedTo + status + } +} diff --git a/dataconnect/connector/message/mutations.gql b/dataconnect/connector/message/mutations.gql new file mode 100644 index 00000000..ea03b0b2 --- /dev/null +++ b/dataconnect/connector/message/mutations.gql @@ -0,0 +1,39 @@ +mutation CreateMessage( + $conversationId: UUID!, + $senderName: String!, + $content: String!, + $readBy: String +) @auth(level: USER) { + message_insert( + data: { + conversationId: $conversationId + senderName: $senderName + content: $content + readBy: $readBy + } + ) +} + +mutation UpdateMessage( + $id: UUID!, + $conversationId: UUID, + $senderName: String, + $content: String, + $readBy: String +) @auth(level: USER) { + message_update( + id: $id, + data: { + conversationId: $conversationId + senderName: $senderName + content: $content + readBy: $readBy + } + ) +} + +mutation DeleteMessage( + $id: UUID! +) @auth(level: USER) { + message_delete(id: $id) +} diff --git a/dataconnect/connector/message/queries.gql b/dataconnect/connector/message/queries.gql new file mode 100644 index 00000000..a999f19d --- /dev/null +++ b/dataconnect/connector/message/queries.gql @@ -0,0 +1,39 @@ +query listMessage @auth(level: USER) { + messages { + id + conversationId + senderName + content + readBy + } +} + +query getMessageById( + $id: UUID! +) @auth(level: USER) { + message(id: $id) { + id + conversationId + senderName + content + readBy + } +} + +query filterMessage( + $conversationId: UUID, + $senderName: String +) @auth(level: USER) { + messages( + where: { + conversationId: { eq: $conversationId } + senderName: { eq: $senderName } + } + ) { + id + conversationId + senderName + content + readBy + } +} diff --git a/dataconnect/schema/activityLog.gql b/dataconnect/schema/activityLog.gql new file mode 100644 index 00000000..735fef46 --- /dev/null +++ b/dataconnect/schema/activityLog.gql @@ -0,0 +1,21 @@ +enum ActivityType { + EVENT_CREATED + EVENT_UPDATED + STAFF_ASSIGNED + INVOICE_PAID + INVOICE_CREATED + VENDOR_APPROVED + MESSAGE_RECEIVED +} + +type ActivityLog @table(name: "activity_logs") { + id: UUID! @default(expr: "uuidV4()") + title: String! + description: String! + activityType: ActivityType! + userId: UUID! # user_id (FK lógica a User.id) + isRead: Boolean @default(expr: "false") + createdDate: Timestamp @default(expr: "request.time") + updatedDate: Timestamp @default(expr: "request.time") + createdBy: String @default(expr: "auth.uid") +} diff --git a/dataconnect/schema/conversation.gql b/dataconnect/schema/conversation.gql new file mode 100644 index 00000000..45114f19 --- /dev/null +++ b/dataconnect/schema/conversation.gql @@ -0,0 +1,26 @@ +enum ConversationType { + CLIENT_VENDOR + STAFF_CLIENT + STAFF_ADMIN + VENDOR_ADMIN + CLIENT_ADMIN + GROUP_STAFF + GROUP_EVENT_STAFF +} + +enum ConversationStatus { + ACTIVE + ARCHIVED + CLOSED +} + +type Conversation @table(name: "conversations") { + id: UUID! @default(expr: "uuidV4()") + participants: String! # participants (jsonb -> String, required array of strings) + conversationType: ConversationType! + relatedTo: UUID! # related_to (generic FK as string) + status: ConversationStatus + createdDate: Timestamp @default(expr: "request.time") + updatedDate: Timestamp @default(expr: "request.time") + createdBy: String @default(expr: "auth.uid") +} diff --git a/dataconnect/schema/message.gql b/dataconnect/schema/message.gql new file mode 100644 index 00000000..bbdd322c --- /dev/null +++ b/dataconnect/schema/message.gql @@ -0,0 +1,10 @@ +type Message @table(name: "messages") { + id: UUID! @default(expr: "uuidV4()") + conversationId: UUID! # conversation_id (FK lógica a Conversation.id) + senderName: String! + content: String! + readBy: String # read_by (jsonb -> String, array de user IDs) + createdDate: Timestamp @default(expr: "request.time") + updatedDate: Timestamp @default(expr: "request.time") + createdBy: String @default(expr: "auth.uid") +}