From c47002430e375e65c2c416b4cc628b68492c5d0c Mon Sep 17 00:00:00 2001 From: Timur Gordon <31495328+timurgordon@users.noreply.github.com> Date: Mon, 17 Mar 2025 01:25:26 +0100 Subject: [PATCH] implement mcc baobab generation example --- examples/baobab/generator/mcc_example.vsh | 24 + .../baobab/generator/openapi_e2e/.gitignore | 1 + .../openapi_e2e/generate_actor_module.vsh | 2 +- lib/circles/mcc/.gitignore | 1 + lib/circles/mcc/openapi.json | 1972 +++++++++++++++++ 5 files changed, 1999 insertions(+), 1 deletion(-) create mode 100755 examples/baobab/generator/mcc_example.vsh create mode 100644 lib/circles/mcc/.gitignore create mode 100644 lib/circles/mcc/openapi.json diff --git a/examples/baobab/generator/mcc_example.vsh b/examples/baobab/generator/mcc_example.vsh new file mode 100755 index 00000000..26ec5d3a --- /dev/null +++ b/examples/baobab/generator/mcc_example.vsh @@ -0,0 +1,24 @@ +#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run + +import freeflowuniverse.herolib.baobab.generator +import freeflowuniverse.herolib.baobab.specification +import freeflowuniverse.herolib.schemas.openapi +import os + +const example_dir = os.join_path('${os.home_dir()}/code/github/freeflowuniverse/herolib/lib/circles/mcc', 'baobab') +const openapi_spec_path = os.join_path('${os.home_dir()}/code/github/freeflowuniverse/herolib/lib/circles/mcc', 'openapi.json') + +// the actor specification obtained from the OpenRPC Specification +openapi_spec := openapi.new(path: openapi_spec_path)! +actor_spec := specification.from_openapi(openapi_spec)! + +actor_module := generator.generate_actor_module( + actor_spec, + interfaces: [.openapi, .http] +)! + +actor_module.write(example_dir, + format: true + overwrite: true + compile: false +)! \ No newline at end of file diff --git a/examples/baobab/generator/openapi_e2e/.gitignore b/examples/baobab/generator/openapi_e2e/.gitignore index be606019..8d6fa828 100644 --- a/examples/baobab/generator/openapi_e2e/.gitignore +++ b/examples/baobab/generator/openapi_e2e/.gitignore @@ -1,3 +1,4 @@ methods.v meeting_scheduler_actor generate_actor_module +src \ No newline at end of file diff --git a/examples/baobab/generator/openapi_e2e/generate_actor_module.vsh b/examples/baobab/generator/openapi_e2e/generate_actor_module.vsh index f7722ba8..7e5cd97f 100755 --- a/examples/baobab/generator/openapi_e2e/generate_actor_module.vsh +++ b/examples/baobab/generator/openapi_e2e/generate_actor_module.vsh @@ -25,4 +25,4 @@ actor_module.write(example_dir, compile: false )! -os.execvp('bash', ['${example_dir}/meeting_scheduler_actor/scripts/run.sh'])! \ No newline at end of file +// os.execvp('bash', ['${example_dir}/meeting_scheduler_actor/scripts/run.sh'])! \ No newline at end of file diff --git a/lib/circles/mcc/.gitignore b/lib/circles/mcc/.gitignore new file mode 100644 index 00000000..c2571a70 --- /dev/null +++ b/lib/circles/mcc/.gitignore @@ -0,0 +1 @@ +baobab \ No newline at end of file diff --git a/lib/circles/mcc/openapi.json b/lib/circles/mcc/openapi.json new file mode 100644 index 00000000..0fa149cb --- /dev/null +++ b/lib/circles/mcc/openapi.json @@ -0,0 +1,1972 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "HeroLib Circles MCC API", + "description": "API for Multi-Currency Circles (MCC) module of HeroLib Circles.\nThis API provides endpoints for managing emails and calendar events.\n", + "version": "1.0.0", + "contact": { + "name": "FreeFlow Universe", + "url": "https://freeflowuniverse.org" + } + }, + "servers": [ + { + "url": "https://api.example.com/v1", + "description": "Production server" + }, + { + "url": "https://dev-api.example.com/v1", + "description": "Development server" + } + ], + "paths": { + "/emails": { + "get": { + "summary": "List all emails", + "description": "Returns a list of all emails in the system", + "operationId": "listEmails", + "parameters": [ + { + "name": "mailbox", + "in": "query", + "description": "Filter emails by mailbox", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "A list of emails", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Email" + } + }, + "examples": { + "listEmails": { + "value": [ + { + "id": 1, + "uid": 101, + "seq_num": 1, + "mailbox": "INBOX", + "message": "Hello, this is a test email.", + "attachments": [], + "flags": [ + "\\Seen" + ], + "internal_date": 1647356400, + "size": 256, + "envelope": { + "date": 1647356400, + "subject": "Test Email", + "from": [ + "sender@example.com" + ], + "sender": [ + "sender@example.com" + ], + "reply_to": [ + "sender@example.com" + ], + "to": [ + "recipient@example.com" + ], + "cc": [], + "bcc": [], + "in_reply_to": "", + "message_id": "" + } + }, + { + "id": 2, + "uid": 102, + "seq_num": 2, + "mailbox": "INBOX", + "message": "This is another test email with an attachment.", + "attachments": [ + { + "filename": "document.pdf", + "content_type": "application/pdf", + "data": "base64encodeddata" + } + ], + "flags": [], + "internal_date": 1647442800, + "size": 1024, + "envelope": { + "date": 1647442800, + "subject": "Email with Attachment", + "from": [ + "sender2@example.com" + ], + "sender": [ + "sender2@example.com" + ], + "reply_to": [ + "sender2@example.com" + ], + "to": [ + "recipient@example.com" + ], + "cc": [ + "cc@example.com" + ], + "bcc": [], + "in_reply_to": "", + "message_id": "" + } + } + ] + } + } + } + } + } + } + }, + "post": { + "summary": "Create a new email", + "description": "Creates a new email in the system", + "operationId": "createEmail", + "requestBody": { + "description": "Email to create", + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EmailCreate" + }, + "examples": { + "createEmail": { + "value": { + "mailbox": "INBOX", + "message": "Hello, this is a new email.", + "attachments": [], + "flags": [], + "envelope": { + "subject": "New Email", + "from": [ + "sender@example.com" + ], + "to": [ + "recipient@example.com" + ], + "cc": [], + "bcc": [] + } + } + } + } + } + } + }, + "responses": { + "201": { + "description": "Created email", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Email" + }, + "examples": { + "createdEmail": { + "value": { + "id": 3, + "uid": 103, + "seq_num": 3, + "mailbox": "INBOX", + "message": "Hello, this is a new email.", + "attachments": [], + "flags": [], + "internal_date": 1647529200, + "size": 128, + "envelope": { + "date": 1647529200, + "subject": "New Email", + "from": [ + "sender@example.com" + ], + "sender": [ + "sender@example.com" + ], + "reply_to": [ + "sender@example.com" + ], + "to": [ + "recipient@example.com" + ], + "cc": [], + "bcc": [], + "in_reply_to": "", + "message_id": "" + } + } + } + } + } + } + } + } + } + }, + "/emails/{id}": { + "get": { + "summary": "Get email by ID", + "description": "Returns a single email by ID", + "operationId": "getEmailById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of the email to retrieve", + "required": true, + "schema": { + "type": "integer", + "format": "uint32" + } + } + ], + "responses": { + "200": { + "description": "Email found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Email" + }, + "examples": { + "getEmail": { + "value": { + "id": 1, + "uid": 101, + "seq_num": 1, + "mailbox": "INBOX", + "message": "Hello, this is a test email.", + "attachments": [], + "flags": [ + "\\Seen" + ], + "internal_date": 1647356400, + "size": 256, + "envelope": { + "date": 1647356400, + "subject": "Test Email", + "from": [ + "sender@example.com" + ], + "sender": [ + "sender@example.com" + ], + "reply_to": [ + "sender@example.com" + ], + "to": [ + "recipient@example.com" + ], + "cc": [], + "bcc": [], + "in_reply_to": "", + "message_id": "" + } + } + } + } + } + } + }, + "404": { + "description": "Email not found" + } + } + }, + "put": { + "summary": "Update email by ID", + "description": "Updates an existing email", + "operationId": "updateEmailById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of the email to update", + "required": true, + "schema": { + "type": "integer", + "format": "uint32" + } + } + ], + "requestBody": { + "description": "Updated email data", + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EmailUpdate" + }, + "examples": { + "updateEmail": { + "value": { + "flags": [ + "\\Seen", + "\\Flagged" + ] + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Email updated", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Email" + } + } + } + }, + "404": { + "description": "Email not found" + } + } + }, + "delete": { + "summary": "Delete email by ID", + "description": "Deletes an email", + "operationId": "deleteEmailById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of the email to delete", + "required": true, + "schema": { + "type": "integer", + "format": "uint32" + } + } + ], + "responses": { + "204": { + "description": "Email deleted" + }, + "404": { + "description": "Email not found" + } + } + } + }, + "/emails/search": { + "get": { + "summary": "Search emails", + "description": "Search for emails by various criteria", + "operationId": "searchEmails", + "parameters": [ + { + "name": "subject", + "in": "query", + "description": "Search by subject", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "query", + "description": "Search by email address (from, to, cc, bcc)", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Search results", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Email" + } + }, + "examples": { + "searchBySubject": { + "value": [ + { + "id": 1, + "uid": 101, + "seq_num": 1, + "mailbox": "INBOX", + "message": "Hello, this is a test email.", + "attachments": [], + "flags": [ + "\\Seen" + ], + "internal_date": 1647356400, + "size": 256, + "envelope": { + "date": 1647356400, + "subject": "Test Email", + "from": [ + "sender@example.com" + ], + "sender": [ + "sender@example.com" + ], + "reply_to": [ + "sender@example.com" + ], + "to": [ + "recipient@example.com" + ], + "cc": [], + "bcc": [], + "in_reply_to": "", + "message_id": "" + } + } + ] + } + } + } + } + } + } + } + }, + "/emails/uid/{uid}": { + "get": { + "summary": "Get email by UID", + "description": "Returns a single email by UID", + "operationId": "getEmailByUid", + "parameters": [ + { + "name": "uid", + "in": "path", + "description": "UID of the email to retrieve", + "required": true, + "schema": { + "type": "integer", + "format": "uint32" + } + } + ], + "responses": { + "200": { + "description": "Email found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Email" + } + } + } + }, + "404": { + "description": "Email not found" + } + } + }, + "delete": { + "summary": "Delete email by UID", + "description": "Deletes an email by UID", + "operationId": "deleteEmailByUid", + "parameters": [ + { + "name": "uid", + "in": "path", + "description": "UID of the email to delete", + "required": true, + "schema": { + "type": "integer", + "format": "uint32" + } + } + ], + "responses": { + "204": { + "description": "Email deleted" + }, + "404": { + "description": "Email not found" + } + } + } + }, + "/emails/mailbox/{mailbox}": { + "get": { + "summary": "Get emails by mailbox", + "description": "Returns all emails in a specific mailbox", + "operationId": "getEmailsByMailbox", + "parameters": [ + { + "name": "mailbox", + "in": "path", + "description": "Mailbox name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Emails found", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Email" + } + }, + "examples": { + "getEmailsByMailbox": { + "value": [ + { + "id": 1, + "uid": 101, + "seq_num": 1, + "mailbox": "INBOX", + "message": "Hello, this is a test email.", + "attachments": [], + "flags": [ + "\\Seen" + ], + "internal_date": 1647356400, + "size": 256, + "envelope": { + "date": 1647356400, + "subject": "Test Email", + "from": [ + "sender@example.com" + ], + "sender": [ + "sender@example.com" + ], + "reply_to": [ + "sender@example.com" + ], + "to": [ + "recipient@example.com" + ], + "cc": [], + "bcc": [], + "in_reply_to": "", + "message_id": "" + } + }, + { + "id": 2, + "uid": 102, + "seq_num": 2, + "mailbox": "INBOX", + "message": "This is another test email with an attachment.", + "attachments": [ + { + "filename": "document.pdf", + "content_type": "application/pdf", + "data": "base64encodeddata" + } + ], + "flags": [], + "internal_date": 1647442800, + "size": 1024, + "envelope": { + "date": 1647442800, + "subject": "Email with Attachment", + "from": [ + "sender2@example.com" + ], + "sender": [ + "sender2@example.com" + ], + "reply_to": [ + "sender2@example.com" + ], + "to": [ + "recipient@example.com" + ], + "cc": [ + "cc@example.com" + ], + "bcc": [], + "in_reply_to": "", + "message_id": "" + } + } + ] + } + } + } + } + } + } + }, + "delete": { + "summary": "Delete emails by mailbox", + "description": "Deletes all emails in a specific mailbox", + "operationId": "deleteEmailsByMailbox", + "parameters": [ + { + "name": "mailbox", + "in": "path", + "description": "Mailbox name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "Emails deleted" + } + } + } + }, + "/emails/flags/{uid}": { + "put": { + "summary": "Update email flags", + "description": "Update the flags of an email by its UID", + "operationId": "updateEmailFlags", + "parameters": [ + { + "name": "uid", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "uint32" + }, + "description": "Unique identifier of the email", + "example": 101 + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "flags": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Updated flags for the email", + "example": [ + "\\Seen", + "\\Flagged" + ] + } + }, + "required": [ + "flags" + ] + } + } + } + }, + "responses": { + "200": { + "description": "Email flags updated successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Email" + }, + "example": { + "id": 1, + "uid": 101, + "seq_num": 1, + "mailbox": "INBOX", + "message": "Hello, this is a test email.", + "attachments": [], + "flags": [ + "\\Seen", + "\\Flagged" + ], + "internal_date": 1647356400, + "size": 256, + "envelope": { + "date": 1647356400, + "subject": "Test Email", + "from": [ + "sender@example.com" + ], + "sender": [ + "sender@example.com" + ], + "reply_to": [ + "sender@example.com" + ], + "to": [ + "recipient@example.com" + ], + "cc": [], + "bcc": [], + "in_reply_to": "", + "message_id": "" + } + } + } + } + }, + "404": { + "description": "Email not found" + }, + "500": { + "description": "Internal server error" + } + } + } + }, + "/calendar": { + "get": { + "summary": "List all calendar events", + "description": "Returns a list of all calendar events in the system", + "operationId": "listCalendarEvents", + "responses": { + "200": { + "description": "A list of calendar events", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CalendarEvent" + } + }, + "examples": { + "listEvents": { + "value": [ + { + "id": 1, + "title": "Team Meeting", + "description": "Weekly team sync meeting", + "location": "Conference Room A", + "start_time": "2023-03-15T10:00:00Z", + "end_time": "2023-03-15T11:00:00Z", + "all_day": false, + "recurrence": "FREQ=WEEKLY;BYDAY=MO", + "attendees": [ + "john@example.com", + "jane@example.com" + ], + "organizer": "manager@example.com", + "status": "CONFIRMED", + "caldav_uid": "event-123@example.com", + "sync_token": "token123", + "etag": "etag123", + "color": "blue" + }, + { + "id": 2, + "title": "Company Holiday", + "description": "New Year's Day", + "location": "", + "start_time": "2023-01-01T00:00:00Z", + "end_time": "2023-01-01T23:59:59Z", + "all_day": true, + "recurrence": "", + "attendees": [], + "organizer": "hr@example.com", + "status": "CONFIRMED", + "caldav_uid": "holiday-123@example.com", + "sync_token": "token456", + "etag": "etag456", + "color": "red" + } + ] + } + } + } + } + } + } + }, + "post": { + "summary": "Create a new calendar event", + "description": "Creates a new calendar event in the system", + "operationId": "createCalendarEvent", + "requestBody": { + "description": "Calendar event to create", + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CalendarEventCreate" + }, + "examples": { + "createEvent": { + "value": { + "title": "Project Kickoff", + "description": "Initial meeting for new project", + "location": "Conference Room B", + "start_time": "2023-04-01T14:00:00Z", + "end_time": "2023-04-01T15:30:00Z", + "all_day": false, + "recurrence": "", + "attendees": [ + "team@example.com", + "client@example.com" + ], + "organizer": "manager@example.com", + "status": "CONFIRMED", + "color": "green" + } + } + } + } + } + }, + "responses": { + "201": { + "description": "Created calendar event", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CalendarEvent" + }, + "examples": { + "createdEvent": { + "value": { + "id": 3, + "title": "Project Kickoff", + "description": "Initial meeting for new project", + "location": "Conference Room B", + "start_time": "2023-04-01T14:00:00Z", + "end_time": "2023-04-01T15:30:00Z", + "all_day": false, + "recurrence": "", + "attendees": [ + "team@example.com", + "client@example.com" + ], + "organizer": "manager@example.com", + "status": "CONFIRMED", + "caldav_uid": "event-456@example.com", + "sync_token": "token789", + "etag": "etag789", + "color": "green" + } + } + } + } + } + } + } + } + }, + "/calendar/{id}": { + "get": { + "summary": "Get calendar event by ID", + "description": "Returns a single calendar event by ID", + "operationId": "getCalendarEventById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of the calendar event to retrieve", + "required": true, + "schema": { + "type": "integer", + "format": "uint32" + } + } + ], + "responses": { + "200": { + "description": "Calendar event found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CalendarEvent" + }, + "examples": { + "getEvent": { + "value": { + "id": 1, + "title": "Team Meeting", + "description": "Weekly team sync meeting", + "location": "Conference Room A", + "start_time": "2023-03-15T10:00:00Z", + "end_time": "2023-03-15T11:00:00Z", + "all_day": false, + "recurrence": "FREQ=WEEKLY;BYDAY=MO", + "attendees": [ + "john@example.com", + "jane@example.com" + ], + "organizer": "manager@example.com", + "status": "CONFIRMED", + "caldav_uid": "event-123@example.com", + "sync_token": "token123", + "etag": "etag123", + "color": "blue" + } + } + } + } + } + }, + "404": { + "description": "Calendar event not found" + } + } + }, + "put": { + "summary": "Update calendar event by ID", + "description": "Updates an existing calendar event", + "operationId": "updateCalendarEventById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of the calendar event to update", + "required": true, + "schema": { + "type": "integer", + "format": "uint32" + } + } + ], + "requestBody": { + "description": "Updated calendar event data", + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CalendarEventUpdate" + }, + "examples": { + "updateEvent": { + "value": { + "title": "Updated Team Meeting", + "location": "Virtual Meeting", + "status": "TENTATIVE" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Calendar event updated", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CalendarEvent" + } + } + } + }, + "404": { + "description": "Calendar event not found" + } + } + }, + "delete": { + "summary": "Delete calendar event by ID", + "description": "Deletes a calendar event", + "operationId": "deleteCalendarEventById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of the calendar event to delete", + "required": true, + "schema": { + "type": "integer", + "format": "uint32" + } + } + ], + "responses": { + "204": { + "description": "Calendar event deleted" + }, + "404": { + "description": "Calendar event not found" + } + } + } + }, + "/calendar/search": { + "get": { + "summary": "Search calendar events", + "description": "Search for calendar events by various criteria", + "operationId": "searchCalendarEvents", + "parameters": [ + { + "name": "title", + "in": "query", + "description": "Search by title", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "date", + "in": "query", + "description": "Search by date (YYYY-MM-DD)", + "required": false, + "schema": { + "type": "string", + "format": "date" + } + }, + { + "name": "organizer", + "in": "query", + "description": "Search by organizer", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "attendee", + "in": "query", + "description": "Search by attendee", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Search results", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CalendarEvent" + } + }, + "examples": { + "searchByTitle": { + "value": [ + { + "id": 1, + "title": "Team Meeting", + "description": "Weekly team sync meeting", + "location": "Conference Room A", + "start_time": "2023-03-15T10:00:00Z", + "end_time": "2023-03-15T11:00:00Z", + "all_day": false, + "recurrence": "FREQ=WEEKLY;BYDAY=MO", + "attendees": [ + "john@example.com", + "jane@example.com" + ], + "organizer": "manager@example.com", + "status": "CONFIRMED", + "caldav_uid": "event-123@example.com", + "sync_token": "token123", + "etag": "etag123", + "color": "blue" + } + ] + } + } + } + } + } + } + } + }, + "/calendar/caldav/{caldav_uid}": { + "get": { + "summary": "Get calendar event by CalDAV UID", + "description": "Returns a single calendar event by CalDAV UID", + "operationId": "getCalendarEventByCaldavUid", + "parameters": [ + { + "name": "caldav_uid", + "in": "path", + "description": "CalDAV UID of the calendar event to retrieve", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Calendar event found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CalendarEvent" + } + } + } + }, + "404": { + "description": "Calendar event not found" + } + } + }, + "delete": { + "summary": "Delete calendar event by CalDAV UID", + "description": "Deletes a calendar event by CalDAV UID", + "operationId": "deleteCalendarEventByCaldavUid", + "parameters": [ + { + "name": "caldav_uid", + "in": "path", + "description": "CalDAV UID of the calendar event to delete", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "Calendar event deleted" + }, + "404": { + "description": "Calendar event not found" + } + } + } + }, + "/calendar/date/{date}": { + "get": { + "summary": "Get calendar events by date", + "description": "Returns all calendar events on a specific date", + "operationId": "getCalendarEventsByDate", + "parameters": [ + { + "name": "date", + "in": "path", + "description": "Date in YYYY-MM-DD format", + "required": true, + "schema": { + "type": "string", + "format": "date" + } + } + ], + "responses": { + "200": { + "description": "Calendar events found", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CalendarEvent" + } + }, + "examples": { + "getEventsByDate": { + "value": [ + { + "id": 1, + "title": "Team Meeting", + "description": "Weekly team sync meeting", + "location": "Conference Room A", + "start_time": "2023-03-15T10:00:00Z", + "end_time": "2023-03-15T11:00:00Z", + "all_day": false, + "recurrence": "FREQ=WEEKLY;BYDAY=MO", + "attendees": [ + "john@example.com", + "jane@example.com" + ], + "organizer": "manager@example.com", + "status": "CONFIRMED", + "caldav_uid": "event-123@example.com", + "sync_token": "token123", + "etag": "etag123", + "color": "blue" + }, + { + "id": 4, + "title": "Lunch with Client", + "description": "Discuss project requirements", + "location": "Restaurant", + "start_time": "2023-03-15T12:30:00Z", + "end_time": "2023-03-15T14:00:00Z", + "all_day": false, + "recurrence": "", + "attendees": [ + "client@example.com" + ], + "organizer": "sales@example.com", + "status": "CONFIRMED", + "caldav_uid": "event-789@example.com", + "sync_token": "token101112", + "etag": "etag101112", + "color": "purple" + } + ] + } + } + } + } + } + } + } + }, + "/calendar/organizer/{organizer}": { + "get": { + "summary": "Get calendar events by organizer", + "description": "Retrieve all calendar events organized by a specific person", + "operationId": "getCalendarEventsByOrganizer", + "parameters": [ + { + "name": "organizer", + "in": "path", + "required": true, + "schema": { + "type": "string" + }, + "description": "Email address of the organizer", + "example": "manager@example.com" + } + ], + "responses": { + "200": { + "description": "A list of calendar events organized by the specified person", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CalendarEvent" + } + }, + "example": [ + { + "id": 1, + "title": "Team Meeting", + "description": "Weekly team sync meeting", + "location": "Conference Room A", + "start_time": "2023-03-15T10:00:00Z", + "end_time": "2023-03-15T11:00:00Z", + "all_day": false, + "recurrence": "FREQ=WEEKLY;BYDAY=MO", + "attendees": [ + "john@example.com", + "jane@example.com" + ], + "organizer": "manager@example.com", + "status": "CONFIRMED", + "caldav_uid": "event-123@example.com", + "sync_token": "token123", + "etag": "etag123", + "color": "blue" + } + ] + } + } + }, + "404": { + "description": "No events found for the specified organizer" + }, + "500": { + "description": "Internal server error" + } + } + } + }, + "/calendar/attendee/{attendee}": { + "get": { + "summary": "Get calendar events by attendee", + "description": "Retrieve all calendar events that a specific person is attending", + "operationId": "getCalendarEventsByAttendee", + "parameters": [ + { + "name": "attendee", + "in": "path", + "required": true, + "schema": { + "type": "string" + }, + "description": "Email address of the attendee", + "example": "john@example.com" + } + ], + "responses": { + "200": { + "description": "A list of calendar events the specified person is attending", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CalendarEvent" + } + }, + "example": [ + { + "id": 2, + "title": "Project Review", + "description": "Monthly project status review", + "location": "Conference Room B", + "start_time": "2023-03-20T14:00:00Z", + "end_time": "2023-03-20T15:00:00Z", + "all_day": false, + "recurrence": "FREQ=MONTHLY", + "attendees": [ + "john@example.com", + "team@example.com" + ], + "organizer": "director@example.com", + "status": "CONFIRMED", + "caldav_uid": "event-456@example.com", + "sync_token": "token456", + "etag": "etag456", + "color": "green" + } + ] + } + } + }, + "404": { + "description": "No events found for the specified attendee" + }, + "500": { + "description": "Internal server error" + } + } + } + }, + "/calendar/status/{id}": { + "put": { + "summary": "Update calendar event status", + "description": "Update the status of a calendar event by its ID", + "operationId": "updateCalendarEventStatus", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "uint32" + }, + "description": "Unique identifier of the calendar event", + "example": 1 + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "CONFIRMED", + "CANCELLED", + "TENTATIVE" + ], + "description": "New status for the event", + "example": "TENTATIVE" + } + }, + "required": [ + "status" + ] + } + } + } + }, + "responses": { + "200": { + "description": "Calendar event status updated successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CalendarEvent" + } + } + } + }, + "400": { + "description": "Invalid status value" + }, + "404": { + "description": "Calendar event not found" + }, + "500": { + "description": "Internal server error" + } + } + } + } + }, + "components": { + "schemas": { + "Email": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "uint32", + "description": "Database ID (assigned by DBHandler)", + "example": 1 + }, + "uid": { + "type": "integer", + "format": "uint32", + "description": "Unique identifier of the message (in the circle)", + "example": 101 + }, + "seq_num": { + "type": "integer", + "format": "uint32", + "description": "IMAP sequence number (in the mailbox)", + "example": 1 + }, + "mailbox": { + "type": "string", + "description": "The mailbox this email belongs to", + "example": "INBOX" + }, + "message": { + "type": "string", + "description": "The email body content", + "example": "Hello, this is a test email." + }, + "attachments": { + "type": "array", + "description": "Any file attachments", + "items": { + "$ref": "#/components/schemas/Attachment" + } + }, + "flags": { + "type": "array", + "description": "IMAP flags like \\Seen, \\Deleted, etc.", + "items": { + "type": "string" + }, + "example": [ + "\\Seen" + ] + }, + "internal_date": { + "type": "integer", + "format": "int64", + "description": "Unix timestamp when the email was received", + "example": 1647356400 + }, + "size": { + "type": "integer", + "format": "uint32", + "description": "Size of the message in bytes", + "example": 256 + }, + "envelope": { + "$ref": "#/components/schemas/Envelope" + } + }, + "required": [ + "id", + "uid", + "mailbox", + "message" + ] + }, + "EmailCreate": { + "type": "object", + "properties": { + "mailbox": { + "type": "string", + "description": "The mailbox this email belongs to", + "example": "INBOX" + }, + "message": { + "type": "string", + "description": "The email body content", + "example": "Hello, this is a new email." + }, + "attachments": { + "type": "array", + "description": "Any file attachments", + "items": { + "$ref": "#/components/schemas/Attachment" + } + }, + "flags": { + "type": "array", + "description": "IMAP flags like \\Seen, \\Deleted, etc.", + "items": { + "type": "string" + }, + "example": [] + }, + "envelope": { + "$ref": "#/components/schemas/EnvelopeCreate" + } + }, + "required": [ + "mailbox", + "message" + ] + }, + "EmailUpdate": { + "type": "object", + "properties": { + "mailbox": { + "type": "string", + "description": "The mailbox this email belongs to" + }, + "message": { + "type": "string", + "description": "The email body content" + }, + "attachments": { + "type": "array", + "description": "Any file attachments", + "items": { + "$ref": "#/components/schemas/Attachment" + } + }, + "flags": { + "type": "array", + "description": "IMAP flags like \\Seen, \\Deleted, etc.", + "items": { + "type": "string" + }, + "example": [ + "\\Seen", + "\\Flagged" + ] + }, + "envelope": { + "$ref": "#/components/schemas/EnvelopeCreate" + } + } + }, + "Attachment": { + "type": "object", + "properties": { + "filename": { + "type": "string", + "description": "Name of the attached file", + "example": "document.pdf" + }, + "content_type": { + "type": "string", + "description": "MIME type of the attachment", + "example": "application/pdf" + }, + "data": { + "type": "string", + "description": "Base64 encoded binary data", + "example": "base64encodeddata" + } + }, + "required": [ + "filename", + "content_type", + "data" + ] + }, + "Envelope": { + "type": "object", + "properties": { + "date": { + "type": "integer", + "format": "int64", + "description": "Unix timestamp of the email date", + "example": 1647356400 + }, + "subject": { + "type": "string", + "description": "Email subject", + "example": "Test Email" + }, + "from": { + "type": "array", + "description": "From addresses", + "items": { + "type": "string" + }, + "example": [ + "sender@example.com" + ] + }, + "sender": { + "type": "array", + "description": "Sender addresses", + "items": { + "type": "string" + }, + "example": [ + "sender@example.com" + ] + }, + "reply_to": { + "type": "array", + "description": "Reply-To addresses", + "items": { + "type": "string" + }, + "example": [ + "sender@example.com" + ] + }, + "to": { + "type": "array", + "description": "To addresses", + "items": { + "type": "string" + }, + "example": [ + "recipient@example.com" + ] + }, + "cc": { + "type": "array", + "description": "CC addresses", + "items": { + "type": "string" + }, + "example": [] + }, + "bcc": { + "type": "array", + "description": "BCC addresses", + "items": { + "type": "string" + }, + "example": [] + }, + "in_reply_to": { + "type": "string", + "description": "Message ID this email is replying to", + "example": "" + }, + "message_id": { + "type": "string", + "description": "Unique message ID", + "example": "" + } + }, + "required": [ + "subject", + "from", + "to" + ] + }, + "EnvelopeCreate": { + "type": "object", + "properties": { + "subject": { + "type": "string", + "description": "Email subject", + "example": "New Email" + }, + "from": { + "type": "array", + "description": "From addresses", + "items": { + "type": "string" + }, + "example": [ + "sender@example.com" + ] + }, + "to": { + "type": "array", + "description": "To addresses", + "items": { + "type": "string" + }, + "example": [ + "recipient@example.com" + ] + }, + "cc": { + "type": "array", + "description": "CC addresses", + "items": { + "type": "string" + }, + "example": [] + }, + "bcc": { + "type": "array", + "description": "BCC addresses", + "items": { + "type": "string" + }, + "example": [] + } + }, + "required": [ + "subject", + "from", + "to" + ] + }, + "CalendarEvent": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "uint32", + "description": "Unique identifier", + "example": 1 + }, + "title": { + "type": "string", + "description": "Event title", + "example": "Team Meeting" + }, + "description": { + "type": "string", + "description": "Event details", + "example": "Weekly team sync meeting" + }, + "location": { + "type": "string", + "description": "Event location", + "example": "Conference Room A" + }, + "start_time": { + "type": "string", + "format": "date-time", + "description": "Start time", + "example": "2023-03-15T10:00:00Z" + }, + "end_time": { + "type": "string", + "format": "date-time", + "description": "End time", + "example": "2023-03-15T11:00:00Z" + }, + "all_day": { + "type": "boolean", + "description": "True if it's an all-day event", + "example": false + }, + "recurrence": { + "type": "string", + "description": "RFC 5545 Recurrence Rule", + "example": "FREQ=WEEKLY;BYDAY=MO" + }, + "attendees": { + "type": "array", + "description": "List of emails or user IDs", + "items": { + "type": "string" + }, + "example": [ + "john@example.com", + "jane@example.com" + ] + }, + "organizer": { + "type": "string", + "description": "Organizer email", + "example": "manager@example.com" + }, + "status": { + "type": "string", + "description": "CONFIRMED, CANCELLED, TENTATIVE", + "enum": [ + "CONFIRMED", + "CANCELLED", + "TENTATIVE" + ], + "example": "CONFIRMED" + }, + "caldav_uid": { + "type": "string", + "description": "CalDAV UID for syncing", + "example": "event-123@example.com" + }, + "sync_token": { + "type": "string", + "description": "Sync token for tracking changes", + "example": "token123" + }, + "etag": { + "type": "string", + "description": "ETag for caching", + "example": "etag123" + }, + "color": { + "type": "string", + "description": "User-friendly color categorization", + "example": "blue" + } + }, + "required": [ + "id", + "title", + "start_time", + "end_time" + ] + }, + "CalendarEventCreate": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "Event title", + "example": "Project Kickoff" + }, + "description": { + "type": "string", + "description": "Event details", + "example": "Initial meeting for new project" + }, + "location": { + "type": "string", + "description": "Event location", + "example": "Conference Room B" + }, + "start_time": { + "type": "string", + "format": "date-time", + "description": "Start time", + "example": "2023-04-01T14:00:00Z" + }, + "end_time": { + "type": "string", + "format": "date-time", + "description": "End time", + "example": "2023-04-01T15:30:00Z" + }, + "all_day": { + "type": "boolean", + "description": "True if it's an all-day event", + "example": false + }, + "recurrence": { + "type": "string", + "description": "RFC 5545 Recurrence Rule", + "example": "" + }, + "attendees": { + "type": "array", + "description": "List of emails or user IDs", + "items": { + "type": "string" + }, + "example": [ + "team@example.com", + "client@example.com" + ] + }, + "organizer": { + "type": "string", + "description": "Organizer email", + "example": "manager@example.com" + }, + "status": { + "type": "string", + "description": "CONFIRMED, CANCELLED, TENTATIVE", + "enum": [ + "CONFIRMED", + "CANCELLED", + "TENTATIVE" + ], + "example": "CONFIRMED" + }, + "color": { + "type": "string", + "description": "User-friendly color categorization", + "example": "green" + } + }, + "required": [ + "title", + "start_time", + "end_time" + ] + }, + "CalendarEventUpdate": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "Event title", + "example": "Updated Team Meeting" + }, + "description": { + "type": "string", + "description": "Event details" + }, + "location": { + "type": "string", + "description": "Event location", + "example": "Virtual Meeting" + }, + "start_time": { + "type": "string", + "format": "date-time", + "description": "Start time" + }, + "end_time": { + "type": "string", + "format": "date-time", + "description": "End time" + }, + "all_day": { + "type": "boolean", + "description": "True if it's an all-day event" + }, + "recurrence": { + "type": "string", + "description": "RFC 5545 Recurrence Rule" + }, + "attendees": { + "type": "array", + "description": "List of emails or user IDs", + "items": { + "type": "string" + } + }, + "organizer": { + "type": "string", + "description": "Organizer email" + }, + "status": { + "type": "string", + "description": "CONFIRMED, CANCELLED, TENTATIVE", + "enum": [ + "CONFIRMED", + "CANCELLED", + "TENTATIVE" + ], + "example": "TENTATIVE" + }, + "color": { + "type": "string", + "description": "User-friendly color categorization" + } + } + } + } + } +} \ No newline at end of file