From eade4643e502a0e658bdb54aa5aac126b5dd306f Mon Sep 17 00:00:00 2001 From: riyadhafraa <49757212-riyadhafraa@users.noreply.replit.com> Date: Tue, 5 May 2026 15:28:41 +0000 Subject: [PATCH] Add ability to view personal notes and update note schemas Adds a new endpoint for listing user-specific notes and refines OpenAPI schemas for better data structure definition. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 77cfe984-2c65-4152-bb7a-0df28274fe66 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 3565b59b-6890-4cf5-90a7-0c8041e15041 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/c3c252e4-c83d-40ca-9fff-99a3ea60701e/77cfe984-2c65-4152-bb7a-0df28274fe66/G3ZvHke Replit-Helium-Checkpoint-Created: true --- .../src/generated/api.schemas.ts | 7 +- lib/api-client-react/src/generated/api.ts | 102 ++++++++++++++++++ lib/api-spec/openapi.yaml | 21 +++- lib/api-zod/src/generated/api.ts | 17 ++- 4 files changed, 142 insertions(+), 5 deletions(-) diff --git a/lib/api-client-react/src/generated/api.schemas.ts b/lib/api-client-react/src/generated/api.schemas.ts index 6d7ff151..695efa56 100644 --- a/lib/api-client-react/src/generated/api.schemas.ts +++ b/lib/api-client-react/src/generated/api.schemas.ts @@ -1075,7 +1075,6 @@ export interface NoteRecipientSummary { id: number; noteId?: number; recipientUserId: number; - senderUserId: number; status: NoteRecipientStatus; sentAt: string; /** @nullable */ @@ -1701,6 +1700,12 @@ export type GetAdminServiceDependentOrdersParams = { offset?: number; }; +export type ListMyNotesAliasParams = { + archived?: boolean; +}; + +export type ListMyNotesAlias200Item = { [key: string]: unknown }; + export type ListReceivedNotesParams = { archived?: boolean; }; diff --git a/lib/api-client-react/src/generated/api.ts b/lib/api-client-react/src/generated/api.ts index 3a9ff48b..9471bc36 100644 --- a/lib/api-client-react/src/generated/api.ts +++ b/lib/api-client-react/src/generated/api.ts @@ -78,6 +78,8 @@ import type { LeaveConversationBody, ListAuditLogsParams, ListGroupsParams, + ListMyNotesAlias200Item, + ListMyNotesAliasParams, ListReceivedNotesParams, ListUsersParams, LoginBody, @@ -8261,6 +8263,106 @@ export function useGetAdminServiceDependentOrders< return { ...query, queryKey: queryOptions.queryKey }; } +/** + * @summary Alias of GET /notes — list the caller's own notes + */ +export const getListMyNotesAliasUrl = (params?: ListMyNotesAliasParams) => { + 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/notes/my?${stringifiedParams}` + : `/api/notes/my`; +}; + +export const listMyNotesAlias = async ( + params?: ListMyNotesAliasParams, + options?: RequestInit, +): Promise => { + return customFetch( + getListMyNotesAliasUrl(params), + { + ...options, + method: "GET", + }, + ); +}; + +export const getListMyNotesAliasQueryKey = ( + params?: ListMyNotesAliasParams, +) => { + return [`/api/notes/my`, ...(params ? [params] : [])] as const; +}; + +export const getListMyNotesAliasQueryOptions = < + TData = Awaited>, + TError = ErrorType, +>( + params?: ListMyNotesAliasParams, + options?: { + query?: UseQueryOptions< + Awaited>, + TError, + TData + >; + request?: SecondParameter; + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? getListMyNotesAliasQueryKey(params); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => listMyNotesAlias(params, { signal, ...requestOptions }); + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey }; +}; + +export type ListMyNotesAliasQueryResult = NonNullable< + Awaited> +>; +export type ListMyNotesAliasQueryError = ErrorType; + +/** + * @summary Alias of GET /notes — list the caller's own notes + */ + +export function useListMyNotesAlias< + TData = Awaited>, + TError = ErrorType, +>( + params?: ListMyNotesAliasParams, + options?: { + query?: UseQueryOptions< + Awaited>, + TError, + TData + >; + request?: SecondParameter; + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getListMyNotesAliasQueryOptions(params, options); + + const query = useQuery(queryOptions) as UseQueryResult & { + queryKey: QueryKey; + }; + + return { ...query, queryKey: queryOptions.queryKey }; +} + /** * @summary List notes the caller has sent */ diff --git a/lib/api-spec/openapi.yaml b/lib/api-spec/openapi.yaml index 628fece3..2bebce9d 100644 --- a/lib/api-spec/openapi.yaml +++ b/lib/api-spec/openapi.yaml @@ -2733,6 +2733,24 @@ paths: $ref: "#/components/schemas/ErrorResponse" # ----- Notes (in-app messaging) ----- + /notes/my: + get: + operationId: listMyNotesAlias + tags: [notes] + summary: Alias of GET /notes — list the caller's own notes + parameters: + - in: query + name: archived + required: false + schema: { type: boolean, default: false } + responses: + "200": + description: The caller's notes + content: + application/json: + schema: + type: array + items: { type: object, additionalProperties: true } /notes/sent: get: operationId: listSentNotes @@ -4856,7 +4874,6 @@ components: id: { type: integer } noteId: { type: integer } recipientUserId: { type: integer } - senderUserId: { type: integer } status: { $ref: "#/components/schemas/NoteRecipientStatus" } sentAt: { type: string, format: date-time } readAt: { type: ["string", "null"], format: date-time } @@ -4866,7 +4883,7 @@ components: - $ref: "#/components/schemas/NoteUserSummary" - type: "null" required: - [id, recipientUserId, senderUserId, status, sentAt, readAt, archivedAt] + [id, recipientUserId, status, sentAt, readAt, archivedAt] SentNote: type: object diff --git a/lib/api-zod/src/generated/api.ts b/lib/api-zod/src/generated/api.ts index ad2342ba..209f44db 100644 --- a/lib/api-zod/src/generated/api.ts +++ b/lib/api-zod/src/generated/api.ts @@ -3328,6 +3328,21 @@ export const GetAdminServiceDependentOrdersResponse = zod.object({ nextOffset: zod.number().nullable(), }); +/** + * @summary Alias of GET /notes — list the caller's own notes + */ +export const listMyNotesAliasQueryArchivedDefault = false; + +export const ListMyNotesAliasQueryParams = zod.object({ + archived: zod.coerce.boolean().default(listMyNotesAliasQueryArchivedDefault), +}); + +export const ListMyNotesAliasResponseItem = zod.record( + zod.string(), + zod.unknown(), +); +export const ListMyNotesAliasResponse = zod.array(ListMyNotesAliasResponseItem); + /** * @summary List notes the caller has sent */ @@ -3346,7 +3361,6 @@ export const ListSentNotesResponseItem = zod.object({ id: zod.number(), noteId: zod.number().optional(), recipientUserId: zod.number(), - senderUserId: zod.number(), status: zod.enum(["unread", "read", "replied", "archived"]), sentAt: zod.coerce.date(), readAt: zod.coerce.date().nullable(), @@ -3448,7 +3462,6 @@ export const GetNoteDetailResponse = zod.object({ id: zod.number(), noteId: zod.number().optional(), recipientUserId: zod.number(), - senderUserId: zod.number(), status: zod.enum(["unread", "read", "replied", "archived"]), sentAt: zod.coerce.date(), readAt: zod.coerce.date().nullable(),