From 3c8bb9f6a3f7edd4eadd22af20a613cf2f9fafb9 Mon Sep 17 00:00:00 2001 From: jbpenrath Date: Wed, 9 Jul 2025 18:32:55 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=BD=EF=B8=8F(api)=20update=20openapi?= =?UTF-8?q?=20schema=20and=20api=20client?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Run `make api-update` --- src/backend/core/api/openapi.json | 280 ++++++++++++- .../admin-maildomain-user.ts | 242 ++++++++++++ .../src/features/api/gen/contacts/contacts.ts | 372 ++++++++++++++++++ src/frontend/src/features/api/gen/index.ts | 2 + .../src/features/api/gen/labels/labels.ts | 4 +- .../api/gen/maildomains/maildomains.ts | 38 +- .../api/gen/models/contacts_list_params.ts | 18 + .../src/features/api/gen/models/index.ts | 7 + .../api/gen/models/mailbox_admin_create.ts | 34 ++ .../mailbox_admin_create_metadata_request.ts | 14 + .../mailbox_admin_create_payload_request.ts | 15 + .../models/maildomains_users_list_params.ts | 14 + .../src/features/api/gen/models/message.ts | 3 +- .../src/features/api/gen/models/thread.ts | 3 +- .../src/features/api/gen/models/type_enum.ts | 21 + .../src/features/api/gen/models/user.ts | 3 + .../features/api/gen/models/user_abilities.ts | 12 + 17 files changed, 1052 insertions(+), 30 deletions(-) create mode 100644 src/frontend/src/features/api/gen/admin-maildomain-user/admin-maildomain-user.ts create mode 100644 src/frontend/src/features/api/gen/contacts/contacts.ts create mode 100644 src/frontend/src/features/api/gen/models/contacts_list_params.ts create mode 100644 src/frontend/src/features/api/gen/models/mailbox_admin_create.ts create mode 100644 src/frontend/src/features/api/gen/models/mailbox_admin_create_metadata_request.ts create mode 100644 src/frontend/src/features/api/gen/models/mailbox_admin_create_payload_request.ts create mode 100644 src/frontend/src/features/api/gen/models/maildomains_users_list_params.ts create mode 100644 src/frontend/src/features/api/gen/models/type_enum.ts create mode 100644 src/frontend/src/features/api/gen/models/user_abilities.ts diff --git a/src/backend/core/api/openapi.json b/src/backend/core/api/openapi.json index 5a2c1a6f..d18f9137 100644 --- a/src/backend/core/api/openapi.json +++ b/src/backend/core/api/openapi.json @@ -144,6 +144,90 @@ } } }, + "/api/v1.0/contacts/": { + "get": { + "operationId": "contacts_list", + "description": "List contacts with optional filtering by mailbox and search query.\n\nQuery parameters:\n- mailbox_id: Optional UUID to filter contacts by mailbox\n- q: Optional search query for name or email (case insensitive)", + "parameters": [ + { + "in": "query", + "name": "mailbox_id", + "schema": { + "type": "string", + "format": "uuid" + }, + "description": "Filter contacts by mailbox ID." + }, + { + "in": "query", + "name": "q", + "schema": { + "type": "string" + }, + "description": "Search contacts by name or email (case insensitive)." + } + ], + "tags": [ + "contacts" + ], + "security": [ + { + "cookieAuth": [] + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Contact" + } + } + } + }, + "description": "" + } + } + } + }, + "/api/v1.0/contacts/{id}/": { + "get": { + "operationId": "contacts_retrieve", + "description": "ViewSet for Contact model.", + "parameters": [ + { + "in": "path", + "name": "id", + "schema": { + "type": "string" + }, + "required": true + } + ], + "tags": [ + "contacts" + ], + "security": [ + { + "cookieAuth": [] + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Contact" + } + } + }, + "description": "" + } + } + } + }, "/api/v1.0/draft/": { "post": { "operationId": "draft_create", @@ -2244,7 +2328,7 @@ }, "post": { "operationId": "maildomains_mailboxes_create", - "description": "ViewSet for managing Mailboxes within a specific MailDomain.\nNested under /maildomains/{maildomain_pk}/mailboxes/\nPermissions are checked by IsMailDomainAdmin for the maildomain_pk.\n\nThis viewset serves a different purpose than the one in mailbox.py (/api/v1.0/mailboxes/).\nThat other one is for listing the mailboxes a user has access to in regular app use.\nThis one is for managing mailboxes within a specific maildomain in the admin interface.", + "description": "Create new mailbox in a specific maildomain.", "parameters": [ { "in": "path", @@ -2259,21 +2343,36 @@ "tags": [ "maildomains" ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MailboxAdminCreatePayloadRequest" + } + }, + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/MailboxAdminCreatePayloadRequest" + } + } + }, + "required": true + }, "security": [ { "cookieAuth": [] } ], "responses": { - "201": { + "200": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/MailboxAdmin" + "$ref": "#/components/schemas/MailboxAdminCreate" } } }, - "description": "" + "description": "The new mailbox with one extra field `one_time_password` if identity provider is keycloak." } } } @@ -2453,6 +2552,54 @@ } } }, + "/api/v1.0/maildomains/{maildomain_pk}/users/": { + "get": { + "operationId": "maildomains_users_list", + "description": "Search users by email, first name and last name.", + "parameters": [ + { + "in": "path", + "name": "maildomain_pk", + "schema": { + "type": "string", + "format": "uuid" + }, + "required": true + }, + { + "in": "query", + "name": "q", + "schema": { + "type": "string" + }, + "description": "Search maildomains user by full name, short name or email." + } + ], + "tags": [ + "admin-maildomain-user" + ], + "security": [ + { + "cookieAuth": [] + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "description": "" + } + } + } + }, "/api/v1.0/messages/": { "get": { "operationId": "messages_list", @@ -3983,6 +4130,107 @@ "updated_at" ] }, + "MailboxAdminCreate": { + "type": "object", + "description": "Serialize Mailbox details for create admin endpoint, including users with access and\nmetadata.", + "properties": { + "id": { + "type": "string", + "format": "uuid", + "readOnly": true, + "description": "primary key for the record as UUID" + }, + "local_part": { + "type": "string", + "readOnly": true + }, + "domain_name": { + "type": "string", + "readOnly": true + }, + "alias_of": { + "type": "string", + "format": "uuid", + "description": "primary key for the record as UUID", + "readOnly": true, + "nullable": true + }, + "accesses": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MailboxAccessNestedUser" + }, + "readOnly": true + }, + "created_at": { + "type": "string", + "format": "date-time", + "readOnly": true, + "title": "Created on", + "description": "date and time at which a record was created" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "readOnly": true, + "title": "Updated on", + "description": "date and time at which a record was last updated" + }, + "one_time_password": { + "type": "string", + "nullable": true, + "description": "Fake method just to make the OpenAPI schema valid.", + "readOnly": true + } + }, + "required": [ + "accesses", + "alias_of", + "created_at", + "domain_name", + "id", + "local_part", + "one_time_password", + "updated_at" + ] + }, + "MailboxAdminCreateMetadataRequest": { + "type": "object", + "properties": { + "type": { + "$ref": "#/components/schemas/TypeEnum" + }, + "first_name": { + "type": "string" + }, + "last_name": { + "type": "string" + } + }, + "required": [ + "type" + ] + }, + "MailboxAdminCreatePayloadRequest": { + "type": "object", + "properties": { + "local_part": { + "type": "string", + "minLength": 1 + }, + "alias_of": { + "type": "string", + "format": "uuid" + }, + "metadata": { + "$ref": "#/components/schemas/MailboxAdminCreateMetadataRequest" + } + }, + "required": [ + "local_part", + "metadata" + ] + }, "MailboxLight": { "type": "object", "description": "Serializer for mailbox details in thread access.", @@ -4032,7 +4280,8 @@ }, "subject": { "type": "string", - "readOnly": true + "readOnly": true, + "nullable": true }, "created_at": { "type": "string", @@ -4501,7 +4750,8 @@ }, "subject": { "type": "string", - "readOnly": true + "readOnly": true, + "nullable": true }, "snippet": { "type": "string", @@ -4783,6 +5033,15 @@ "slug" ] }, + "TypeEnum": { + "enum": [ + "personal", + "shared", + "redirect" + ], + "type": "string", + "description": "* `personal` - personal\n* `shared` - shared\n* `redirect` - redirect" + }, "User": { "type": "object", "description": "Serialize users.", @@ -4809,9 +5068,16 @@ "type": "string", "readOnly": true, "nullable": true + }, + "abilities": { + "type": "object", + "additionalProperties": {}, + "description": "Return abilities of the logged-in user on the mail domain.", + "readOnly": true } }, "required": [ + "abilities", "email", "full_name", "id", @@ -4827,4 +5093,4 @@ } } } -} +} \ No newline at end of file diff --git a/src/frontend/src/features/api/gen/admin-maildomain-user/admin-maildomain-user.ts b/src/frontend/src/features/api/gen/admin-maildomain-user/admin-maildomain-user.ts new file mode 100644 index 00000000..291fb295 --- /dev/null +++ b/src/frontend/src/features/api/gen/admin-maildomain-user/admin-maildomain-user.ts @@ -0,0 +1,242 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * messages API + * This is the messages API schema. + * OpenAPI spec version: 1.0.0 (v1.0) + */ +import { useQuery } from "@tanstack/react-query"; +import type { + DataTag, + DefinedInitialDataOptions, + DefinedUseQueryResult, + QueryClient, + QueryFunction, + QueryKey, + UndefinedInitialDataOptions, + UseQueryOptions, + UseQueryResult, +} from "@tanstack/react-query"; + +import type { MaildomainsUsersListParams, User } from ".././models"; + +import { fetchAPI } from "../../fetch-api"; + +type SecondParameter unknown> = Parameters[1]; + +/** + * Search users by email, first name and last name. + */ +export type maildomainsUsersListResponse200 = { + data: User[]; + status: 200; +}; + +export type maildomainsUsersListResponseComposite = + maildomainsUsersListResponse200; + +export type maildomainsUsersListResponse = + maildomainsUsersListResponseComposite & { + headers: Headers; + }; + +export const getMaildomainsUsersListUrl = ( + maildomainPk: string, + params?: MaildomainsUsersListParams, +) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? "null" : value.toString()); + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 + ? `/api/v1.0/maildomains/${maildomainPk}/users/?${stringifiedParams}` + : `/api/v1.0/maildomains/${maildomainPk}/users/`; +}; + +export const maildomainsUsersList = async ( + maildomainPk: string, + params?: MaildomainsUsersListParams, + options?: RequestInit, +): Promise => { + return fetchAPI( + getMaildomainsUsersListUrl(maildomainPk, params), + { + ...options, + method: "GET", + }, + ); +}; + +export const getMaildomainsUsersListQueryKey = ( + maildomainPk: string, + params?: MaildomainsUsersListParams, +) => { + return [ + `/api/v1.0/maildomains/${maildomainPk}/users/`, + ...(params ? [params] : []), + ] as const; +}; + +export const getMaildomainsUsersListQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + maildomainPk: string, + params?: MaildomainsUsersListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + request?: SecondParameter; + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? + getMaildomainsUsersListQueryKey(maildomainPk, params); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => + maildomainsUsersList(maildomainPk, params, { signal, ...requestOptions }); + + return { + queryKey, + queryFn, + enabled: !!maildomainPk, + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type MaildomainsUsersListQueryResult = NonNullable< + Awaited> +>; +export type MaildomainsUsersListQueryError = unknown; + +export function useMaildomainsUsersList< + TData = Awaited>, + TError = unknown, +>( + maildomainPk: string, + params: undefined | MaildomainsUsersListParams, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useMaildomainsUsersList< + TData = Awaited>, + TError = unknown, +>( + maildomainPk: string, + params?: MaildomainsUsersListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useMaildomainsUsersList< + TData = Awaited>, + TError = unknown, +>( + maildomainPk: string, + params?: MaildomainsUsersListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; + +export function useMaildomainsUsersList< + TData = Awaited>, + TError = unknown, +>( + maildomainPk: string, + params?: MaildomainsUsersListParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getMaildomainsUsersListQueryOptions( + maildomainPk, + params, + options, + ); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} diff --git a/src/frontend/src/features/api/gen/contacts/contacts.ts b/src/frontend/src/features/api/gen/contacts/contacts.ts new file mode 100644 index 00000000..d13fd946 --- /dev/null +++ b/src/frontend/src/features/api/gen/contacts/contacts.ts @@ -0,0 +1,372 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * messages API + * This is the messages API schema. + * OpenAPI spec version: 1.0.0 (v1.0) + */ +import { useQuery } from "@tanstack/react-query"; +import type { + DataTag, + DefinedInitialDataOptions, + DefinedUseQueryResult, + QueryClient, + QueryFunction, + QueryKey, + UndefinedInitialDataOptions, + UseQueryOptions, + UseQueryResult, +} from "@tanstack/react-query"; + +import type { Contact, ContactsListParams } from ".././models"; + +import { fetchAPI } from "../../fetch-api"; + +type SecondParameter unknown> = Parameters[1]; + +/** + * List contacts with optional filtering by mailbox and search query. + +Query parameters: +- mailbox_id: Optional UUID to filter contacts by mailbox +- q: Optional search query for name or email (case insensitive) + */ +export type contactsListResponse200 = { + data: Contact[]; + status: 200; +}; + +export type contactsListResponseComposite = contactsListResponse200; + +export type contactsListResponse = contactsListResponseComposite & { + headers: Headers; +}; + +export const getContactsListUrl = (params?: ContactsListParams) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? "null" : value.toString()); + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 + ? `/api/v1.0/contacts/?${stringifiedParams}` + : `/api/v1.0/contacts/`; +}; + +export const contactsList = async ( + params?: ContactsListParams, + options?: RequestInit, +): Promise => { + return fetchAPI(getContactsListUrl(params), { + ...options, + method: "GET", + }); +}; + +export const getContactsListQueryKey = (params?: ContactsListParams) => { + return [`/api/v1.0/contacts/`, ...(params ? [params] : [])] as const; +}; + +export const getContactsListQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + params?: ContactsListParams, + options?: { + query?: Partial< + UseQueryOptions>, TError, TData> + >; + request?: SecondParameter; + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getContactsListQueryKey(params); + + const queryFn: QueryFunction>> = ({ + signal, + }) => contactsList(params, { signal, ...requestOptions }); + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ContactsListQueryResult = NonNullable< + Awaited> +>; +export type ContactsListQueryError = unknown; + +export function useContactsList< + TData = Awaited>, + TError = unknown, +>( + params: undefined | ContactsListParams, + options: { + query: Partial< + UseQueryOptions>, TError, TData> + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useContactsList< + TData = Awaited>, + TError = unknown, +>( + params?: ContactsListParams, + options?: { + query?: Partial< + UseQueryOptions>, TError, TData> + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useContactsList< + TData = Awaited>, + TError = unknown, +>( + params?: ContactsListParams, + options?: { + query?: Partial< + UseQueryOptions>, TError, TData> + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; + +export function useContactsList< + TData = Awaited>, + TError = unknown, +>( + params?: ContactsListParams, + options?: { + query?: Partial< + UseQueryOptions>, TError, TData> + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getContactsListQueryOptions(params, options); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * ViewSet for Contact model. + */ +export type contactsRetrieveResponse200 = { + data: Contact; + status: 200; +}; + +export type contactsRetrieveResponseComposite = contactsRetrieveResponse200; + +export type contactsRetrieveResponse = contactsRetrieveResponseComposite & { + headers: Headers; +}; + +export const getContactsRetrieveUrl = (id: string) => { + return `/api/v1.0/contacts/${id}/`; +}; + +export const contactsRetrieve = async ( + id: string, + options?: RequestInit, +): Promise => { + return fetchAPI(getContactsRetrieveUrl(id), { + ...options, + method: "GET", + }); +}; + +export const getContactsRetrieveQueryKey = (id: string) => { + return [`/api/v1.0/contacts/${id}/`] as const; +}; + +export const getContactsRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + id: string, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + request?: SecondParameter; + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getContactsRetrieveQueryKey(id); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => contactsRetrieve(id, { signal, ...requestOptions }); + + return { + queryKey, + queryFn, + enabled: !!id, + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type ContactsRetrieveQueryResult = NonNullable< + Awaited> +>; +export type ContactsRetrieveQueryError = unknown; + +export function useContactsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: string, + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useContactsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: string, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useContactsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: string, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; + +export function useContactsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: string, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getContactsRetrieveQueryOptions(id, options); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} diff --git a/src/frontend/src/features/api/gen/index.ts b/src/frontend/src/features/api/gen/index.ts index f7dde5bb..a169f8fa 100644 --- a/src/frontend/src/features/api/gen/index.ts +++ b/src/frontend/src/features/api/gen/index.ts @@ -1,5 +1,6 @@ export * from "./blob/blob"; export * from "./config/config"; +export * from "./contacts/contacts"; export * from "./messages/messages"; export * from "./flags/flags"; export * from "./import/import"; @@ -7,6 +8,7 @@ export * from "./labels/labels"; export * from "./mailboxes/mailboxes"; export * from "./mailbox-accesses/mailbox-accesses"; export * from "./maildomains/maildomains"; +export * from "./admin-maildomain-user/admin-maildomain-user"; export * from "./mta/mta"; export * from "./tasks/tasks"; export * from "./threads/threads"; diff --git a/src/frontend/src/features/api/gen/labels/labels.ts b/src/frontend/src/features/api/gen/labels/labels.ts index bba842b6..7d270953 100644 --- a/src/frontend/src/features/api/gen/labels/labels.ts +++ b/src/frontend/src/features/api/gen/labels/labels.ts @@ -36,7 +36,7 @@ import { fetchAPI } from "../../fetch-api"; type SecondParameter unknown> = Parameters[1]; /** - * + * List all labels accessible to the user in a hierarchical structure. The response returns labels in a tree structure where: @@ -45,7 +45,7 @@ type SecondParameter unknown> = Parameters[1]; - The hierarchy is determined by the label's name (e.g., "Inbox/Important" is a child of "Inbox") You can filter labels by mailbox using the mailbox_id query parameter. - + */ export type labelsListResponse200 = { data: TreeLabel[]; diff --git a/src/frontend/src/features/api/gen/maildomains/maildomains.ts b/src/frontend/src/features/api/gen/maildomains/maildomains.ts index 119d5108..bbdc35bd 100644 --- a/src/frontend/src/features/api/gen/maildomains/maildomains.ts +++ b/src/frontend/src/features/api/gen/maildomains/maildomains.ts @@ -23,6 +23,8 @@ import type { import type { MailboxAdmin, + MailboxAdminCreate, + MailboxAdminCreatePayloadRequest, MaildomainsListParams, MaildomainsMailboxesListParams, PaginatedMailDomainAdminList, @@ -447,21 +449,15 @@ export function useMaildomainsMailboxesList< } /** - * ViewSet for managing Mailboxes within a specific MailDomain. -Nested under /maildomains/{maildomain_pk}/mailboxes/ -Permissions are checked by IsMailDomainAdmin for the maildomain_pk. - -This viewset serves a different purpose than the one in mailbox.py (/api/v1.0/mailboxes/). -That other one is for listing the mailboxes a user has access to in regular app use. -This one is for managing mailboxes within a specific maildomain in the admin interface. + * Create new mailbox in a specific maildomain. */ -export type maildomainsMailboxesCreateResponse201 = { - data: MailboxAdmin; - status: 201; +export type maildomainsMailboxesCreateResponse200 = { + data: MailboxAdminCreate; + status: 200; }; export type maildomainsMailboxesCreateResponseComposite = - maildomainsMailboxesCreateResponse201; + maildomainsMailboxesCreateResponse200; export type maildomainsMailboxesCreateResponse = maildomainsMailboxesCreateResponseComposite & { @@ -474,6 +470,7 @@ export const getMaildomainsMailboxesCreateUrl = (maildomainPk: string) => { export const maildomainsMailboxesCreate = async ( maildomainPk: string, + mailboxAdminCreatePayloadRequest: MailboxAdminCreatePayloadRequest, options?: RequestInit, ): Promise => { return fetchAPI( @@ -481,6 +478,8 @@ export const maildomainsMailboxesCreate = async ( { ...options, method: "POST", + headers: { "Content-Type": "application/json", ...options?.headers }, + body: JSON.stringify(mailboxAdminCreatePayloadRequest), }, ); }; @@ -492,14 +491,14 @@ export const getMaildomainsMailboxesCreateMutationOptions = < mutation?: UseMutationOptions< Awaited>, TError, - { maildomainPk: string }, + { maildomainPk: string; data: MailboxAdminCreatePayloadRequest }, TContext >; request?: SecondParameter; }): UseMutationOptions< Awaited>, TError, - { maildomainPk: string }, + { maildomainPk: string; data: MailboxAdminCreatePayloadRequest }, TContext > => { const mutationKey = ["maildomainsMailboxesCreate"]; @@ -513,11 +512,11 @@ export const getMaildomainsMailboxesCreateMutationOptions = < const mutationFn: MutationFunction< Awaited>, - { maildomainPk: string } + { maildomainPk: string; data: MailboxAdminCreatePayloadRequest } > = (props) => { - const { maildomainPk } = props ?? {}; + const { maildomainPk, data } = props ?? {}; - return maildomainsMailboxesCreate(maildomainPk, requestOptions); + return maildomainsMailboxesCreate(maildomainPk, data, requestOptions); }; return { mutationFn, ...mutationOptions }; @@ -526,7 +525,8 @@ export const getMaildomainsMailboxesCreateMutationOptions = < export type MaildomainsMailboxesCreateMutationResult = NonNullable< Awaited> >; - +export type MaildomainsMailboxesCreateMutationBody = + MailboxAdminCreatePayloadRequest; export type MaildomainsMailboxesCreateMutationError = unknown; export const useMaildomainsMailboxesCreate = < @@ -537,7 +537,7 @@ export const useMaildomainsMailboxesCreate = < mutation?: UseMutationOptions< Awaited>, TError, - { maildomainPk: string }, + { maildomainPk: string; data: MailboxAdminCreatePayloadRequest }, TContext >; request?: SecondParameter; @@ -546,7 +546,7 @@ export const useMaildomainsMailboxesCreate = < ): UseMutationResult< Awaited>, TError, - { maildomainPk: string }, + { maildomainPk: string; data: MailboxAdminCreatePayloadRequest }, TContext > => { const mutationOptions = getMaildomainsMailboxesCreateMutationOptions(options); diff --git a/src/frontend/src/features/api/gen/models/contacts_list_params.ts b/src/frontend/src/features/api/gen/models/contacts_list_params.ts new file mode 100644 index 00000000..6c46b195 --- /dev/null +++ b/src/frontend/src/features/api/gen/models/contacts_list_params.ts @@ -0,0 +1,18 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * messages API + * This is the messages API schema. + * OpenAPI spec version: 1.0.0 (v1.0) + */ + +export type ContactsListParams = { + /** + * Filter contacts by mailbox ID. + */ + mailbox_id?: string; + /** + * Search contacts by name or email (case insensitive). + */ + q?: string; +}; diff --git a/src/frontend/src/features/api/gen/models/index.ts b/src/frontend/src/features/api/gen/models/index.ts index 83020ad5..6d6ff315 100644 --- a/src/frontend/src/features/api/gen/models/index.ts +++ b/src/frontend/src/features/api/gen/models/index.ts @@ -11,6 +11,7 @@ export * from "./blob_upload_create201"; export * from "./blob_upload_create_body"; export * from "./change_flag_request_request"; export * from "./contact"; +export * from "./contacts_list_params"; export * from "./draft_create2400"; export * from "./draft_create2403"; export * from "./draft_create2404"; @@ -46,11 +47,15 @@ export * from "./mailbox_access_role_enum"; export * from "./mailbox_access_write"; export * from "./mailbox_access_write_request"; export * from "./mailbox_admin"; +export * from "./mailbox_admin_create"; +export * from "./mailbox_admin_create_metadata_request"; +export * from "./mailbox_admin_create_payload_request"; export * from "./mailbox_light"; export * from "./mailboxes_accesses_list_params"; export * from "./mailboxes_search_list_params"; export * from "./maildomains_list_params"; export * from "./maildomains_mailboxes_list_params"; +export * from "./maildomains_users_list_params"; export * from "./message"; export * from "./message_html_body_item"; export * from "./message_text_body_item"; @@ -89,4 +94,6 @@ export * from "./threads_stats_retrieve400"; export * from "./threads_stats_retrieve_params"; export * from "./threads_stats_retrieve_stats_fields"; export * from "./tree_label"; +export * from "./type_enum"; export * from "./user"; +export * from "./user_abilities"; diff --git a/src/frontend/src/features/api/gen/models/mailbox_admin_create.ts b/src/frontend/src/features/api/gen/models/mailbox_admin_create.ts new file mode 100644 index 00000000..5a86638b --- /dev/null +++ b/src/frontend/src/features/api/gen/models/mailbox_admin_create.ts @@ -0,0 +1,34 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * messages API + * This is the messages API schema. + * OpenAPI spec version: 1.0.0 (v1.0) + */ +import type { MailboxAccessNestedUser } from "./mailbox_access_nested_user"; + +/** + * Serialize Mailbox details for create admin endpoint, including users with access and +metadata. + */ +export interface MailboxAdminCreate { + /** primary key for the record as UUID */ + readonly id: string; + readonly local_part: string; + readonly domain_name: string; + /** + * primary key for the record as UUID + * @nullable + */ + readonly alias_of: string | null; + readonly accesses: readonly MailboxAccessNestedUser[]; + /** date and time at which a record was created */ + readonly created_at: string; + /** date and time at which a record was last updated */ + readonly updated_at: string; + /** + * Fake method just to make the OpenAPI schema valid. + * @nullable + */ + readonly one_time_password: string | null; +} diff --git a/src/frontend/src/features/api/gen/models/mailbox_admin_create_metadata_request.ts b/src/frontend/src/features/api/gen/models/mailbox_admin_create_metadata_request.ts new file mode 100644 index 00000000..eeeabc74 --- /dev/null +++ b/src/frontend/src/features/api/gen/models/mailbox_admin_create_metadata_request.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * messages API + * This is the messages API schema. + * OpenAPI spec version: 1.0.0 (v1.0) + */ +import type { TypeEnum } from "./type_enum"; + +export interface MailboxAdminCreateMetadataRequest { + type: TypeEnum; + first_name?: string; + last_name?: string; +} diff --git a/src/frontend/src/features/api/gen/models/mailbox_admin_create_payload_request.ts b/src/frontend/src/features/api/gen/models/mailbox_admin_create_payload_request.ts new file mode 100644 index 00000000..f90024e4 --- /dev/null +++ b/src/frontend/src/features/api/gen/models/mailbox_admin_create_payload_request.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * messages API + * This is the messages API schema. + * OpenAPI spec version: 1.0.0 (v1.0) + */ +import type { MailboxAdminCreateMetadataRequest } from "./mailbox_admin_create_metadata_request"; + +export interface MailboxAdminCreatePayloadRequest { + /** @minLength 1 */ + local_part: string; + alias_of?: string; + metadata: MailboxAdminCreateMetadataRequest; +} diff --git a/src/frontend/src/features/api/gen/models/maildomains_users_list_params.ts b/src/frontend/src/features/api/gen/models/maildomains_users_list_params.ts new file mode 100644 index 00000000..659fbdc0 --- /dev/null +++ b/src/frontend/src/features/api/gen/models/maildomains_users_list_params.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * messages API + * This is the messages API schema. + * OpenAPI spec version: 1.0.0 (v1.0) + */ + +export type MaildomainsUsersListParams = { + /** + * Search maildomains user by full name, short name or email. + */ + q?: string; +}; diff --git a/src/frontend/src/features/api/gen/models/message.ts b/src/frontend/src/features/api/gen/models/message.ts index 204472cb..d676efe1 100644 --- a/src/frontend/src/features/api/gen/models/message.ts +++ b/src/frontend/src/features/api/gen/models/message.ts @@ -21,7 +21,8 @@ export interface Message { readonly parent_id: string | null; /** @nullable */ readonly thread_id: string | null; - readonly subject: string; + /** @nullable */ + readonly subject: string | null; /** date and time at which a record was created */ readonly created_at: string; /** date and time at which a record was last updated */ diff --git a/src/frontend/src/features/api/gen/models/thread.ts b/src/frontend/src/features/api/gen/models/thread.ts index cfb32f57..591a2c28 100644 --- a/src/frontend/src/features/api/gen/models/thread.ts +++ b/src/frontend/src/features/api/gen/models/thread.ts @@ -14,7 +14,8 @@ import type { ThreadLabel } from "./thread_label"; export interface Thread { /** primary key for the record as UUID */ readonly id: string; - readonly subject: string; + /** @nullable */ + readonly subject: string | null; readonly snippet: string; readonly messages: string; readonly has_unread: boolean; diff --git a/src/frontend/src/features/api/gen/models/type_enum.ts b/src/frontend/src/features/api/gen/models/type_enum.ts new file mode 100644 index 00000000..56bc29c4 --- /dev/null +++ b/src/frontend/src/features/api/gen/models/type_enum.ts @@ -0,0 +1,21 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * messages API + * This is the messages API schema. + * OpenAPI spec version: 1.0.0 (v1.0) + */ + +/** + * * `personal` - personal + * `shared` - shared + * `redirect` - redirect + */ +export type TypeEnum = (typeof TypeEnum)[keyof typeof TypeEnum]; + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const TypeEnum = { + personal: "personal", + shared: "shared", + redirect: "redirect", +} as const; diff --git a/src/frontend/src/features/api/gen/models/user.ts b/src/frontend/src/features/api/gen/models/user.ts index 98a832bf..5fb196c8 100644 --- a/src/frontend/src/features/api/gen/models/user.ts +++ b/src/frontend/src/features/api/gen/models/user.ts @@ -5,6 +5,7 @@ * This is the messages API schema. * OpenAPI spec version: 1.0.0 (v1.0) */ +import type { UserAbilities } from "./user_abilities"; /** * Serialize users. @@ -18,4 +19,6 @@ export interface User { readonly full_name: string | null; /** @nullable */ readonly short_name: string | null; + /** Return abilities of the logged-in user on the mail domain. */ + readonly abilities: UserAbilities; } diff --git a/src/frontend/src/features/api/gen/models/user_abilities.ts b/src/frontend/src/features/api/gen/models/user_abilities.ts new file mode 100644 index 00000000..ac08ffe4 --- /dev/null +++ b/src/frontend/src/features/api/gen/models/user_abilities.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * messages API + * This is the messages API schema. + * OpenAPI spec version: 1.0.0 (v1.0) + */ + +/** + * Return abilities of the logged-in user on the mail domain. + */ +export type UserAbilities = { [key: string]: unknown };